Repository navigation
fix: treat a 404 on session close as a completed close - #14834
Conversation
UX Review (Fable 5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] 370512a Description read[DESCRIPTION-READ] a87c6d5f93f53a38d14384ed50d3c883612314df4f02c05683abc4fe8b3ebdd0 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 (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 370512a Description read[DESCRIPTION-READ] a0211c6bbc035f69a0a6e5b55a17fa0b711ff0ee9886890cab3ce1313bfa9d02 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 |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the server-side premise: a close that popped the key can still fail and restore the slot — it alone justifies the hold-release/distrust/ That premise is client-untestable here; if the pop is actually irrevocable, items 3–5 guard a state that cannot occur and the simple What this change shipsInventory (6 items) — 6 justifiedIntent: closing a session the server already deleted succeeds quietly instead of raising an error — a FIX.
[FIRST-PRINCIPLES-REVIEWED] 370512a Description read[DESCRIPTION-READ] 386f457d9423e7f09e26fbf22088e4262b32edaf6e6beb2524575cf5909412d5 That sha256 names the PR description this verdict read. Recompute it with |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo blocking issues; one advisory gap in the new 404 branch. FINDING — website/src/store/chatSlice.ts:3771 — the new [OPUS-REVIEWED] 370512a |
9e0d2d5 to
4ce79ce
Compare
|
self-added: yes
|
|
Status on head 4ce79ce, not yet fixed on a new head. Both line-lane findings on the 404 branch of
Planned fix for the next head: on a 404, keep Separately, |
4ce79ce to
dc1ac59
Compare
|
Dispositions for the Opus 5 Review of 4ce79ce, fixed on head dc1ac59 (rebased onto origin/main 7610731).
|
|
Disposition for the GPT 5.6 Review of 4ce79ce (security-fenced F1), fixed on head dc1ac59.
|
Closing a chat session the server already deleted (a second tab, or a repeat close racing a slow first one) got a 404 from DELETE /api/chat/slots/<key>, and deleteSlot treated it like any failure: released the close hold, refetched slots and showed 'save failed'. A 404 there means the slot is gone, which is the requested end state, so deleteSlot now resolves on it instead of rejecting. Everything else on that path matches the failure path, because this request closed nothing and the close that did pop the key can still fail and restore the slot: - it drops its close hold rather than confirming it, so a restored row is not hidden behind this request's tombstone; - before releasing, it pairs every fetchSlots still in flight with the key in staleSlotFetches (releaseCloseHold's distrustInFlight), since such a reply may predate the pop and would otherwise re-add the row whichever order it lands in; - it still dispatches the recovery fetchSlots after that pairing, the trusted post-pop list that shows the row again if it was restored; - its fulfilled action carries meta.alreadyGone, and the chat slice skips evictSlotState for it, leaving the slot's view state to the authoritative slot-list writers. The close-hold paragraph of the dashboard spec now describes the 404 path. Other statuses keep the failure path. Closes kirodotdev#14823
dc1ac59 to
370512a
Compare
|
Disposition for the GPT 5.6 Review of dc1ac59 (fenced F1, upheld), fixed on head 370512a (rebased onto origin/main 2e09b10).
|
|
Disposition for the Opus 5 Review advisory FINDING on 370512a (
|
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed on behalf of the maintainers (readiness sweep 2026-09-29): readiness passed, the required PR Readiness check is green on this head, no live CHANGES_REQUESTED, no open blocking review threads; where the PR's files also moved on main since its merge-base, the PR's own tests were run on the main+PR merge tree and passed. Approving and squash-merging.
Problem / Motivation
Goal: Closing a chat session the server has already deleted succeeds quietly instead of showing a "not found" error.
When a session is closed twice, for example from a second tab still showing it or by a repeat click while a slow first close is in flight, the second
DELETE /api/chat/slots/<key>returns HTTP 404{"error": "not found"}. The dashboard treats that like any failure: it puts the close back in doubt, refetches the slot list and raises an error report, even though the session is gone.Why it matters
The user sees an error for an action that worked. It suggests the session is still there or that something broke, and it lands in the dashboard's error reports as noise. Nothing is wrong server-side.
Not a goal
api_chat_slot_delete.deleteChatSlotcallers: the ones inchatSlice.tsalready swallow errors, andArtifactDetailPage.tsxalready treats a 404 as "already archived".What changed (motivation → approach → change)
A second close of the same session showed an error. The cause is the
deleteSlotthunk inwebsite/src/store/chatSlice.ts: itscatcharoundapi.deleteChatSlot(key)releases the close hold, refetches slots and throwssave failedfor every rejection, and a 404 from that endpoint is a rejection. For a dashboard caller the server only answers 404 when the slot is no longer instate._slots, which is the end state the close asked for.deleteSlotnow reads the rejection with the existingisNotFoundErrorhelper fromwebsite/src/api/apiError.ts. A 404 resolves the close instead of throwingsave failed. Because this request closed nothing, and the close that did pop the key can still fail and put the slot back, the rest of the 404 path matches the failure path:fetchSlotsstill in flight with the key instaleSlotFetches(new optionaldistrustInFlightonreleaseCloseHoldinwebsite/src/store/dashboardSlice.ts, the same pairing theremovedbranch ofsseSlotPatchrecords), because such a reply may predate the pop and would otherwise re-add the row whichever order it lands in;fetchSlots()after that pairing, so the post-pop list is trusted and shows the row again if the popping close restored it;fulfilledaction carriesmeta.alreadyGone(throughfulfillWithValue), anddeleteSlot.fulfilledskipsevictSlotStatefor it, so the tab keeps that slot's in-memory view state until an authoritative list (reconcileSlotResidueon the nextslotsframe, or aslot_patchremovedkey) settles it.The payload is still the key, so
unwrap()callers are unchanged. The close-hold paragraph indocs/system-specs/modules/learn-cron-dashboard.mdnow describes the 404 path and says why it differs from the other already-answered removal sites, which arm a confirmed hold. Every other status keeps the current failure path.Backwards compatibility
Compatible: only a 404 from this one DELETE changes outcome, from a false failure to success, with the same hold release and refetch as before; every other status and the success path behave as before.
Tests
website/src/test/ChatSliceCoverage.test.tsx,treats a 404 on DELETE as a completed close: a 404 rejection resolvesdeleteSlotas fulfilled, leaves no close hold and keeps the row removed. Fails on origin/main (expected 'chat/deleteSlot/rejected' to be 'chat/deleteSlot/fulfilled').refetches after a 404 close so a pre-close slot list cannot keep the row: afetchSlotsalready in flight at click time answers with the closed row after the 404, and the recovery refetch's post-pop list removes it again. Fails on 4ce79ce (no secondchatSlotscall, row stays).drops a pre-close slot list that lands after the 404 close's recovery refetch: the in-flight reply lands last with the closed row and is filtered for that key. Fails on dc1ac59 (row comes back).trusts the recovery refetch when the popping close restored the slot: a recovery list that still carries the key shows the row, and the late pre-close reply does not remove it.keeps the slot's view state on a 404 close and evicts it on a real one: after a 404 closeslotMessagesfor the key survives; after a successful close it is evicted. Fails on 4ce79ce.shows a slot the server restores after a 404 close: after a 404 close, a slot list that still carries the key shows the row.still fails the close on a non-404 status: a status-500 rejection still rejects and still refetches slots.Run locally on head
370512a4f(base origin/main2e09b1030):npx vitest run src/test/ChatSliceCoverage.test.tsx: 114 passed.SCOPED_TESTS_BASE_REF=$(git merge-base HEAD origin/main) scripts/run_scoped_tests.py --surface frontend: 352 files, 10565 tests passed.tsc -b,tsc -p tsconfig.app.json --noEmit,eslinton the three changed source files,npm run jscpd(0 clones),scripts/docs_lint.py: clean.Manual verification
N/A: unit coverage sufficient. The change is a branch inside the store thunk, and the tests drive that thunk with the same rejection shape the API client produces for a 404.
Screenshots / video
Why no screenshot: no component, layout or string changes; the store stops raising an error in a two-close race, which the unit tests cover.
Related Issues
Closes #14823
Pattern harvest
Not generalizable: the other DELETE-slot callers already treat 404 as done (
ArtifactDetailPage.tsx) or ignore errors, so this was the one caller left.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)