Skip to content

fix(agents): wire ask_user answering into session/pane chat - #2303

Merged
2witstudios merged 3 commits into
masterfrom
fix/ask-user-answering-in-agent-session-panes
Aug 1, 2026
Merged

fix(agents): wire ask_user answering into session/pane chat#2303
2witstudios merged 3 commits into
masterfrom
fix/ask-user-answering-in-agent-session-panes

Conversation

@2witstudios

Copy link
Copy Markdown
Owner

Summary

  • Fixes ask_user questions being permanently non-interactive in agent-session panes (AgentPanes) and in AgentPageView's session-less chat.
  • Wires useAnswerAskUser + AskUserAnswerProvider into the shared useAgentSessionChat/useAssistantSessionChatSessionChatView pipeline, matching how GlobalAssistantView and SidebarChatTab already do it.

Root cause

useAnswerAskUser/useAskUserAnsweringStore (#2112) replaced the old useAskUserAnswering hook and fixed its answerability logic, but only got wired into two of the four chat surfaces: GlobalAssistantView.tsx and SidebarChatTab.tsx. The shared agent-session chat pipeline — useAgentSessionChat/useAssistantSessionChatSessionChatView, rendered by AgentPageView directly and by every pane in AgentPanes (PaneChatSessionChat/AssistantSessionChat) — never got the same wiring.

AskUserAnswerContext defaults to null when unwrapped (by design, so read-only/historical renderers stay non-interactive). With no provider, useAskUserAnswerContext() returned null inside AskUserQuestionCard, so isAnswerable was unconditionally false — every ask_user card in an agent session or pane rendered "Waiting for a response…" forever, regardless of the tool part's actual state.

Changes

  • useAgentSessionChat.ts / useAssistantSessionChat.ts: call useAnswerAskUser with the hook's own renderedMessages/isConversationBusy (displayIsStreaming)/setMessages/addToolResult/wrapSend/prepareSend, plus a new buildBody() callback extracted from handleSend's inline body construction (now shared by the send path and the answer path — mirrors the GlobalAssistantView/SidebarChatTab pattern). Both hooks now expose askUserAnswering on UseAgentSessionChatReturn.
  • SessionChat.tsx: wraps SessionChatView's render in <AskUserAnswerProvider value={chat.askUserAnswering}> — covers both the 'page' (ChatMessagesArea) and 'console' (SidebarMessagesContent) renderers, since both dispatch AskUserQuestionCard for tool-ask_user parts.

Context

Found while investigating #2238 ("unblock ask_user selections in developer/machine chats"), which turned out to be fully superseded by #2112's useAskUserAnsweringuseAnswerAskUser rewrite (closed, see #2238's closing comment). While verifying that rewrite covered #2238's original bug, this wiring gap in the pane/session surfaces turned up — it's the actual live "ask_user broken in panes" bug on master today.

Verification

  • ✅ New tests: useAgentSessionChat.test.ts and useAssistantSessionChat.test.ts each got a case seeding a pending ask_user tool part on the last assistant message, asserting askUserAnswering.answerableToolCallIds includes it, and that submitAnswers drives a real addToolResult call with the right toolCallId/tool.
  • bun run --filter web test -- src/components/agents/ — 307/307 passing (22 files), including the new cases.
  • bunx eslint on all touched files — clean.
  • bun run --filter web typecheck — clean.

useAnswerAskUser + AskUserAnswerProvider were only wired into
GlobalAssistantView and SidebarChatTab (#2112). The shared agent-session
chat pipeline (useAgentSessionChat/useAssistantSessionChat ->
SessionChatView) — rendered by AgentPageView and every pane in
AgentPanes — never got the same wiring, so any ask_user tool call
surfaced there was permanently non-interactive: no AskUserAnswerContext
provider meant useAskUserAnswerContext() returned null, which
AskUserQuestionCard treats as unconditionally unanswerable.

- useAgentSessionChat/useAssistantSessionChat: call useAnswerAskUser
  with the hook's own renderedMessages/isConversationBusy/wrapSend/
  prepareSend, and a new buildBody() extracted from handleSend's body
  construction (shared by both the send and answer paths). Expose
  askUserAnswering on UseAgentSessionChatReturn.
- SessionChat.tsx: wrap SessionChatView's render in
  AskUserAnswerProvider so both the 'page' (ChatMessagesArea) and
  'console' (SidebarMessagesContent) renderers pick it up — covers
  AgentPageView and every AgentPanes pane (chat + assistant-in-pane).
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@2witstudios, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c7ea9c8d-51a6-4bf5-afef-63386fa8679d

📥 Commits

Reviewing files that changed from the base of the PR and between 2b5616b and 8505c38.

📒 Files selected for processing (6)
  • apps/web/src/components/agents/chat/SessionChat.tsx
  • apps/web/src/components/agents/chat/__tests__/SessionChat.test.tsx
  • apps/web/src/components/agents/chat/__tests__/useAgentSessionChat.test.ts
  • apps/web/src/components/agents/chat/__tests__/useAssistantSessionChat.test.ts
  • apps/web/src/components/agents/chat/useAgentSessionChat.ts
  • apps/web/src/components/agents/chat/useAssistantSessionChat.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@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: 01dce22393

ℹ️ 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 thread apps/web/src/components/agents/chat/SessionChat.tsx Outdated
Codex review (PR #2303, P2): AskUserAnswerProvider ignored isReadOnly,
so a viewer without edit permission still saw ask_user options/Submit
as interactive — attempting to answer would 403, or could actually
resume a global-assistant pane despite the surface showing "View only".

Gate the provider's value on isReadOnly (null when read-only, same as
rendering outside a chat surface entirely) instead of passing the live
askUserAnswering unconditionally.
@2witstudios

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@2witstudios

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 4691a5e64c

ℹ️ 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 thread apps/web/src/components/agents/chat/useAgentSessionChat.ts Outdated
Codex review (PR #2303, P1): isConversationBusy was wired to
displayIsStreaming, which is deliberately own-stream-only (it's what
Stop is scoped to). When a REMOTE collaborator is streaming in the
same conversation, displayIsStreaming stays false while
renderedMessages filters their in-flight message out — so the
conversation's last SETTLED message can still be a stale ask_user
prompt from before their run started. Submitting it would call
addToolResult, whose server-side per-conversation takeover aborts the
collaborator's still-running generation and resumes the stale prompt.

Compute a separate isConversationBusyForAskUser (displayIsStreaming OR
any non-own entry in remoteStreams) and pass that to useAnswerAskUser
in both session hooks, without touching displayIsStreaming itself
(Stop and the streaming UI indicator stay own-stream-scoped).
@2witstudios

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@2witstudios
2witstudios merged commit dac8888 into master Aug 1, 2026
4 of 5 checks passed
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