_yuchanns_ on X, on the interactive mode falling back to -p: for people
who stayed off magpie's Claude subscriptions because of -p, a fallback
is a time bomb. Settings › Models › Replies › Claude Code's interactive
mode now has three choices: Off (always -p), On (the default, falling
back to -p as before) and Interactive only.
With Interactive only (settings.ClaudeTUIOnly; ClaudePrintMode set too
wins):
- a run claudeTUI would make -p is not started; the request fails with
the reason and the setting (claudeOnlyErr, claudeNotTUIWhy);
- the helper is handed MAGPIE_CLAUDE_TUI_ONLY=1 (claudetui.OnlyEnv,
claudeCLI.tuiEnv). Where it would exec -p (no start, sign-in, first-run
notes, untrusted folder, 45s timeout) it exits with the reason
(fallBack in Run), and it ignores the broken mark;
- a helper that never answers initialize ends the turn with an error,
not a -p retry, and `broken` isn't counted (claudeMachineWhy), so the
next run tries the interactive mode again;
- the model test's and warm-up's "hi" (askClaude) runs through the
helper (askClaudeTUI) in stream-json, its stdin closed at the first
result. The helper command and env are built in one place now
(tuiCommand, tuiEnv) for both.
Reading the plan's allowance (/usage) asks no model and stays -p; the
setting's text says so. Docs: claude-subscription-bridge.md.
Provider editor, on e8347401f's "Claude Code runs as" pill
(ClaudeMode.Only): with the interactive mode in use and no last
request, it says a request it can't take fails, and the card's foot says
nothing runs as -p. Where the interactive mode can't run, the pill names
Interactive only, never claude -p, the line says "Claude requests fail:
<why>", and Change in Settings goes to the row. A request refused this
way never ran, so it isn't noted as the last request (noteClaudeRun
comes after the refusal).
app.js: the Replies rows share one helper (segRow, which waitRow uses
too), so app.js is 530 bytes under main's with the third choice; no
budget raise.
Tests: TestClaudeTUIOnlyRefusesPrint, TestClaudeTUIOnlyHungHelperNoPrint,
TestClaudeTUIOnlyTellsHelper, TestAskClaudeTUIOnly (gateway);
TestShimOnlyNeverPrints (claudetui: fake fail/trust/login/notes each
exit with an error and no -p, a marked-broken run still interactive);
claude-tui-setting.test.cjs (three choices, Only saves claudeTUIOnly with
claudePrintMode false) and claude-mode.test.cjs (Only in use, and Only where it can't run).
Broken by hand, each red, then put back: the startRun gate off
(RefusesPrint 200); start()'s Only check off (HungHelper 502 without the
Only reason); tuiEnv's OnlyEnv off (TellsHelper); askClaude's branch off
(AskClaudeTUIOnly); the helper's fallBack ignoring only (4 subtests);
BrokenSince's `&& !only` gone ("marked broken"); the save without
claudeTUIOnly (16 of 16 setting tests) and claudemode.js's m.only
branches gone, rebuilt on e8347401f's file (10 of 10 Only tests,
Chromium).
Run on mote at e8347401f + this commit:
- at f1d6f4137 (main, after #4571's claude_cache.go) + this commit: go
vet of gateway and gui ok, CoreScriptBudget|I18n ok, the gateway's
TUI|Warm|Claude|AskClaude|Cache tests ok; the rest below at e8347401f
- gofmt -l clean; go vet and GOOS=windows go vet of claudetui, gateway,
settings and gui ok; Linux vet (wsl-run, -tags nogui) ok
- go test ./internal/claudetui ./internal/settings ok; the gateway's
TUI|Warm|Claude|AskClaude tests ok
- internal/gui CoreScriptBudget|I18n|Settings: ok but
TestSettingsSaveKeepsWhatItDoesNotSend, SearchAll, red on main since
b09349d17 (#4514)
- GUI (Chromium + WebKit, every language): claude-mode, claude-tui-setting
and i18n-keys 94 of 94 at e8347401f; with the other Replies rows'
files (claude-lean-prompt, member-model, loop-guard, refusal-retries,
classify-timeout, image-timeout) 180 of 180 at 2e9df9b1b. Earlier
segs-press-redraw's searchAllRow red is #4566, not this change.
Not tried: a real account under Interactive only (the fallback paths
are forced by the fake Claude Code); the full GUI suite (mote had
another session's full GUI suite and an agent+gateway suite going).
32 lines
1.3 KiB
Go
32 lines
1.3 KiB
Go
package claudetui
|
|
|
|
// Command is the hidden subcommand that runs it.
|
|
const Command = "claude-tui-helper"
|
|
|
|
// TrustEnv, "1", has the shim tell Claude Code yes when it asks whether
|
|
// to trust the folder it runs in: the bridge sets it for magpie's own
|
|
// folder, and for a caller's in an account folder of magpie's, whose
|
|
// Claude Code no one else runs. Otherwise the question is the user's to
|
|
// answer in their own Claude Code, and the run is -p.
|
|
const TrustEnv = "MAGPIE_CLAUDE_TUI_TRUST"
|
|
|
|
// OnlyEnv, "1", has the shim never become -p: a run whose interactive
|
|
// mode doesn't come up ends with why (the user's "Interactive only",
|
|
// settings.ClaudeTUIOnly), and one after a failure tries it again.
|
|
const OnlyEnv = "MAGPIE_CLAUDE_TUI_ONLY"
|
|
|
|
// WSLEnv holds, as JSON (WSL), how to run a Claude Code that is in a WSL
|
|
// distro: the helper, on Windows, runs wsl.exe in its pseudo console.
|
|
const WSLEnv = "MAGPIE_CLAUDE_TUI_WSL"
|
|
|
|
// WSL is a Claude Code in a WSL distro, as the helper runs it.
|
|
type WSL struct {
|
|
// Args are wsl.exe's arguments up to Claude Code's own, its path last
|
|
Args []string `json:"args"`
|
|
// Mount is where the distro mounts Windows' drives ("/mnt/"): an
|
|
// image's path is pasted as Claude Code there reads it
|
|
Mount string `json:"mount"`
|
|
// Projects is Claude Code's projects folder, as Windows reads it
|
|
Projects string `json:"projects"`
|
|
}
|