Skip to content

fix(web): unblock ask_user selections in developer/machine chats - #2238

Closed
2witstudios wants to merge 1 commit into
masterfrom
fix/ask-user-developer-workspace-answer-lock
Closed

fix(web): unblock ask_user selections in developer/machine chats#2238
2witstudios wants to merge 1 commit into
masterfrom
fix/ask-user-developer-workspace-answer-lock

Conversation

@2witstudios

@2witstudios 2witstudios commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • fixes ask_user option cards becoming non-interactive in developer/machine-style chat surfaces
  • removes the status === 'ready' gate from ask_user answerability computation
  • keeps answerability scoped to pending tool-ask_user parts on the last assistant message
  • adds a focused logic test suite for answerability selection

Root cause

useAskUserAnswering required transport status to be ready before exposing answerable tool call ids. In complex surfaces (mode switches / machine/developer contexts), status can be surface-local or stale relative to the rendered conversation, causing ask_user cards to render in a disabled state (not-allowed cursor) even when the last message has a pending input-available question.

Changes

  • apps/web/src/lib/ai/shared/hooks/useAskUserAnswering.ts
    • extracted getAnswerableAskUserToolCallIds(messages) helper
    • removed status gate from answerable-id selection
  • apps/web/src/lib/ai/shared/hooks/__tests__/useAskUserAnswering.logic.test.ts
    • verifies:
      • pending ask_user on last assistant message is answerable
      • ask_user not on last message is not answerable
      • output-available ask_user is not answerable

Verification

  • bun run test src/lib/ai/shared/hooks/__tests__/useAskUserAnswering.logic.test.ts
  • bun run lint (warnings only, pre-existing)
  • ⚠️ bun run typecheck in apps/web could not complete in sandbox (tool execution failed/timeout despite increased memory and timeout)

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of “Ask User” prompts so response options remain available when appropriate.
    • Prevented completed prompts or prompts from earlier messages from being treated as answerable.
  • Tests

    • Added coverage for active, completed, and outdated “Ask User” prompt scenarios.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ab12919-513c-4fc4-8f1a-2dfaeb62f4d1

📥 Commits

Reviewing files that changed from the base of the PR and between 8d7a9e2 and dc6b247.

📒 Files selected for processing (2)
  • apps/web/src/lib/ai/shared/hooks/__tests__/useAskUserAnswering.logic.test.ts
  • apps/web/src/lib/ai/shared/hooks/useAskUserAnswering.ts

📝 Walkthrough

Walkthrough

The change extracts ask-user answerability into an exported helper, removes transport-status gating from the hook, and adds tests for pending, non-latest, and completed ask-user tool calls.

Changes

Ask-user answerability

Layer / File(s) Summary
Extract answerable tool calls
apps/web/src/lib/ai/shared/hooks/useAskUserAnswering.ts, apps/web/src/lib/ai/shared/hooks/__tests__/useAskUserAnswering.logic.test.ts
The exported helper selects input-available ask_user tool calls from the last assistant message, with tests covering their position and completion state.
Integrate helper into answering hook
apps/web/src/lib/ai/shared/hooks/useAskUserAnswering.ts
useAskUserAnswering derives answerable IDs from messages without using status and memoizes only on messages.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: unblocking ask_user selections in developer and machine chats.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ask-user-developer-workspace-answer-lock
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix/ask-user-developer-workspace-answer-lock

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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: dc6b247b06

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

}
return ids;
}, [messages, status]);
const answerableToolCallIds = useMemo(() => getAnswerableAskUserToolCallIds(messages), [messages]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Disable the question once answer submission starts

When a user submits an answer, addToolResult updates only the transport message and auto-resumes the chat, while the store-backed messages passed by these surfaces can retain the pending input-available part throughout the submitted/TTFB window. Because answerability now depends only on that unchanged array, the Submit button remains enabled and a second click invokes wrapSend again; useSendHandoff has no duplicate-send guard, so this can start duplicate agent resumptions and repeat billed or side-effecting tool work. Preserve the fix for stale cross-surface status, but add a conversation/tool-call-scoped submitting guard that removes the ID as soon as submission begins.

Useful? React with 👍 / 👎.

@2witstudios

Copy link
Copy Markdown
Owner Author

Closing as superseded.

apps/web/src/lib/ai/shared/hooks/useAskUserAnswering.ts — the only file this PR touches — was deleted by #2112 ("recovery, retry, AskUser, voice, errors on the store model"), which replaced the whole ask_user answerability pipeline with useAnswerAskUser + useAskUserAnsweringStore (a claimAnswering mutex) + selectAnswerableAskUserToolCallIds. That rewrite already:

  • removes the status === 'ready' gate this PR was fixing (replaced by an isConversationBusy computed at the selector level), and
  • adds a synchronous claim-mutex specifically to prevent the double-submit race @chatgpt-codex-connector flagged here (P1, useAskUserAnswering.ts:56) — useAskUserAnsweringStore.claimAnswering is exactly that guard, with tests covering it.

So there's no longer a diff for this PR to make. Merging it as-is would either resurrect a dead, unused file or resolve to a no-op against master's deletion.

Separately: while verifying this, we found the ask_user answerability fix from #2112 was only wired into GlobalAssistantView and SidebarChatTab — the shared agent-session chat pipeline (useAgentSessionChat/SessionChatView, used by AgentPageView and every pane in AgentPanes) never got useAnswerAskUser/AskUserAnswerProvider wired in, so ask_user is still non-interactive there today. That's the actual "developer/machine chats" surface this PR's title referenced. Following up with a fix targeting that surface directly.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex couldn't complete this request. Try again later.

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