Repository navigation
engine: a numbered draft in a named chat is not a permission prompt - #147
Conversation
The widget detectors recognised the input box only by an unlabeled top rule
(RULE_RE). The TUI draws a session name into that rule ("──── <name> ─",
captured on CLI 2.1.311), so in a named chat a numbered draft such as
"❯ 1. fix tests" / "2. run lint" read as a #20 widget: a false input_needed,
the quiet-exit budget widened by CLAUDE_PROMPT_GRACE_MS, and pending
clarifications never typed in (the injection gate checks !paneAwaitingInput).
Measured on 2.1.311: `--resume` without --name draws whatever title an
earlier `-p --name` run stored, and `--name X` replaces it with X. The
subscription engine never passed --name, so the label was not a value it
knew.
- The engine now launches with the chat's --name (cleanSessionName, shared
with claude-cli.js), records it as CCS_NAME in the tmux env (kept out of
cfgHash, so a rename does not respawn), and every widget-detector call
passes it back as { boxLabel }: the startup wait, the poll, the injection
gate and the idle reaper. The task runner passes the same name its api
branch already does.
- A labeled rule is a box top ONLY when its label equals that launch name.
RULE_RE stays unlabeled, so a dialog under a labeled header is still a
widget; no recorded name means exactly the previous behaviour.
- The numbered detector skips only the box's own lines, so a draft can no
longer hide a real widget above the box (also for an unlabeled box, where
that used to be a missed prompt). The unnumbered detector still stops at
a box caret: that is its only defence against history.
test/pane-busy.test.js pins the cases on a real capture
(test/fixtures/claude-tui/named-draft.txt) and on built panes, plus every
detector call site and every server.js engine door; each guard reverted on
its own turns cases red.
Address an independent review (codex) of the previous commit: - paneAwaitingInput counted its 24-line tail BEFORE skipping the input box, so a labeled box holding a 26-line numbered draft pushed a real widget above it out of the window and the prompt was missed. Box lines are now skipped before they count against the tail. - The comment and CLAUDE.md claimed no dialog header can match the launch name by accident. It can, if a chat is titled exactly like a labeled dialog header sitting directly above its caret; none is known on CLI 2.1.311. Stated as a residual instead.
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: 5da8e9df92
ℹ️ 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".
| for (let i = lines.length - 1, seen = 0; i >= 0 && seen < AWAIT_TAIL_LINES; i--) { | ||
| if (_inInputBox(lines, i, label)) continue; | ||
| seen++; | ||
| const m = CARET_RE.exec(lines[i].trim()); | ||
| if (!m) continue; |
There was a problem hiding this comment.
Distinguish historical numbered prompts from active widgets
When a previous user message starts with a numbered list (for example, ❯ 1. inspect the repo followed by 2. summarize it), skipping the current input box lets that historical caret satisfy the widget detector. A finished conversation with that history and a numbered draft in an unlabeled input box returns false before this change but true afterward. The startup check consequently waits for a nonexistent dialog and refuses to send the next message; the polling injection gate also blocks clarifications. Preserve the distinction between historical user prompts and active option lists when scanning above the draft, and add a regression case containing both a previous numbered request and a current numbered draft.
Useful? React with 👍 / 👎.
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.
Problem
_inInputBox()recognised the subscription engine's input box only by an unlabeled top rule (RULE_RE). The TUI draws a session name into that rule (──── <name> ─). In a named chat, a numbered draft typed into the box (❯ 1. fix tests/2. run lint) therefore read as a #20 permission widget. That caused three problems:input_neededbanner;CLAUDE_PROMPT_GRACE_MS(5 min);!paneAwaitingInput.What I measured first (CLI 2.1.311, own tmux sessions on the default socket, Enter never sent)
claude --name ccs-c-probedraws──…── ccs-c-probe ─. With1. fix tests/2. run lintpasted and not submitted,origin/main'spaneAwaitingInputreturnstrueon that capture. The capture is committed astest/fixtures/claude-tui/named-draft.txt, with statusline values scrubbed; rules, caret, indentation and label are byte-exact.--name(buildInteractiveCommand). The labels in studio panes come from--resume: without--name, it draws the title an earlier-p --namerun stored (shown:beta due later today). With--resume … --name ccs-c-probe, it drawsccs-c-probe. So before this PR the label was not a value the engine knew.Change
--name.cleanSessionName()is now exported fromclaude-cli.jsand used by both local engines. The engine records the name asCCS_NAMEin the tmux session env. It stays out ofcfgHash, so renaming a chat does not respawn the pane, and the pane keeps the label it was spawned with.CCS_NAMEback as{ boxLabel }: the startup wait, the poll'sawaiting, the injection gate and the idle reaper.RULE_REis not widened, so a dialog under a labeled header is still a widget. With no recorded name (a pane from an older build, or an untitled chat), behaviour is exactly as before.paneAwaitingInputskips only the box's own lines, and does so before counting its 24-line tail. A draft of any length can no longer hide a real widget above the box. This also turns a former missed prompt into a detection for an unlabeled box: a widget above a box that holds a numbered draft.paneAwaitingSelectionstill stops at a box caret, now label-aware. That is its only defence against history: tool output indented under a past❯ promptreads as a sibling option.name: taskBot?.label || task.titleto the engine, the same expression its api branch already passes. The chat and Telegram doors spread theparamsthey share withrunCliSingle. Telegram has no name in either engine, so it is unchanged.Tests
test/pane-busy.test.jsgains 23 cases:--namein the spawn command;server.jsengine door.test/interrupt-delivery.test.js: the gate pin now requires!paneAwaitingInput(pane, promptOpts).Each guard was reverted on its own (sources backed up and restored, verified with
cmp), and each mutation turns named cases red: label ignored, box not excluded, box excluded after the window, any label accepted,RULE_REwidened, gate without label, no--name, task runner without name, reaper without label, selection without label,CCS_NAMEnot recorded.Targeted runs:
pane-busy52/0,claude-firstrun49/0,engine-pane31/0,interrupt-delivery21/0,engine-idle-reaper31/0,engine-spawn-cmd21/0. I did not run the fullnpm test.Residuals
CCS_NAME. They behave as before until they respawn./renametyped in the live pane, or a label the TUI truncates, falls back to the old behaviour. That is the safe direction.