Skip to content

fix(chat): ignore a session-gone answer after its panel closed - #32833

Merged
buluoray merged 1 commit into
mainfrom
crew/slack/fix-own-slot-late-gone
Nov 8, 2026
Merged

buluoray merged 1 commit into
mainfrom
crew/slack/fix-own-slot-late-gone

Conversation

@buluoray

@buluoray buluoray commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

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: useOwnSlotChat opens it with switchSlot, and on a 404 the host forgets the session. That 404 branch was the one path in the effect without the current guard. 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

  • Any change to how a live panel handles a 404 or a gateway failure.
  • The switchSlot thunk'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 .catch called onSessionGone without checking current, unlike the success and non-404 branches.

Change:

  • website/src/hooks/useOwnSlotChat.ts: the .catch returns at once when the effect is no longer current, before onSessionGone or setFailure.

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 case keeps 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').
  • Related vitest files (ArtifactChatPanel.ownSession, ChatPanel, ArtifactDetailPage.companionChat, the two Papyrus panel files, switchSlotCallsiteClassification): 123 passed. eslint and tsc --noEmit are clean.

Manual verification

Not run in a browser; the timing is driven through the mocked switchSlot in 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 -- useOwnSlotChat is the only caller of onSessionGone; ArtifactChatPanel, the app SDK ChatPanel and the Papyrus panels all go through it

Pattern harvest

Not generalizable: the guard is local to this effect, which already used it on its other branches.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

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
@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 8, 2026 01:29
@buluoray
buluoray requested a review from tim-finnigan November 8, 2026 01:29
@buluoray
buluoray enabled auto-merge (squash) November 8, 2026 01:29
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 46b5ad8ff39a6727675983140bd94c9a60bbf757 — 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 does not.

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

  • Item 2 — undeclared: the same if (!current) return also fires when a mounted panel's slotKey changes during a pending open. The old key's 404 then no longer forgets that deleted session. The description only claims "a mounted panel handles a 404 exactly as before", so this case is unstated, though it does fit the Goal's "closed or moved on" comment.

What this change ships

Inventory (3 items) — 2 justified

Intent: 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.

  1. A late "session not found" answer for a closed embedded chat panel no longer removes or tombstones the session — justified
  2. A panel that switched to another session ignores a late 404 for its previous session — undeclared
  3. A regression test where the 404 arrives after the panel unmounts — justified

[FIRST-PRINCIPLES-REVIEWED] 46b5ad8

Description read

[DESCRIPTION-READ] c07ad6eb3674efff01415d8a740ab44bd523f9752b0ea577bfa33ce94bdd7d2d

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 46b5ad8ff39a6727675983140bd94c9a60bbf757 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 46b5ad8ff39a6727675983140bd94c9a60bbf757 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the change applies the same current guard the other branches already use.

Notes

  • The guard also drops a real 404 when the panel switches to another session instead of closing. The deleted key then stays listed until something opens it again. That is acceptable, since the next open of that key gets its own 404 and forgets it.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 46b5ad8ff39a6727675983140bd94c9a60bbf757 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 46b5ad8

Verdict parsed from the review's SHA-scoped output markers for commit 46b5ad8ff39a6727675983140bd94c9a60bbf757.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 46b5ad8ff39a6727675983140bd94c9a60bbf757 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 46b5ad8ff39a6727675983140bd94c9a60bbf757 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 46b5ad8

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 46b5ad8ff39a6727675983140bd94c9a60bbf757 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 8, 2026
@buluoray
buluoray merged commit cfca397 into main Nov 8, 2026
98 checks passed
@buluoray
buluoray deleted the crew/slack/fix-own-slot-late-gone branch November 8, 2026 02:35
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 8, 2026
buluoray added a commit that referenced this pull request Nov 8, 2026
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)
buluoray added a commit that referenced this pull request Nov 8, 2026
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)
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