Skip to content

fix: revert refused optimistic title on header rename failure (#10203) - #10237

Merged
dwu96 merged 1 commit into
mainfrom
fix/header-rename-revert-10203
Sep 12, 2026
Merged

dwu96 merged 1 commit into
mainfrom
fix/header-rename-revert-10203

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

The chat-header session-title rename in website/src/pages/ChatPage.tsx dispatches the optimistic sseSlotTitle, then calls api.renameSlot. Its .catch only reported the failure through showActionError: the refused optimistic title was never reverted, so the header and the sidebar kept showing a server-rejected title until an unrelated slot refetch or a reload. This is the header-side mirror of #10151, which covers the sidebar's inline rename; renameSlot has exactly two call sites and this was the remaining one.

Why it matters

The user is told the rename failed while the UI keeps displaying the failed title as if it succeeded. The contradiction persists indefinitely on an idle dashboard, and the wrong title is what gets read, screenshotted, and searched for until something else happens to refetch slots.

What changed (motivation -> approach -> change)

Slot titles live in the Redux dashboard slice (written by sseSlots / fetchSlots.fulfilled), so the recovery goes through Redux: the .catch now also dispatches fetchSlots(), whose fulfilled reconciler overwrites the stale optimistic title with the server truth. This is the recovery the delete-slot failure path already uses after its optimistic removal (chatSlice deleteSlot), and the shape the pending sidebar-rename fix (#10151 / PR #10172) adopts for the same defect class.

Because a transport or auth failure takes renameSlot and chatSlots down together (and fetchSlots.rejected restores nothing), the catch falls back to a local revert to the pre-rename title when the refetch does not fulfil, guarded on the store still holding the refused value so a newer concurrent title write is never clobbered.

Known residual (accepted, pre-existing shape): fetchSlots.fulfilled applies the whole snapshot, so a reply that predates a concurrent successful write inside one round-trip can briefly show the older title until the next slots frame. Same narrow window as the existing delete-slot recovery; a keyed partial apply would be a separate change.

Tests

  • website/src/test/ChatPage.titleRenamePin.test.tsx, three new cases driving the real header rename UI (click title -> input -> blur commits):
    • renameSlot rejects -> the store title snaps back to the server value delivered by chatSlots (mutation-verified: fails without the fix).
    • renameSlot and chatSlots both reject -> the local-revert fallback restores the pre-rename title.
    • successful rename -> the new title stays and slots are never refetched (macrotask flush).
  • npx tsc -b clean; scoped npx vitest run src/test/ChatPage.titleRenamePin.test.tsx 9/9; scoped eslint clean on both touched files.

Manual verification

Behavior-only revert of an optimistic value back to what the UI showed before the edit; no new visual surface. Covered by the DOM-driven vitest cases above.

Screenshots / video

Why no screenshot: behavior-only revert of an optimistic value back to the pre-edit state; no new or changed visual surface (the failure toast and the title rendering both pre-date this PR).

Related Issues

Closes #10203

Pattern harvest

Rule candidate: an optimistic Redux dispatch whose paired request has a .catch that only reports (toast/notice) and never restores the value is the defect class here -- recovery must re-assert server truth (authoritative refetch, plus a guarded local revert when the refetch can share the failure mode), and queryClient.invalidateQueries recovers nothing that lives in Redux rather than under a registered query key.

@chenmingwei23
chenmingwei23 requested review from a team and Zedmor September 11, 2026 23:02
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 2cff0ee9c4192c3268d5e2e7b917f3d87bb59027 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Sound fix to a real defect, but the recovery state machine lives inline in JSX, diverges from the sibling sidebar fix, and the description documents an abandoned shape.

Watch

  • Same defect class, two divergent implementations at renameSlot's only two call sites: this PR builds a per-slot {baseline, inflight, gen} generation map with boundStore.getState() reconciliation inside a single JSX onBlur attribute (ChatPage.tsx:6571), while the still-open sibebar fix (fix: refetch slots when a sidebar rename is refused (#10151) #10172, "refetch slots when a sidebar rename is refused") adopts a simpler refetch shape — and today's ChatSidebar.tsx:2751 still uses the invalidateQueries call the PR's own "Pattern harvest" declares recovers nothing in Redux. This Redux-reconciliation logic belongs in a chatSlice thunk shared by both call sites; leaving it inline bakes in drift the next rename bug has to untangle twice.
    Clears when: the recovery is extracted to a shared thunk/helper consumed by both call sites (coordinated with #10172), or a human explicitly accepts the divergence.
  • Description ↔ diff mismatch: the description says the catch "dispatches fetchSlots(), whose fulfilled reconciler overwrites the stale optimistic title" and accepts a whole-snapshot residual — no such code ships; the diff uses a keyed queryClient.fetchQuery apply plus a generation guard that explicitly avoids that residual (and ships six tests, not three). Reviewers reading the description will evaluate the wrong design.
    Clears when: the PR description is updated to the shipped keyed-fetch + generation-guard mechanism.

Suggestions

[DESIGN-REVIEWED] 2cff0ee

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ PASS

UX-level review of 2cff0ee9c4192c3268d5e2e7b917f3d87bb59027 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

The evidence set is clear: no screenshots and no blind read, but the PR declares <!-- no-visual-delta --> with a stated reason. The diff confirms it — the only user-facing change is behavioral: on a refused header rename, the optimistic title now reverts to the server truth (or the pre-edit baseline), using the pre-existing failure toast and the pre-existing title rendering. No new control, label, string, or state is added; no component swap occurs (the same title element's text is restored, an error-recovery lifecycle, not a persistent-element transform). Tests drive the real header UI. The change removes a contradiction the user previously experienced — a "rename failed" toast beside a title still showing the failed rename.

UX-Verdict: PASS

Behavior-only fix that makes the UI stop contradicting its own error toast; no new or changed visual surface, so no screenshot is owed.

[UX-REVIEWED] 2cff0ee

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 2cff0ee9c4192c3268d5e2e7b917f3d87bb59027 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All the facts I need are verified: fetchSlots is the existing Redux recovery thunk (dashboardSlice.ts:99, ~8 dispatch sites), no useQuery registers ['chat-slots'] (0 matches), and renameSlot has exactly 2 non-test call sites (this one plus ChatSidebar.tsx:2751, the declared sibling deferred to #10151/#10172). The pivotal finding: the description says the catch "dispatches fetchSlots()" and accepts a whole-snapshot residual, but the diff never calls fetchSlots — it ships a bespoke keyed queryClient.fetchQuery recovery plus an undeclared per-slot generation/baseline/inflight tracker, and seven tests where the description says three.

First-Principles-Verdict: CONCERNS

The diff does not ship what the description says: no fetchSlots(), but an undeclared bespoke recovery machine (renameRecoveryRef gen/baseline/inflight) instead.

Not justified as shipped

  1. Per-slot generation/baseline/inflight tracking — undeclared; the description mentions only a "guarded on the store still holding the refused value" check, and the races the extra machinery guards (identical-string re-rename mid-recovery, overlapping refused renames) have no reported instance — they are derived from constructed interleavings, not a defect anyone hit.

What this change ships

Inventory (4 items) — 3 justified

Intent: when the server refuses a header rename, stop showing the refused title as if it succeeded — a FIX (issue #10203, mutation-verified test).

  1. A refused header rename now snaps the title back to the server's value — justified
  2. When the recovery re-read also fails, the title reverts locally to the last confirmed pre-rename title — justified
  3. A failed rename now triggers a background slots re-read, applied to this slot only — justified
  4. Per-slot rename-attempt tracking (generation/baseline/inflight map) so delayed recoveries never overwrite newer renames — undeclared; guards unreported races

Watch

  • Description contradicts the diff: "the .catch now also dispatches fetchSlots()" and "Known residual (accepted…): fetchSlots.fulfilled applies the whole snapshot" — the diff never calls fetchSlots (0 uses in the hunk; the thunk at website/src/store/dashboardSlice.ts:99 has ~8 dispatch sites elsewhere) and ships a keyed fetchQuery apply specifically to avoid that residual; "three new cases" is seven. Clears when: the description states the shipped mechanism, including renameRecoveryRef.
  • The gen machinery's harms rest only on interleavings the PR's own tests construct; if the author has a real occurrence of the identical-string race, naming it settles this. Clears when: a linked report or the author's confirmation that race-logic derivation is the intended provenance.

Subtractions

  • If no real occurrence of the identical-string / overlapping-rename races is nameable, shrink to the declared shape: keep the keyed re-read plus the store-still-holds-refused-value guard and a captured pre-rename title, delete renameRecoveryRef (gen/inflight/baseline) and the three tests that exist only to exercise it.

[FIRST-PRINCIPLES-REVIEWED] 2cff0ee

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 2cff0ee9c4192c3268d5e2e7b917f3d87bb59027 — this comment is updated in place on each push.

Review details

Only one candidate exists, and it self-rates "low" confidence, admitting it "could not construct a case where the two-attempt path produces a visibly wrong title."

Tracing it independently: the identical-string collapse in inflight (a Set<string>) does let attempt #2 delete the map entry while attempt #1 is still pending. But the observable harm requires stacking four conditions simultaneously — two overlapping renames to the identical string, a specific settle ordering, a third rename that seeds baseline from the still-optimistic store value, and that third attempt failing both renameSlot and chatSlots. Attempt #1 is correctly no-op'd anyway (its myGen is stale, so mayRecover() returns false). The residual is a cosmetic title revert to a slightly-wrong string in a fully-offline path — no data loss, no security boundary.

(a) concrete input, (b) call path, and (c) observable wrong outcome only resolve under that contrived multi-failure interleaving; each comes out as "could/if," not something that occurs in practice at 80+. Nothing else in the diff (a self-contained header-rename recovery handler plus its regression tests) grounds a new finding to that bar.

No findings.

[OPUS-REVIEWED] 2cff0ee

Verdict parsed from the review's SHA-scoped output markers for commit 2cff0ee9c4192c3268d5e2e7b917f3d87bb59027.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 2cff0ee9c4192c3268d5e2e7b917f3d87bb59027: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ human override accepted

Human judgment by @chenmingwei23 overrides the GPT 5.6 finding for 2cff0ee9c4192c3268d5e2e7b917f3d87bb59027; the recorded reason is authoritative for this commit.

This comment is updated in place on each push.

The model was not re-run because an authorized human decision supersedes it.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 2cff0ee9c4192c3268d5e2e7b917f3d87bb59027: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 11, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/header-rename-revert-10203 branch from d7844f8 to a7133ea Compare September 11, 2026 23:45
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 11, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/header-rename-revert-10203 branch from a7133ea to 61ef60e Compare September 12, 2026 01:26
@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for 61ef60ed3ffd524392c9e5b3972b7aa7d8ca2b25; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 61ef60ed3ffd524392c9e5b3972b7aa7d8ca2b25: <one-sentence reason>

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 12, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/header-rename-revert-10203 branch from 61ef60e to bf20719 Compare September 12, 2026 01:50
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 12, 2026
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Sep 12, 2026
The chat-header session-title rename dispatches the optimistic
sseSlotTitle, then calls api.renameSlot. Its .catch only reported the
failure through showActionError: the refused optimistic title was never
reverted, so the header and sidebar kept showing a server-rejected title
until an unrelated slot refetch or a reload.

The .catch now re-reads the server truth (deduped through
queryClient.fetchQuery) and applies ONLY this slot's title -- not the
whole snapshot, whose late fulfillment could transiently clobber a
newer concurrent write of another slot. A recovery may apply only
while its own attempt is still the slot's latest generation AND the
store still holds its refused value, so a delayed recovery can never
overwrite a newer attempt's outcome -- including a newer confirmed
rename to the identical string, which title equality alone cannot
distinguish. When the re-read fails too (a transport or auth failure
takes renameSlot and chatSlots down together), the catch falls back to
a per-slot recovery baseline: the last CONFIRMED title, refreshed at
commit time from any store title that is not one of this slot's own
pending optimistic values.

Extends the header-rename vitest with cases pinning the server-truth
revert, the local-revert fallback when both calls fail, the guard
against clobbering a newer concurrent write, the overlap baseline, the
confirmed-external baseline refresh, the stale-generation guard (each
verified to fail without its fix), and success keeping the title with
no refetch.

Closes #10203
@chenmingwei23
chenmingwei23 force-pushed the fix/header-rename-revert-10203 branch from bf20719 to 2cff0ee Compare September 12, 2026 02:31
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 12, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 2cff0ee: Verified: requires overlapping same-slot renames where B succeeds, C fails, AND an outage that also downs the recovery fetch; server keeps B, only the client header transiently shows A and self-heals on the reconnect fetchSlots (useWebSocket.ts:1023 -> applySlots). Display-only residual, no data loss; serializing per-slot renames is disproportionate for a four-way coincidence. Rounds 1-4 fixed the real defect classes in this span.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 2cff0ee9c4192c3268d5e2e7b917f3d87bb59027.

Verified: requires overlapping same-slot renames where B succeeds, C fails, AND an outage that also downs the recovery fetch; server keeps B, only the client header transiently shows A and self-heals on the reconnect fetchSlots (useWebSocket.ts:1023 -> applySlots). Display-only residual, no data loss; serializing per-slot renames is disproportionate for a four-way coincidence. Rounds 1-4 fixed the real defect classes in this span.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 12, 2026
@dwu96
dwu96 enabled auto-merge (squash) September 12, 2026 04:04

@dwu96 dwu96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: frontend-only fix reverting a refused optimistic session-title dispatch back to server truth, with a generation-guarded local-revert fallback; one source file plus its DOM-driven vitest cases, clear root cause (the .catch reported the failure without restoring the value).

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: a refused header rename left its optimistic title in the store; the catch now re-reads server truth and applies it keyed to the slot (so a newer concurrent write is not clobbered), falling back to the confirmed pre-rename baseline when the re-read also fails.

@dwu96
dwu96 merged commit 21c0c26 into main Sep 12, 2026
71 of 72 checks passed
@dwu96
dwu96 deleted the fix/header-rename-revert-10203 branch September 12, 2026 04:09
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 12, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer review (agent-assisted, owner delegated), pinned to 2cff0ee. Approving: rename reconciliation uses per-slot generation guards and partial apply from a deduplicated chat-slots read; if that read also fails, guarded local revert restores the title without overwriting a newer authoritative write. This addresses the double-rejection contract missing in #10172/#10140; it does not use their whole-snapshot fetchSlots fallback. Body cleanup requested as nonblocking: describe this partial reconciliation and seven tests, rather than fetchSlots/three. Shared lifecycle work in #9485 must rebase over this. Dedicated-worktree source/test review; current-head readiness green; no local suite rerun this wave.

amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…tdev#10203) (kirodotdev#10237)

The chat-header session-title rename dispatches the optimistic
sseSlotTitle, then calls api.renameSlot. Its .catch only reported the
failure through showActionError: the refused optimistic title was never
reverted, so the header and sidebar kept showing a server-rejected title
until an unrelated slot refetch or a reload.

The .catch now re-reads the server truth (deduped through
queryClient.fetchQuery) and applies ONLY this slot's title -- not the
whole snapshot, whose late fulfillment could transiently clobber a
newer concurrent write of another slot. A recovery may apply only
while its own attempt is still the slot's latest generation AND the
store still holds its refused value, so a delayed recovery can never
overwrite a newer attempt's outcome -- including a newer confirmed
rename to the identical string, which title equality alone cannot
distinguish. When the re-read fails too (a transport or auth failure
takes renameSlot and chatSlots down together), the catch falls back to
a per-slot recovery baseline: the last CONFIRMED title, refreshed at
commit time from any store title that is not one of this slot's own
pending optimistic values.

Extends the header-rename vitest with cases pinning the server-truth
revert, the local-revert fallback when both calls fail, the guard
against clobbering a newer concurrent write, the overlap baseline, the
confirmed-external baseline refresh, the stale-generation guard (each
verified to fail without its fix), and success keeping the title with
no refetch.

Closes kirodotdev#10203
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.

Header rename failure keeps the refused optimistic title (mirror of #10151)

4 participants