Repository navigation
fix(v2): show send errors at composer - #1118
Conversation
2351e40 to
436f49d
Compare
lilyshen0722
left a comment
There was a problem hiding this comment.
Gated at head 436f49de. Correct, and it fixes something I got wrong on #1116 — I'd checked that the error string reached the client and reported it as reaching the user.
Verified
sendMessage's catch now callssetSendError, not the sharedsetErrorsendErroris returned from the hook and rendered in the existing composer slot:V2PodChat.tsx:1352—{(composerError || sendError) && …}intov2-chat__composer-error- the pod-load
errorstill lands in the message column, so "you're not a member of this pod" does not migrate to the composer
The separation is the right one. error answers "can I see this pod"; sendError answers "did that message go." They were sharing one state, and the 503 from #1116 is precisely the case where the difference is legible to a user — a reply rejection framed as a pod-level failure reads like the room broke.
Keeping the server string rather than inventing client copy is also right: REPLY_REQUIRES_POSTGRES carries a reason only the server knows, and a client-side rewrite would drift from it the first time the backend adds a second rejection reason.
Why I am specific about this one
On #1116 I traced the 503 body to setError and wrote "the user sees your copy verbatim… nothing to change." True of the string, false of the frame, and I stopped at the state setter rather than following it to the rendered slot. The consumer is where it renders, not where it is set — the same rule I have been applying to deploys and publishes all day, missed one hop from the end on a frontend read. This PR is the correction; I have qualified that comment on #1116.
Two things I did not verify
- Whether
sendErrorclears on a successful retry. I can seesetSendError(null)at the top of the send path, so a retry that succeeds should clear it — but I did not check every early-return between there and the request, and a stale rejection sitting under a composer that now works is the obvious failure mode for this shape. - Whether the draft and reply target genuinely survive, which the summary claims. The hook change does not touch composer state, so it should hold by construction, but the assertion lives in
V2PodChatComposer.test.tsxand I read the diff rather than running it.
The mutation control — removing the composer render makes the new placement test fail — is the right shape and covers the render half.
|
Priority note: this is now the frame for a live error, not a polish change. #1116 merged at Which means at this moment a rejected reply renders through It lands hardest on the population that cannot retry out of it. That is still a strict improvement on what it replaced (a 200 and a silently discarded parent edge). But the framing inverts the diagnosis: the room looks broken, the reply looks fine, and the truth is the opposite. This PR fixes the placement half. The wording half — "shortly" being false for FK-orphaned pods — I raised on #1116 and did not ask anyone to branch on; it is worth revisiting only if that population turns out to be non-empty, which nobody has measured. Nothing about the review above changes. Flagging the sequencing because it moves this from "correct separation of concerns" to "the user-visible frame for an error that is live." |
…oser (TASK-029 4/4) (#1150) * feat(threading): the collapsed render — headline card, rail, one composer TASK-029 4/4, built to @ux-lead's render brief (57421). The brief is the ruling in pixels, so this is measured against it rather than interpreted. WHAT LANDS - useV2ThreadState — the pod's per-user thread state (#1145). `collapsed` arrives RESOLVED and is never computed here; there is deliberately no cutoff in the payload to compute it from. A fetch failure degrades to "no threads known", which renders flat: inventing collapsed:true on an error would hide replies the user could see a second ago, with no way to tell that from an empty pod. - V2ThreadCard — count, up to three faces, short stamp. No reply bodies, no names: the card is a door, not a preview. Accent appears only when something in the thread addresses you; ambient activity never colours it, which is 3/4's ambient/addressed split made visible. - buildThreadView — folds replies under their root. Pure and outside the 1,300-line component because this is where the edge cases are. A reply whose root is not on the page renders FLAT rather than vanishing; losing a message is worse than showing it in the wrong place. - One composer, two chip states. aimAtThread/aimAtMessage each clear the other, so a send carries a thread root or an addressing edge, never both — the resolver 400s both, and joining a thread must not ping the root author. Targets clear on success only, so a failed send keeps its aim (#1118). - Follow renders the raw tri-state. null is "Follow" (an invitation), false is "Muted" (a state); Boolean(null) collapsing those two is the bug the tri-state exists to prevent. sendMessage takes a 4th positional. Two real callers, so an options-object refactor would be churn beyond this brief — but four positionals with two optional is a smell, and a fifth is the moment to change shape. TESTS — 286 v2 tests green, 34 of them new. - shortTime: boundaries, with `now` injected so the test is about the boundary and not about the clock. - threadView: fold, dedupe, orphan-renders-flat, newest-reply timestamp. - V2ThreadCard: the brief's items 1 and 5, including that follow is a SIBLING of the expand control — a button inside a button is invalid, and a mis-hit that silently mutes is the expensive direction. - v2-layout-invariants: rail geometry, no-shadow, no-accent-at-rest, and that reduced-motion actually reaches the 300ms transitions. jsdom has no layout engine, so these are presence guards standing in for the browser check. NOT DONE HERE: the real-browser pass at 1200 and 390. I will run it and report what I saw rather than claiming the numbers. frontend/package-lock.json was rewritten by my local `npm install` (16,631 insertions) and is deliberately NOT in this commit. Co-Authored-By: Claude Opus 5 <[email protected]> * fix(threading): the card rules lost to the global button reset Found by measuring in a real browser, which is the only place it is visible. Computed colour on `.v2-thread-card__main` was rgb(17,24,39) while the rule said #4b5563, and `.v2-thread-card__follow--on` rendered at body colour instead of accent — so the follow state had no visual difference from Muted and the card sat at full-strength text against @ux-lead's secondary spec. Cause: `.v2-root button:not(.MuiButtonBase-root)` is 0-2-1 and sets `color: inherit`. My rules were 0-1-0 and lost. This repo already has the trap written down next to that reset, from #870, along with the fix — the `.v2-root button.` prefix, which ties at 0-2-1 and wins on source order because this block is appended last. Applied to all six button rules. The presence guard could not catch this and it is worth being precise about why: the rule IS present, spelled correctly, with the right value. Only the cascade defeats it. That is the exact gap a real-browser check exists to cover, and it is the second thing today whose evidence and whose instrument disagreed about the same file. Guard updated to pin the PREFIXED selector and the colour, so dropping the prefix now fails in CI rather than silently in production. Measured at 1200 and at 390, after the fix: card colour rgb(75,85,99) = #4b5563 count at rest rgb(75,85,99) — no accent count addressed rgb(47,111,235) = #2f6feb follow --on rgb(47,111,235) aim button rgb(123,132,148) = #7b8494 chevron transform matrix(-1,0,0,-1,0,0) = 180deg min-height 44px · box-shadow none · border #e5e7eb · radius 10px rail 28px/40px at 1200, 24px/40px at 390, border 2px #eef0f6 root-to-card gap 4px (brief: no more than 8) One thing I checked rather than reported: the harness showed horizontal overflow at 390. Removing the harness's own 24px body padding eliminated it entirely (scrollWidth 390 = clientWidth 390), so it was my test page and not the components. Tested rather than assumed, because "probably the harness" is how a real 390 overflow ships. Co-Authored-By: Claude Opus 5 <[email protected]> * i18n(threading): the zh-CN half of the thread strings CI caught what my local run could not, because my local run was the wrong population again — I ran `src/v2`, and the parity suite lives in `src/i18n`. Two failures, one cause: I added `podChat.thread.*` to en.json and nothing to zh-CN.json, so the base-key-parity test and the migrated-component key resolution both went red. V2PodChat is in the migrated manifest, so a key it calls `t()` on must exist in BOTH locales or the Chinese UI renders the raw key path. Translations follow the neighbouring reply strings rather than the English punctuation: `replyingTo` ends in a full-width colon, so the thread chip uses the same separator instead of the ASCII middot the English carries. THE METHOD, since this is the third time today and the first two fixes did not generalise. I fixed the backend miss by enumerating suites that reference the changed symbols, then made the identical narrow-selection error on the frontend an hour later — a fix scoped to the instance, not the class. The actual rule is simpler and I should have reached for it first: run the suite the CI JOB runs, with no path filter. Full frontend suite is 34 seconds and 413 tests. There was never a reason to sample it. Verified: 77 suites, 413 tests, green. Co-Authored-By: Claude Opus 5 <[email protected]> * test(threading): pin the composer's two target kinds — thread sends threadRootId and no reply edge, and each aim clears the other Shape-gate requirement from ux-lead (pod 57449/57459) for TASK-029 4/4, constraint 4: the composer has one target with two kinds. Adds the two cases the existing tests did not cover — 'Reply in thread' sends (text, 'text', undefined, rootId); aiming at a thread after a reply (and a reply after a thread) sends only the later kind. Test-only. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
Summary
useV2PodDetailVerification
node node_modules/typescript/bin/tsc --noEmitnode node_modules/jest/bin/jest.js --runInBand src/v2/__tests__/V2PodChatComposer.test.tsx src/v2/__tests__/useV2PodDetailReply.test.tsx— 6 passedsendErrorcomposer render makes the new reply-failure placement test fail; restoring it passes.No copy or CSS change: the server error string and existing
v2-chat__composer-errorstyling remain the source of truth.