ac4af582301a4e8a29245dbba767eba31334ddf9
10
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
325dc3ab32 |
claude-tui: a Claude Code that draws nothing is said with what it waits on, and its turn isn't waited out twice
sowhynot (v0.1.3222, macOS): every interactive run ended "Claude Code showed no prompt in 45s: nothing on its screen (0 bytes read)", and the bridge then started a new Claude Code told the whole conversation, which waited out another 45s before the turn was answered 502. Cause class: Claude Code blocks before its first draw on something it waits for and writes nothing to the pty. Reproduced on mote with real Claude Code 2.1.319 (npm latest) in a sandbox HOME: its read of the "Claude Code" Keychain item is a synchronous `security find-generic-password` with no time limit (its other Keychain reads have 2s/10s limits), so a Keychain waiting on an allow window or a locked keychain gives exactly "0 bytes read" at 45s. Its network waits (remote managed settings and policy limits, for a setup-token or team account with --mcp-config) are bounded at ~30s and draw after, so they don't give 0 bytes. - claudetui: with 0 bytes read, the reason adds what Claude Code runs (its descendants from ps, longest first) and how much it holds; a Keychain read is named with its item and what to do. Other commands are named by program (and an interpreter's script) only, never their arguments. macOS and Linux; Windows says what it said before. - gateway: a helper that ends saying why the interactive mode didn't come up is tuiNoStart, not tried again told the whole conversation, unless Claude Code ended itself before its prompt (claudetui.EndedEarly, the "No conversation found" case the retry is for). - No early end on 0 bytes: a Keychain window may still be answered. No -p fallback: removed on purpose in |
||
|
|
6b4a6dcd41 |
claudetui: the Bypass Permissions disclaimer is answered as the trust question is (#5042, luzhuang)
A claude magpie spawns runs --dangerously-skip-permissions: the flag is
on the bridge's own arguments, a user's claude may be a wrapper that
adds it, and an account's default mode may be Bypass Permissions. Where
no settings source the run reads has skipDangerousModePermissionPrompt,
Claude Code 2.1.295 blocks on its disclaimer — "❯ No, exit / Yes, I
accept, Enter to confirm" — and no one was there to answer it: each run
sat on the dialog for 45s (ReadyWait), ended, and the next run asked
again, so interactive requests failed in a loop (502 or a hung restart)
until magpie fell back to claude -p.
- the helper tells the disclaimer yes where TrustEnv says so, with the
same ↓-until-"Yes"-then-Enter the trust question gets (its "No, exit"
pairs the same, and a key sent as it is first drawn is lost the same
way); Claude Code records the acceptance itself, and the next run is
shown none of it.
- where TrustEnv isn't set — the account Claude Code is signed in to, in
a caller's folder — the disclaimer is the user's to answer: the run
ends at once saying so, not after 45s.
- a disclaimer left unanswered at a run's deadline is named as such
("asked to accept running in Bypass Permissions mode, not answered"),
never "showed no prompt".
Generated-by: GLM-5.3-Flash (ZCode)
Reviewed and ported, narrowed: as written, the shim accepted the
disclaimer wherever TrustEnv was set, and the bridge sets TrustEnv for
magpie's own folder in the account Claude Code is signed in to
(configDir ""), as do the warmup and /usage runs. Accepting there makes
Claude Code write skipDangerousModePermissionPrompt into the user's own
~/.claude/settings.json, a consent for every run after that is the
user's to give. Now a separate claudetui.BypassEnv says yes, set only by
claudeBypassEnv for a tui run in an account folder of magpie's
(configDir != ""), at the bridge and both warmup sites; TrustEnv alone
ends the run at once with the "asks to accept" message. The subject's
"as the trust question is" holds for the keys sent, not for where.
On mote, with tui.go at the parent: TestShimAcceptsBypassDisclaimer FAIL
("the shim wrote 0 lines of 3 in 30s"), TestShimNeverPrints' bypass
cases FAIL ("neither answered nor ended in 30s"),
TestShimEndsAtItsCallersDeadline/bypass_disclaimer_unanswered FAIL
("showed no prompt"); green with the patch. Broken by hand: the gate
back on TrustEnv turns TestShimNeverPrints/bypass_disclaimer_with_the_
folder_trusted red, and claudeBypassEnv ignoring configDir turns
TestClaudeBypassOnlyInMagpiesAccountFolder red ("user's own account: got
[MAGPIE_CLAUDE_TUI_BYPASS=1]"). go test -timeout 45m ./internal/gateway
and ./internal/claudetui ok; GOOS=linux/windows/darwin go vet ok. Not
tried: a real Claude Code 2.1.295 showing the disclaimer under a saved
account (needs a wrapper adding the flag).
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
d39358f1bb |
claude: /usage and "hi" reads run in magpie's work folder and say why they ended (#4830)
mydosu's Claude Code quota reads on Windows failed for both accounts
with "exit status 1" alone. Two things were behind it:
- Each one-off interactive run (claudeUsageTUI, askClaudeTUI) started in
a new magpie-claude-<n> temp folder, which the helper trusted, so each
read wrote one more trusted projects entry into the config's state file.
The reporter had 67 in ~/.claude.json.
- The caller's budget (subscriptionTimeout, 20s) is shorter than the
helper's own waits (45s for the prompt, 20s for a panel). The context's
kill came first, and that is TerminateProcess on Windows, so Wait said
"exit status 1" with an empty stderr. On Unix the same kill says
"signal: killed".
What changed:
- One-off TUI runs work in claudeWorkDir (oneOffDir). That is the
owner-checked folder the bridge's own runs already use, so each config
directory holds one trusted entry instead of one per read. A temp
folder is made only when that folder can't be.
- The run's session file there is removed by the session_id the helper's
init line names (dropOneOff). It is not removed under WSL.
- The helper is told its caller's deadline (claudetui.DeadlineEnv, the
context's deadline less min(3s, a quarter of what is left)). At that
time it ends on its own, saying what Claude Code hadn't done and its
last screen, e.g. "Claude Code hadn't drawn /usage's panel in the
2.9s its caller waits for it: ...".
- A run that still says nothing reads "Claude Code's interactive mode
said nothing before magpie stopped waiting for it (...)" (oneOffErr),
not an exit code.
- quotaError says these reasons on the card as "Allowance unavailable:
{why}" (an existing key in every language). The full text stays in
the tooltip. Nearby comments were cut so the core script budget holds
without a raise.
- No -p fallback was added. The -p asks keep their own temp folder,
since -p asks nothing about trust.
- The entries older magpies left in ~/.claude.json are left alone:
magpie never writes that file.
Run at this head (after the rebase on
|
||
|
|
14e3513780 |
claude: Claude Code in WSL runs interactively when Windows can't read its transcripts
With the interactive mode on, Claude Code in WSL was refused with a 502
in two cases: the distro user's own folder unreadable from Windows
(\\wsl$ needs the 9P redirector, which a session over ssh hasn't;
"wslread") and a distro whose home the probe didn't find ("wsl-home").
Both now run interactively: the helper reads the transcript inside the
distro.
- claudetui/wslread.go: before Claude Code starts, a shell run through
wsl.exe notes how much of $HOME/.claude/projects/*/<sid>.jsonl is
there (a resumed session's earlier turns), says "ready", then tail -F's
the rest; the helper copies it to a file of its own and tails that as
any transcript. When Claude Code ends it waits for the copy to stop
growing (settle), then closes the shell's stdin, which ends it.
- claudetui.WSL gets Distro (Projects omitempty); the gateway's tuiWSL
sets it when Windows can't read the folder or the home is unknown.
- the wslread and wsl-home refusals are gone (claudeTUI, claudeWhy,
claudeNotTUIWhy); the GUI's "wsl-home" reason and its 4 strings too.
- docs/subsystems/claude-subscription-bridge.md says how it is read.
Run, at origin/main
|
||
|
|
59fdab0af7 |
gateway: a caller's folder the user hasn't trusted runs in magpie's, not a 502 (lwjef on X)
lwjef (X, 2116867007799030000): a cwd Claude Code hasn't trusted hangs the interactive-mode bridge (paseo chat). Cause: in the user's own account the helper leaves the trust question to the user (no MAGPIE_CLAUDE_TUI_TRUST) and ends at once saying so. Up to 11-01 that run became -p; since |
||
|
|
bee3ea6753 |
claudetui: the first message waits for Claude Code to list magpie's tools (MinhuWang on X)
MinhuWang (X, 2116836405548916907): in the interactive mode the first
message can go before MCP has loaded, and then has none of pi's tools.
Cause: the helper's ready() took the drawn "❯ " prompt as ready. Claude
Code connects its MCP servers beside the prompt, so a message pasted at
once was answered with no mcp__magpie__ tools. Reproduced with the real
Claude Code 2.1.309 (sandbox HOME, a copy of the owner's account): an MCP
server held 8s before answering initialize got "NOTOOL" for "what is the
secret word, use your tool".
Fix: startRun gives claude-mcp-helper a third argument, a `listed` file in
the run's temp folder, which RunMCP writes after it has answered
tools/list. The helper finds that path in the run's --mcp-config
(mcpListed) and ready() waits for it as well as the prompt, inside the
same ReadyWait (45s); past it the run ends saying the tools weren't
listed. Runs without that server (warm-up, model test) don't wait.
Run (mote, at this tree):
- go test ./internal/claudetui ./internal/claudebridge: ok
- go test -run 'Claude|MCP|Bridge' ./internal/gateway: ok
- real Claude Code 2.1.309 here, a sandbox HOME with a copy of the
account's credentials, the new helper and the real claude-mcp-helper
behind an 8s sleep: initialize answered at 12.7s, the first turn called
mcp__magpie__pi_secret and answered "The secret word is PELICAN".
Without the sleep: answered at 2.1s, same answer. 2.1.309 sends
server/discover before initialize; the helper's method-not-found answer
is taken and initialize follows.
Broken by hand: toolsListed returning true made
TestShimFirstMessageWaitsForTools red ("echo: hello (without magpie's
tools)"); RunMCP not writing the file made TestToolsListedFileWritten
red.
Not tried: Claude Code in WSL (the path is the gateway's Windows temp
path, handed to magpie.exe as the callback path is); a Claude Code that
lists tools only on its first request (2.1.309 lists them at start),
which would now wait 45s and fail saying so instead of answering
without tools; the full gateway suite (run after the next commits).
|
||
|
|
e5f66f8a61 |
claude: with the interactive mode on, nothing ever runs as -p; the editor switches TUI and claude -p
The owner (11-01): the interactive mode falling back to -p is dangerous,
for the account (a -p request counts as another client's) and for the
cache (a -p run starts without the interactive mode's), so it goes
entirely. With Settings › Models › Replies' interactive mode on:
- a request it can't take (safeguards, client cache marks, a JSON
schema, an image by URL, words over 400KB, a branch of a -p session,
a WSL Claude Code whose home or transcripts magpie can't reach) is
refused before any Claude Code starts, saying why and naming the
setting (claudeTUIErr), never run as -p;
- a helper that can't start the interactive mode (sign-in asked,
first-run notes, an untrusted folder, no prompt within ReadyWait)
ends saying why (claudetui fail); printMode, OnlyEnv and the
claude-tui-broken mark that sent every run to -p for a day are gone;
- a helper that never answers initialize fails the turn
(tuiNoStart), and the next turn tries again.
Off still runs every request as -p. The "Interactive only" choice of
v0.1.2448 (claudeTUIOnly) is what On is now; the setting is no longer
read or sent.
The Claude Code provider editor's "Claude Code runs as" row is a
switch between Interactive mode (TUI) and claude -p (owner, 11-01),
saving claudePrintMode and reading /api/claude/mode again; disabled in
magpie web. It reads the settings first when the Settings page was
never opened (prefs null crashed the switch; found by the GUI test).
Chromium has no onfocusin property, so the card on keyboard focus
listens for focusin/focusout. Words in en, zh, zh-TW, ja and de.
Docs: claude-subscription-bridge.md describes refusal, not fallback.
Not covered yet, now refused under On rather than run as -p (follow-
ups, each to be done inside the interactive mode): an image by URL, a
JSON schema, safeguards, client cache marks, over 400KB, a -p
session's branch, WSL transcripts Windows can't read. /usage reads
the allowance with claude -p /usage (no model request) either way.
Run (worktree at
|
||
|
|
e6b595e1ab |
claude: Interactive only, a setting under which a model request never runs as claude -p (_yuchanns_ on X)
_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
|
||
|
|
fb9c176756 |
claudetui: Claude Code in WSL runs in its interactive mode too
A Claude Code found in a WSL distro (Windows has none of its own) was always claude -p, the entrypoint the plan counts at about twice the interactive mode's. Many Windows users run it there. The Windows helper now runs wsl.exe in its pseudo console. The gateway hands it MAGPIE_CLAUDE_TUI_WSL (claudetui.WSL, claudeCLI.tuiWSL): the wsl.exe arguments up to Claude Code's (wslrun.Tool.Args, with MAGPIE_WSL_RUN), the distro's mount, and the projects folder as Windows reads it. That is the account's config directory, handed in through CLAUDE_CONFIG_DIR/p, or the distro user's own ~/.claude/projects through \\wsl$\<distro> (wslrun.Tool.Home, a new line in the probe; wslrun.Tool.Windows). TERM is added to WSLENV, and an image's path is pasted as the distro reads it (/mnt/c/…). The helper is the Windows magpie.exe, not the /mnt/c/… path the MCP helper starts at; the first real run failed on exactly that (fork/exec /mnt/c/...magpie.exe). The gate keeps -p for a WSL Claude Code whose home is unknown, and, in the distro user's own folder, when Windows can't stat \\wsl$\<distro>\<home> (tuiWSLUnread): over ssh it can't (no 9P redirector), and the helper would wait for a transcript it can't see. Doc updated. Run: - go test ./internal/claudetui ./internal/wslrun on mote and on Windows 11 (xiaomi-gpu): ok. New: TestShimInWSL (image path, WSLENV), TestClaudeTUIWSL (projects folder both ways, wsl args), the home in the probe and Windows() in wslrun, the gate's two WSL cases, TestClaudeTUIWSLUnread. - go test -run 'Claude|Refusal|Thinking' ./internal/gateway on mote: ok. - go vet of claudetui, gateway, wslrun for darwin, linux, windows (-tags nogui, and the main package for windows); gofmt -l clean. - Real account on xiaomi-gpu: a sandbox HOME gateway (3462) with no Windows Claude Code reachable (PATH trimmed, MAGPIE_TEST_SANDBOX so the registry PATH isn't read), the Claude Max account, Claude Code 2.1.289 in magpie-desktop, haiku-5-5. Tree: helper -> wsl.exe -> claude on a pts in the distro, TERM=xterm-256color, CLAUDE_CONFIG_DIR=/mnt/c/..., no CLAUDE_CODE_ENTRYPOINT. One tool call, two in one message, text then a call, and two image turns: all right. Every transcript row "entrypoint":"cli", no "-p" line in the log, images noted as /mnt/c/.../magpie-claude-images-*/image-N.png and no folder left. Killing the gateway ended its four claude processes in the distro within 3s. The token wasn't refreshed; the copied credentials were deleted. Broken by hand: shim.path returning the Windows path unchanged, TestShimInWSL red; tuiWSLUnread ignoring the stat error, TestClaudeTUIWSLUnread red. Not tried: a WSL Claude Code run from the distro user's own ~/.claude for real (only the account config directory ran; over ssh \\wsl$\magpie-desktop is unreadable, so that run would be -p, and a desktop session's \\wsl$ wasn't tried), a distro whose default user is root, a distro not sharing Windows' loopback (wslrun.Tool.Host set), WSL1. |
||
|
|
43966a53fb |
claude: a subscription's run is Claude Code's interactive mode, -p only as the fallback
The owner (10-31): a Claude subscription ran `claude -p`, whose
requests Anthropic labels sdk-cli and counts at about twice the
interactive mode's cli (anthropics/claude-code#97074). Running the real
interactive Claude Code is what its terms describe and uses the plan as
a person does. Wanted inside magpie, on by default, with a way off.
`magpie claude-tui-helper <claude> <-p args>` (internal/claudetui)
stands where `claude -p` stood and speaks the same stream-json. It
turns the -p arguments into the interactive mode's (no -p, no
--dangerously-skip-permissions: --permission-mode default with only
mcp__magpie, and the WebSearch -p was given, allowed; --no-chrome;
--session-id or the --resume given), starts Claude Code in a
pseudo-terminal of its own (no tmux), pastes each message into its
prompt and presses Enter, and tells the session's transcript back as
-p's lines: whole assistant messages, an API error as the turn's error
result with its rate_limit_info, turn_duration as the result. Nothing
sets CLAUDE_CODE_ENTRYPOINT, and the user's ~/.claude and
~/.claude.json are never written. The folder-trust question is
answered only for magpie's own folder or a saved account's config
directory (MAGPIE_CLAUDE_TUI_TRUST).
A Claude Code that doesn't start or show its prompt in 45s becomes
`claude -p` on the same pid, its input still unread, so the turn is
answered all the same; that is remembered for 30 minutes
(<cache>/magpie/claude-tui-broken). An untrusted folder goes to -p
without the mark.
claudeTUI keeps -p for Windows and WSL, Settings › Models › Replies ›
Claude Code's interactive mode Off (claudePrintMode), safeguards,
client cache marks, a JSON schema, images and a first message over
400KB. A TUI run ends instead of taking an image turn, a rewind or an
effort change, and letGo doesn't take one back. The gateway's tests
run with claudeTUIRuns off: their binary has no claude-tui-helper.
docs/subsystems/claude-subscription-bridge.md has the section.
The core's scripts grow 725 bytes with the setting's row;
coreScriptBudget is raised to the exact size, 1,537,356, with no room
added.
Run (rebased on
|