Skip to content

feat(site): edit queued chat messages - #29216

Closed
mafredri wants to merge 10 commits into
mathias/codagt-971-queue-hold-backendfrom
mathias/codagt-971-queue-hold-frontend
Closed

mafredri wants to merge 10 commits into
mathias/codagt-971-queue-hold-backendfrom
mathias/codagt-971-queue-hold-frontend

Conversation

@mafredri

@mafredri mafredri commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Frontend for CODAGT-971, stacked on #29215.

Queued messages get an Edit action. Edit loads the row into the composer at once and sends {editing:true} in the background; Save sends {content, editing:false}; Cancel sends {editing:false}. Rows behind the one under edit show Waiting. While the chat is paused (its turn ended at the row under edit) the sidebar shows Paused, the send button reads Queue, Edit on other rows is disabled with the reason, and Cancel edit on the head sends it unchanged. A chat that loads with a row under edit opens the composer on it.

Notes for review:

  • useConversationEditingState tracks an EditingTarget (history or queued) and holds composer state only; the page makes every PATCH. Begin and end markers use their own mutation so they never mark the composer pending, and queued-message requests run in order so an end or save cannot be applied before its begin.
  • Rows render a QueuedEditOverride (the composer's target, or a row whose end is in flight) ahead of the server marker, so badges and actions do not wait for the queue update.
  • A refused begin returns the composer to the row the server has under edit. When a snapshot shows the row lost its edit or left the queue, the composer leaves edit mode; a row that leaves before its begin was confirmed is cancelled, otherwise the typed text is kept as a draft.
  • Queue snapshots are compared structurally. Without this the Editing badge never appeared on a second client.
  • paused counts as a finished turn for the completion chime and for discarding late stream parts.

The page-level wiring in AgentChatPage.tsx has no unit tests; it was exercised in UAT and with Playwright against the backend branch. Visual states are Storybook stories.

Closes https://linear.app/codercom/issue/CODAGT-971

🤖 This PR was created with the help of Coder Agents on behalf of @mafredri, and will be reviewed by a human. 🏂🏻

@linear-code

linear-code Bot commented Sep 11, 2026

Copy link
Copy Markdown

CODAGT-971

@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-frontend branch from fcc2b67 to e8fc8ee Compare September 14, 2026 15:08
@mafredri mafredri changed the title feat(site): edit queued chat messages with a hold feat(site): edit queued chat messages Sep 14, 2026
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-frontend branch 2 times, most recently from 71dc7ce to 604d342 Compare September 14, 2026 16:08
@mafredri
mafredri added this pull request to stack #29294 September 14, 2026 16:23
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-frontend branch from 604d342 to 7b6119c Compare September 15, 2026 10:37
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from 28604ca to c188dec Compare September 17, 2026 15:19
mafredri and others added 7 commits September 17, 2026 15:21
Queued rows gain an Edit action. Edit begins a server-side edit (PATCH
{editing:true}) and loads the row into the composer only after the 204;
Save sends {content, editing:false}; Cancel and Escape send
{editing:false}. Nothing is optimistic: editing_since arrives through
queue_update, so queue snapshots are compared by content and
editing_since as well as identity and order.

The row under edit and the rows behind it render as waiting. A chat
whose turn ended at a row under edit has status "paused": the sidebar
shows Paused, the head offers Resume (ends the edit and sends), Edit is
hidden on other rows because the server refuses them, and the send
button reads Queue because a send queues behind the head. A paused turn
is a finished turn for the chime and for discarding late stream parts.

A queue snapshot in which the edited row lost editing_since (another
client ended or moved the edit) or left the queue (sent or removed)
exits edit mode and keeps the typed text as the draft. A 404 on save or
cancel does the same. A row is only counted as having lost the edit
after a snapshot showed it under edit, because the begin request's 204
can arrive before that snapshot.

Edit and Resume are hidden for read-only viewers.

Part of CODAGT-971. Stacked on the backend PR.

Co-authored-by: Coder Agents <noreply@coder.com>
The row-level action on a queued message under edit sends editing:false,
which cancels the edit; on a paused chat that also sends the row. It was
labelled Resume and shown only while paused, which described the chat
and hid that the edit is discarded. It is now Cancel edit, shown for any
row under edit, with the paused tooltip stating that the message is sent
as it is.
The hook kept composer state and also called the server to end a queued
edit, while the page ended it on a history-edit switch and the server
moved it on a queued-to-queued switch. Three owners for one rule. The
hook is now composer state only: begin, cancel, leave.

A 404 on any queued PATCH drops the row from the store instead of
throwing a dedicated error class. The existing lost-target effect then
leaves edit mode, so the composer has one exit path for a row that is
gone.

Switching to a history edit now waits for the queued edit to end and
stays put on failure, instead of moving the composer while the server
row remains marked.
handleBeginEdit, cancel, draft persistence and send rollback do not
branch on the target kind, so the queued copies of those tests only re-
ran history coverage. The queued describe keeps the two behaviors that
differ: a successful save restores the pre-edit draft, and leaveEdit
hands the composer text over as the new draft.

trackQueuedEditTarget is tested as the snapshot sequence it models
rather than six point evaluations, so the stale-then-seen-then-cleared
property reads as one case.
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-frontend branch from 81aec80 to 577e774 Compare September 17, 2026 15:24
The four queued row actions become one QueuedMessageActionButton, which
also removes the renderActionIcon helper: Spinner already renders its
children when not loading. The lost-edit check moves from an effect plus
ref to the render-time adjust pattern, so the composer leaves edit mode
in the same frame the row disappears. EditingTarget is a single object
type since both kinds carry the same fields.
Edit mode opens before the begin request settles, and a refused begin
returns the composer to the row the server has under edit. Rows show the
local edit state before the queue update arrives. A chat that loads with
a row under edit opens the composer on it. Edit stays visible but
disabled with a reason while the chat is paused, and the head's Enter
hint hides while the composer edits a message.
@mafredri

Copy link
Copy Markdown
Member Author

Superseded by a 4-PR stack per review feedback: #29553 (refactors), #29554 (paused and edit markers, read-only), #29555 (edit queued messages, awaited), #29556 (eager updates). Same final tree except that the mutation no longer awaits its invalidations.

🤖 This comment was created with the help of Coder Agents on behalf of @mafredri.

@mafredri mafredri closed this Sep 18, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 18, 2026
@mafredri
mafredri removed this pull request from stack #29294 October 30, 2026 11:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant