Skip to content

fix(server): resolve Claude user input prompts on stop#4096

Open
nateEc wants to merge 1 commit into
pingdotgg:mainfrom
nateEc:codex/fix-stale-user-input-gui
Open

fix(server): resolve Claude user input prompts on stop#4096
nateEc wants to merge 1 commit into
pingdotgg:mainfrom
nateEc:codex/fix-stale-user-input-gui

Conversation

@nateEc

@nateEc nateEc commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Closes #4060.

Summary

  • Cancel pending Claude AskUserQuestion requests when the provider session stops.
  • Emit user-input.resolved during session stop so projected threads clear stale user-input prompts.
  • Keep SDK permission results as deny/cancel instead of allowing an empty answer payload.

Verification

  • corepack pnpm exec vp test run apps/server/src/provider/Layers/ClaudeAdapter.test.ts
  • corepack pnpm exec vp run typecheck
  • corepack pnpm exec vp check (passes with existing warnings outside this change)

Note

Low Risk
Scoped to Claude AskUserQuestion lifecycle and session teardown; behavior change is intentional cancellation with test coverage and no auth or data-model changes.

Overview
Fixes stale AskUserQuestion prompts when a Claude session ends while the UI is still waiting for answers.

ClaudeAdapter now tracks pending user input with a tagged answered / cancelled resolution instead of a bare answers deferred. Session stop cancels every open prompt (mirroring pending approvals): it completes the wait, emits user-input.resolved with empty answers so projected threads clear, and the SDK canUseTool path returns deny with a cancel message rather than allowing empty answers. Abort while waiting uses the same cancelled resolution; user-input.resolved is not emitted twice when stop already published the cancel event.

Adds a test that stopSession during an in-flight AskUserQuestion produces the resolved event and deny permission result.

Reviewed by Cursor Bugbot for commit f7f07cf. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Resolve pending Claude user input prompts with cancellation on session stop

  • Introduces a PendingUserInputResolution discriminated union (answered | cancelled) to replace the raw answers Deferred in PendingUserInput.
  • When a session stops, stopSessionInternal now iterates pending user-input requests, fulfills each with a cancelled resolution, emits a user-input.resolved event with empty answers, and clears the map.
  • In the AskUserQuestion handler, a cancelled resolution returns a deny PermissionResult with the message 'User cancelled tool execution.' and skips emitting a duplicate user-input.resolved event if the session already emitted one on stop.
  • respondToUserInput now tags fulfilled resolutions as answered before resolving the deferred.

Macroscope summarized f7f07cf.

- Cancel pending AskUserQuestion requests when a Claude session stops.

- Emit user-input.resolved so projected threads no longer stay trapped in stale prompts.

- Add ClaudeAdapter coverage for stopping while user input is pending.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c6f57b7a-e91b-4627-bd05-43c2ec856339

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jul 17, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f7f07cf. Configure here.

payload: { answers },
},
});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing resolved after abort then stop

Medium Severity

When an AskUserQuestion wait is cancelled via the SDK AbortSignal, onAbort removes the request from pendingUserInputs before session teardown runs. If stopSessionInternal then sets context.stopped with an empty map, no user-input.resolved is emitted, and the handler skips emission for cancelled resolutions while stopped—so projected threads can keep a stale user-input prompt.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f7f07cf. Configure here.

@macroscopeapp

macroscopeapp Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

An unresolved review comment identifies a potential race condition where abort-before-stop could leave stale user-input prompts. This potential bug in the fix warrants human review.

You can customize Macroscope's approvability policy. Learn more.

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

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Stuck on User Input Tool GUI

1 participant