From d3c99a7dec87c2ee2b1d039d632596b4b5b10358 Mon Sep 17 00:00:00 2001 From: Lexus2016 Date: Wed, 7 Oct 2026 18:22:49 +0200 Subject: [PATCH 1/2] fix(engine): apply the configured engine at boot, wait for it before the first send, sync the mobile chips Three ways the UI and the chat disagree about the engine. #103 and #105 proposed two of them and were withdrawn because they did not cure the reported 402; verifying them in a browser found the cause they both missed. - checkVersion() called loadTerminalCapability() before it stored the default engine, and that helper lives in the last script block. A reply landing before the parser reached it threw a ReferenceError into checkVersion's own catch{}, skipping the configured engine, the chat defaults and loadBots(). Measured on a clean main with defaultEngine=subscription and a late xterm.js: curEngine stayed "api". The call is now optional; its other callers load the capability lazily. - send() read curEngine on its 'api' placeholder before /api/version had landed. It now awaits engineDefaultReady(), bounded by VERSION_WAIT_MS so a dead /api/version cannot freeze the composer. First chat frame: engine "api" after 8 ms -> "subscription" after 2722 ms. - syncMobSheetFromDesktop() had no engine branch, so cur stayed '' and the toggle removed the shipped `on` from both engine chips. test/render/engine-default.test.mjs: 10 tests, each watched failing for the right reason first. CLAUDE.md test counts corrected (101 = 20 + 81; the 89/19/70 were already stale). Co-Authored-By: Claude Sonnet 5.5 --- CLAUDE.md | 4 +- public/index.html | 27 ++++- test/render/engine-default.test.mjs | 164 ++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+), 4 deletions(-) create mode 100644 test/render/engine-default.test.mjs diff --git a/CLAUDE.md b/CLAUDE.md index ac22cd18..3239c901 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -31,7 +31,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 89 test files under `test/`: 19 DOM-less render/UI-logic tests (`test/render/*.test.mjs`, run through `node --test`) plus 70 plain-`node` suites in `test/` covering 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 `