ac4af582301a4e8a29245dbba767eba31334ddf9
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8fa3c60f80 |
claude: an interactive run takes many images between words (#5654)
Chapin2018's message of nineteen images between words (the issue's
script, Claude Code 2.1.319, claude-fable-5-1) ended the interactive
helper "after 13s (exit status 1)" and the client got a 502, while -p
answered. The cause is how the helper saw a paste taken. It looked for
"[Image #N]" and "[Pasted text #N" only in what Claude Code drew after
the paste. Once the prompt runs past a row, Claude Code draws it again
only where it changed and moves the cursor past cells that are already
right. After the 33rd piece the drawing held "\r\x1b[16C\x1b[1B3": one
digit of "[Image #33]". The helper waited out pasteWait (10s) and ended.
Text marks came out in part too ("[Pasted t xt #16"), so several word
pieces each sat out their own 10s before that. There is no limit in
Claude Code's TUI: the same paste is on its screen whole, so no -p
fallback is needed.
Each check now also reads the prompt as the 200x50 screen grid shows
it: the rows between its last two rules, words one space apart (a mark
can wrap onto the next row). The mark that ends it counts (lastMark),
an image's [Image #N] or a whole [Pasted text #N +k lines], numbered
past the piece before, and so do words the prompt ends with. The
stream check stays first.
Run:
- Real, macOS arm64, this Mac, sandbox HOME and CLAUDE_CONFIG_DIR
(token by env, nothing rotated, DISABLE_AUTOUPDATER=1), the issue's
script unchanged, --images 19, Claude Code 2.1.319:
- origin/main
|
||
|
|
dd61299231 |
claudetui: /usage's saved figures, drawn while Claude Code refreshes them, are not told as today's
jsc9495 (Discord #help, 0.1.2950+, Claude Max): on one account at one
moment magpie's card said 5h 92% / 7d 99% left, another app 53% / 94%.
Claude Code 2.1.316's /usage panel draws the figures it saved on its last
read (cachedUsageUtilization in .claude.json, used up to an hour old,
keyed by accountUuid) at once, with "Refreshing…" under them, while it
asks Anthropic for today's. When that fails it keeps them and says
"Showing last-known usage as of 20m ago (rate limited until …)" or
"… (could not refresh)". The helper took any figures that stood still
for a second as the answer, so with a refresh slower than 1s, or a
rate-limited or failed one, each read told the figures of the read
before it (up to an hour old) stamped with the time now.
Now "Refreshing…" is waited past (up to commandWait). A panel that is
still refreshing at that point, or that shows last-known usage, is told as
"/usage couldn't load the plan's usage: …". claudeUsageUnknown already
matches that, so the card keeps its own last reading and that reading's
time. Figures Claude Code seeds from this session's own reply headers
("Partial usage data", "Per-model breakdown unavailable", "Could not
refresh usage data") are current and are still reported.
Fixtures are real bytes. Claude Code 2.1.316 ran on mote in a sandbox
CLAUDE_CONFIG_DIR with a made-up sign-in and saved figures 20 minutes
old (8% / 1%), and /usage was typed through a pty. It drew "Refreshing…"
and then "Showing last-known usage as of 20m ago (rate limited until
12:11am)". No real account was used, and no Keychain or live config was
touched.
Run (mote-run, at this tree on
|
||
|
|
3a74cd92e8 |
claude: /usage waits for its figures, and a read without them is unknown
Seagull fries (haioushutiao, Discord #help; magpie 0.1.2704, Claude Code
2.1.316, Windows 11, Claude Pro): the Claude card said 暂时无法获取额度,
"Claude Code's /usage told no allowance: ❯ /usage ─── Settin s Status
Config Usage …". Reproduced with a real Claude Code 2.1.316 under
Windows' pseudo console in a sandbox: /usage's panel is drawn first with
"Loading usage data…" while Claude Code asks Anthropic for the figures
(5s timeout, retried only on a 401), and the helper took 3s of a still
screen as the panel drawn whole. On a slow answer it told the panel's
frame as the result, and parseClaudeUsage called any text with no window
"told no allowance". A failed load ("Error: Failed to load usage data",
"r to retry") went the same way.
claudetui:
- screen.go: a small terminal grid (CUP/CUU..CHA/VPA, EL, ED, ECH, CR/LF
with scrolling, OSC/DCS skipped, an escape or UTF-8 character cut
between reads kept), 200x50 on Windows as the pseudo console is made,
80x24 elsewhere. The pseudo console sends only the cells that changed,
skipping a cell that holds the same letter ("Settin\x1b[1Cs"), so the
stream read split words and kept a redrawn digit beside the old one.
While /usage is read, each look of the screen with a window is kept
(panel), and usageText reads that before the stream.
- command(), built on b4073c06a's wait for the panel (ikunbots; its
usageDrawn and "hadn't drawn" error kept, now also judged on the grid,
since the pseudo console's split "Settin s" never matched its tabs):
"Loading usage data" on screen is waited out (to
commandWait, s.doing "was still loading /usage's figures" for the
deadline message); "Failed to load usage data" gets one "r"; a panel
still with no figure and loading or failed on screen is an
error_during_execution result, "/usage couldn't load the plan's usage:
<screen>".
- the fake draws the panel a frame at a time (fakeFrames), as Claude Code
does: with one write, the pseudo console passed on only the last
frame, which no longer shows the windows. TestShimReadsUsage now passes
on Windows (#4820, the fake's side; a real panel with figures was not
seen on Windows, see below).
provider:
- parseClaudeUsage: a panel with no figure is "Claude Code's /usage
showed no usage figures: …", not "told no allowance" (kept for
claudeUsageDenied's refusals).
- claudeUsageUnknown: Claude Code's "temporarily unavailable" and the
helper's "couldn't load the plan's usage" keep the account's reported
reading (quota_last), as the first did alone before. Other no-figure
text is still shown as an error (TestClaudeHeaderSurvivesUnclassified-
UsageFailure, TestClaudeUsageReadingAloneDoesNotHideUnclassifiedFailure
hold that).
Fixtures are the reporter's case as the pseudo console passed it on for
the real 2.1.316 (a temporary dump of the helper's screen bytes, sandbox config,
proxy that never answers / refuses): testdata/usage-loading-win-2.1.316.bin
and usage-failed-win-2.1.316.bin.
Run at the pushed head:
- mote: go test ./internal/claudetui ./internal/provider ok; go test
-run 'Claude|Usage|TUI' ./internal/gateway ok; GOOS=darwin/linux/
windows go vet ./internal/claudetui ./internal/provider ok; gofmt -l
clean.
- xiaomi-gpu (win-run): go test ./internal/claudetui: all pass except
TestShimFirstMessageWaitsForTools, red on Windows at main (#4810).
- xiaomi-gpu, real Claude Code 2.1.316 (npm), sandbox CLAUDE_CONFIG_DIR
with a fake token, magpie.exe built from this tree, helper run as the
gateway runs it: a proxy that never answers gives is_error "/usage
couldn't load the plan's usage: … Settings Status … Loading usage data…"
after the 20s wait (was a success with the chrome); a refused proxy
shows "Failed to load usage data", "r" is pressed, and the same error
comes back in 6.6s. "Settings" is whole now.
Broken by hand (before the rebase onto b4073c06a; the merged loop is
re-checked below):
- old tui.go: TestShimWaitsForUsageFigures slow, retried and failed again
all red, each telling the reporter's chrome as success.
- the "r" not written: TestShimWaitsForUsageFigures/retried red.
- old parse message: TestClaudeUsageWithoutFiguresIsUnknown red ("told
no allowance"); old quota_last check: its couldn't-load cases red.
- after the rebase, on the merged loop: the "r" not written,
TestShimWaitsForUsageFigures/retried red; the old "anything still 3s"
in place of usageDrawn on the grid, TestShimWaitsPastTheBanner red.
Not tried: a real account (the box has none of the owner's), so a real
2.1.316 panel with figures was never seen through the pseudo console;
whether Claude Code's frames that show the windows reach the pseudo
console's output before it renders the next one is shown only by the
fake. Not taken: asking Anthropic's /api/oauth/usage, which the owner
ruled out (
|
||
|
|
ccd746e039 |
claude: /usage is read in the interactive mode, typed in it, not through -p
With the interactive mode on, the plan's allowance (the Claude account's
usage card) was still read by `claude -p /usage`, the one -p run left
beside a request. Claude Code 2.1.316's -p /usage also tells only the
session's cost, no window. Now claudeUsage, with claudeTUIOn, runs the
interactive mode's helper (claudeUsageTUI) and gives it a line
{"type":"command","command":"/usage"}. The helper types /usage, waits for
the panel to settle (a "N% used" and a second without change, or three
seconds of anything else, 20s at most), closes it with Esc, and tells
what was drawn as -p's lines say it (usageText: "Current session: 0% used
· resets 5am (Asia/Shanghai)"), so parseClaudeUsage reads it unchanged.
No model is asked. The helper types no other command. The machine
reasons a request is refused for (no shim, OS, missing, off) refuse the
read the same way. Turned off, -p runs it as before.
Run (mote, at this tree on origin/main
|