Skip to content

Complete AskUserQuestion natively instead of the Esc+prompt workaround #601

Description

@Juliusolsson05

PR #600 answers AskUserQuestion (multi-select / multi-question / free-text) by dismissing the picker with Esc and sending the choices as an XML prompt — a deliberate workaround. This issue tracks replacing it with a native completion, and removing the code the workaround orphaned.

Why the workaround exists

Keystroke-driving Claude's TUI picker is broken for everything except single-select and re-breaks each release (confirmed live against claude v2.1.218):

  • multi-select / multi-question never press the new "Submit answers" review screen (driver reports ok:true while Claude hangs);
  • multi-select over-toggles an option whose [ ] checkbox wraps;
  • free-text always times out (its footer still matches the picker fingerprint).

The workaround is version-proof but has costs: Claude records the tool as declined (a generic rejection result, is_error:true, indistinguishable from an abandonment — see docs/decomposition/evidence/auq-decline/), the answer arrives as a follow-up message rather than a real tool_result, and the raw XML shows as a visible user message.

What "native" would need

A real tool_result carrying the structured selections, delivered without screen-scraping the picker. Options to investigate:

  • Does Claude Code expose (or could upstream expose) a non-TUI way to complete an AskUserQuestion tool call — an SDK/headless hook, a control message, or a stable machine-readable completion path?
  • If not, is there a robust way to drive the current TUI (including the "Submit answers" review screen, wrapped checkboxes, and the free-text field) that survives version drift — e.g. reading cell attributes rather than plain text?

Cleanup this unblocks (the orphaned "bodies")

Once native (or a robust driver) lands, delete the keystroke-driver code the workaround orphaned in claude-code-headless — all confirmed unreachable after #600 (the renderer no longer routes multi/free-text through resolveCondition):

  • driveMulti, focusSubmit, optionToggled, waitForStableTextEntry, sanitizeFreeText, sameScreenQuestion, the free-text branches of driveSingle, and the multi-answer loop in resolveAskUserQuestionAnswer.
  • The allowTruncated gate + the multi-select fail-closed test (they gate/test the code above).
  • The dead snapshotPlain resolve-ctx field.
  • Stale "PR-5 / read-only until PR-5" comments in askUserQuestion.ts and the parser header.

And in agent-code: AskOption.preview is parsed but never rendered.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions