From f8c0a4fc4190f20801b8b84c50083dbb6f8239f3 Mon Sep 17 00:00:00 2001 From: Lexus2016 Date: Mon, 16 Nov 2026 17:55:53 +0100 Subject: [PATCH] engine: answer a TUI prompt from the banner's buttons (#131) 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. --- CLAUDE.md | 40 ++- claude-interactive.js | 160 ++++++++++- engine-prompts.js | 52 +++- package.json | 2 +- public/index.html | 87 +++++- server.js | 42 ++- test/engine-prompts.test.js | 2 +- .../claude-tui/askuserquestion-multi-q2.txt | 50 ++++ .../claude-tui/askuserquestion-multi.txt | 50 ++++ .../claude-tui/askuserquestion-single.txt | 50 ++++ .../claude-tui/askuserquestion-submit.txt | 50 ++++ test/prompt-answer.test.js | 264 ++++++++++++++++++ test/render/prompt-buttons.test.mjs | 136 +++++++++ 13 files changed, 959 insertions(+), 26 deletions(-) create mode 100644 test/fixtures/claude-tui/askuserquestion-multi-q2.txt create mode 100644 test/fixtures/claude-tui/askuserquestion-multi.txt create mode 100644 test/fixtures/claude-tui/askuserquestion-single.txt create mode 100644 test/fixtures/claude-tui/askuserquestion-submit.txt create mode 100644 test/prompt-answer.test.js create mode 100644 test/render/prompt-buttons.test.mjs diff --git a/CLAUDE.md b/CLAUDE.md index 2371195..a16d22e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -32,7 +32,7 @@ npm run release # bump, commit, tag, push → GitHub npm run release:mac # on the Mac with the cert: build, notarize, verify, upload, bump the cask ``` -No linting and no build step configured. `npm test` chains 117 test files under `test/`: 20 DOM-less render/UI-logic tests (`test/render/*.test.mjs`, run through `node --test`) plus 97 plain-`node` suites in `test/` covering the focused workspace and its Back/Forward history (`focused-workspace.test.js`, `secondary-navigation.test.js` — see "Focused workspace navigation" below), the form workflows of every section (`settings-ux`, `team-forms-ux`, `section-controls-ux`, `page-forms-ux` — see docs/SECTION-CONTROLS-REVIEW.md), the sidebar rows and chat delete (`sidebar-ux.test.js` runs the real `delSess`/`delSelectedHist` in a `vm`: a 409 `UNMERGED_WORK` is asked about and resent with force, never swallowed — both doors used to close the tab and reload, so the chat came straight back; and it pins that hover-only row actions take no width on a mouse), the overload detector, env load order, multi-agent results, terminals, bots, telegram, updates, kanban scheduling, the Kanban card's run-settings badges (`kanban-run-badges.test.js` pins the card's model/effort/engine chain against the one `startTask` actually resolves — the two live in different files and the card silently lies when they drift), the board-only `create_task` status (`task-backlog.test.js`), session expiry (`session-expiry.test.js` boots a real server TWICE against one `APP_DIR`, ages sessions in SQLite between the boots, and pins that expiry removes the worktree, branch and queued messages of a clean session while keeping one with uncommitted work, its Kanban cards, and an orphan tree younger than an hour), the external agents' model/effort catalogs (`agent-catalog.test.js` — #123: the Settings form and `POST /api/external-agents` both carry them, and the browser's comma parser is RUN against the server sanitiser so the two cannot drift), the Kanban group form (`kanban-group-button.test.js` RUNS the real `buildChainForm` in a `vm` context so a stray free variable in its template throws there instead of silently killing the modal — see #115 — and parses every inline `