Skip to content

fix(gateway,tui): queue-mode busy guard + queued-turn cancel contract#89078

Closed
SebTardif wants to merge 0 commit into
openclaw:mainfrom
SebTardif:fix/tui-queue-mode-busy-guard
Closed

fix(gateway,tui): queue-mode busy guard + queued-turn cancel contract#89078
SebTardif wants to merge 0 commit into
openclaw:mainfrom
SebTardif:fix/tui-queue-mode-busy-guard

Conversation

@SebTardif

@SebTardif SebTardif commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #89059
Fixes #90012

What Problem This Solves

Fixes an issue where TUI users sending a prompt during an active run would have the prompt blocked before Gateway queue handling could apply. It also fixes queued prompts becoming unabortable after the original chat.send client run finalized, which could let Esc or /stop report completion while queued work still executed.

Why This Change Was Made

Gateway and the auto-reply queue now own one queued-turn lifecycle across admission, collect-mode aggregation, transcript persistence, cancellation, dispatch, and terminal state. TUI remains a thin client: it forwards mid-run prompts, blocks only while admission is pending, and uses session-scoped abort for Esc and /stop even after a queued client run has left local UI state.

Queued cancellation remains requester-authorized by device or connection identity. Collect mode keeps cancellation owners in separate batches, retains queue-level cancellation after admission, and retires sibling client identities only when the aggregate has atomically acquired the reply lane.

User Impact

TUI users can send follow-up and collect-mode prompts while an agent is running, intentionally repeat prompt text, cancel queued work reliably, and continue chatting after the queue drains. Failed post-admission bookkeeping no longer produces contradictory accepted-then-error terminal events, and queued transcript/media/context data stays attached to the collected turn.

Evidence

  • Blacksmith Testbox provider: blacksmith-testbox; lease tbx_01kwq9sqcc96ax8hcsevfr44fj (amber-barnacle).
  • Exact remote PR tree: 0466533396c49168397ea452e912f6828ceb7d8a; remote head e307d2534636a42acb4329c3a2e8afca56385393.
  • Production pnpm build: passed.
  • Focused regression matrix: 347 tests passed across Gateway, TUI command handling, queue collect, and follow-up runner suites.
  • Live PTY matrix: 4 scenarios passed using the real local backend/Gateway path with a mocked model endpoint: local turn, mid-run follow-up plus a later turn, Esc cancellation before model dispatch, and collect-mode aggregation.
  • pnpm check:changed: passed core/test typechecks, all lint shards, dependency and patch guards, storage/runtime sidecar checks, import-cycle check, webhook ordering, and pairing guards.
  • Fresh Codex autoreview after the final fixes: no accepted or actionable findings.
  • Dependency Guard: successful exact-head rerun.
  • Exact-head CI release gate: run 28718961851.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 1, 2026
@clawsweeper

clawsweeper Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 4, 2026, 8:20 PM ET / 00:20 UTC.

Summary
This PR changes TUI active-run submit/stop handling and adds Gateway-owned queued-turn cancellation for followup/collect work, with related docs and tests.

Reproducibility: yes. Current main still blocks non-local active-run TUI sends in both sendMessage and canSubmitTuiChatMessage before Gateway queue handling can apply.

Review metrics: 3 noteworthy metrics.

  • Merge state: CONFLICTING/DIRTY. Maintainers cannot rely on the final merged diff until the branch is refreshed.
  • Exact-head proof gap: 1 behavior-sensitive commit after supplied proof. The PR body proves e307d25, while live head efc3c8e includes an additional queue ownership change.
  • Dependency guard surface: 81 dependency-related paths listed; latest guard failed. Package, lock, and shrinkwrap paths are supply-chain review surfaces even when some drift is current-main-only.

Stored data model
Persistent data-model change detected: migration/backfill/repair: docs/cli/onboard.md, unknown-data-model-change: ui/src/ui/controllers/sessions.test.ts, unknown-data-model-change: ui/src/ui/controllers/sessions.ts, unknown-truncated-pull-files, vector/embedding metadata: docs/channels/pairing.md, vector/embedding metadata: docs/cli/onboard.md, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #89078
Summary: This PR is the active candidate fix for the two open TUI queue-mode busy-guard reports; the older burst optimistic-send PR is adjacent but does not own this queue/cancel contract.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🐚 platinum hermit
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Refresh the branch until GitHub reports a clean merge result.
  • Update the live TUI/Gateway proof for the current final head, with private details redacted.
  • Resolve or explicitly authorize the latest dependency guard state.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body supplies strong live_output proof for e307d25, but the current head is efc3c8e after an additional queue ownership commit, so exact-head behavior proof is stale. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Live GitHub reports this head as CONFLICTING/DIRTY, so the actual merge result still needs a refresh before maintainer approval.
  • [P1] The protected security label is meaningful because queued-turn abort ownership and dependency/shrinkwrap surfaces are security-review surfaces.
  • [P1] The PR body's live Testbox/PŤY proof is for e307d25, not the current efc3c8e head after the latest queue ownership commit.
  • [P1] Dependency Guard is failing on the latest head; maintainers need either exact-head false-positive authorization or a clean dependency graph before merge.

Maintainer options:

  1. Refresh and re-prove exact head (recommended)
    Rebase or otherwise refresh the PR until GitHub has a clean merge result, then update the live TUI/Gateway proof for efc3c8e or a newer final head.
  2. Accept maintainer-owned security risk
    Maintainers can intentionally accept the queued-turn authorization model after security review clears requester-scoped abort behavior and the dependency guard state.
  3. Replace with a narrower queue branch
    If the broad dirty file list remains hard to review, preserve the queue fix in a smaller replacement PR and close this branch only after that replacement is viable.

Next step before merge

  • [P1] The remaining action is maintainer/security review plus branch/proof/dependency refresh, not a narrow automated repair.

Security
Cleared: No concrete security or supply-chain defect was found, but the protected security label and dependency guard state still require maintainer handling before merge.

Review details

Best possible solution:

Refresh to a clean merge result, keep the Gateway-owned queued-turn cancellation design, renew exact-head proof or maintainer override, and clear security/dependency review before landing.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main still blocks non-local active-run TUI sends in both sendMessage and canSubmitTuiChatMessage before Gateway queue handling can apply.

Is this the best way to solve the issue?

Mostly yes. Keeping TUI thin and moving queued-turn cancellation into Gateway is the right owner boundary, but this exact branch still needs clean merge, exact-head proof, and security/dependency clearance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4ec7842be0af.

Label changes

Label changes:

  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body supplies strong live_output proof for e307d25, but the current head is efc3c8e after an additional queue ownership commit, so exact-head behavior proof is stale. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: This is a normal-priority TUI/Gateway queue bug with bounded but real message-delivery impact.
  • merge-risk: 🚨 compatibility: The PR changes client-visible TUI stop/submit behavior and mixed-version chat.abort fallback behavior.
  • merge-risk: 🚨 message-delivery: The PR changes whether active-run TUI prompts reach Gateway and how queued followup/collect turns are cancelled.
  • merge-risk: 🚨 security-boundary: The PR changes requester-owned queued-turn abort authorization, so cross-connection and cross-device scoping must be correct.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body supplies strong live_output proof for e307d25, but the current head is efc3c8e after an additional queue ownership commit, so exact-head behavior proof is stale. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

What I checked:

  • Current main blocks active-run TUI sends: Current main still returns before client.sendChat when a non-local activeChatRunId exists, so Gateway queue policy cannot apply. (src/tui/tui-command-handlers.ts:780, 4ec7842be0af)
  • Current main submit gate blocks active runs: canSubmitTuiChatMessage returns false for non-local active runs, matching the linked issue's typed-submit complaint. (src/tui/tui.ts:417, 4ec7842be0af)
  • PR head forwards active-run prompts: At PR head, TUI serializes only pending admission and leaves already-active queue policy to Gateway. (src/tui/tui-command-handlers.ts:778, efc3c8e96972)
  • Gateway queued-turn registry added: The PR adds a Gateway-owned queued-turn map so queued chat.send turns can remain abortable without being projected as active runs. (src/gateway/chat-queued-turns.ts:41, efc3c8e96972)
  • TUI stop now uses session-scoped abort: The PR makes TUI abort through the session so queued turns whose local run handles disappeared can still be stopped by Gateway. (src/tui/tui-session-actions.ts:636, efc3c8e96972)
  • Live PR state has merge/security blockers: Live GitHub reports mergeable=CONFLICTING, mergeStateStatus=DIRTY, a protected security label, and a failed dependency-guard check on head efc3c8e. (efc3c8e96972)

Likely related people:

  • steipete: Requested the Gateway-owned queued-turn cancellation contract and authored the two latest queue ownership commits on this PR. (role: reviewer and queue-contract contributor; confidence: high; commits: e307d2534636, efc3c8e96972, 7a736bff9095; files: src/gateway/chat-queued-turns.ts, src/gateway/server-methods/chat.ts, src/auto-reply/reply/queue/drain.ts)
  • vincentkoc: Live PR metadata lists vincentkoc as assignee, and recent history touches adjacent TUI/status and release-stabilization surfaces. (role: assigned follow-up owner and recent area contributor; confidence: medium; commits: e085fa1a3ffd; files: src/tui/tui-command-handlers.ts, src/tui/tui.ts)
  • Dallin Romney: Current-main blame for the TUI busy-guard and submit-gate lines points to a recent TUI rewrite commit, though the semantic queue behavior is older. (role: recent TUI run-state contributor; confidence: medium; commits: 6c53dfa1df99; files: src/tui/tui-command-handlers.ts, src/tui/tui.ts)
  • Vignesh Natarajan: History shows prior work preserving optimistic user messages during active runs in the same TUI state area. (role: adjacent TUI active-run contributor; confidence: medium; commits: 61a0b0293104; files: src/tui/tui-command-handlers.ts, src/tui/tui.ts, src/tui/tui-event-handlers.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-04T12:46:49.231Z sha d673c3b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T12:58:16.300Z sha 0dc6764 :: needs real behavior proof before merge. :: [P2] Mirror the shared queue directive parser
  • reviewed 2026-07-04T13:04:52.504Z sha 0dc6764 :: needs real behavior proof before merge. :: [P2] Mirror the shared queue directive parser
  • reviewed 2026-07-04T16:14:01.963Z sha d5f1863 :: needs real behavior proof before merge. :: [P2] Use the shared queue directive parser
  • reviewed 2026-07-04T16:20:05.012Z sha 35816e0 :: needs real behavior proof before merge. :: [P2] Use the shared queue directive parser
  • reviewed 2026-07-04T20:32:13.284Z sha e307d25 :: needs real behavior proof before merge. :: [P1] Remove unrelated dependency graph changes
  • reviewed 2026-07-04T20:40:01.417Z sha e307d25 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T20:47:47.159Z sha e307d25 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 1, 2026
@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 2, 2026
@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@SebTardif
SebTardif force-pushed the fix/tui-queue-mode-busy-guard branch 3 times, most recently from 2091d97 to cbc7fa5 Compare June 4, 2026 04:52
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 4, 2026
@SebTardif
SebTardif force-pushed the fix/tui-queue-mode-busy-guard branch from cbc7fa5 to 0c98adc Compare June 4, 2026 17:30
@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 4, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 3, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 3, 2026
@SebTardif
SebTardif force-pushed the fix/tui-queue-mode-busy-guard branch from 18f883d to 79b1507 Compare July 3, 2026 14:45
@SebTardif

Copy link
Copy Markdown
Contributor Author

Still actively maintained. Rebased onto latest main just now (clean rebase, no conflicts).

The fix remains necessary on current main: sendMessage and canSubmitTuiChatMessage still hard-block on activeChatRunId without consulting queue mode.

ClawSweeper last rated this silver shellfish and asked for live TUI+Gateway mid-run proof for non-steer modes. Existing proof covers unit tests, build, compiled-dist greps, and gateway startup. Live mid-run TUI proof still needs a long-running provider turn with credentials; happy to add that if a maintainer wants it prioritized.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 3, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 4, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 4, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 4, 2026
@SebTardif
SebTardif force-pushed the fix/tui-queue-mode-busy-guard branch from d673c3b to 0dc6764 Compare July 4, 2026 12:54
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 4, 2026
@SebTardif

Copy link
Copy Markdown
Contributor Author

CI failure classification: native-command-session-target (QA Smoke)

Verdict: flake (not a regression from this PR). No further empty-commit retrigger needed; current head is green.

Evidence (failed run 28667710235, artifact qa-smoke-profile-28667710235-1)

Scenario report (flow/isolated/scenarios/native-command-session-target/qa-suite-report.md):

  • Scenario: Native command active session target evidence
  • Step: native stop targets the active conversation session
  • Result: timed out after 5000ms
  • Suite overall on that profile: 24 passed / 1 failed (only this scenario)

Gateway stderr in the same artifact only recorded:

[gateway] startup model warmup timed out after 5000ms; continuing without waiting

Why not a regression from this branch

Check Result
PR touch set TUI + session queueMode plumbing only (src/tui/*, src/gateway/session-utils*.ts)
Failed scenario Telegram/Crabline native command session targeting (/stop active session), gateway QA path
Overlap No shared code path with TUI editor busy-guard / queueMode submit gate
Current head 0dc6764 QA Smoke CI = SUCCESS, full check set green after rebase onto main

Follow-ups already landed on this PR (unrelated to that timeout)

CI later failed on tui-command-handlers assertions after merge-with-main introduced addBlockedChatSubmitNotice (coalesceConsecutive: true). That was a real test drift, fixed by rebasing and updating expectations. Not related to native-command-session-target.

@steipete steipete left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reported TUI queue-mode bug is valid, but this PR needs a Gateway-owned queued-turn cancellation contract before it is safe to land.

Once TUI forwards a prompt during an active run, Gateway can enqueue it and then terminalize the original chat.send before the queued turn starts. The TUI loses that run as an abort target, so Esc or /stop can report completion while the queued prompt still executes.

Two maintainer-side implementations were tested and rejected:

  • Retaining the per-send controller across queue wait breaks terminal dedupe, collect batching, reconnect projection, embedded-run start/timeout ownership, and summarize-overflow behavior.
  • Clearing the whole session queue bypasses per-requester and hidden-run authorization, and clearing after active abort races queue drain promotion.

The right pre-merge state is one canonical Gateway queue lifecycle: owner-aware queued identity/cancellation, cleanup before active-run signaling, selected-global-agent scoping, and coherent terminal/dedupe/projection/timeout behavior across followup, collect, and summarize. TUI should still forward active-run prompts to Gateway rather than project queue policy locally.

Verified useful pieces in the maintainer rewrite: real PTY TUI-to-Gateway follow-up delivery, repeated identical TUI prompts not coalesced, transcript slot ordering, and preservation of the older active run/status when queue admission fails. Those pieces are not being pushed while the cancellation contract remains unresolved.

@SebTardif

Copy link
Copy Markdown
Contributor Author

Addressing CHANGES_REQUESTED (queued-turn cancellation contract)

Implemented a Gateway-owned cancel identity for turns admitted to followup/collect after chat.send terminalizes.

What landed

steipete requirement Implementation
TUI must not be the only abort handle chatQueuedTurns registry on Gateway context, keyed by client runId
Do not retain active send controller as “active” across wait Separate map + phase (queued / promoting); not projected as active session run
Do not clear whole session queue as stop Owner-aware cancel only (ownerConnId / ownerDeviceId / admin), same rules as active abort
Cleanup before active-run signaling Session chat.abort cancels authorized queued turns first, then active runs
Global-agent scoping listQueuedChatTurnsForSession respects agentId on sessionKey === "global"
TUI forwards mid-run prompts Existing non-steer busy-guard fix retained; Esc/preferActive uses session-scoped chat.abort

Code map

  • src/gateway/chat-queued-turns.ts — register / abort-by-id / session list / ordered abort helpers
  • chat.sendqueuedFollowupLifecycle.onEnqueued registers cancel identity; onComplete drops it
  • get-reply-run — always attach abortSignal to followup runs (not only room_event) so drain skips aborted items
  • chat.abort — runId path checks queued registry after active/pending-agent; session path uses ordered cancel
  • TUI — abortActive({ preferActive: true }) calls session-scoped abort (Gateway owns order)
  • Docs — docs/concepts/queue.md “Queued-turn cancellation” section

Tests

  • chat-queued-turns.test.ts (registry)
  • chat.abort-authorization.test.ts (queued-by-id, foreign owner reject, session order queued-then-active, foreign session unauthorized)
  • Existing TUI queue-mode + session-actions tests updated/green

Happy to add a live PTY mid-run followup + Esc proof recording if you want that as the final merge gate.

@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Dependency graph guard cleared

This PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh /allow-dependencies-change comment after the guard blocks that new head SHA.

  • Current SHA: 4ec7842be0afc2cf3f64f30ef3918441a6c098dd

@steipete

steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

/allow-dependencies-change false positive from native prep push: verified zero dependency files differ from mainline base 7a0188c; remote tree 0466533396c49168397ea452e912f6828ceb7d8a matches the rebased local prep tree.

@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Thanks @SebTardif — this PR supplied the starting point for the TUI queue-mode fix. During maintainer rebase recovery the fork branch stopped accepting edits, so I recreated the reviewed tree as #100123 and preserved your contribution with Co-authored-by credit.

The replacement expanded the fix across queued-turn admission, authorization, cancellation, restart cleanup, overflow/collect lifecycle, mixed-version TUI stop, and real PTY proof. It landed in 1b8d837.

For future PRs, keeping GitHub’s “Allow edits by maintainers” enabled helps avoid the replacement path when a rebase is needed. Thanks again for the report and implementation direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: ios App: ios app: macos App: macos app: web-ui App: web-ui channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: nostr Channel integration: nostr channel: qa-channel Channel integration: qa-channel channel: qqbot channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: twitch Channel integration: twitch channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: acpx extensions: amazon-bedrock extensions: anthropic-vertex extensions: byteplus extensions: codex extensions: codex-supervisor Extension: codex-supervisor extensions: copilot extensions: diagnostics-otel Extension: diagnostics-otel extensions: diffs extensions: firecrawl extensions: github-copilot extensions: google extensions: llama-cpp extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb extensions: memory-wiki extensions: oc-path extensions: ollama extensions: policy extensions: qa-lab extensions: tavily extensions: volcengine extensions: webhooks extensions: xai gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. plugin: file-transfer plugin: google-meet plugin: workboard proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security Security documentation size: XS stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUI sendMessage busy guard ignores queue mode setting TUI sendMessage blocks messages with 'agent is busy' regardless of /queue mode setting

3 participants