Skip to content

Build Claude's question and plan cards from the transcript's tool call, not the screen #211

Closed as not planned

Description

@devswha

Problem

Prompt cards for Claude Code's structured questions are built from the screen. server/prompt.ts parses the terminal rows of AskUserQuestion, its answer review and the plan approval. When the drawing changes, or a row wraps or a description gets in the way, no card appears. #140 is exactly this case: an AskUserQuestion waited for two hours with no card and was finally answered in the terminal.

These dialogs are tool calls, so their content is also recorded in structured form. AskUserQuestion puts its questions, options and descriptions in the tool call's input, and ExitPlanMode carries the plan. Codex already takes this route: its queued request_user_input questions come from the rollout (unansweredCodexQuestions in server/codex.ts), not from the screen.

Proposal

  • Content from the transcript. For a Claude pane that herdr reports blocked, find the newest AskUserQuestion or ExitPlanMode tool call in the session transcript that has no tool result yet. Build the card's questions, options, descriptions or plan from its input.
  • Answering stays on the screen, and is verified. The transcript does not show the menu's cursor or its keys. The answer still goes through the existing key path, but only after the screen's rows match the transcript's option labels, re-checked before Enter the way claude-confirm does since fix(prompt): read Claude Code's unnumbered menus, such as the folder-trust check #200. When the rows don't match, show no structured card and let the fallback card (fix(prompt): a blocked pane no reader knows still gets a card #205) take over.
  • Richer approval cards. For a permission prompt, the pending tool call (for example the exact Bash command) can fill the card's body instead of the wrapped screen text.
  • Not in scope: screens that are not tool calls, such as folder trust, login, update prompts, /config menus and MCP approval. Those stay with the screen readers and the fallback card.

To verify first

  • When Claude Code writes the tool_use entry for AskUserQuestion and ExitPlanMode to its JSONL transcript: before the dialog appears, or only later.
  • How a pane's transcript is found. The chat lens already does this for the conversation view, so it can probably be reused.
  • Multi-question AskUserQuestion: how the answered/unanswered state maps between the transcript and the screen's review step.

Order of preference for a blocked pane

  1. Transcript tool call plus screen verification. This is exact.
  2. Agent-specific screen readers.
  3. The fallback card (fix(prompt): a blocked pane no reader knows still gets a card #205).

Activity

  1. added
    enhancement
    on Sep 30, 2026
  2. devswha commented on Oct 1, 2026

    @devswha
    OwnerAuthor

    Tried in #254, and checked against a real Claude Code 2.1.286.

    In three of three real AskUserQuestion dialogs the session file did not change while the dialog was on screen. The tool_use appeared in the file only together with its result. So on this Claude version the pending call is not there when the card is needed, and the screen is still what gets read. A dialog taller than the pane (#140) still gets the last-resort card.

    #254 builds the card from the pending call when the file has one, and is harmless when it does not, but on 2.1.286 that path does not fire. It is left as a draft and not merged: it adds about 220 lines to code that sends keys, for no gain on the current Claude.

    A source that does have the call while it waits is Claude Code's PreToolUse hook, which receives the tool input. That is a different design (a hook installed for the user's Claude, a place to store what it reports), so it needs a decision before any work.

  3. devswha commented on Oct 3, 2026

    @devswha
    OwnerAuthor

    Closing as not planned.

    What is left is the PreToolUse hook, which does receive the tool input while the dialog waits. That means installing a hook in the user's Claude settings and storing what it reports, which is a different design and deserves its own issue if it is ever wanted.

    Worth reopening if a later Claude Code writes the pending call to the session file before the dialog is answered. Not re-checked on versions after 2.1.286.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions