fix(unified-messages): show reply box with "Unknown message" when parent is missing (#4245) - #4246
Conversation
…ent is missing (#4245) The reply preview was gated on `parent` being truthy, so a message whose parent packet was never received (or has since been purged) rendered exactly like a message that was never a reply -- `replyId` was dropped silently even though it was non-null. Resolution is now a three-state helper, `resolveReplyPreview`, extracted as a pure exported function so the distinction is directly testable: - none -> replyId is null; render no reply box (unchanged) - resolved -> parent found; quote it (unchanged) - unknown -> replyId set but parent absent; render the box with an italicized "Unknown message" placeholder Note `replyId` is checked with `!= null`, not truthiness: packet id 0 is falsy but is still a valid reply target. A test pins that. Closes #4245 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016bxVewVnissUKiGZmhf9FW
|
Claude finished @Yeraze's task —— View job PR Review: fix(unified-messages): show reply box with "Unknown message" when parent is missingTasks:
This is a clean, well-reasoned fix. The three-state discriminated union approach is exactly the right model for this problem. Notes below range from strong positives to a few minor observations. Code Quality
JSX rendering (
Test CoverageThe test file covers all five meaningful cases:
The use of One gap: there are no tests for the JSX rendering of the CSSThe modifier class approach ( LocalizationThe Minor Observations
SummaryNo bugs found. The fix is correct, the abstraction is clean, and the tests are well-targeted. The |
CI lint ratchet caught react-refresh/only-export-components: a module whose default export is a component must not also export non-components, or Fast Refresh breaks. Exporting the helper from UnifiedMessagesPage.tsx purely to make it testable was the wrong seam. Moved to src/utils/replyPreview.ts and made generic over the message type, so it carries no coupling to the page's UnifiedMessage shape. The test moves with it and no longer needs the jsdom environment, since it no longer imports the page (and its CSS) just to reach a pure function. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016bxVewVnissUKiGZmhf9FW
|
Claude finished @Yeraze's task —— View job PR Review: fix(unified-messages): show reply box with "Unknown message" when parent is missingTasks:
This is a clean, well-structured fix. The latest synchronize commit refactored Code Quality
JSX rendering (
Test CoverageThe tests in
The stub message object at line 14 uses a plain object literal rather than One gap: there are no tests for the JSX rendering of the CSS
Localization
Minor Observations
SummaryNo bugs found. The refactor to |
Closes #4245
Problem
The reply preview in Unified Messages was gated on
parentbeing truthy (UnifiedMessagesPage.tsx:605).parentcomes frombyPacketId.get(msg.replyId), so when the replied-to packet was never received by any source — or has since been purged — the entire block was skipped and the message rendered identically to one that was never a reply. The non-nullreplyIdwas dropped on the floor.Fix
Resolution is now a three-state pure helper,
resolveReplyPreview, exported so the distinction is testable without standing up a full page render:nonereplyId == nullresolvedunknownreplyIdset, parent absentThe placeholder is italic and slightly dimmer (
--unknownmodifier) so it reads as absent rather than as a real message whose body happens to be the words "Unknown message".Note on
replyId != nullThe check is deliberately
!= nullrather than truthiness — packet id0is falsy but is still a valid reply target, and a truthiness test would silently reclassify it as a non-reply. There's a test pinning this specifically, since it's the obvious way for this to regress.Validation
UnifiedMessagesPage.replyPreview.test.ts— 5 tests,success: truenpx tsc --noEmit— no errorsnpx eslinton both changed source files — cleantsc caught one real mistake during development: after switching to the helper, a bare
parentreference in the JSX silently resolved to the globalWindowinstead of erroring as undefined. Worth knowing that identifier is booby-trapped in this file.There was no existing test file for this page; this adds the first one.
🤖 Generated with Claude Code
https://claude.ai/code/session_016bxVewVnissUKiGZmhf9FW