From 765c16e599b588624f5a70e86957c6e4728b49d9 Mon Sep 17 00:00:00 2001 From: Lexus2016 Date: Mon, 16 Nov 2026 08:53:24 +0100 Subject: [PATCH] engine: a reloaded page is told about a prompt the turn is still waiting on (#130) The subscription engine announces a blocking TUI prompt once (input_needed) and withdraws it once (input_resolved). A page reloaded in between got a new socket that saw neither frame and a fresh tab state with nothing to redraw the banner from, so the chat showed a running turn and no question. This is the part #143 left open. - The engine reports both edges through an optional onPromptState callback, from wsSendAll, the one place both frames go through. - engine-prompts.js keeps the open prompt per session; all three runInteractiveSingle call sites (chat, Kanban task, Telegram) feed it. - subscribe_session replays it only without noCatchUp (a background tab that never reloaded still has it) and only while isSessionLive(), so a prompt left by a crash between the edges is dropped, not shown. test/engine-prompt-replay.test.js boots a real server whose fake claude draws the trust screen: a foreground subscribe gets the prompt, a noCatchUp one and one after the turn ended do not. It fails on the two positive checks without the replay. --- CLAUDE.md | 14 ++- claude-interactive.js | 10 ++- engine-prompts.js | 39 +++++++++ package.json | 2 +- server.js | 13 +++ test/claude-firstrun.test.js | 7 +- test/engine-prompt-replay.test.js | 139 ++++++++++++++++++++++++++++++ test/engine-prompts.test.js | 77 +++++++++++++++++ 8 files changed, 296 insertions(+), 5 deletions(-) create mode 100644 engine-prompts.js create mode 100644 test/engine-prompt-replay.test.js create mode 100644 test/engine-prompts.test.js diff --git a/CLAUDE.md b/CLAUDE.md index c26a11d..fbec108 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 115 test files under `test/`: 20 DOM-less render/UI-logic tests (`test/render/*.test.mjs`, run through `node --test`) plus 95 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 `