Repository navigation
fix(chat): hold a queued message while its card's editor is open - #30549
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: no control, label or layout changes. The editor now sends an open/close signal to the server, and the queue waits while a card's editor is open. Notes
[UX-REVIEWED] b982ca8 Description read[DESCRIPTION-READ] 0a4bd7656e8d7131e44d1865362a989f9fcb79f07df279cab0bb5fe7d72ef117 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 (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level blocker: the hold reuses the drain's existing user-hold path, lives only in memory, always ends at a deadline, and removes nothing. Notes
[DESIGN-REVIEWED] b982ca8 Description read[DESCRIPTION-READ] 4585a3e1fdff32458ae76b9b7a8d48a0340dabb5437b1ef5c8990db889cdfc51 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 (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the hold reuses the drain's existing Notes
What this change shipsInventory (8 items) — 4 justifiedIntent: when a turn ends while someone is editing a queued message, the edited words are sent, not the old ones. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] b982ca8 Description read[DESCRIPTION-READ] 3b1c690dd7db541d7888873e836b1211a94223ed6143c2a8cf65c5f08154fefe That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ human override acceptedHuman judgment by @buluoray overrides the GPT 6.1 finding for [GPT-OVERRIDE] b982ca8 This comment is updated in place on each push. The model was not re-run because an authorized human decision supersedes it. False positive or not applicable? A repository writer can comment: |
e477092 to
8b9d2f9
Compare
|
Disposition for head 8b9d2f9 (findings raised on e477092). Static Ratchet Gate ( Opus — release drain skips the sign-in hold — fixed. GPT F1 — cancelling a held entry strands the queue — fixed. GPT F2 — an opening POST landing after its close — not changed; the adjudication downgraded it. It needs two POSTs from one tab to arrive in reverse order inside one body read, and the result is a hold that clears itself at the 300 s deadline, with no wrong text sent. A per-card request chain to rule it out costs more than the harm. Design note — a killed tab keeps its hold for 300 s — deferred, as the note says; recorded in the UX note — no sign the queue is waiting on the open editor — out of this PR's goal; the editor being open on screen is the sign today. builder-security checked: no new listener; the route keeps the PATCH's auth and |
8b9d2f9 to
00d5b7a
Compare
|
Disposition for head 00d5b7a (GPT findings raised on 8b9d2f9). F1 — a session switch leaves the outgoing queue held — fixed. Both hosts key F3 — feature map — fixed. The Sessions row of F2 — editor handoff to another card can drain that card first — not changed; the adjudication downgraded it. It needs merging on, the turn ending while the first editor is open, and a click straight onto another card's pencil. What goes out is the person's own queued words as written, the same as before this PR, and the later save fails visibly. An acknowledged handoff across blur, PATCH and release is a new client/server ordering contract for that one path. |
00d5b7a to
456348c
Compare
456348c to
46ebdf6
Compare
390cb51 to
010cd05
Compare
010cd05 to
53cbfe8
Compare
A turn that ended while the person was still typing in a queued card's
editor drained the entry as it was: the agent got the unedited words and
the save then landed on an entry that was already gone.
Opening the editor now places a short server-side hold on the entry
(POST .../queue/{queue_id}/editing). While it is held the drain keeps
user entries queued, the same way the sub-agent hold does, and system
injections still flow. Saving the edit releases the hold after the text
is stored, closing the editor without a save releases it, and a
300-second deadline releases it on its own; each release starts the
drain on an idle slot.
53cbfe8 to
b982ca8
Compare
|
/ai-review override gpt b982ca8 deferred #31437: Needs two editors open on the same queued card while the slot is idle, then one closed. The worst case equals behaviour before this PR (no hold at all): the original words send and the card visibly disappears. Per-editor hold identity is tracked in #31437. |
|
AI-review override not recorded: issue #31437 is not a tracked deferral. What is missing:
Fix the issue, then re-issue the command. |
|
/ai-review override gpt b982ca8 deferred #31437: Needs two editors open on the same queued card while the slot is idle, then one closed. The worst case equals behaviour before this PR (no hold at all): the original words send and the card visibly disappears. Per-editor hold identity is tracked in #31437. |
Human judgment recorded@buluoray recorded a deferred release (class
This decision applies only to this commit. A new push requires a new judgment. |
bolichen97
left a comment
There was a problem hiding this comment.
Approving b982ca8.
What I checked on this head:
- All checks are green and none is pending, including PR Readiness, CodeQL, E2E, Integration, Coverage Gate and the Design, First Principles, Opus and UX lanes. The GPT lane shows a human override with a recorded reason and a tracked follow-up. The cancelled entries in the gate list are older duplicate runs, and each has a newer run that passed.
- The fix matches the problem: the server now learns that a queued card's editor is open, and the drain treats that entry like the sub-agent hold. User entries wait, system injections still pass, a save, a close, a cancel or the 300 s deadline releases it, and a release on an idle slot starts the drain. Run now is the only path that skips the hold, and a held queue is never auto-promoted.
- The new route
POST /api/chat/slots/{slot}/queue/{queue_id}/editingis registered next to the PATCH and DELETE on the same queue entry and checks what a slot route should: it looks up the slot, checks app slot access withdeny_app_slot_access, reads the body with the bounded JSON reader, requires a booleanediting, and returns coded 400 and 404 errors. The hold lives only in memory and is never persisted, so a restart does not restore it. - It adds no restriction: the default behavior for a queue with no open editor is unchanged.
- No regex in the added product code.
I did not set auto-merge, because it is already set on this PR.
) A turn that ended while the person was still typing in a queued card's editor drained the entry as it was: the agent got the unedited words and the save then landed on an entry that was already gone. Opening the editor now places a short server-side hold on the entry (POST .../queue/{queue_id}/editing). While it is held the drain keeps user entries queued, the same way the sub-agent hold does, and system injections still flow. Saving the edit releases the hold after the text is stored, closing the editor without a save releases it, and a 300-second deadline releases it on its own; each release starts the drain on an idle slot. Backport note: the conflicts were context only. The feature-map Sessions row and the ComposerDockView destructuring line carry unreleased wording and props (composerPresence), so they keep release's text and gain only this fix's additions. (cherry picked from commit d4b20d0)
Problem / Motivation
Goal: A queued message that is being edited when the running turn ends is sent with the edited words, not the original ones.
A user opens the pencil editor on a queued card while a turn is running and starts typing. If the turn ends before they save, the queue drains the entry as it was: the agent receives the unedited message, the card disappears, and the save then targets an entry that is already gone (404, swallowed). The user sees their edit lost and the old text sent.
Why it matters
Editing a queued message is exactly what people do while waiting on a long turn, so the window where the turn ends mid-edit is common. When it hits, the agent acts on words the user was in the middle of changing, which can send it in the wrong direction with no warning.
Not a goal
shortcut:comment inqueue_edit_hold.py./side/queue/...endpoints.What changed (motivation → approach → change)
Symptom → cause. The queue's only record of an edit is the PATCH sent when the editor commits. Nothing tells the server an editor is open, so
_start_next_queued_turn(chat_turn/queue_drain.py) popsslot._queue[...]["content"]at turn end with the pre-edit text. The later PATCH finds no entry (api_chat_slot_queue_editreturns 404, anduseQueuedMessageActions.onEditswallows it).Approach. Tell the server while the editor is open, and reuse the drain's existing user hold instead of adding a new drain path.
src/kiro_crew/dashboard/queue_edit_hold.py(new):POST /api/chat/slots/{slot}/queue/{queue_id}/editingwith{"editing": true|false}.truestamps the in-memory entry with_edit_hold_until(monotonic, 300 s, never persisted: underscore keys are outside_DURABLE_QUEUE_KEYS).falsereleases it. A release on an idle slot starts the drain underslot._lock, the same guardresponsive_chat.acceptuses. The deadline releases the hold on its own viacall_later.queue_edit_hold.edit_hold_blocks_user_turn, is asked by every path that starts a user turn. Only a card's Run now passes it.chat_turn/queue_drain.py:hold_usersis also true while any entry is held, whatever picked the entry (a turn's end, a responsive send's promotion, a queued arrival, a restored card). User entries stay queued and system injections still drain, as with the sub-agent hold. A held queue is never auto-promoted, so a promoted entry cannot park a system injection.chat_api/chat_send.py: a send on an idle slot while an entry is held joins the queue behind it, steer or not, instead of being answered ahead of the earlier queued messages.chat_utils_injected_rows._dequeue_next_system_message: skips a held entry, so a requeued steer (which passes the sub-agent hold) also waits while its card is open.chat_api/prompt_queue.api_chat_slot_queue_edit: releases the hold after the edit is stored, so the drain starts with the new words.QueueStackreportsonEditOpen(queueId, true)when the pencil opens the editor andfalseon cancel, on an unchanged/empty commit (those route to cancel), when switching to another card's editor, and on unmount. It sends no release beside a save: a release that reached the server before the PATCH would drain the old words.useQueuedMessageActionsmaps it to the new API call, and the two hosts (ChatPane,ChatPageviabusyTurnControlsandComposerDockView) pass it through.builder-security checked: the new route sits on the existing dashboard listener behind the same auth middleware, and applies the same
deny_app_slot_access(..., "slot_queue_edit")gate as the PATCH. No new listener, bind, or auth change.Backwards compatibility
Compatible: the new route and the
onEditOpenprop are additive. A client that never calls the route sees the old drain behaviour, and a hold always ends by save, close, unmount or deadline.Removes nothing: no route, key, prop or behaviour is removed or tightened; the drain only waits while an editor is open.
Tests
test/test_queue_edit_hold.py: the drain leaves a held entry queued; open editor → turn end sends nothing → PATCH → the drained row is the edited text; close without a save → the original entry drains; input validation (400/404); deadline expiry; the dashboard registers the route.website/src/test/QueueStack.test.tsx(QueueStack editor hold): open reportstrue, cancel reportsfalse, a save sends no release, unmount with an open editor releases.Proof: not provable -- other: prove.py's all-hunks mode cannot import the new module once reverted (INCONCLUSIVE); --per-hunk shows the drain-hold and PATCH-release hunks are caught by test_the_drain_leaves_a_held_entry_queued and test_saving_the_edit_sends_the_edited_words (head e477092). The frontend tests were checked by hand: removing the
onEditOpen(queueId, true)call fails bothQueueStack editor holdcases.Also run, one file at a time with no
-n:test_queue_edit.py,test_queue_drain_preserve_attachments.py,test_chat_handlers_composition_contract.py,test_chat_runner_composition_contract.py,test_chat_runner_coverage_queue.py,test_queue_reorder.py,test_queue_cancel.py,test_queued_user_text_display.py,test_dashboard_server_composition_contract_guards.py,test_flake_pattern_ratchet.py; vitestQueueStack.test.tsx,QueueStackReadOnly.test.tsx,useQueuedMessageActions.test.tsx.Manual verification
Not run against a live gateway. The backend tests drive the real PATCH and hold handlers through aiohttp and the real
_start_next_queued_turn, with only the turn spawn stubbed.Screenshots / video
Why no screenshot: The queue card and its editor render exactly as before; the change only adds a request when the editor opens and closes.
Related Issues
Reported by a dashboard user: editing a queued message sends the unedited version once it can be sent.
Follow-up: #31300 (renew the edit hold's 300 s deadline while the editor stays open)
Follow-up: #31437 (per-editor holds for the same card in two tabs and fast switching between cards)
Sibling sweep
Swept: git grep -n "api.editQueuedMessage|sideQueueEdit" -- website/src
Sibling: website/src/pages/chat/SideChat.tsx -- not affected -- side chat queue uses its own server-authoritative /side/queue endpoints and drain
Sibling: website/src/hooks/useQueuedMessageActions.ts -- changed here
Pattern harvest
Not generalizable: the defect is specific to an editor that commits only on save while a background consumer can take the same record first.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.