Repository navigation
fix(chat): ignore a session-gone answer after its panel closed - #32833
Conversation
An embedded chat panel opens its session with switchSlot and, on a 404, has the host forget that session. The 404 was acted on even when it arrived after the panel had closed, so a session the user reopened from History in the meantime was removed and switched away from. A late answer to a closed panel's open is now ignored, as a late success and a late failure already were. Refs #32434
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix is one guard on the only path in the effect that had none. The defect has provenance: the added test fails on base with the quoted assertion. Notes
What this change shipsInventory (3 items) — 2 justifiedIntent: keep a session reopened from History from being removed by a late 404 meant for a chat panel that has since closed. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 46b5ad8 Description read[DESCRIPTION-READ] c07ad6eb3674efff01415d8a740ab44bd523f9752b0ea577bfa33ce94bdd7d2d That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The change only stops a late reply for a closed chat panel from acting, and adds or changes no control, string or state, so the missing blind read leaves no evidence gap. [UX-REVIEWED] 46b5ad8 Description read[DESCRIPTION-READ] e33b02a44761b68f59f841bf4f3493d807eab59d2424faea1456a756a46f3c9a That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change applies the same Notes
[DESIGN-REVIEWED] 46b5ad8 Description read[DESCRIPTION-READ] 6d54924142d06757d69ff950ab3156702b60dafd75380da5352a22b6cc599af8 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
An embedded chat panel opens its session with switchSlot and, on a 404, has the host forget that session. The 404 was acted on even when it arrived after the panel had closed, so a session the user reopened from History in the meantime was removed and switched away from. A late answer to a closed panel's open is now ignored, as a late success and a late failure already were. Refs #32434 (cherry picked from commit cfca397)
An embedded chat panel opens its session with switchSlot and, on a 404, has the host forget that session. The 404 was acted on even when it arrived after the panel had closed, so a session the user reopened from History in the meantime was removed and switched away from. A late answer to a closed panel's open is now ignored, as a late success and a late failure already were. Refs #32434 (cherry picked from commit cfca397)
Problem / Motivation
Goal: A session the user reopened from History is never removed by a late "session not found" answer meant for a chat panel that has since closed.
#32434 keeps an embedded chat panel (the artifact companion, an app's chat panel) on its own session:
useOwnSlotChatopens it withswitchSlot, and on a 404 the host forgets the session. That 404 branch was the one path in the effect without thecurrentguard. If the panel closes while the open is pending and the user reopens the same session from History before the late 404 lands, the closed panel's callback tombstones and removes the resumed session, and ChatPage switches away from it.Found by GPT on the 0.12.1 port #32823 (finding at
useOwnSlotChat.ts:115, upheld); the same code is on main.Why it matters
The chat the user just reopened disappears from the session list and the page moves to another chat, with no error shown.
Not a goal
switchSlotthunk's own stale-response handling.What changed (motivation → approach → change)
Symptom: close the panel during a pending open, reopen the session from History, then the late 404 removes it.
Cause: the
.catchcalledonSessionGonewithout checkingcurrent, unlike the success and non-404 branches.Change:
website/src/hooks/useOwnSlotChat.ts: the.catchreturns at once when the effect is no longer current, beforeonSessionGoneorsetFailure.Backwards compatibility
Compatible: a mounted panel handles a 404 exactly as before. A retry or a new session for the same panel re-runs the switch, so its own answer is still acted on.
Removes nothing.
Tests
ArtifactChatPanel.ownSession.test.tsx: new casekeeps a session whose 404 arrives after the panel closed. The switch answers only when the test rejects it; the panel unmounts first, then the 404 lands. The session stays listed and is not marked closing. It goes red without the guard (expected [ 'zzq-other' ] to include 'zzq-late').ArtifactChatPanel.ownSession,ChatPanel,ArtifactDetailPage.companionChat, the two Papyrus panel files,switchSlotCallsiteClassification): 123 passed. eslint andtsc --noEmitare clean.Manual verification
Not run in a browser; the timing is driven through the mocked
switchSlotin the test above.Related Issues
Follow-up to #32434; found on its release port #32823.
Sibling sweep
Swept: git grep -n "onSessionGone" -- website/src
Siblings: none --
useOwnSlotChatis the only caller ofonSessionGone;ArtifactChatPanel, the app SDKChatPaneland the Papyrus panels all go through itPattern harvest
Not generalizable: the guard is local to this effect, which already used it on its other branches.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.