Repository navigation
feat(ui): reorder queued chat messages from the composer - #121682
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
e41d250 to
1a4d4ea
Compare
1a4d4ea to
8fded94
Compare
|
Codex review: found issues before merge. Reviewed August 10, 2026, 8:03 PM ET / August 11, 2026, 00:03 UTC. ClawSweeper reviewWhat this changesAdds persistent drag-and-keyboard reordering of queued Control UI chat messages, with the stored queue order intended to control Gateway delivery. Merge readinessKeep this maintainer-authored PR open. The proposed canonical ordering repairs the display/drain split, but equal Priority: P2 Review scores
Verification
How this fits togetherThe Control UI keeps queued follow-ups in browser storage while a Gateway is offline or busy. The visible queue and the outbox drain both consume those rows, so their ordering determines what the operator sees and which message is delivered next. flowchart LR
A[Composer follow-ups] --> B[Stored chat outbox]
B --> C[Canonical queue ordering]
C --> D[Queued-row controls]
C --> E[Outbox drain]
D --> F[Operator reorder]
E --> G[Gateway delivery]
Decision needed
Why: This is a new operator-facing behavior that changes which queued follow-up reaches the Gateway next; a code fix can make it correct, but acceptance of the capability remains maintainer product scope. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +291, Tests +454, Docs +1. Total +746 across 22 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Make the persisted queue position a total order, including deterministic distinct ranks for legacy or newly queued equal-millisecond rows, then prove a same-timestamp move changes both the visible queue and the drain-read outbox. Do we have a high-confidence way to reproduce the issue? Yes, from source: queue multiple rows with the same Is this the best way to solve the issue? No. A single numeric key derived from millisecond timestamps is not a total order; persist or derive a deterministic unique tie-breaker before using it for both projection and delivery. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 94490bd69bc6. 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)
|
8fded94 to
c5ce0f8
Compare
|
Finding accepted and fixed — thanks, this was a real hole and the review traced it exactly right. [P1] Keep locked queue rows as ordering barriers — fixed in The old The repair puts the rule in the ordering owner rather than guarding the call site.
It takes a predicate so a caller holding a row for its own reason splits the queue on the same terms — the stacked edit PR (#121692) uses that for the row it is editing, which is likewise a drain barrier. Coverage for the reported case:
Docs updated to describe the barrier honestly rather than the weaker claim. On the two merge-risk notes: the keyed-Lit contract that was not inspectable in your checkout is covered by Full Control UI lane green on the rebased head (Blacksmith Testbox, Linux, Node 24): 8331 passed, plus |
c5ce0f8 to
6893f68
Compare
Queue position becomes an explicit, operator-owned fact on ChatQueueItem instead of an accident of arrival time and storage array order. One comparator now serves the visible projection, the drain head selection, the steer rebuild, and the alias merge, so what the composer shows is what the Gateway receives. Reordering lives entirely on one handle at the left of a queued row: drag it, or focus it and press the arrow keys. Keyed rows keep focus on the handle as it moves. Rows already handed to a run keep their place. Also routes .chat-image-action through var(--cursor-action); its hardcoded pointer was failing the cursor-policy test on main.
6893f68 to
c6f0f16
Compare
|
[P2] Give same-timestamp rows a distinct persisted rank — respectfully rejecting the premise; the coverage ask is accepted and now added. The finding reads const keys = ordered.map(chatQueueOrderKey);
for (let index = 1; index < keys.length; index += 1) {
// Same-millisecond arrivals would otherwise share a key and swallow the move.
keys[index] = Math.max(keys[index]!, keys[index - 1]! + 1);
}Three rows created in the same millisecond hold
Existing unit coverage: Coverage ask accepted. The suggested storage-to-drain case is now in
That is a fair gap to have named: the existing proof was at the pure-function boundary, and the invariant deserves a check where the drain actually reads. Both pass on the exact head. Status of the other listed items: the merge-risk entry restates the same premise, so it resolves with it. The exact-head validation is green — full CI on The previous review's P1 (locked rows as ordering barriers) remains fixed as described in the earlier reply; that repair is unchanged by this push. |
|
Merged via squash.
|
Queue position becomes an explicit, operator-owned fact on ChatQueueItem instead of an accident of arrival time and storage array order. One comparator now serves the visible projection, the drain head selection, the steer rebuild, and the alias merge, so what the composer shows is what the Gateway receives. Reordering lives entirely on one handle at the left of a queued row: drag it, or focus it and press the arrow keys. Keyed rows keep focus on the handle as it moves. Rows already handed to a run keep their place. Also routes .chat-image-action through var(--cursor-action); its hardcoded pointer was failing the cursor-policy test on main.
Related: #121667
The pencil on these rows arrives in #121692, which is stacked on this branch; the final row anatomy is handle · status · text · pencil · discard.
What Problem This Solves
Queued chat messages in the Control UI composer arrive in one fixed order and stay there. An operator who lines up three follow-ups behind a long run, then realizes the third one should go first, has to discard two rows and retype them.
Underneath that, queue position had two independent representations that agreed only by accident:
createdAt(chat-outbox-owner.ts).chat-outbox-drain.ts).Nothing kept the two in step. Alias consolidation already re-sorted a merged queue by
createdAtwhile writing an array in a different order, so what the operator saw and what the Gateway received could diverge.Why This Change Was Made
Queue position becomes an explicit, operator-owned fact —
orderKeyonChatQueueItem, defaulting tocreatedAtso an untouched queue is still FIFO. One comparator now serves the visible projection, the drain head selection, the steer rebuild, and the alias merge, so the list the operator reads is the order the Gateway receives.listStoredChatOutboxessorts on the way out, which is what removes the second representation rather than adding a third.Moving a row permutes the existing position values among the movable rows instead of minting new ones, so a message queued later still lands at the back. Each changed row is persisted individually, so a storage failure leaves a readable queue and a visible error rather than a silent reshuffle.
Rows already handed to a run — sending, steering, running a local command, awaiting settings, or delivery-uncertain — hold their place and split the queue. A message is reordered only inside the contiguous run of movable rows it belongs to, so it can never be permuted ahead of work whose delivery is still open. Reordering itself stays available while the gateway is offline, which is exactly when a queue grows long enough to need it.
Non-goals: editing a queued message back into the composer, and any change to what
SteerorRetrydo. Those are the rest of #121667.Locked rows are barriers, not just immovable rows
Revised after review: the first version filtered the locked rows out of the permutation instead of letting them divide it. With
waiting A · unconfirmed B · waiting C, moving C to the front handed it A's position and left B in the middle — and because this PR makes the sorted order the delivery order, the drain would then send C ahead of the row it is supposed to stop on. The docs promised rows "cannot be moved past"; the code only stopped them being moved.chatQueueMovableSegmentsnow splits the queue at every locked row, and both the move action and the row renderer consume it: a handle offers no move out of its own segment, a drop from another segment is refused rather than reinterpreted, and a row alone between two locked rows has nothing to move against.User Impact
Revised after review: the
Move up/Move downoverflow menu is gone; the handle now carries the keyboard contract directly.Operators can reorder queued messages. Drag a row by its handle, or focus that same handle and press the up and down arrow keys, so this is not a pointer-only feature. The new order decides delivery, not just the look of the list, and it is stored with the message, so it survives a reload.
Row height, the existing state badges, the discard
×,Steer, andRetryare all unchanged.Evidence
Queued rows — the handle is the whole reorder surface
With #121692 stacked on top, the same rows carry the pencil in the slot before the discard
×— this PR reserves and holds that column, so nothing here shifts when the edit action lands:Keyboard reorder — handle focused, then one ArrowUp
Focus stays on the handle as its row moves, so repeated presses keep moving the same message. Screenshots come from the mocked Control UI E2E harness (headless Chromium, mock Gateway, no live credentials) and are not committed.
Tests (Blacksmith Testbox, Linux, Node 24)
node scripts/run-vitest.mjs ui/src— 564 files, 8326 passed, 0 failed.ui/src/e2e/chat-flow.queue-reorder.e2e.test.tsqueues three messages offline, focuses a handle, presses ArrowUp twice, and asserts the visible order after each. The second press is what proves focus followed the row.ui/src/pages/chat/chat-queue-reorder.test.tsasserts the move lands in the stored outbox that the drain reads, survives a fresh host, leaves an in-flight row pinned, refuses to cross a locked row in the middle, and moves a row whose whole queue shares one arrival millisecond.ui/src/lib/chat/chat-queue-order.test.tscovers the comparator, permutation, index clamping, same-millisecond arrivals, and the movability rule.ui/src/pages/chat/chat-composer-queue.test.tscovers the handle's ARIA contract, both arrow keys, non-arrow keys passing through, and the absence of any overflow menu.node scripts/run-tsgo.mjs -p tsconfig.ui.json,node scripts/run-oxlint.mjs ui/src/lib/chat ui/src/pages/chat ui/src/components/icons.ts, andoxfmt --checkon every touched file — all clean.gpt-5.6-sol, high) on the branch diff: no accepted or actionable findings.Size
Production +299 / -8 (net +291), tests +469, docs +1, counted separately against
origin/main. The growth is the new capability plus its ordering owner; it also removes the second ordering representation rather than adding a third, which is whylistStoredChatOutboxessorts at the read boundary instead of every caller re-sorting.chatQueueOrderKeystays module-private — the comparator and the reorder are the whole public surface.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.Size
+290 / -12 production lines, +327 test lines. The growth buys the reorder capability, the canonical position owner, and the removal of four duplicated queue comparators.