Skip to content

fix(social-controllers): pass realtime authorComment through from the backend - #11209

Merged
xavier-brochard merged 2 commits into
mainfrom
fix/social-realtime-author-pass-through
Oct 30, 2026
Merged

xavier-brochard merged 2 commits into
mainfrom
fix/social-realtime-author-pass-through

Conversation

@xavier-brochard

@xavier-brochard xavier-brochard commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

Realtime feed items in social-controllers derived authorComment from 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:

  • The authorComment the backend puts on the realtime socket payload is passed through unchanged. Core no longer derives authorComment from trade comments on realtime events.
  • An absent field stays absent. An explicit null stays null.
  • A present value is validated with AuthorCommentStruct, the same struct the REST feed uses. A malformed value drops the realtime item.
  • Realtime translation validation now matches REST. sourceLanguage and translations are validated by AuthorCommentStruct, 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.
  • AuthorCommentStruct is exported from src/structs.ts for 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 authorComment on the socket payload, realtime items carry no authorComment.

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

  • Backend PR: TBD (placeholder, to be updated)
  • Changelog: packages/social-controllers/CHANGELOG.md, Unreleased, Fixed

Verification

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 --check on the four changed files: pass.
  • yarn workspace @metamask/social-controllers run changelog:validate: exit 0.
  • tsc --build tsconfig.lint.json in packages/social-controllers: no errors in social-controllers. The build exits non-zero because of type errors in other packages (for example json-rpc-engine, keyring-controller, and geolocation-controller), which this PR does not touch.

Not verified:

  • End-to-end behaviour against the backend. The authorComment shape on the realtime socket payload has not been checked against a live backend or the backend PR.
  • Mobile consumption of the next core release.
  • Root-level yarn lint (constraints, dependency, teams, and codeowners checks) and whole-repo yarn lint:tsc.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes realtime feed item shape and drop rules for WebSocket events, so clients may see different or missing authorComment until the backend sends the field; malformed comments now silently omit entire items.

Overview
Realtime feed normalization stops inferring authorComment from trade comments and instead uses the socket payload field the server sends. Missing authorComment stays off the item, explicit null is kept, and a present value is copied through unchanged when valid.

Validation now reuses exported AuthorCommentStruct (same as REST). Malformed authorComment—including non-string translation entries—causes parseRealtimeFeedItem to 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 in realtime-feed-item.ts are 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.

xavier-brochard and others added 2 commits October 30, 2026 09:43
… 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]>
@xavier-brochard
xavier-brochard marked this pull request as ready for review October 30, 2026 08:54
@xavier-brochard
xavier-brochard requested review from a team as code owners October 30, 2026 08:54
@xavier-brochard
xavier-brochard added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 73a35d7 Oct 30, 2026
50 checks passed
@xavier-brochard
xavier-brochard deleted the fix/social-realtime-author-pass-through branch October 30, 2026 09:08

This branch was successfully deployed

1 active deployment
default-branch — d842c93f Deployed Oct 30, 2026 by xavier-brochard via Determine whether this PR is a release PR #6292
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants