Repository navigation
fix(social-controllers): pass realtime authorComment through from the backend - #11209
Merged
Merged
Conversation
… backend Realtime feed items derived authorComment from trade comments, which does not match the server's selection. Pass the authorComment on the socket payload through unchanged instead: an absent field stays absent, an explicit null stays null, and a present value is validated with AuthorCommentStruct so a malformed value drops the item, matching the REST feed. Export AuthorCommentStruct for that check. Co-authored-by: Cursor <[email protected]>
…ntry Co-authored-by: Cursor <[email protected]>
xavier-brochard
marked this pull request as ready for review
October 30, 2026 08:54
xavier-brochard
enabled auto-merge
October 30, 2026 08:58
joaosantos15
approved these changes
Oct 30, 2026
This was referenced Oct 30, 2026
Merged
3 of 4 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Realtime feed items in
social-controllersderivedauthorCommentfrom the position's trades. That does not match how the server selects the author comment, so core should not recompute it.This PR makes realtime normalization a pass-through:
authorCommentthe backend puts on the realtime socket payload is passed through unchanged. Core no longer derivesauthorCommentfrom trade comments on realtime events.nullstaysnull.AuthorCommentStruct, the same struct the REST feed uses. A malformed value drops the realtime item.sourceLanguageandtranslationsare validated byAuthorCommentStruct, so a non-string translation entry drops the realtime item. Before this change, the realtime parser kept the comment and dropped only the bad translation entry.AuthorCommentStructis exported fromsrc/structs.tsfor that check. It is not added to the package index.Because an absent field stays absent, this PR is safe to merge before or after the backend PR. Until the backend sends
authorCommenton the socket payload, realtime items carry noauthorComment.Rollout order: backend merge, then core release, then the mobile dependency bump. Mobile must bump to the next core release before it uses this change.
References
packages/social-controllers/CHANGELOG.md, Unreleased, FixedVerification
What was run:
yarn workspace @metamask/social-controllers run test run: 5 test files and 248 tests pass, with 100% statements, branches, functions, and lines coverage.src/realtime-feed-item.test.ts: 15 tests pass, including pass-through, absent, null, malformed, and translation cases. The former "drops non-string translations" test now asserts that the realtime item is dropped, because the malformed-value rule applies.yarn lint:oxlint packages/social-controllers/src: exit 0.yarn oxfmt --checkon the four changed files: pass.yarn workspace @metamask/social-controllers run changelog:validate: exit 0.tsc --build tsconfig.lint.jsoninpackages/social-controllers: no errors in social-controllers. The build exits non-zero because of type errors in other packages (for examplejson-rpc-engine,keyring-controller, andgeolocation-controller), which this PR does not touch.Not verified:
authorCommentshape on the realtime socket payload has not been checked against a live backend or the backend PR.yarn lint(constraints, dependency, teams, and codeowners checks) and whole-repoyarn lint:tsc.Checklist
Note
Medium Risk
Changes realtime feed item shape and drop rules for WebSocket events, so clients may see different or missing
authorCommentuntil the backend sends the field; malformed comments now silently omit entire items.Overview
Realtime feed normalization stops inferring
authorCommentfrom trade comments and instead uses the socket payload field the server sends. MissingauthorCommentstays off the item, explicitnullis kept, and a present value is copied through unchanged when valid.Validation now reuses exported
AuthorCommentStruct(same as REST). MalformedauthorComment—including non-string translation entries—causesparseRealtimeFeedItemto drop the whole realtime event, whereas the old parser could keep the item and strip bad translation keys. The large hand-rolled comment parsing helpers inrealtime-feed-item.tsare removed in favor of that struct on the raw hydrated payload.Reviewed by Cursor Bugbot for commit d842c93. Bugbot is set up for automated code reviews on this repo. Configure here.