Repository navigation
fix(ui): abort stale destructive session confirmations on reconnect - #124254
Conversation
SessionDataController retires the session-mutation scope on reconnect, capability replacement, and host disconnect, but left any open destructive confirmation dialog in place. If the operator confirmed after reconnect the action silently no-opped, and the dialog's global lock stayed held until manually dismissed. Give SessionDataController an AbortController owned by the mutation epoch, abort it whenever the epoch advances, and expose the signal on SidebarSessionMutationScope. Wire it into every scope-bound confirm dialog: batch delete, single delete, cloud-worker stop, preserved- worktree removal, and session-group delete. confirm-dialog.ts already tears down its modal and releases the lock on an aborted signal, so a stale dialog now dismisses itself instead of surviving the reconnect. Fixes #124227
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 6:57 PM ET / 22:57 UTC. ClawSweeper reviewWhat this changesThe PR aborts sidebar and chat-header destructive session confirmations when their Gateway mutation scope retires, then shows a retry toast instead of silently discarding the action. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open for protected maintainer merge review. The PR repairs the lifecycle owner that currently retires mutation scopes without cancelling their dialogs, and it extends that rule to the independently scoped chat-header path; the prior missing-header concern is addressed. Priority: P1 Review scores
Verification
How this fits togetherControl UI session actions capture a Gateway-bound mutation scope before showing a destructive confirmation. Reconnects and teardown retire that scope; the dialog layer must release its global confirmation lock, prevent the stale request, and tell the operator to retry. flowchart LR
A[Operator starts session action] --> B[Capture mutation scope]
B --> C[Open destructive confirmation]
D[Gateway reconnect or pane teardown] --> E[Retire scope generation]
E --> F[Abort scope dialog signal]
F --> G[Release dialog lock]
G --> H[Show retry notice]
H --> I[Operator retries on current connection]
Decision needed
Why: The patch is technically supported, but the Before merge
Agent review detailsSecurityNone. PR surfaceSource +71, Tests +105. Total +176 across 11 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land one owner-bound cancellation signal per sidebar epoch and chat-header connection generation, preserving the existing confirmation behavior and giving each retired destructive action a visible retry outcome. Do we have a high-confidence way to reproduce the issue? Yes in source: open a destructive session confirmation, then reconnect or replace the session capability before confirming. Current main retires the scope but leaves the dialog active, while the PR includes focused regression scenarios for that sequence. Is this the best way to solve the issue? Yes. The patch attaches cancellation to the same lifecycle owners that define scope validity, covers the independent chat-header owner, and preserves action-specific user outcomes rather than adding downstream retries or fallbacks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1db8fe4d4f52. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
The sidebar epoch-abort wiring left the chat-header delete/fork/archive path uncovered: it builds its own SidebarSessionMutationScope from connectionGeneration but never handed it a signal, so a header confirm left open across a reconnect kept the shared confirmation lock forever. Give ChatPaneBase its own AbortController, retire it everywhere connectionGeneration advances (reconnect and pane teardown), and wire the signal into the header's captured scope, matching SessionDataController's controller for the sidebar. Separately, resolving an aborted confirm to `false` looked identical to an ordinary cancel, so the operator's lost intent vanished silently. Reorder every destructive confirm site to check scope staleness ahead of the `confirmed` guard and show the existing "Gateway connection replaced ... Try again." toast on abort, matching the pattern deleteSessionGroup already used for the same race. This also fixes a regression the PR had introduced in a pre-existing main test (app-sidebar.test.ts's "keeps a reconnected group delete retryable after its confirm opened"), which is what failed checks-node-compact-large-22 and checks-ui on the previous head.
Pre-merge maintainer decisionLanding this as maintainer ( "Resolve merge risk (P1)" — production grows +71 net; confirm per-action notices over a shared helper. Accepted as-is, keeping the explicit notices. The three new strings ( "Complete next step (P2)" — no repair job needed. Informational; nothing to apply. "Stored data model" flag. False positive from the heuristic's "serialized state" match on UI controller filenames. All 11 changed files live under Land-ready verification
|
|
Merged via squash.
|
…penclaw#124254) * fix(ui): abort stale destructive session confirmations on reconnect SessionDataController retires the session-mutation scope on reconnect, capability replacement, and host disconnect, but left any open destructive confirmation dialog in place. If the operator confirmed after reconnect the action silently no-opped, and the dialog's global lock stayed held until manually dismissed. Give SessionDataController an AbortController owned by the mutation epoch, abort it whenever the epoch advances, and expose the signal on SidebarSessionMutationScope. Wire it into every scope-bound confirm dialog: batch delete, single delete, cloud-worker stop, preserved- worktree removal, and session-group delete. confirm-dialog.ts already tears down its modal and releases the lock on an aborted signal, so a stale dialog now dismisses itself instead of surviving the reconnect. Fixes openclaw#124227 * fix(ui): abort chat-header confirms too and surface a retry notice The sidebar epoch-abort wiring left the chat-header delete/fork/archive path uncovered: it builds its own SidebarSessionMutationScope from connectionGeneration but never handed it a signal, so a header confirm left open across a reconnect kept the shared confirmation lock forever. Give ChatPaneBase its own AbortController, retire it everywhere connectionGeneration advances (reconnect and pane teardown), and wire the signal into the header's captured scope, matching SessionDataController's controller for the sidebar. Separately, resolving an aborted confirm to `false` looked identical to an ordinary cancel, so the operator's lost intent vanished silently. Reorder every destructive confirm site to check scope staleness ahead of the `confirmed` guard and show the existing "Gateway connection replaced ... Try again." toast on abort, matching the pattern deleteSessionGroup already used for the same race. This also fixes a regression the PR had introduced in a pre-existing main test (app-sidebar.test.ts's "keeps a reconnected group delete retryable after its confirm opened"), which is what failed checks-node-compact-large-22 and checks-ui on the previous head.
Fixes #124227
What Problem This Solves
Resolves a problem where a destructive confirmation (session delete, batch
delete, cloud-worker stop, preserved-worktree removal, or session-group
delete) stayed open across a Gateway reconnect, capability replacement, or
disconnect. Confirming it afterward silently did nothing, because the code
that ran on confirm re-checked the mutation scope and bailed out with no
visible outcome. The dialog also held the shared confirmation lock the whole
time it sat open, so the operator had to dismiss it manually before any other
confirmation could appear. This covers both the sidebar and the chat-header
delete/fork/archive menu, which shares the same delete operation through its
own independently-owned mutation scope.
Why This Change Was Made
SessionDataControlleralready retires the sidebar's mutation scope byadvancing an epoch on reconnect, capability replacement, and teardown, but
nothing told the open dialog about it.
confirm-dialog.tsalready accepts anAbortSignaland tears itself down (and releases its lock) when that signalfires — the same pattern the Devices page uses for its own destructive
confirms. This change gives
SessionDataControlleranAbortControllerowned by the mutation epoch, aborts it whenever the epoch advances, and
exposes the signal on
SidebarSessionMutationScope. Every scope-boundshowConfirmDialogcall insession-organizer-operations.runtime.tsandsession-organizer-catalog.tsnow passes that signal, so a stale dialogdismisses itself the moment its scope retires instead of waiting for the
operator.
The chat header builds its own
SidebarSessionMutationScopefromconnectionGenerationinstead of going throughSessionDataController, so ithad no signal to wire in and stayed uncovered.
ChatPaneBasenow owns its ownheaderSessionMutationAbortController, retired everywhereconnectionGenerationadvances (a reconnect inchat-pane-context.tsandpane teardown in
chat-pane-lifecycle.ts), andcaptureHeaderSessionActionScopehands its signal to the captured scope the same way
SessionDataControllerdoes for the sidebar.
Separately, an aborted confirm resolves to
false, which is indistinguishablefrom an ordinary cancel click. Every destructive-confirm call site checked
!confirmedbefore checking whether the scope was still current, so anabort's
falseshort-circuited past the existing staleness check and theoperator's lost intent vanished with no notice at all — the dialog just closed
on its own with no explanation. Each site now checks scope staleness first and
shows a toast ("Gateway connection replaced ... Try again.") before falling
through to the ordinary cancel path, reusing the exact pattern
deleteSessionGroupalready had for a narrower race (confirmed but the scopewent stale before the request went out). New i18n strings
(
deleteSessionStale,deleteSessionsStale,stopCloudWorkerStale) followthat same existing convention; the preserved-worktree follow-up confirm reuses
the existing
deletePreservedWorktreescopy since the outcome is identical(the worktree stays put).
User Impact
A confirmation dialog left open across a reconnect — in the sidebar or the
chat header — now disappears on its own instead of sitting there until the
operator dismisses it, and a fresh confirmation can open immediately
afterward. When that happens the operator now sees a toast explaining the
action was canceled by the reconnect and inviting a retry, instead of the
dialog just vanishing with no explanation. Ordinary confirm/cancel behavior
and the "don't ask again" delete preference are unchanged.
Evidence
Focused suites, with the fix applied:
Regression-test proof (stashed the production fix, kept the strengthened
tests, reran the same suites):
Without the header abort wiring, the header's dialog never dismisses itself
and the new test hangs the same way the original sidebar bug did. Without the
reordered staleness check, the toast assertions fail with zero calls: the
!confirmedbranch swallows the abort before the stale-scope toast is everreached.
node scripts/check-changed.mjs -- ui/src/components/session-organizer-batch-mutations.test.ts ui/src/components/session-organizer-catalog.ts ui/src/components/session-organizer-operations.runtime.ts ui/src/i18n/locales/en.ts ui/src/pages/chat/chat-pane-base.ts ui/src/pages/chat/chat-pane-context.ts ui/src/pages/chat/chat-pane-lifecycle.ts ui/src/pages/chat/chat-pane-session-menu.ts ui/src/pages/chat/chat-pane.test.tspassed lint/typecheck/duplicate-scan/dependency-pin/format/i18n gates
(delegated through Testbox).
.agents/skills/autoreview/scripts/autoreview --mode uncommittedreported noaccepted/actionable findings.
CI diagnosis (previous head)
checks-node-compact-large-22andchecks-uiboth failed on the same singletest,
ui/src/components/app-sidebar.test.ts > AppSidebar group mutation collapsed state > keeps a reconnected group delete retryable after its confirm opened(pre-existing onmain, unrelated to this PR's statedscope). That test reconnects while a group-delete confirm is open, then
clicks confirm, and expects the existing "Gateway connection replaced ..."
toast. Wiring
signal: scope.signalintodeleteSessionGroup's confirm callmade the dialog auto-dismiss on reconnect before the click could land, so
confirmedcame backfalseand the oldif (!confirmed) return false;ordering skipped the toast branch entirely — a real regression this PR's
earlier commits introduced into a
maintest, not a flake. The reorderingabove fixes it directly; both jobs had exactly one failing test each and no
other failures. All 12
checks-ui-e2eshards andchecks-ui-e2e-real-gatewaywere green on this PR's own head, so there's no e2e flake to report here.
Control UI proof (running app, head
5298bea2834)Drove the real sidebar through the mocked-Gateway Playwright harness
(
installMockGateway, the same harnesssession-organizer-batch-mutations.test.ts'ssibling e2e suite uses) with a "Projects" session group, forced a Gateway
reconnect while its delete confirm was open, and screen-recorded the result:
Delete group "Projects":https://github.com/user-attachments/assets/195c9027-f387-42e6-940f-e67fbd4d9270
the reordered staleness check fires the retry toast in the same beat:
https://github.com/user-attachments/assets/6adf5563-2fc6-41bb-bbff-0f8660ca7caf
Delete group "Projects"opens immediately (toast still visible above it):https://github.com/user-attachments/assets/3740d27c-11d0-4a20-bb02-473d4639fdab
sessions.groups.deletelands and "Projects" is gone:https://github.com/user-attachments/assets/22c86389-294c-4efd-bd56-d228a608f5f0
Full recording (open → reconnect → dismiss/toast → retry → success):
https://github.com/user-attachments/assets/0eb46077-8980-42a9-9d5c-1be9eee08034