Queued messages
A message sent while the assistant is answering waits its turn instead of cancelling the answer.
The problem
People type ahead. They see where the answer is going and fire off the follow-up.
The two obvious behaviors both lose something. If sending aborts the turn in flight, they lose the answer they were reading. If sending is disabled until the turn ends, they lose their thought.
What I concluded
There’s one send path, and it only ever adds to a queue. A single effect starts the next turn whenever nothing is running. Every way of sending (the input, a suggestion chip, a button somewhere else in the app) goes through that same queue.
// Sent from an effect, never inline, so every sender shares it.
useEffect(() => {
if (current || held || queue.length === 0) return;
setCurrent(queue[0]);
setQueue(queue.slice(1));
}, [current, held, queue]);
Queued messages stay visible under the conversation, each with Send now and a remove button. Nothing you typed disappears into a hidden buffer. You can see what the assistant is about to do and take it back.
Rules
- Sending only enqueues. One effect decides when a turn starts.
- First in, first out. Send now is the only way to jump the line.
- The queue is visible and editable. Every queued message can be sent now or removed.
- Cap it. Five in the demo. Past the cap the composer shakes and keeps your text instead of dropping it.
- Stop holds the queue. Stopping usually means “wait, let me rethink,” not “send the next thing.”
What you get
Typing ahead just works. The answer you’re reading finishes, your follow-up runs next, and you can always see and change what’s lined up.
Related: Assistant panel, Stateful or stateless, Plant shop demo