Repository navigation
fix: stop delayed chat commands crossing gateway reconnects - #118019
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 1:41 AM ET / 05:41 UTC. ClawSweeper reviewWhat this changesThe PR captures the originating Gateway connection, session, agent, and authorization for delayed Control UI slash commands and queued resets, preventing reconnects from redirecting a mutation or retaining stale post-clear state. Merge readinessKeep this maintainer-authored PR open. Current main still leaves Priority: P2 Review scores
Verification
How this fits togetherControl UI chat converts slash commands and queued sends into Gateway session mutations. The changed path spans command confirmation, durable outbox delivery, reconnect handling, and chat-history refresh, so delayed work must remain bound to the Gateway and session that initiated it. flowchart LR
Operator[Control UI operator] --> Command[Slash command]
Command --> Confirm[Confirmation and access check]
Confirm --> Target[Capture Gateway and session target]
Target --> Queue[Delayed or queued delivery]
Queue --> Recheck[Connection and scope recheck]
Recheck --> Mutation[Gateway session mutation]
Mutation --> History[Refresh visible chat history]
Decision needed
Why: The source confirms that direct session reset is an admin-scoped Gateway action, while the current slash-command reset path does not apply that access check. Aligning them improves authorization consistency but deliberately changes what write-scoped operators can initiate from chat. Before merge
Agent review detailsSecurityNone. PR surfaceSource +532, Tests +1258, Docs +1. Total +1791 across 31 files. View PR surface stats
Review metricsNone. 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. Mantis proof suggestionA redacted Control UI chat proof can directly demonstrate that a queued Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical connection-ownership fence for delayed chat commands and queued resets, use the existing Gateway scope contract for mutations, and land after maintainers explicitly accept the Do we have a high-confidence way to reproduce the issue? Yes, from current source: Is this the best way to solve the issue? Unclear pending the permission decision: binding delayed work to its initiating Gateway/session is the correct owner-boundary repair, but whether AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f6341f2fbacd. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
fb394bf to
603321a
Compare
65bd4d9 to
cfaa582
Compare
cfaa582 to
16dcf4b
Compare
c9155e3 to
e4884d9
Compare
|
Merged. What changed after review:
Verification:
Landed on
Thanks @shakkernerd! |
Related: #117786
What Problem This Solves
Fixes an issue where Control UI chat session commands could outlive the Gateway connection, session selection, or authorization context in which the operator started them.
Commands delayed by session-state loading, reset confirmation, an active run, or durable queue delivery could otherwise continue after a reconnect. In particular, a queued
/resetcould be applied to a replacement Gateway, and the first send after/clearcould retain a stale branch precondition from the destroyed conversation.Why This Change Was Made
Chat slash commands now check the connected Gateway's advertised methods and current operator scopes before mutation, then retain the originating client, connection epoch, session key, and agent across asynchronous work.
/resetrequiresoperator.admin, matching the Gateway lifecycle it triggers, and its captured target is carried through durable queue delivery so a reconnect cannot redirect it.The reset and clear paths also distinguish confirmed, rejected, and ambiguous outcomes. Ambiguous reset sends are not replayed, while
/clearremoves an obsolete active-leaf precondition only after the original connection returns authoritative empty history for the same visible session.This is the chat-command lifecycle portion split from #117920. The first PR owns the shared session authorization policy and general Control UI controls; this PR owns slash-command dispatch, queued delivery, reset confirmation, reconnect handling, and post-clear history state.
User Impact
Operators can continue using
/model,/think,/compact,/clear, and/resetwithout a delayed command mutating a replacement Gateway or a different selected session.Queued resets remain reviewable after interruption instead of being replayed, permission changes are rechecked immediately before mutation, and the first message after a successful clear starts a fresh branch without carrying stale conversation state.
No Gateway protocol, storage schema, or configuration surface changes are introduced.
Evidence
30752889490passed the exact-head changed gate, including production, test, and Control UI types; lint; formatting; dead exports; runtime import cycles; and architecture guards.65bd4d99ca7./resetcompleted withSession reset.through the packaged Control UI./resetwas held during an active run, the Gateway was restarted, and the interrupted run recovered without executing the reset on the replacement connection./clearproof on the behavior-equivalent pre-extraction head accepted the first post-clear message without the stale active-leaf precondition.