Skip to content

feat(site/src): show descendant chat questions on the root chat page - #118

Merged
ibetitsmike merged 32 commits into
mainfrom
mike/descendant-questions-3-question-dock
Nov 10, 2026
Merged

ibetitsmike merged 32 commits into
mainfrom
mike/descendant-questions-3-question-dock

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Part of #73

Xum opened this PR on behalf of @ibetitsmike.

With fork-nested-subagents on, a root chat's page shows a "Question from " card whenever a descendant chat at any depth has called ask_user_question. The user answers on the root page, and the answer goes to the descendant that asked, not to the root chat. Until now these questions showed only on the asking chat's own page.

This makes the model-facing text from #86 true. descendantQuestionNote and the ask_user_question description in coderd/x/chatd/fork_descendant_questions.go both tell the model that the user answers in the root chat.

What changes

  • site/src/api/forkChatQuestions.ts fetches GET /api/v2/chats/fork/{chat}/questions (feat(coderd): list a chat family's pending descendant questions #114). site/src/api/queries/forkChatQuestions.ts holds the query key, query options and mutation options, the same split as forkChatTodos.
    • The query polls every 5 s, because a descendant's question raises no event on the root chat's stream. React Query does not poll a hidden tab.
    • The mutation posts the answer with createChatMessage to the asking chat, then refetches the list. It also refreshes the asking chat's cached chat, prompts and debug runs, with the same helpers that upstream's createChatMessage mutation uses.
  • ForkDescendantQuestionDock (new fork file) renders nothing, and never creates the query, unless the experiment is on, the chat is a root chat and the viewer can act on it. Otherwise it shows the oldest pending question:
    • a header "Question from <title>" (or "a subagent") that links to the asking chat, plus "1 of N" when more questions are pending,
    • upstream's AskUserQuestionForm with the question's tool_call_id, so the answer carries the Answer to ask_user_question call <id>: prefix that the child's wait expects, and with the same draft key and sticky actions as upstream's dock.
    • When the page withholds the root's answer handler because the chat cannot take a turn (for example without the AI Gateway), the dock stays visible with submit disabled.
    • A failed poll shows an error alert above the question, or alone when no question is cached.
    • When a new question replaces a focused one, the new section takes the focus, as in upstream's dock.
  • Upstream edits, kept to the minimum: ChatPageTimeline gets one optional chat prop and renders the fork dock when the root's own question dock is not showing; AgentChatPageView passes chat.

Validation

  • biome, tsc, knip, and vitest for ForkDescendantQuestionDock.test.tsx, ForkComposerSlot.test.tsx and AgentChatPage.test.tsx: all pass.
  • The tests use MSW at the HTTP boundary. They check that no request is made when the experiment is off, the chat is a child or the chat is read-only. They check that answering with two questions pending posts exactly the prefixed answer to the oldest question's asking chat and then refetches. They check that the header link opens the asking chat. Each test fails when its behavior is broken: the gate removed, the answer posted to the root chat, the link pointed at the parent, the newest question picked, or the invalidation removed.
  • Stories: OnePending, SeveralPending, UntitledChat, LoadError, AnswersDisabled.
  • fork-ci is green on 808a20572d, including the site job (vitest, 5m15s) and chat-tests.
  • UAT on a dev build of 76d3d0752f with real chats: all five checks pass. In a depth-2 family (root, coordinator, asker), the root page shows "Question from asker" while the root waits on wait_agent. Submitting Red makes exactly one message POST, to the asker, with the prefixed answer, and the root then reports CHOSEN=Red. Two pending questions show oldest first with "1 of 2". The title link opens the asking chat. A child page and an experiment-off build show no dock and make no /questions request. The full table is in the UAT comment below. The branch has since merged main; that merge does not change this PR's diff.

…hind fork-nested-subagents

A delegated chat that is not an explore subagent gets a blocking
ask_user_question tool. The call records the question in the new
chatd.chat_descendant_questions table and ends the turn; the answer is the
next user message. The parent's wait_agent reports needs_input while the
child's question is unanswered and, when called while it is pending, waits
for the answer before it waits for the child.
…c and cover the late question

TestDescendantQuestionEndsTurn raced the child's turn against the root's wait_agent call: when the question was already pending, wait_agent waited the default five minutes and the test hit its deadline (about 1 in 3 to 1 in 15 runs). The root's wait_agent now starts once the question is pending, with a 1 second timeout.

TestDescendantQuestionWaitAgent now also covers a question the child asks while the parent waits on it, which only the racy end-to-end path exercised. TestAppendForkTools now includes wait_agent, so wrapping it with the experiment off fails.
…ions-1-chatd-tool

# Conflicts:
#	coderd/database/forkdb/forkdbmock/forkdbmock.go
#	coderd/database/forkdb/querier.go
#	coderd/database/forkdb/sqlc.yaml
Adds the forkdb query ListPendingChatDescendantQuestionsByRoot with its
dbauthz (read access to the root chat) and dbmetrics wrappers.
Lists the unanswered ask_user_question calls of the unarchived descendants
in a chat's family behind fork-nested-subagents, so the root chat UI and API
clients can answer them. Adds the codersdk types and client method and the
generated swagger, API docs and TypeScript types.
…tions

wait_agent now always runs the wrapped tool, so include_tool_calls and its
validation apply while a question is pending, a question asked before an
inner timeout is reported, and a failed question lookup is an error.
Model-only user rows from lifecycle hooks no longer answer a question.
…ions-1-chatd-tool

# Conflicts:
#	coderd/database/forkdb/sqlc.yaml
…ions-1-chatd-tool

# Conflicts:
#	coderd/x/chatd/fork_tools.go
…ions-1-chatd-tool

# Conflicts:
#	coderd/database/dbauthz/fork_forkdb_test.go
…ions-1-chatd-tool

# Conflicts:
#	coderd/database/dbauthz/fork_forkdb.go
#	coderd/database/dbmetrics/fork_forkdb.go
#	coderd/database/forkdb/sqlc.yaml
#	coderd/x/chatd/ARCHITECTURE.md
…ions-2-questions-route

# Conflicts:
#	coderd/database/dbauthz/fork_forkdb_test.go
#	coderd/database/forkdb/chat_descendant_questions.sql.go
#	coderd/database/forkdb/chat_descendant_questions_test.go
#	coderd/database/forkdb/queries/chat_descendant_questions.sql
…com:ibetitsmike/coder into mike/descendant-questions-3-question-dock
…ions-2-questions-route

# Conflicts:
#	coderd/apidoc/docs.go
#	coderd/apidoc/swagger.json
…com:ibetitsmike/coder into mike/descendant-questions-3-question-dock
@ibetitsmike

Copy link
Copy Markdown
Owner Author

UAT on 76d3d0752f (PASS)

The current head d1cad80384 only merges main into 76d3d0752f, and that merge does not change this PR's diff.

I ran this on a dev build (develop.sh) of v2.0.0-devel+76d3d0752 in a dedicated UAT workspace, with CODER_EXPERIMENTS=fork-nested-subagents. The model is a local GLM-5.3-Flash served through oMLX, and every chat is a real chat. A headless Chromium (Playwright 1.63.0) inside the workspace opened the chat pages as the admin, clicked through the dock, and recorded every request to /api/v2/chats/fork/*/questions and every POST /api/v2/chats/*/messages. Times are UTC on 2026-11-10.

Check Result
S1 (lead condition): real depth-2 family. Root 86d2d99d (client ui) spawns coordinator be6aa78e, which spawns asker 02dbcc94, and the asker calls ask_user_question (call_6eda0f31) At 06:51:23 the root is running with no wait_agent result yet, and its page shows "Waiting for coordinator" with a spinner. Above the composer the dock shows "Question from asker" (the title links to the asker), the header Color and the options Red and Blue. I picked Red and clicked Submit at 06:51:25.150. The browser made exactly one message POST, to /api/v2/chats/02dbcc94.../messages. The asker's new user row 295 (06:51:25.153) reads Answer to ask_user_question call call_6eda0f31: followed by Red. The root still has exactly 1 user message (its prompt), and the route returns []. The asker replies CHOSEN=Red. The coordinator's wait_agent result is written at 06:51:43.639, and the root's at 06:52:11.016. The root then reports CHOSEN=Red. The dock disappears from the same page within 8 s of Submit and is still absent on a fresh load after the family finishes, when the route is still [].
S2: two children of one root, color-asker (06:49:43) and size-asker (06:50:05), each ask The dock shows the older question first, "Question from color-asker" with "1 of 2". Answering Red posts only to color-asker (Answer to ask_user_question call call_488c399c: then Red). The dock then shows "Question from size-asker" without a counter, and the route lists only size-asker.
S3: click the chat title in the dock header The browser goes to /agents/65826cdd..., the page of color-asker, the chat that asked.
S5: the page of a child chat that has a pending question (size-asker), experiment on The page shows upstream's inline question for its own tool call. There is no "Question from" dock, and in 12 s the page makes no request to /questions.
S4: the same build restarted with CODER_EXPERIMENTS unset, size-asker's question still pending in the DB The route returns 403. The root page shows the upstream timeline with no dock, and in 12 s the browser makes no request to /api/v2/chats/fork/*/questions.

With the experiment on, the root page polls the route about every 5 s (3 requests in 12 s), as intended.

After the run I stopped the dev server and revoked the temporary oMLX sub-key. The screenshots for each step are kept in the UAT evidence directory.

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T09:26:32.284651Z 793c81b 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.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@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: d1cad80384

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@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: 8ac6d6ab93

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@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: 8195ac59bc

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 5e91e3abff

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@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: 41a8622a5f

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 808a20572d

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this on behalf of @ibetitsmike.

Closing and reopening only to make GitHub recompute the merge ref against current main (2d635ea9a6) and run fork-ci on it. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this again on behalf of @ibetitsmike.

The merge ref now points at current main (2d635ea9a6), but the run started by the first reopen was queued against the old merge ref. This second reopen starts fork-ci on the recomputed merge. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 793c81bd52

ℹ️ 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".

@ibetitsmike
ibetitsmike merged commit 8f7fdb0 into main Nov 10, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/descendant-questions-3-question-dock branch November 10, 2026 09:40
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merge evidence for head 793c81bd52bfa4cc700dcb5467aabcd7043606fe:

  • fork-ci pull_request run 42790335635 passed; its build job checked out Merge 793c81bd52 into 2d635ea9a6 (current main). All checks green. biome 2.5.10 on the 9 changed site files: no fixes.
  • Codex on this exact head: no major issues (comment 6763774085). 0 unresolved review threads. Moving focus when the last question disappears was declined: upstream's AskUserQuestionDock behaves the same, and both docks should change together.
  • UAT PASS on a dev build of 76d3d0752f with real chats (PR body, Validation): in a depth-2 family the root page shows "Question from asker" while the root waits on wait_agent, submitting Red makes exactly one message POST to the asker and the root reports CHOSEN=Red, two pending questions show oldest first, and a child page or an experiment-off build makes no /questions request. Accepted as covering this head: the later commits handle load errors, focus, stale answers, a failed poll, disabled answers while the chat cannot take a turn, and the cache refresh after answering, and vitest with MSW at the HTTP boundary covers each of them. AgentChatPage.test.tsx "sends a subagent's answer while the root chat runs" pins the central flow on the real page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant