The owner: the Claude Code provider page should say whether its runs go through the TUI or the CLI, and what tells them apart and what each gains. Under a Claude subscription's accounts a row now says "Running as Claude Code's interactive mode (TUI)" (a green dot) or "Running as claude -p (CLI)" with why: turned off in Settings, failed to start lately, Claude Code in WSL whose home wasn't found, not installed, or a system with no interactive mode. Under the TUI it says which requests still run as -p (safeguards, a JSON schema, an image by URL, a first message over 400KB). "TUI or -p?" opens what each is: entrypoint cli, the plan counting a request at about half; entrypoint sdk-cli, about twice. "Change in Settings" opens Settings › Models at the interactive mode's row. Only switch, which serves nothing, shows no row. The mode comes from GET /api/claude/mode (gateway.ClaudeModeNow), read as the editor opens and kept 30s, never in /api/providers' polls. Its machine-wide reasons are claudeMachineWhy, which claudePrintWhy now calls first, so the row and the gateway's own choice can't disagree. The row is drawn by claudemode.js, which app.js loads with that first read, so it weighs nothing on the core: after a rebase on origin/main29d0ab39fthe core was 1,541,482 bytes, over its 1,539,856, and the budget isn't raised. "Runs as" became "Running as" so its keys don't clash with a plugin's "Runs as" in i18n-keys. A per-account WSL folder the probe can't read is still found only at run time; the doc says so. Run: - go vet ./internal/gateway ./internal/gui (darwin), GOOS=windows, and GOOS=linux -tags nogui: 0. - go test -run 'ClaudeTUI|ClaudeMachine|ClaudeSub' ./internal/gateway: ok (TestClaudeMachineWhy is new). - After the rebase on29d0ab39f, on mote: go test -run 'CoreScriptBudget|I18n|Claude' ./internal/gui ok, the budget not raised; old-webkit.test.cjs lists claudemode.js with the other scripts app.js imports. Before the rebase, go test ./internal/gui: three reds that fail the same on origin/mainccc791231: TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners (#3949), and i18n-keys' "Unmarked" (#4524). - claude-mode.test.cjs in WSL (Chromium and WebKit, 1100 and 420, en, zh, ja, de): 48 of 48. - The full GUI suite on mote (load ~30) had 301 reds in 49 files; each of those files was run again in WSL at this head (743 tests, 259 red) and at origin/mainccc791231(259 red, the same tests; #4600). The one that held apart was account-weight at de web 390: the row puts the accounts a screen above By weight on a phone, and Playwright's click scrolled the chip back into view. The test now brings the chip into view before it measures, so it judges the click's own scrolling; account-weight and claude-mode, both engines: 50 of 50. - After moving the row into claudemode.js: the 142 GUI files with a Claude Code agent, in WSL (Chromium and WebKit): 1392 tests, 8 WebKit reds in 7 files. Each of those files was run again alone at this head and at29d0ab39f: the same kind of WebKit reds on both, which subtests changing from run to run (library-items, number-units, routing-rule-models, usage-heatmap, usage-ledger-chart). phone-rows' Routing click on .rt-day failed 1 of 4 runs at each (WebKit zh, ja, de); the Routing page draws no such row. Filed under #4600, #4471, #4112. - Real use on xiaomi-gpu (Windows 11, sandbox HOME, Claude Code in WSL magpie-desktop): /api/claude/mode said {"tui":true,"wsl":true}; with the setting turned off through POST /api/settings, {"tui":false,"why":"off","wsl":true}; set back, TUI again. - Rebased on origin/main02ff0e908(no file in common): on mote, vet for darwin, windows and linux nogui 0; go test ./internal/claudetui ok; -run 'CoreScriptBudget|I18n|Claude|Budget' ./internal/gui ok; -run Claude ./internal/gateway ok. In WSL claude-mode, account-weight, old-webkit and i18n-keys: 59 of 60, the one red i18n-keys' "Unmarked" (#4524). Broken by hand: the editor draws twice before the read returns, and the test's one-read check went red with two reads until the read in flight was shared (claudeModeRead). account-weight's check went red ("en 1000: a click scrolled") with the chip's click made to scroll the editor 120px. Not tried: the window on macOS with a real account (the row is the same code as the web GUI's), and the "broken" reason with a real failed start.
29 lines
2.1 KiB
JavaScript
29 lines
2.1 KiB
JavaScript
// The Claude Code provider editor's row saying whether a Claude
|
|
// subscription's runs are Claude Code's interactive mode (TUI) or claude
|
|
// -p, why -p, and what tells them apart. app.js imports this with the
|
|
// row's first read of /api/claude/mode (claudeModeRow), so it weighs
|
|
// nothing on the core.
|
|
let open = false;
|
|
window.claudeModeDraw = function draw(box, m) {
|
|
if (!m) return;
|
|
box.hidden = false;
|
|
const why = {
|
|
off: "The interactive mode is turned off in Settings",
|
|
broken: "The interactive mode failed to start on this computer lately; magpie tries it again after a while",
|
|
"wsl-home": "magpie couldn't find the home folder of Claude Code in WSL",
|
|
missing: "Claude Code isn't installed on this computer",
|
|
}[m.why] || (m.why ? "This system has no interactive mode for it" : "A request with safeguards, a JSON schema, an image known by its URL or a first message over 400KB still runs as -p");
|
|
const head = el("div", "mode-head");
|
|
const more = el("button", "link", t("TUI or -p?"));
|
|
more.setAttribute("aria-expanded", String(open));
|
|
more.onclick = () => { open = !open; draw(box, m); };
|
|
const set = el("button", "link", t("Change in Settings"));
|
|
set.onclick = (e) => openSettingsAt(e, "models", $("#claudeTuiRow"));
|
|
head.append(el("span", "dot" + (m.tui ? " on" : "")),
|
|
el("span", "mode-name", t(m.tui ? "Running as Claude Code's interactive mode (TUI)" : "Running as claude -p (CLI)")), more, set);
|
|
box.replaceChildren(head, el("div", "note", t(why)), ...(open ? [
|
|
"TUI: magpie runs Claude Code as a person does, in its interactive screen, and gives it each request there. Anthropic sees Claude Code's own interactive use (entrypoint cli), and the plan counts a request at about half of what -p uses, so the same plan lasts about twice as long.",
|
|
"-p (CLI): claude -p, Claude Code's mode for scripts (entrypoint sdk-cli). It takes everything a request can carry, but the plan counts each request at about twice the interactive mode's. magpie uses it only when the interactive mode is off, can't run here, or a request needs what only -p takes.",
|
|
].map((s) => el("p", "note wraps", t(s))) : []));
|
|
};
|