Repository navigation
fix(chat): hold a restored queue instead of showing it as work in flight - #23971
Pearcekieser wants to merge 1 commit into
Conversation
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The hold restores the session.md rule that a restored prompt is never auto-resent. The one note: the refusal of Send now behind a running turn is extra machinery that an existing stamp makes unnecessary. Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: after a restart, a chat cut while messages were queued shows idle, offers Resume, and never sends the queued words on its own. FIX.
[FIRST-PRINCIPLES-REVIEWED] 5e03b0b Description read[DESCRIPTION-READ] ad4e37d583f4892f93bc27fa87cd2943eb38ffda96d9fbf5109fee30b5be3ce2 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The hold follows the restored-entry contract in session.md, which says restored entries are never auto-sent. The fields it adds are additive, the behaviour change is declared, and screenshots are attached. Notes
[DESIGN-REVIEWED] 5e03b0b Description read[DESCRIPTION-READ] 86cf53507b25f2da71fcdc1979807d2cd62567104c4c67cd73e16f413548dbe5 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 |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
|
self-added: yes
|
|
self-added: yes
|
|
|
b90f6dc to
f674220
Compare
|
Pushed f674220. It carries the two round-1 fixes (dispositions above) and one locale fix for the reds on b90f6dc:
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
|
|
f674220 to
f9c1219
Compare
|
|
|
self-added: yes
Regression: |
|
self-added: yes
|
|
self-added: yes
Regression: |
|
|
self-added: yes
|
|
self-added: yes
Regression: |
|
|
self-added: yes
Regression: |
|
self-added: yes
|
Not changed in this push: the evidence-gap screenshots. |
Regression: |
Regression: |
Not changed in this push: the evidence-gap screenshots. |
|
|
Regression: |
Regression: |
|
Regression: |
|
|
resolution: removed -- SEAM LIMIT retrospective: the marker-identity retirement chain is out of this PR, and the atomic-dequeue follow-up owns the class
|
|
A queue restored after a restart has no owner: nothing drains it on boot, by design. Every reader still treated a non-empty queue as work about to run. The sidebar spun "In progress", the board filed the chat under Working, the queue card's hourglass kept flipping, and Continue refused with slot_queue_pending, so the restart notice's "resume to continue" had no working control. A later send then ran first and the restored card ran on its own behind it. Restored entries are now held (is_held_queue_entry). The drain passes them by and starts one only when the person names it (Send now). Continue, the completion sound and session status count queue_ready_depth. The slot frame carries queue_held_depth and each held entry meta.held, so the sidebar, board, command center and queue card stop showing a held card as working. The turn marker's metadata merge also writes the post-dequeue queue in the same atomic write as the opener copy. Written apart, a SIGKILL between them restored the consumed entry twice: as the interrupted turn's row and as a queue card.
|
resolution: removed -- the xfail pin is gone; the residual it pinned stays stated in the description with the atomic-dequeue follow-up
|
|
[operator: bolichen97] Continuing this in #33214; thanks for the start. |
|
Thanks for this fix, @Pearcekieser. Closing it as superseded: the restored-queue behaviour it targets landed on main in commit 0c7b3bd ("fix: stop showing a restored-only queue as work coming", #33214), which closed #23970, and the Resume part of #16780 landed in #20029. If something here is still missing on latest main, please reopen with the case and we will take another look. |
Problem / Motivation
Goal: After a restart, a chat whose turn was cut while messages were queued shows no work in flight, offers Resume, and never sends the queued messages without the person.
A turn is running and a message is queued behind it. The app restarts. The chat comes back with "This turn was interrupted when the app restarted. Review the partial output above, then resume to continue." and the queued message as a card. Nothing runs (
running: false), yet:POST /continueanswers 409slot_queue_pendingon every press;Why it matters
Every chat that has a queued message when the app restarts (an update, a crash, a watchdog exit) is affected. The UI says work is in progress when nothing is, hides the one control the notice tells the person to use, and later sends words the person typed to a process that no longer exists, out of order.
Not a goal
open_slots.jsoncadence). Separate cause, listed under Manual verification.memory_preparingand the card stays held, so the person sends it again when memory is ready.What changed (motivation → approach → change)
Cause: a queue restored from disk has no owner. Nothing drains it on boot, by design (session.md: restored entries are handed back as cards, not dispatched), except accepted parked sends (
drain_restored_parked_sends). But every reader still askedqueue_depthwhether work was coming, and the drain picked restored entries up after any later turn.Restored entries are now held (
is_held_queue_entry). The drain passes them by, and only the person's Send now on the card starts one. Send now starts a held card directly, on an idle slot. Behind a running turn the gateway refuses it with 409held_turn_runningand the card stays held, because the drain at that turn's end passes held cards by; the card's Send now is disabled while a turn runs, with the tooltip "Available when the current turn ends." If a restart hands back held a card whose ordinary Send now was accepted, the client (website/src/hooks/useQueuedMessageActions.ts) drops its Send now latch, so the card's controls come back."Is work coming?" readers now count
queue_ready_depth: Continue's refusal, the completion sound, session status and the members-thread reset. The slot frame carriesqueue_held_depthand each held entrymeta.held(types/index.chat.ts). The store carriesheldthroughwire.tsandqueue.ts(including a card a first pane hydrate keeps), andselectContinuable(selectors.ts) looks past a held card. The sidebar, board, command center and card (website/src/components/QueueStack.tsx) stop showing a held card as working, and the card reads "Held" (new strings in everywebsite/src/i18n/locales/*.jsoncatalog). Held cards no longer count as user intervention for recovery gates. A Resume skips the written rows of held sends, so it continues the cut request. Continue after a Stop skips those rows too (build_cancelled_turn_preamble(skip_row=...)). Both recovery paths apply it: the native-resume preamble and the cold-start replay (build_session_replay(skip_row=...)insrc/kiro_crew/context.py), which drops the rows from the disk transcript and the live window alike. Agents see the split too: the session-control status and read payloads carryqueue_held_depth, andsession_statusandsession_read_messageinsrc/kiro_crew/mcp_dashboard_session_runs.pycount only ready entries as queued (_queue_phrase, forwarded on thesrc/kiro_crew/mcp_dashboard.pyfacade).The turn-completion chime (
website/src/hooks/websocket/turnCompletion.ts) counts only ready entries too.meta.heldoverrides every content classifier, so a held prompt that happens to read like a system delivery is still an actionable card on every surface. A crewmate chat (ChatPanewithcrewmate) draws held entries as Held cards with Send now instead of sent bubbles, with no typing bubble for them. A held entry whose row is already written (meta.rowWritten) has no Edit and no Cancel: the gateway still refuses it with 409queue_item_already_sent, as on main, so Send now is its way out. Its hint (held_hint_sent) says so.Backwards compatibility
Compatible: new fields are additive (
queue_held_depth,meta.held), and a client that ignores them behaves as before. A gateway without them reads as zero held.Behaviour change: restored cards no longer send themselves after the next turn; they wait for Send now, an edit or a delete. This is the documented session.md contract, now enforced. Session status reports
idleinstead ofqueuedfor a slot whose only queued entries are held.Removes nothing: no field, route or capability is removed. The restored-entry drain path is still reachable, through the card's Send now. Accepted parked sends still resume on boot (
_held_for_drain).Tests
test/test_restart_held_queue.py: held vs ready counts and projection; restore holds every entry; drain skips held entries, keeps their order, runs a named card, refuses Send now on a held card behind a running turn (409held_turn_running, nothing promoted or stopped), never falls through to a held head after a purge, does not park held cards on memory preparation and refuses Send now on a held card there with 409memory_preparing, keeping it held, is not reached by the sub-agent hold's system scan (a restored steer), and does not flush a deferred note into a cron turn behind a held head; Continue runs ahead of held cards, refuses a duplicate press, still refuses on a ready entry; held cards are not user intervention; repeated restarts keep one notice and the same cards.test/test_chat_mode_security_send.py: the four restored-entry security tests now reach restored text through Send now, the only path that runs it.website/src/test/heldQueueAfterRestart.test.tsx: wire and hydrate carryheld(including a crewmate row kept in place); Resume is offered past a held card and withheld behind a ready one; lanes and command center treat a held queue as idle; the card shows "Held" with no hourglass.test/test_chat_slot_facade_contract.pypins the newqueue_held_depthkey.ChatPane.queueActions.test.tsx,useQueuedMessageActions.test.tsx,crewmateBubbles.test.ts: a crewmate's held entry is a Held card with Cancel and no typing bubble; an accepted Send now stays latched until a restart re-hydrates the card held.heldQueueAfterRestart.test.tsx: a held card's Send now is disabled while a turn runs, a ready card's is not.TestResumeNeverContinuesAHeldSend: the interrupted-turn preamble and the cancelled-turn preamble skip the row of a held send; the cold-start replay skips it whether it comes from disk or the live window. A written send cut before its turn marker comes back as a held card. Send now on a held card behind a running turn is refused without claiming a stop, and a press whose turn changed during the body read stands down.test/test_dashboard_chat_handlers_coverage.pychecks a held send whose row is written is still refused with 409 and stays held.TestAgentsAreToldHeldIsNotQueued: the agent-facing session tools leave held cards out of the queued count, and an older gateway's payload still reads as queued.Proof: not provable -- other: the new tests import the held-queue API, so prove.py's revert errors at collection. Run by hand on main c24c7bc with that API shimmed, before the turn-marker and parked Send now changes moved out of this PR: 14 of the 20 backend tests then in the file failed and the other 6 passed, pinning behaviour main already has.
Manual verification
Reproduced on a disposable gateway (fake ACP backend, loopback, throwaway home), never the live install, with a driver script that restarts at each boundary:
running:false, queue_depth:1, sidebar "In progress", hourglass, no Resume,/continue409Not fixed, separate causes: a tab created under 5 s before SIGKILL is not reopened (its transcript, marker and queue are on disk); a force Stop's queue clear rides the 5 s flush.
Screenshots / video
Before (main): "In progress" spinner, animated hourglass, no Resume.
After: "Turn interrupted · Resume", Held card, Resume on the notice and the composer.
Related Issues
Fixes #23970
Closes #16780
Supersedes #20029. Its
meta.restoredprojection and Resume gate are covered here, and its open review blocker (restored cards drain on their own after the recovery turn) is answered by keeping them held.Sibling sweep
Swept:
git grep -nE "queue_depth|len\(slot\._queue\)|if slot\._queue|not slot\._queue" -- src/andgit grep -n "queue_depth" -- website/srcSibling: src/kiro_crew/dashboard/chat_api/continue_turn.py -- changed here
Sibling: src/kiro_crew/dashboard/chat_utils_completion.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/members_thread_turns.py -- changed here
Sibling: src/kiro_crew/dashboard/session_control_parts/session_status.py -- changed here
Sibling: src/kiro_crew/mcp_dashboard_session_runs.py -- changed here (agent-facing queued count)
Sibling: src/kiro_crew/builtin_skills/goal-conductor/SKILL.md -- not affected -- it reads
queue_depththroughsession_read_message, which now counts only ready entriesSibling: website/src/pages/chat/sessionLane.ts -- changed here
Sibling: website/src/pages/chat/command-center/model.ts -- changed here (node state); the options-suppression read keeps raw
queue_depth, since a held card may still be the answerSibling: website/src/lib/closeBusyGate.ts -- not affected -- closing still discards unsent words, so a held card keeps the confirm
Sibling: src/kiro_crew/dashboard/chat_turn/queue_cycle.py -- not affected -- its queue reads feed
_start_next_queued_turn, which now skips held entriesPattern harvest
Rule candidate: review-prompt
Pattern: a predicate that asks "will this run on its own?" reads raw queue/ownership state that a restart can leave without a live owner
Checklist
docs/system-specs/modules/session.md)