Repository navigation
engine: answer a TUI prompt from the banner's buttons (#131) - #148
Conversation
The 'Claude is waiting' banner now offers the numbered widget's options as
buttons. Measured on CLI 2.1.311: a digit selects and confirms an option, so
one digit is a whole answer; a multi-question AskUserQuestion moves through its
questions and a numbered Submit screen without leaving the awaiting state, so
the engine re-announces when the question changes in place.
The browser sends only {promptKey, choice}. The server refuses unless that key
is the open prompt of a live turn, re-captures the pane through an exact tmux
target and types one digit it computed itself only if the same question is
still on screen. A digit that went in consumes the prompt for the turn: no
reload, second window or re-announcement brings its buttons back.
Startup screens get no buttons. Residuals stated in CLAUDE.md: capture and
send-keys are two tmux calls; identical consecutive prompts get Open pane only;
pre-#147 panes still read a numbered draft as a widget.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8c0a4fc41
ℹ️ 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".
| const text = lines.slice(from, to + 1) | ||
| .map(l => _unframe(l).replace(/^[❯➤►▶›»>](?=\s*\d{1,2}[.)]\s)/, '')) | ||
| .map(l => l.trim()).filter(Boolean); | ||
| const options = run.map(h => ({ n: h.n, label: h.label.slice(0, 200) })); | ||
| return { options, key: JSON.stringify(text) }; |
There was a problem hiding this comment.
Keep an edited free-text answer from becoming a new prompt
After choosing “Type something.” and entering a custom answer in the live pane, the typed text replaces that option’s label, changing this key even though the same question is still open. The poll loop consequently re-announces it with buttons, and the store accepts the new key because only the original key was consumed. Another window can then send an answer digit into the focused text field, modifying the user’s answer instead of selecting an option. Preserve the consumed state across free-text editing, or suppress answer buttons while that field is focused.
Useful? React with 👍 / 👎.
Answer buttons on the "Claude is waiting for your answer" banner for the subscription engine. This is proposal 8 in #131: on a phone, most prompts no longer need the terminal.
What changes
input_neededfrom the poll loop now carriesoptionsandpromptKeywhenpromptOptions()finds one numbered widget: the last run 1..k in the tail, exactly one caret, 2 to 9 options. The banner renders one button per option.{type:'engine_prompt_answer', promptKey, choice}. The server refuses the answer unless that key belongs to the open prompt of a live turn.answerPrompt()then:=ccs-<id>:, because a bare-tprefix-matches);input_resolvedarrives without options, both on the wire and in replay.engine_prompt_consumedclears every watcher's banner and tab state.finallyreports the end of the turn separately (onPromptState(null, {turnEnded:true})), and only that edge forgets the answered keys.advanced:falsemeans the widget did not move. "Type something." opens a text field, and a checkbox only toggles. In that case the banner sends the user to the live pane.Measured, not assumed (CLI 2.1.311)
New fixtures
test/fixtures/claude-tui/askuserquestion-{multi,multi-q2,submit,single}.txtwere captured from a live pane:Verification
test/prompt-answer.test.js(69 checks) covers:answerPromptagainst real tmux panes that record every byte. Stale, foreign, malformed and prefix-matched answers send nothing.test/render/prompt-buttons.test.mjs(13 tests) checks what reaches the wire, that replies are matched to their banner by key, and that a consumed prompt clears both the screen and the tab state.TEST_PORT=4391 npm testexits 0.claude(haiku) answered a two-question AskUserQuestion entirely through these frames: Q1 → Q2 → Submit →done. A second tap with Q1's key was refused asstale.Not closed (also stated in CLAUDE.md)
CCS_NAME. They still read a numbered draft in the input box as a widget.Refs #131