Skip to content

feat(site): show paused chats and queued edit markers - #29554

Merged
mafredri merged 16 commits into
mainfrom
mathias/codagt-971-fe-2-paused-display
Oct 30, 2026
Merged

mafredri merged 16 commits into
mainfrom
mathias/codagt-971-fe-2-paused-display

Conversation

@mafredri

@mafredri mafredri commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

The backend (#29215) pauses a chat when its queue head is under edit and marks that row with editing_since. This PR displays both. The row actions that begin, save, or cancel an edit are in #29555.

paused counts as a completed turn: the chime plays, late stream parts are dropped, and a paused sub-agent shows as completed in its parent's tool card. Archiving a chat whose family has a paused member is blocked, with a hint that names the queued edit. The send button reads "Queue" while a turn runs, while the chat is paused, and while the queue head is under edit, because the server queues the send in each case. Enter in an empty composer does not send a head under edit. Queued rows show an Editing badge on the row under edit and a Waiting badge on the rows behind it.

For review: queued rows are compared structurally (lodash/isEqual), because a marker or content change keeps the row's ID and an ID comparison would drop the update. chatStore.createStore.test.ts and the queue cache tests in chatStore.test.tsx cover this. A failed delete, promote, /compact, or history edit restores its pre-request queue only when no queue update arrived during the request; otherwise a failed promote refetches the queue (chatQueueReconciliation.ts).

Part of the CODAGT-971 frontend stack: 2 of 3.

🤖 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 18, 2026

Copy link
Copy Markdown

CODAGT-971

@mafredri

This comment has been minimized.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T13:23:04.059429Z 08d441e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6589d35ea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +185 to +186
expect(screen.getByText("Editing")).toBeInTheDocument();
expect(screen.getAllByText("Waiting")).toHaveLength(1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Replace the DOM-only queued-state tests with visual coverage

These assertions only verify that the new labels render, and the neighboring test similarly checks whether the Enter hint is present. FE1 explicitly reserves rendered presence and visibility for Pixel-backed Storybook stories and requires Vitest assertions to target non-visual outcomes; the newly added RowUnderEditWithWaitingTail and PausedAtHead stories already cover these states, so remove these redundant tests or replace them with an observable interaction outcome.

AGENTS.md reference: site/AGENTS.md:L7-L7

Useful? React with 👍 / 👎.

@mafredri mafredri Sep 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid per FE1. The PR adds no presence tests to QueuedMessagesList.test.tsx. The RowUnderEditWithWaitingTail and HeadUnderEdit stories cover the badges and the hidden Enter hint, and hover the Editing and Waiting badges so both tooltips are in the screenshots. The behavior, Enter on an empty composer not sending a head under edit, is tested in AgentChatInput.test.tsx.

🤖 Reply by Coder Agents on behalf of @mafredri.

Comment on lines 626 to 632
streamReportedTurnFinished = isTurnFinishedChatStatus(nextStatus);
wsStatusReceivedRef.current = true;
store.clearRetryState();
const prevStatus = store.getSnapshot().chatStatus;
store.applyServerChatStatus(nextStatus);
if (nextStatus === "waiting") {
if (streamReportedTurnFinished) {
discardBufferedParts();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exercise paused stream termination through useChatStore

This changes stream buffering behavior for paused, but the useChatStore tests only exercise the equivalent waiting transition; the new chime test validates the helper but cannot catch regressions in buffered-part disposal or late-part gating here. Extend or parameterize the existing waiting stream tests with paused so this behavior change has the required Vitest coverage.

AGENTS.md reference: site/AGENTS.md:L7-L7

Useful? React with 👍 / 👎.

@mafredri mafredri Sep 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid. Both stream tests in chatStore.test.tsx, drops message_part updates after the stream reports %s and discards buffered parts when status transitions to %s, run for waiting and paused.

🤖 Reply by Coder Agents on behalf of @mafredri.

status === "requires_action" ||
status === "interrupting";

// Statuses a turn ends in.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the misleading restatement above the helper

The comment merely paraphrases isTurnFinishedChatStatus, contrary to FE4, and is also broader than the implementation because error transitions end turns but are intentionally excluded from this normal-finish predicate. Delete it or document that narrower semantic distinction rather than restating the identifier.

AGENTS.md reference: site/AGENTS.md:L10-L10

Useful? React with 👍 / 👎.

@mafredri mafredri Sep 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid. The JSDoc on isTurnCompletedChatStatus in chatStore.ts says a turn completes in waiting, or in paused when the queue head is under edit, and that a turn ending in error did not complete.

🤖 Reply by Coder Agents on behalf of @mafredri.

Comment on lines +182 to +184
{chat.status === "paused"
? "Finish editing the queued message first."
: "Interrupt or wait for the agent to finish first."}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the live family status for the paused archive hint

When the per-chat stream reports paused before the global chat cache catches up, ChatTopBar correctly blocks archiving from liveChatStatus, but this branch still reads the stale chat.status and tells the user to interrupt or wait, neither of which unblocks a paused chat. The same incorrect hint appears when a paused child blocks archiving a waiting root. Pass the live or family blocking status into this component and derive the hint from that status.

Useful? React with 👍 / 👎.

@mafredri mafredri Sep 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid. getArchiveBlockedReason in ChatActionsMenuItems.tsx classifies every chat status in one table and returns "active" or "paused" for the chat and its children, so a waiting root with a paused child shows the paused hint. ChatTopBar passes the live stream status, because the stream handler does not update the chat record query, and ChatTreeNode passes the list status. ChatActionsMenuItems.test.ts covers the paused-child case.

🤖 Reply by Coder Agents on behalf of @mafredri.


// Statuses a turn ends in.
export const isTurnFinishedChatStatus = (
status: TypesGen.ChatStatus | null | undefined,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agents really love making functions take | null | undefined which can be a symptom they're not handling data very well further up in the stack

@mafredri mafredri Sep 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The helper, now isTurnCompletedChatStatus in chatStore.ts, takes TypesGen.ChatStatus, and both callers, the stream status handler in useChatStore.ts and maybePlayChime in chime.ts, pass one.

🤖 Reply by Coder Agents on behalf of @mafredri.

Comment on lines +1087 to +1091
const sendButtonLabel = isEditingMessage
? "Save Edit"
: isChatPaused
? "Queue"
: "Send";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agents fucking love ternaries. not saying this should be fixed but it pains me every time. sometimes the ternary is fine but doesn't need to be put into a const, just be used inline

@mafredri mafredri Sep 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendButtonLabel in AgentChatInput.tsx is an if/else chain. It stays a variable because the button text and its tooltip both use it.

🤖 Reply by Coder Agents on behalf of @mafredri.

Comment on lines +179 to +196
it("marks the row under edit and the rows behind it", () => {
renderList([
{ ...MockChatQueuedMessage, id: 8 },
{ ...MockEditingChatQueuedMessage, id: 9 },
{ ...MockChatQueuedMessage, id: 10 },
]);
expect(screen.getByText("Editing")).toBeInTheDocument();
expect(screen.getAllByText("Waiting")).toHaveLength(1);
});

it("hides the Enter hint on a head under edit", () => {
renderList([{ ...MockChatQueuedMessage, id: 9 }]);
expect(screen.getByText("to send")).toBeInTheDocument();
cleanup();

renderList([{ ...MockEditingChatQueuedMessage, id: 9 }]);
expect(screen.queryByText("to send")).not.toBeInTheDocument();
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

violation of our frontend rules

@mafredri mafredri Sep 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The PR adds no presence tests to QueuedMessagesList.test.tsx; the stories cover these states. Details in the FE1 thread above.

🤖 Reply by Coder Agents on behalf of @mafredri.

}) => {
const items = messages.map((message) => {
const editingIndex = messages.findIndex((message) => message.editing_since);
const items = messages.map((message, index) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not asking to fix here but this component has grown too complex. the mapping of items and making badge.label and badge.tooltip in the loop is indicative of the problem

@mafredri mafredri Sep 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that the list has grown. This PR adds the badge derivation you quoted to the row mapping in QueuedMessagesList, and #29555 adds the Edit and Cancel edit actions to the same rows. Whether to split them out is still open.

🤖 Reply by Coder Agents on behalf of @mafredri.

@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch 2 times, most recently from 1b7e89e to 4f80901 Compare September 18, 2026 13:27
@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch from 4f80901 to 01baefb Compare September 18, 2026 14:05
@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch from 01baefb to ab87b95 Compare September 18, 2026 15:48
@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch from ab87b95 to 82d977f Compare September 18, 2026 18:03
@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch 2 times, most recently from 81774fe to 08d441e Compare September 21, 2026 23:07
@mafredri

This comment has been minimized.

@chatgpt-codex-connector

This comment has been minimized.

@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch from 08d441e to 56a1322 Compare September 22, 2026 14:01
@mafredri
mafredri marked this pull request as ready for review September 23, 2026 11:28
@mafredri

This comment has been minimized.

@coder-agents-review

coder-agents-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review in progress (24/24 reviewers complete) | View chat
Requested: 2026-09-23 13:09 UTC by @mafredri

🤖 Managed by Coder Agents.

@coder coder deleted a comment from coder-agents-review Bot Sep 23, 2026
@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch from 96b96a8 to a4332ce Compare October 29, 2026 10:45
@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch from a4332ce to bc5e601 Compare October 29, 2026 11:27
@mafredri
mafredri removed this pull request from stack #29557 October 30, 2026 11:39
@mafredri
mafredri added this pull request to stack #31570 October 30, 2026 11:41
@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch from bc5e601 to 860a4f4 Compare October 30, 2026 12:23
@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch 2 times, most recently from 72ace77 to 9849f7f Compare October 30, 2026 13:52
Base automatically changed from mathias/codagt-971-fe-1-refactors to main October 30, 2026 14:05
The backend pauses a chat while its queue head is under edit and marks
the row with editing_since. The frontend displays both: paused counts
as a completed turn for the chime and for dropping late stream parts,
blocks archiving with its own hint, and labels the send button Queue.
Enter in an empty composer does not send a head under edit. Queued
rows show an Editing badge on the marked row and a Waiting badge on
the rows behind it. This PR only displays the marker; the row actions
to begin or end an edit come in the next one.

Queued rows are compared structurally because a marker or content
change keeps the row's ID, which the ID-only comparison treated as
unchanged.
The buffered-parts test sent only waiting, so a paused status that
stopped setting the completed-turn flag went unnoticed. The test now
runs for both completed statuses.
Queued rows are compared by content, so restoring a pre-request
snapshot now overwrites a same-ID row whose editing_since changed
while a delete, compact or history edit was in flight. These
rollbacks restore the queue only when no queue update arrived during
the request, using the queue convergence fence.

The delete handler moves next to runPromoteQueuedMessage so it can be
tested, and the hook's cache writer and REST re-hydration get tests
for a change that keeps every row ID.
…edit

The server queues every send while the queue head is under edit, not
only while the chat is paused; a chat in error with an edited head
queues too. The label now also reads the head's editing_since marker.
The backend allows archive only from waiting and error. A status table
typed as Record<ChatStatus, ...> makes a new status fail the type
check until it is classified, where the previous check let any
unlisted status archive. Tests now cover error with a waiting child
and a paused chat with no children.
The queued-list stories hovered row text, so neither badge tooltip was
in a screenshot. One story now hovers the Editing badge and one the
Waiting badge. The paused page story builds its row from the shared
under-edit mock.
A paused chat has finished its turn, like a waiting one, but the
sub-agent tool mapped paused to the fallback, so a completed spawn
could render as running.
The completed-status JSDoc restated the helper's name; it now says
when a turn completes in waiting or paused. The chime's inline comment
repeated its doc comment and called one status "the active state".
Plain Enter sends only after the shortcut preference loads; until then
the composer uses the modifier shortcut. Pressed earlier, Enter sent
nothing whether or not the gate existed, so the test passed with the
gate deleted when it ran alone. It now waits until the send button
advertises plain Enter and includes a head that is not under edit.
A failed promote restored the pre-request queue, which overwrote a
queue update received during the request, such as a new Editing
marker. Restoring only when no update arrived is not enough: the
promoted ID is suppressed during the request, so that update was stored
and cached without the promoted row, which the server still holds after
the failure.

When the queue convergence fence moved during the request, the queue is
now refetched and applied as an authoritative update once the ID is
unsuppressed. If the refetch fails, the snapshot is restored. Either
result is also written to the messages cache. The result is dropped
when the active chat changed or another queue update arrived during the
refetch. With no update, the snapshot is restored as before.
@mafredri
mafredri force-pushed the mathias/codagt-971-fe-2-paused-display branch from 9849f7f to dff1c88 Compare October 30, 2026 14:05
@mafredri
mafredri enabled stacked auto-merge (squash) October 30, 2026 14:12
@mafredri
mafredri merged commit 01e213c into main Oct 30, 2026
25 checks passed
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.

2 participants