Repository navigation
feat(ui): edit a queued chat message in place - #121692
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
e41d250 to
1a4d4ea
Compare
80ec080 to
254f88f
Compare
1a4d4ea to
8fded94
Compare
254f88f to
156e817
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 12:52 AM ET / 04:52 UTC. ClawSweeper reviewWhat this changesThis PR lets Control UI operators edit a queued chat message in place, retaining attachments and returning a sent replacement to its stored queue position. Merge readinessThe implementation is technically coherent and covers the prior durability and cross-pane concerns, but it intentionally pauses later shared-outbox deliveries during an edit; that user-visible policy needs maintainer acceptance before merge. Priority: P2 Review scores
Verification
How this fits togetherControl UI stores queued messages in a session-and-agent-scoped browser outbox that can be rendered and drained by multiple panes. This change lifts one queued row into a pane-local composer while coordinating replacement and delivery blocking through the shared outbox owner. flowchart LR
Operator[Operator edits queued row] --> Composer[Pane-local composer]
Composer --> Replacement[Durable replacement admission]
Replacement --> Outbox[Shared session outbox]
Outbox --> Drain[Outbox delivery drain]
Composer --> Hold[Edited-row delivery hold]
Hold --> Drain
Drain --> Gateway[Gateway chat delivery]
Decision needed
Why: Code cannot determine the UX tradeoff between never delivering visibly superseded text and delaying later queued work across panes. Before merge
Agent review detailsSecurityNone. PR surfaceSource +420, Tests +485, Docs +1. Total +906 across 24 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: Retain the single scope-validated edit hold and land it only if maintainers accept that it pauses later delivery in the shared outbox. Do we have a high-confidence way to reproduce the issue? Not applicable as a feature request; the supplied mock-Gateway browser E2E and owner-boundary tests demonstrate the intended edit, send, and cancel flows. Is this the best way to solve the issue? Technically yes: durable replacement is owned by the outbox write and the cross-pane hold reads the shared owner; whether the pause is the best product behavior remains a maintainer choice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c5b7b8e33c99. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What 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 (7 earlier review cycles)
|
156e817 to
4dff86e
Compare
4dff86e to
f825727
Compare
8fded94 to
c5ce0f8
Compare
|
Both P1 findings from the latest review are accepted. I traced each one through the code and they are real, so this PR is not landing until they are fixed — recording that here so nobody lands it on the strength of green CI. The base of the stack, #121682, landed separately as [P1] Retire the original only after replacement admission succeeds — confirmed. The sequence is:
So a rejected durable write leaves the original gone and the replacement never persisted: after a reload the operator's message is lost, along with any attachment payload the replacement dropped, because The related detail in the same finding also holds: Repair shape: make it one scoped durable replacement rather than remove-then-admit. The source row and its payloads stay until exactly one durable replacement write for that scope succeeds; only then is the original retired and the dropped payloads released. If the write is rejected, the edit stays open and the row is still there, which is already what cancel promises. [P1] Bind the edit token to the selected global agent — confirmed. Repair shape: the token carries the source agent scope, and every reader validates the full scope rather than the session key alone. That is the same principle already applied to the session: the edit belongs to the scope it started in, and one accessor makes that true everywhere. Both repairs land in one focused update at the queue owner boundary, with the two regressions the review names: a rejected durable write must leave the original row and its attachments intact, and a selected-global-agent switch must not let an edit cross outboxes. CI on this head is green, but green CI does not cover either case — that is precisely the gap, and the regressions above are what close it. |
The send retired the source row first and admitted the replacement second, so a rejected store write left the operator with neither: the original gone, the replacement never persisted, and the attachments it dropped already released. Admission now carries the source id and swaps both rows in one store write, so a rejected write changes nothing and the edit stays open on the row that is still there, which is what cancelling already promises. Filtering the source before the cap check also keeps a replacement admissible on a full queue. The edit token recorded only the session key, but an outbox is scoped by session and agent, and a raw global session keeps its key while the selected agent changes underneath it. The token now carries the agent that owned the row and every reader validates the whole scope, so a send after a switch cannot retire a row in the outbox it left behind.
|
Both accepted P1s are fixed at the owner boundary in [P1] Retire the original only after replacement admission succeeds The remove-then-admit sequence is gone. Admission now carries the id of the row it replaces, and the store performs one write:
Filtering before the cap check has a second effect worth naming: a replacement is now admissible on a queue already at [P1] Bind the edit token to the selected global agent The token now records the agent that owned the row ( Regressions (both fail on the pre-fix code, for the right reason)
Both drive the real Size: production +68 / -23 for this repair, net +45, tests +77 / -5. That delta is mostly prose and formatter: 31 of the added lines are the JSDoc and inline comments recording the two invariants, and roughly 11 more are @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Panes share one outbox and one drain lane while composer state stays per pane, so the hold that keeps a row from being delivered while it is rewritten was invisible to the pane that drained it: a session event in a second split pane resumed every stored outbox, saw no edit, and sent the original text. The hold is now read across every pane subscribed to the outbox, which keeps one source of truth — each pane's own scope-validated edit — and needs no lifecycle of its own, so closing a pane or switching agent releases it by simply no longer being an active edit. The payloads an edit owns now travel with its token. The write that admits the replacement retires the source row and tells every pane synchronously, so by the time the send released the images the replacement had dropped, the row holding them was already gone and nothing was released. That leaked the payload and its object URL for the rest of the browser session.
|
Both new findings are real — I traced each one through the code before touching it — and both are fixed in [P1] Centralize queued-edit ownership across panes Confirmed, and worse than a guard gap: The hold now reads across every pane subscribed to the outbox: I deliberately did not add a hold registry to the owner. A second stored copy of the fact needs its own lifecycle — release on cancel, on send, on pane close, on agent switch — and a hold that outlives its edit is a queue stalled with nothing on screen explaining why, which is the worse failure of the two. Reading the fact from each pane's own scope-validated edit keeps one source of truth: closing a pane removes it from the owner's set, and switching agent makes that pane's edit inactive, so the hold releases by construction with no cleanup path to miss. [P2] Retain dropped attachment payloads after an edit Confirmed, and the mechanism is exactly as described. Rather than have the caller capture metadata around the write — ordering knowledge at the call site is what produced the first P1 — the payloads now travel with the edit token ( Regressions (both fail on the pre-fix code, for the right reason)
Size: this revision is production +41 / -9 (net +32), tests +66 / -1. Fourteen of the added production lines are the comments recording why the hold is derived rather than stored. Local: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer decision: accept the documented shared-outbox barrier. While a queued row is actively edited, that row and later rows in the same outbox wait until the operator submits or cancels; this prevents another pane from delivering text that is visibly being rewritten. Exact-head proof for
This resolves the latest ClawSweeper decision item and its rank-up move. No actionable findings remain. |
|
Merged via squash.
|
* feat(ui): edit a queued chat message in place The pencil on a queued row, or a double-click, lifts the message and its attachments into the composer. The row stays where it is, marked Editing, so the position the corrected message will take is visible rather than promised. The composer shows an edit banner with an X to cancel. Cancelling touches storage not at all, because the row never left the queue. Sending retires the original and hands its position to the replacement, which lands in the same slot. While an edit is open the drain refuses that row, so a reconnect cannot deliver the text the operator is visibly rewriting; the queue behind it waits, which is the same contract the held position promises. * fix(ui): retire an edited queued row only with its replacement The send retired the source row first and admitted the replacement second, so a rejected store write left the operator with neither: the original gone, the replacement never persisted, and the attachments it dropped already released. Admission now carries the source id and swaps both rows in one store write, so a rejected write changes nothing and the edit stays open on the row that is still there, which is what cancelling already promises. Filtering the source before the cap check also keeps a replacement admissible on a full queue. The edit token recorded only the session key, but an outbox is scoped by session and agent, and a raw global session keeps its key while the selected agent changes underneath it. The token now carries the agent that owned the row and every reader validates the whole scope, so a send after a switch cannot retire a row in the outbox it left behind. * fix(ui): hold an edited queued row across every pane Panes share one outbox and one drain lane while composer state stays per pane, so the hold that keeps a row from being delivered while it is rewritten was invisible to the pane that drained it: a session event in a second split pane resumed every stored outbox, saw no edit, and sent the original text. The hold is now read across every pane subscribed to the outbox, which keeps one source of truth — each pane's own scope-validated edit — and needs no lifecycle of its own, so closing a pane or switching agent releases it by simply no longer being an active edit. The payloads an edit owns now travel with its token. The write that admits the replacement retires the source row and tells every pane synchronously, so by the time the send released the images the replacement had dropped, the row holding them was already gone and nothing was released. That leaked the payload and its object URL for the rest of the browser session. * fix(ui): release attachments from cancelled queue edits
Related: #121667
Was stacked on #121682, which landed as
1d989027cf6; this PR is rebased ontomainand reviews on its own.What Problem This Solves
Fixing a typo in a queued chat message costs the whole message. The only action on a queued row is discard, so an operator who spots a mistake has to throw the row away and retype it — and every image they attached is gone with it. Attachment payloads are released on discard, so a queued screenshot cannot be recovered; the operator has to take it again.
Why This Change Was Made
A pencil sits directly on the queued row, next to the discard X; double-clicking the row does the same thing. The message and its attachments move into the composer, and a small pencil marker with an X to cancel appears beside the input, so the operator always knows they are rewriting a queued message rather than composing a new one.
The row itself stays in the queue, in its own slot, marked Editing. That is what makes the return-to-the-same-position contract self-evident: the operator can see where the corrected message will land instead of being told. It also makes cancel free — the row never left, so cancelling touches storage not at all.
Sending hands the original row's position to the replacement, reusing the operator-owned queue position from #121682 rather than introducing a second ordering concept. If the queue drained during the edit, that position is simply the only one and the message sends as a normal turn, with no special case.
The original is retired by the same store write that admits its replacement, never before it. Admission carries the id of the row it replaces, and the store writes the queue once with the source filtered out and the replacement in it (
composer-persistence.ts,chat-queue.ts). A rejected write therefore changes nothing at all: the original is still queued, the replacement was never stored, no attachment was released, and the edit is still open on the row that is still there — which is exactly what cancelling already promises. Retiring first and admitting second would leave a rejected write having consumed both copies, in the one failure the offline queue exists to survive. Filtering before the stored-queue cap also keeps a replacement admissible on a full queue.Resuming an edit is now the composer submit's business rather than every pending enqueue's.
enqueuePendingSendMessagebuilds pending rows for the reset-command sender too, so reading the edit token inside it meant a/newtyped over an abandoned edit would retire the operator's queued row and hand its slot to the reset message. The submit path passes the resumed position and the replaced id explicitly; the reset path passes neither, so an open edit is simply left alone.An edit belongs to the scope it started in, and an outbox is scoped by session and agent. A raw global session keeps its key while the selected agent changes underneath it, so the token records the agent that owned the row and the single accessor compares the whole scope through
visibleSessionMatches, the helper the queue and delivery paths already share. A send after an agent switch cannot retire a row in the outbox it left behind.While an edit is open, the drain refuses that row. A reconnect must not deliver the text the operator is visibly rewriting, and the queue behind it waits — the same contract the row's held position already promises. This sits next to the existing
unconfirmedguard inchat-outbox-drain.ts.That hold is read across every pane, not just the one holding the composer. Panes share an outbox and its drain lane, and a session event makes any of them resume every stored outbox, so a hold only its own pane could see would let the other pane deliver the superseded text. It stays derived from each pane's own scope-validated edit rather than stored a second time at the owner: a stored hold would need releasing on cancel, on send, on pane close and on agent switch, and one that outlived its edit would stall the queue with nothing on screen explaining why. Derived, it releases by construction — a closed pane leaves the owner's set, and a switched agent makes that pane's edit inactive.
Two deliberate boundaries. Editing requires an empty composer, matching the existing rule that newer composer input is never overwritten (
chat-send-composer.ts), and it reports that instead of silently clobbering a draft. Routing the pane to another session drops the edit, alongside the in-progress title-edit cleanup that already lives there.Every reader goes through that one accessor — the row badge, the composer marker, the drain block, and the send. A pane showing another session, or the same global session after an agent switch, sees no edit, so no lifecycle hook has to remember to clear one — which is why the retained-pane rework on
maindid not leave a hole here.Non-goal: queued slash commands. They take a different enqueue path that cannot carry a resumed position, so they keep the discard-and-retype flow and are excluded from the action rather than half-supported.
Row anatomy holds in every state
A queued row is always the same five slots — handle, status, text, pencil, discard — and a row never loses a slot because of the state it is in. An open edit makes the slots it owns inert, not absent, so no column moves while the operator retypes:
Editing is an active state, not a failure, so the row tint, the badge, and the composer marker use the informational family.
--accentis the brand red in every shipped theme and sits directly on top of--danger(see the--runtoken note inbase.css), which is exactly why a neutral state must not borrow it.The composer row aligns by construction
The composer's input row bottom-aligns its children so it can follow a growing textarea, which only reads as one axis while every child is the same height. That was an unwritten rule each control happened to satisfy, so the marker — the first genuinely small child — landed low.
The row now owns the rule:
--chat-composer-control-height(36px, 44px on touch layouts) is declared once on.agent-chat__input,.agent-chat__composer-input-row > *claims that box, and the attach button and textarea read the token instead of repeating the literals. The marker needs noalign-selfor margin nudge, and neither will the next child added to this row.User Impact
An operator can correct a queued message — text and attachments — and it goes back to the same place in the queue. Cancelling leaves the queued message exactly as it was.
Evidence
Row anatomy, light and dark
Handle, status dot and badge sit on the same x on all three rows while the middle one is being edited; the Editing badge and the row outline read informational, never danger.
Composer row in edit mode
A pencil glyph and a cancel X beside the input, on the same axis as the attach button, the text and the send controls. The queued row already names the state, so the composer only says which mode it is in and how to leave it.
The whole flow — queued row, pencil, editing, send, cancel
Six steps: the queued row with its pencil; the row held in place marked Editing with the composer marker; the rewritten text; the message back in the same slot; a second edit being abandoned; and the queue restored untouched.
Stepped stills of the same six frames, if the animation is too quick to read:
Recorded from the mocked Control UI E2E harness (headless Chromium, mock Gateway, no live credentials); frames are not committed.
Tests (Blacksmith Testbox, Linux, Node 24)
node scripts/run-vitest.mjs ui/src— 565 files, 8338 passed, 0 failed.ui/src/e2e/chat-flow.queue-edit.e2e.test.tsqueues three messages offline, double-clicks the middle row, asserts the row stayed in place carrying the Editing badge while the composer took the text, then edits and sends it and asserts it replaced the same slot. A second case drives the pencil and the composer's cancel, asserting the queue comes back untouched.chat-composer-queue.test.tsasserts that while a row is edited every handle stays in its column and every one of them is inert, because the edited row splits the queue.queued-message-edit.test.tsasserts a stale edit from another session neither marks a row nor locks the composer.ui/src/pages/chat/chat-composer-queue.test.tsasserts every row keeps its handle, pencil and discard button while an edit is open, that each one is disabled exactly where it should be, and that a live X on another row still discards.ui/src/pages/chat/queued-message-edit.test.tscovers the attachment lift with the row held in storage, cancel leaving the queue byte-identical, the resumed send replacing the same slot, one edit at a time, the empty-composer requirement, the refused row kinds, and the edit not following a session switch. The send cases drive the realhandleSendChatpath, so the admit/retire ordering itself is what is under test rather than the pieces.keeps the original queued when the replacement's stored write is rejectedqueues three rows offline, edits the middle one, then makes the store refuse any write that would grow it — exactly how quota behaves — and asserts the original row, the open edit, the restored draft and the visible storage error. On the pre-fix ordering it fails withexpected [ 'message 1', 'message 3' ] to deeply equal [ 'message 1', 'message 2', 'message 3' ]: the operator's message is simply gone.cannot retire a row in the outbox a global agent switch left behindqueues a row in one agent's global outbox, edits it, switches the selected agent, and asserts each outbox keeps its own row. On the pre-fix token it fails at the switch (expected true to be false) and the send retires the previous agent's row.holds a row being edited against a drain owned by another pane, inui/src/pages/chat/chat-send.test.ts's existing two-pane harness. One pane edits a queued row, the other runs the realretryReconnectableQueuedChatSends. With a pane-local hold it fails with achat.sendon the wire; with the shared read no request is issued and the row stays in the stored outbox.releases only the images the replacement droppedstages two images in the payload store, drops one during the edit and sends. Reading the retired row's attachments after the write fails (expected null, received "data:image/png;base64,…") because the write already retired the row everywhere; reading them from the edit token releases the dropped image and keeps the retained one.node scripts/run-tsgo.mjs -p tsconfig.ui.json,node scripts/run-oxlint.mjs ui/src,pnpm check:import-cycles(0 runtime value cycles), andoxfmt --checkon every touched file — all clean.gpt-5.6-sol, high) on the branch diff: no accepted or actionable findings.Size
Against
main, counted with test and production separated: production +441 / -30 (net +411), tests +471 / -1, docs +1. This is a feature, so the growth is capability rather than a bug-fix delta: the pencil affordance, the edit-mode composer, the row anatomy rules, and the queue-edit state itself.Where it could be absorbed, it was. The composer's queue-edit wiring is grouped into one
queuedEditshape, which keepschat-view.tsunder themax-linescap without a suppression. Leaving the row in the queue removed the re-admit path and its storage-failure branch that the earlier revision needed. The edit-mode surface shrank across revisions: the full-width banner and its six CSS rules are gone, replaced by the inline marker. The alignment fix is close to LOC-neutral — one token and one shared rule replace three hardcoded control heights.The cross-pane hold and payload-ownership revision is production +41 / -9 (net +32) with tests +66 / -1; fourteen of those production lines are the comments recording why the hold is derived rather than stored, and the new surface is
anyPaneon the outbox owner plusanyChatOutboxPaneMatches.The ordering repair before it is production +68 / -23 (net +45) with tests +77 / -5. Thirty-one of those added lines are the JSDoc and inline comments recording the two invariants, and roughly eleven more are
oxfmtre-wrapping a call and an object literal that already existed. It is a reshape rather than an addition:consumeQueuedMessageEditwas replaced, not supplemented, and the remove-then-admit ordering is deleted. About ten lines are genuinely new —isDurableQueuedMessage, thereplacesIdparameter through two layers, the queue filter that replaces the queue read, and the send-path guard.isDurableQueuedMessageis the one addition carrying capability rather than safety: without it an edit could not be sent at all in a browser with no session storage.Main is red independently of this PR
ui/src/pages/chat/components/chat-thread.measure.test.ts> "rebinds guarded transcript images when the gateway rotates its auth token" fails onorigin/main. It runs in thecore-runtime-media-uishard, which is whychecks-ui,check-lint,check-dependencies, and fourchecks-node-compact-*jobs all go red together. Two managed-media browser tests fail alongside it:chat-flow.media-files.e2e.test.ts> "evicts and refetches managed image Blob URLs after the cache reaches capacity" andmanaged-media-base-path.e2e.test.ts> "keeps origin-root managed-media APIs outside the UI base path".A second, independent breakage sits in
checks-node-compact-small-11:src/cron/service.stream-trigger.test.ts,src/cron/service.stream-validation.test.ts, andsrc/cron/service/timer.timeout-watchdog.test.tsall expect the old failure-alert payload shape and now receive the generic "Automation ... failed N times" text.A third:
pnpm check:test-typesfails onsrc/gateway/managed-image-actions.e2e.test.ts:125(unknownpassed wherestring | URLis expected) andui/src/pages/chat/components/chat-message.test.ts:4590,4595(missingdownloadproperty, empty tuple index).Unrelated PR #121686 shows the same failing set, so none of this comes from this branch, and nothing here touches the transcript-image, managed-media, or cron paths. The one failure from #77017 that landed in this PR's own lane — the hardcoded
cursor: pointeron.chat-image-action— is fixed here.