Repository navigation
feat(site/src/pages/AgentsPage): collapse the question dock and keep focus in the chat - #31372
Closed
ibetitsmike wants to merge 160 commits into
Closed
ibetitsmike wants to merge 160 commits into
ibetitsmike wants to merge 160 commits into
Conversation
…he turn In chats created from the web UI, ask_user_question is now available outside plan mode. The call returns at once with async: true, the agent keeps working, and chatd sends the chat owner a web push. The UI keeps the question answerable while the agent runs, sends the answer as a user message that names the tool call, and shows superseded questions as closed. API chats and plan mode keep today's behavior.
…l call ID Address frontend review: branch on async instead of an empty prefix, recognize a prefixed answer even when a queued message lands first, replace the attribute-asserting test with a story for the blocking while-running state, and add stories for answered async questions.
…ions open A question still in the live stream is now the latest question, so it does not render as closed before its step persists and the persisted question it supersedes does. Also share one spelling of the async answer prefix and read each user message's text once.
…pers to a module The async answer format is shared by the question component and the conversation timeline, so it lives in its own module.
…ching Nest the answer lookup under one guard, tighten the helper docs, and reuse the shared question fixture in the live-stream story.
…until answered An async ask_user_question is now answered only by a user message whose first line names its call, and closed only by a newer valid question. Unrelated messages and failed calls no longer close it. A queued answer counts as the answer, so a reload or another tab does not offer the question again, and removing that answer from the queue reopens it. User bubbles and queue rows show the answer without the call ID line.
…nc answer handling Move ask_user_question result parsing next to parseArgs, reuse the async check in Tool.tsx, rename the answered-question prop and helpers to say what they track, build story fixtures from getAsyncAnswerPrefix, and tighten comments.
…ixtures and docs Share text part concatenation with getEditableUserMessagePayload, add a story for a question left open by an unrelated message, replace a story that duplicated the answered state with a getAsyncAnswerText test, and trim comments that restated code.
…async answer Cover the timeline state where the answer to an async question waits in the queue, and tighten three comments.
…ers at the timeline boundary Move the running-chat async answer test from the Tool renderer to ConversationTimeline, where it also covers the unrelated-message regression and the tool call ID plumbing through MessageBlocks.
…c-ask-user-question # Conflicts: # site/src/pages/AgentsPage/components/ChatPageContent.tsx
Copy and Edit on a delivered async answer exposed the hidden 'Answer to ask_user_question call <id>:' line. Copy now uses the answer body, and Edit shows the body and restores the line on send so the answer stays tied to its question. Also moves the answer submission state into useAnswerSubmission, drops a comment that restated a field, and records webpush mock messages before bumping the dispatch count.
… failed edit The history-edit rollback now restores the answer prefix line with the rest of the edit snapshot. Also moves the answer submission state back into AskUserQuestionTool, because FE3 disallows a one-consumer hook that component state can express.
The async ask_user_question tool sent its web push from inside the tool run, before the step that holds the result committed. A failed commit left the user with a push for a question the UI never showed, and a re-run after a retryable failure pushed the same question again. chatd now reads the async question from the step's tool results and sends the push from afterGenerationOutcome once the step commits. A fail-closed commit sends only the error push, and a step that asks more than once pushes only the last question, the one the UI offers.
…smallest result budget chatloop truncates a tool result longer than its byte budget into invalid JSON, which hid the async marker from the UI and the question push. Async results now fail validation above the smallest budget, so the model shortens them instead.
… call they name Providers choose tool call IDs, and chatd stores them raw, so the answer prefix parser now accepts any ID on the first line, spaces included. An answer to an earlier async call no longer closes a newer plan mode question; only an ordinary message or one that names that call does.
…he turn Expose ask_user_question outside plan mode for chats created from the web UI. Outside plan mode the tool returns at once, the turn keeps running, and the answer arrives later as a user message that names the tool call. API-created chats keep the tool in plan mode only.
Adds stories for a two-question async dock advanced to its second step and for a blocking question that stays inline, renames the read-only story to an archived chat, defaults the story page height, and trims JSDoc on the dock, showsStreamOutput, and createPreferenceSeededQueryClient.
…roll between steps
…m without the transcript card
The dock rendered AskUserQuestionTool, the transcript card, and turned the
card's own behavior off: it passed isLatestAskUserQuestion, silenced the
announcement with announcesQuestion={false}, and reached the questions
through the exported AskUserQuestionRenderer.
AskUserQuestionForm now owns the answers, the wizard, the send, and the
answered view. The card keeps the error, running, closed, and docked
states, the announcement, and the async call ID: it strips the answer's
prefix line and adds it to the answer it sends. The dock renders the form
directly with getAskUserQuestions, so announcesQuestion and the exported
renderer go away.
…r sender The card already wraps its send in a named function that adds the async prefix line; the dock now does the same instead of an inline ternary lambda.
…turn the result's questions when the args have none Once the args have no questions, the old fallback chain could only return an empty list or the result's questions, so getAskUserQuestions now returns the parsed result or an empty list, and parses the result only when it needs it. The card also gets blank lines between its steps.
…prefix in the question form The card and the dock each wrapped the form's send to add the async answer's prefix line, and each stripped that line before passing the answer in, so the form's previousResponseText and onSubmitAnswer carried other text than the card's props with the same names. The form now takes asyncToolCallId and handles the prefix line in both directions, and getAnswerBody replaces getAsyncAnswerBody so the card and the form share the same check. Also from the frontend review: showSubmittedAnswer is required and named like other boolean props, getAskUserQuestions parses the result itself, the docked notice takes precedence explicitly, the card's running header is written once, and the announcement comment says why its live region renders early.
…dy the question form after review From the second frontend review round: the form and the card document what they own, getAnswerBody's doc names the argument that passes text through, both question lists build their keys with getQuestionKey, and the asked-question text drops an id that nothing reads, so the card no longer needs useId. getAnswerBody gets unit tests for each case.
…line the asked-question row From the third frontend review round: AskedQuestions renders its rows itself, since it was the only caller of AnsweredQuestionText. The form's docs state the async contract once, and the getAnswerBody tests name the expected result and cover a message without the prefix line.
…when the question form is read-only The dock keeps passing onSubmitAnswer while its answer waits in the queue, so the prop doc now says the form is also read-only once it shows an answer. getAskUserQuestions' doc names its empty-list result.
…nd answer
- The question label ("Question 2 of 6 · Header") is a small header, and
the question text sits on its own line in a larger, bolder font. The
options lose their border box.
- The "Other" field is always visible. Clicking it or typing in it
selects "Other"; tabbing through it keeps the chosen option.
- A Skip button answers the current question with "Skipped" and moves
on, or sends the answers on the last question.
- In the question panel, the label is a header button that collapses
and expands the whole panel.
- Unsent answers and the current question are saved in localStorage
per call until a send succeeds.
- The panel grows to show the whole question instead of scrolling
inside a 50vh box; it scrolls only past 60vh.
…ew of the question form changes - Key the inline card's draft by call ID and start time, as the dock does. - Extract the panel header into QuestionPanelHeader and inline the label. - Tighten the draft types and reuse asRecord and parseJSON in questionDraft. - Move the new keyboard checks from story play functions into Vitest. - Restore "questions answered" in the collapsed header; trim comments.
… scroll and clear answered drafts - Key the dock's scroller by call, so a newer question starts at the top. - Remove a saved draft once the form shows any answer, including one sent as a chat message. - Name the radio group by the question label and text. - Compare saved questions with isEqual, and cover a Skip on the last question.
…can no longer be sent - A closed async question removes its saved draft. - Type the restored drafts, keep focused options clear of the sticky actions with scroll padding, and test the draft removal on an answer.
…raft A history edit can reopen a closed question, so its saved draft stays until the form shows an answer. Also rename getDraftKey to getQuestionCallKey, since the dock keys its panel by it too.
…ment on the scroller Also document the empty selection of a question draft.
…Markdown in ask_user_question forms Agents write question text and option descriptions in Markdown (headings, tables, bold, code), which the form showed as raw source. Render them with Response, as the transcript does.
…tion descriptions out of the radio label A Markdown description can hold links and copy buttons, which must not nest inside the option's label, so the description now sits beside the label and describes the radio. Stories show Markdown in the open form and in the answered list; the Markdown unit test is dropped in favor of them.
… the question focus assertions A substring match also passes when focus falls to the page body.
ibetitsmike
force-pushed
the
mike/codagt-1460-question-dock
branch
from
October 30, 2026 21:21
a55bcf0 to
6625dff
Compare
Collaborator
Author
Closing: the stack was reshaped into five layers, and this PR's changes (collapsing the question dock and returning focus to the chat input after an answer) now live in #31312. |
mafredri
pushed a commit
that referenced
this pull request
Nov 3, 2026
The agent keeps working after an async question, so its transcript card scrolls away under new output. While the question is open, its answer form moves to a collapsible panel above the chat input, and sending an answer returns focus to the chat input. This is the net change of mike/codagt-1460-question-dock at c455707, collapsed into one commit to rebase it onto main without replaying the merges from the layer below. It includes the focus handling from the closed #31372.
mafredri
pushed a commit
that referenced
this pull request
Nov 6, 2026
The agent keeps working after an async question, so its transcript card scrolls away under new output. While the question is open, its answer form moves to a collapsible panel above the chat input, and sending an answer returns focus to the chat input. This is the net change of mike/codagt-1460-question-dock at c455707, collapsed into one commit to rebase it onto main without replaying the merges from the layer below. It includes the focus handling from the closed #31372.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack
This stack lets the agent in Coder Agents web UI chats ask a question with
ask_user_questionwithout ending its turn (CODAGT-1460).Refs CODAGT-1460
Why
Two review threads on #31294 and #31312 found two cases where focus falls to the page body, so the next Tab starts from the top of the page:
maindoes the same.What changes (
site/src/pages/AgentsPage)focus()only sets the page's focused element and cannot take focus from the address bar or another window. Composer sends keep their narrow-screen behavior.useComposerFocusAfterSendwraps the answer's send and focuses the chat input in an effect once the send succeeds. The focus cannot happen right after the request, because the editor is disabled while the send is pending and accepts focus only in the commit that enables it again.AsyncQuestionDockFocusedstory captures.AskUserQuestionDocknow stays mounted across questions and keys only its inner section, by call ID and start time as before, so each question still gets a fresh draft and starts scrolled to the top. The section's ref cleanup records whether the section held focus: React detaches a ref before it removes the node, so the replaced section still contains the focused element at that point. The new section's ref then takes the focus when it finds focus on the page body, asMessageAttachmentCarddoes onmain.Response, as the transcript does. An option's description sits beside its label rather than inside it, because Markdown links and copy buttons must not nest in a label, so clicking the description no longer selects the option.questionDraft.tssaves the unsent answers and the current step in local storage, keyed by call ID and start time together with the questions they answer. A reload or a navigation restores them; a successful send, or the answer showing in the chat, removes them. A draft for a question that closed without an answer stays, because a history edit can reopen it.Tests
AskUserQuestionTool.test.tsx: Other is selected from its field but not when Tab passes through; a skipped question sends as "Skipped", and skipping the last question sends at once; an unsent draft is restored after a remount and removed once the answer sends or the question shows an answer.questionDraft.test.ts: a draft reads back only for the same questions, and malformed drafts are ignored.AgentChatPage.test.tsx: on a narrow viewport, answering from the panel with the keyboard leaves focus in the chat input; a failed send does not move focus there; and focus that the user moved during the send, to another control or by a click on the page background, stays there.ChatPageContent.test.tsx: the existing replacement test (new and reused call ID) now also checks that the panel holds focus, and a new test checks that focus on a control outside the panel, or on the page body, stays put when a newer question arrives.ChatPageContent.test.tsx: collapsing and expanding the panel keeps the chosen option for Submit; it fails when the panel remounts the form on collapse. The newAsyncQuestionDockCollapsedstory captures the collapsed line.Known follow-up (not in this PR)
main, so a failed answer or a focus move during the send still ends with focus in the chat input there.mainbehave the same.