feat(frontend): queue agent chat messages typed during a stream#4903
Conversation
Previously the composer dropped anything typed while a turn was in flight
(Ant X gates onSubmit on !loading). Now those messages are queued and sent
one-by-one after the turn settles.
- canReleaseQueuedMessage / isHitlPending (@agenta/playground, +13 unit tests):
the release gate. Never releases mid human-in-the-loop — a tool-approval
gate ends the stream (status "ready") while the turn is really paused on the
user's approve/deny, and useChat auto-resumes after. Composes
agentShouldResumeAfterApproval so the pre-resume window is held too. Holds on
error rather than firing follow-ups into a failed turn.
- useAgentChatQueue: queue state + a release effect that emits exactly one
message per clean settle (ref-guarded, StrictMode-safe).
- AgentChatPanel: handleSubmit queues when busy or mid-approval; the Sender
drops loading={busy} so the send button stays live and routes to the queue,
with Stop + a queued count moved to the footer; QueuedMessages shows the
removable pending chips.
- Also stabilizes the panel's handleRewind (useCallback + refs) so memo'd
AgentMessage rows aren't re-rendered on every streamed token — the same fix
the perf branch applied only to the contract-v1 surface.
The inline chip strip grew with the queue and truncated long messages to unhelpful stubs. Replace it with a fixed-footprint count pill in the composer footer that opens a popover to manage the queue. - QueuedMessages: a "N queued" pill (count only — no truncation on the trigger) opening a popover list with order number, remove, and Clear all. Previews use a 3-line clamp + break-words + full text on hover, so long messages stay identifiable; the list scrolls past ~3 instead of growing the composer. - Footer is now HITL-aware: "Streaming… [Stop]" while busy, "Waiting for approval" when the turn is paused on a tool approval (busy false but messages still held), so the queue count stays visible and the hold is explained. The footer now renders for busy || queued.length > 0, not just busy.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds queued agent-chat submissions with HITL-aware release gating. The queue hook, queued-message popover, and AgentChatPanel wiring now coordinate submission, release, rewind, and footer state. The gating helpers are exported through the state modules and covered by unit tests. ChangesAgent chat queued-message sending with HITL gating
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…t/agent-chat-message-queue-onbig
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: acf9e698-e2ac-486f-a8de-d06c84e33bd4
📒 Files selected for processing (8)
web/oss/src/components/AgentChatSlice/AgentChatPanel.tsxweb/oss/src/components/AgentChatSlice/components/QueuedMessages.tsxweb/oss/src/components/AgentChatSlice/hooks/useAgentChatQueue.tsweb/packages/agenta-playground/src/index.tsweb/packages/agenta-playground/src/state/execution/agentMessageQueue.tsweb/packages/agenta-playground/src/state/execution/index.tsweb/packages/agenta-playground/src/state/index.tsweb/packages/agenta-playground/tests/unit/agentMessageQueue.test.ts
Review follow-up on the message-queue branch. - handleSubmit had its own send-vs-queue decision (busy || hitlPending) that drifted from the release effect's gate, so a new message could jump ahead of held queued items or fire into an errored turn. Replace both with a single hook-owned submit() that uses canReleaseQueuedMessage — one decision point, one sender (sendQueued), and no duplicated payload building. - Footer guard now includes hitlPending, so "Waiting for approval" renders during a HITL pause even when the queue is empty. - Add the deny-path assertion to the pre-resume gate test (approve AND deny both resume, so both must hold the queue).
The queue popover showed only a file count. Render each attachment as a small 24px tile — an image thumbnail (from the inline data: URL) or a type icon for audio/video/other — so a queued message's attachments are identifiable at a glance. Filenames stay as hover titles only. Also tightens the popover density (2-line text clamp, smaller padding, 300px width).
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4ba37045-7deb-4567-9ecb-684fa9112158
📒 Files selected for processing (4)
web/oss/src/components/AgentChatSlice/AgentChatPanel.tsxweb/oss/src/components/AgentChatSlice/components/QueuedMessages.tsxweb/oss/src/components/AgentChatSlice/hooks/useAgentChatQueue.tsweb/packages/agenta-playground/tests/unit/agentMessageQueue.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- web/packages/agenta-playground/tests/unit/agentMessageQueue.test.ts
- web/oss/src/components/AgentChatSlice/AgentChatPanel.tsx
Second review round on the message-queue branch. - submit could direct-send twice when two submits landed in the same render before status left "ready", breaking FIFO. Share the release latch (releasingRef) across both send paths and read the live queue length via a ref, so the first send closes the window and the next message queues behind it. - Non-image attachment tiles exposed no accessible name (title is mouse-only): add role="img" + aria-label and mark the decorative icon aria-hidden. - Collapse the multi-line comments that exceeded the one-line rule.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Stacked on #4902 — review/merge that first. Base is
fe-perf/agent-chat-long-conversation-onbigso this PR shows only the queue diff.Problem
While an agent turn was streaming, the composer silently dropped anything the user typed (Ant Design X gates
onSubmiton!loading, and the panel passedloading={busy}). You could type but not send.Change
Messages typed during a turn are now queued and sent one at a time after the turn settles.
@agenta/playground, pure + unit-tested):canReleaseQueuedMessage/isHitlPending. The trap is human-in-the-loop — a tool-approval gate ends the stream (status: "ready") while the turn is really paused on the user's approve/deny, anduseChatauto-resumes after. The gate never releases mid-HITL, and composesagentShouldResumeAfterApprovalso the pre-resume window is held too. It also holds onerrorrather than firing follow-ups into a failed turn. 13 unit tests.useAgentChatQueue: owns the queue and a release effect that emits exactly one message per clean settle (ref-guarded, StrictMode-safe).handleSubmitqueues when busy or mid-approval. TheSenderdropsloading={busy}(so the send button stays live and routes to the queue) and gains a footer. A collapsed count pill → popover manages the queue at a fixed footprint regardless of size; previews use a 3-line clamp + full text on hover so long messages stay identifiable. The footer is HITL-aware:Streaming… [Stop]vsWaiting for approval.This branch also carries the
AgentChatPanelcopy of the stable-onRewindfix from #4902 (the primary surface had the same re-render bug the perf PR fixed on the contract-v1 surface).Testing
tsc --noEmit+ eslint clean; 13/13 new unit tests pass (agentMessageQueue.test.ts).