Repository navigation
feat(chat): order queue edits by a server revision so a stale echo cannot overwrite a newer edit - #22479
Conversation
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check: the diff adds no visible control, label or state. Its frontend change is a reducer guard on queue-edit revisions plus one optional wire field ( [UX-REVIEWED] 8c69262 Description read[DESCRIPTION-READ] ccd790fb328b881cee2d00a2e17fdc10eb9e857125777cbaee65101b7bc9b9c7 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 |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Each revision surface has one real reader (the client's ordering guard), and nothing in the repo already does this ordering. What this change shipsInventory (6 items) — 6 justifiedIntent: when a queued message is edited in two places at once, its card ends up showing the text the agent will actually run. FIX (part of #6825).
[FIRST-PRINCIPLES-REVIEWED] 8c69262 Description read[DESCRIPTION-READ] 830984b60f9386b5c5fcd04039e85b9ee380715246214416bf11aaab2977c0e1 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: a per-entry revision assigned by the server is the right way to order edits, it is kept across restarts and refetches, and gateways that send no revision still work. Notes
[DESIGN-REVIEWED] 8c69262 Description read[DESCRIPTION-READ] b4b3432c2e243eb7c8cc491b2ee4dcc665c0c441a2401ffa625199f0e1a6ef43 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 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
4827129 to
f354060
Compare
f354060 to
b539683
Compare
b539683 to
bde150a
Compare
b5078aa to
98f178d
Compare
98f178d to
c035e2b
Compare
c035e2b to
a82dc43
Compare
a82dc43 to
64510be
Compare
64510be to
d08455e
Compare
Code change approver recommendation: ApproveWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. Each queue entry now gets a server-assigned revision that goes up by one on every edit. The revision rides on the queue_edit frame, slot detail, resume and the saved queue, so it survives a restart and is kept only if it is a positive integer. The client reducer refuses only a frame whose revision is lower than the one it already holds; frames without a revision, and the editing tab's own optimistic update, still apply. Every reader and writer is consistent: the slot-detail snapshot, queue_entry_view, the resume queue_view calls, normalizeQueueEntries, the hydrateQueuedBubbles meta, and the useWebSocket pass-through. The saved revision is not a trust input, since it only orders the display. Tests cover the server counter, the wire shape end to end, the save and restore round trip, and every reducer branch. Spec drift is the only gap, and it does not change behaviour. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
…nnot overwrite a newer edit A queue edit now gets a server-assigned `edit_rev`, sent on the `queue_edit` frame and served on slot detail, so a late echo of a superseded edit is ignored.
d08455e to
8c69262
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approve at 8c69262. I read the whole product diff: the queue edit route, slot detail, queue_entry_view, the slot queue repository, and the web store's queue.ts and wire.ts.
queue_edit_by_id bumps a per-entry edit_rev on every stored edit. The queue_edit frame, the slot-detail queue and queue_entry_view carry it as editRev. editQueuedMessage then drops an echo whose editRev is below the one the row already shows, so a stale frame can no longer overwrite a newer edit. A frame with no editRev, or a row without one, applies as before.
edit_rev joins _DURABLE_QUEUE_KEYS, and sanitize_restored_queue keeps it only as a positive non-bool int. A restart then keeps the next edit above what a tab already holds, and a hand-edited value can't smuggle in anything but a number.
No regex, no new refusal, and all 94 checks are green.
Optional nit: prompt_queue.py and slot_detail.py check isinstance(edit_rev, int) without the not isinstance(edit_rev, bool) that the other two sites use. The repository never writes a bool there, so this doesn't block.
Problem / Motivation
Goal: A queued message edited in two places at once ends up showing the text the agent will actually run, instead of whichever edit's echo happened to arrive last.
Split out of #6825, as its maintainer triage asked: this is the queue-edit revision protocol, one of the three units named there.
A queue edit today broadcasts only
{queue_id, content}. Nothing in that frame says in what order edits happened, so a client cannot tell a late echo of an edit the server has already replaced from a genuinely newer one. Comparing the text does not work either: the display form is redacted, so two different edits can render identically.Why it matters
When two tabs edit the same queued card, or a tab rebuilds the card from slot detail and then receives an older echo, the card can settle on text the queue no longer holds. The user then reads one prompt on screen while the agent runs another.
Not a goal
sendIdon thequeue_pushbroadcast. That is a separate decision with its own scope.What changed (motivation → approach → change)
The server assigns each queue entry a revision that goes up by one on every edit, and the client refuses only an edit frame older than the revision it already holds.
queue_edit_by_idincrementsedit_revon the entry. The edit endpoint putseditRevon thequeue_editframe. The HTTP response is unchanged.edit_revis saved with the queued entry (_DURABLE_QUEUE_KEYS) andsanitize_restored_queuerestores it only as a positive integer, so after a gateway restart the next edit continues above the revision a tab still holds instead of starting over at 1.queue_entry_viewserveseditRev, and the detail handler's snapshot copiesedit_rev, so a row rebuilt by a refetch (reconnect, slot switch, new tab) keeps its revision.normalizeQueueEntriescarrieseditRevfrom slot detail onto the rebuilt row.editQueuedMessagereducer recordseditRevon the row and refuses a frame whoseeditRevis lower than the one already applied. A frame with an equal revision still applies.Example: tab B reloads and rebuilds the card from slot detail at revision 2. A delayed revision-1 frame then arrives. It is older than 2, so it is ignored and the card keeps the revision-2 text.
Backwards compatibility
Compatible: the frame and detail shapes gain one optional field,
editRev. A client that ignores it behaves as today, and the reducer applies a frame withouteditRevexactly as before. The request and response shapes are unchanged.Removes nothing: no field, route or reducer is removed or renamed.
Tests
test/test_queue_edit_revision.py: the revision advances on each edit and counts per entry,queue_entry_viewserves it only when present (a boolean is refused), one test drivesGET /api/chat/slots/{slot}end to end so the snapshot is covered, not just the serializer, and the revision survives a save and restore while a stored value that is not a positive integer is dropped.test/test_queue_edit.py: two edits broadcast revisions 1 then 2, and the response carries noeditRev. Two existing shape pins updated foredit_rev.test/test_queue_drain_preserve_attachments.py: one frame-shape pin updated foreditRev.store/chat/queue.editRevision.test.ts: an older revision is ignored, an equal one applies with its attachments, a newer one applies, an unrevisioned frame applies, cards are ordered independently, and a row hydrated from slot detail keeps its revision and refuses an older frame.Negative controls: changing the reducer guard to refuse an equal revision turns the equal-revision test red, and dropping
edit_revfrom_DURABLE_QUEUE_KEYSturns the restart test red.Backend: every test matching
queue,slot_detailorfacade(10786 passed). The 2 failures and 2 errors in that run are intest_server_md_notebook_facade.py,test_onboarding_import_refactor_contract.pyandtest_mcp_stdio_wake.py, and they fail identically on the unmodified previous head in this environment. Frontend: every test file undersrc/store/chat, plus the hook and public-surface tests, 646 of 646.tsc,eslinton the changed files,blackandflake8are clean.Manual verification
N/A for this draft: the ordering is a pure reducer decision and the wire shape is covered end to end by the endpoint and detail tests.
Screenshots / video
Why no screenshot: the frontend change is a reducer guard and a revision carried on refetch, and nothing on screen renders differently.
Related Issues
Part of #6825.
Checklist