Commit Graph
50 Commits
Author SHA1 Message Date
yetone f418edffc3 sessions: a session's details show how full its context was, request by request
liang_yongxiang on Discord: Routing tells how full one request's context
window was; does Sessions have the same, each turn's share?

A session's details on the Sessions page (and in Usage's Sessions list,
which draws the same details) get a Context line when the gateway sent
calls of it (s.via): the Context tab's spark of its prompts, request by
request against its window, and the fullest one's share beside it, toned
as the tab tones it. A point's tip says "Request 2: 80K of 200K (40%)" (the
tab's spark says it too now, where the window is known); a point clicked
opens that request in Routing with its card. A session the gateway never
saw asks nothing; one it kept no prompt of shows no line.

The data is the routing history the Context tab already reads. A new
GET /api/context/session?agent=&id=&from=&to= reads only the days from the
session's first to its last (30 at most), through the tab's per-day cache
(daysRecsLocked, split out of contextRecsLocked, so the tab's cached days
are not evicted), and keeps that one session (contextOfRecsFor), with up
to 1000 of its requests. The tab keeps the latest 80 sessions and would
leave an older one out. Subagent and side calls are left out as the tab
leaves them out; the same id under another agent is that agent's.

The line's code is in plugins/usage/page.js (sessCtxLine). context.js only
exports spark and health, and pays for its tip by cutting comments, so
the core's scripts are 10 bytes under main's, no budget raise.

Run at this head (rebased on e215d335a), on WSL (magpie-desktop, Linux;
mote rebooted mid-run):
- gofmt -l clean; go test -tags nogui -run
  'TestContextSessionLine|TestCoreScriptBudget|TestContext' ./internal/gui/: ok
  (also ok on mote at this head).
- node --test sessions-context-line (new: Chromium and WebKit, en zh zh-TW
  ja de, 1100 and 420 wide) and context-window: 44 of 44.
Run on mote before the rebase, at 627fd1a3b:
- the whole internal/gui package: its one red, TestCoreScriptBudget
  (1,536,110 > 1,533,802), is why the line moved into the plugin.
- sessions-context-line: 20 of 20.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- i18n-keys: "a plugin's words are its own" red, the same on origin/main
  e215d335a (#5327, #5332, #5426, #5482); the new strings pass its other
  checks.

Broken by hand:
- the one-session filter dropped: TestContextSessionLine red ("its
  requests' prompts: [21000]", another session's line).
- the tip back to "Request {n}: {tokens} tokens": sessions-context-line red
  in de ("Anfrage 2: 80K Token" for "Anfrage 2: 80K von 200K (40%)").
- the details line turned off: sessions-context-line red in en and zh.

Not tried: the whole GUI suite (it was running under mote's suite lock
when mote rebooted; not run at push); a real magpie with real routing history (the GUI test stubs
/api/context/session; the Go test reads real history files in a sandbox
config); the Linux app's WebKitGTK.

Reported-by: liang_yongxiang (Discord)
2026-11-08 18:13:30 +08:00
yetone f78d6b0d95 tune: gateway mode leaves Tuned for you out
/api/tune replays this computer's Claude Code and Codex files, and a
~/.claude folder alone makes a Claude Code card. In gateway mode the agents
are on other computers, so the card said Claude Code made 0 requests while
the harness card counted the gateway's. /api/tune now says gateway: true
with no agents, Use and Undo answer 409, and context.js draws no section.

Run (mote): go test ./internal/gui -run 'TestTune|TestGatewayMode' ok;
node --test context-tune-gateway, context-tune, context-tune-shapes 334/334
(Chromium and WebKit, en and zh, 900 and 420 wide); vet both OSes and gofmt
clean.
Broken by hand: with the ownSessionsOff checks taken out the Go test shows
the reported Claude card with 0 calls; the GUI test fails 20 of 30 (every
gateway-mode case) on the old context.js.
Not tried: a real Docker magpie; the full suite (mote rebooted mid-run).

Reported-by: linkaww on Discord
2026-11-08 02:37:09 +08:00
yetone 784113472d gui: motion answers sooner: strong ease-out, folds and popovers under 300ms, no scale(0)
The owner asked for every animation to follow Emil Kowalski's "make your
app feel faster" rules (x.com/emilkowalski/status/2118687605776597482):
ease-out for anything the user starts, a strong curve over the stock one,
and UI motion under ~300ms. Spinners, attention flashes, decorative loops
and the chart intros are left as they were.

- New token --ease-out: cubic-bezier(.23, 1, .32, 1); --morph-ease is now
  the strong ease-in-out (.77, 0, .175, 1).
- Agents' fold, and the panel's edge that moves with it (UNROLL/ROLLUP):
  .62s/.42s -> .34s/.26s on --ease-out; its rows .56s with a 48ms stagger
  -> .32s with 24ms.
- An agent row's details (ROW_OPEN/ROW_CLOSE, .ag-open, .ag-body):
  .48s/.40s -> .32s/.26s. The curve stays the gentle-start spring the
  comment chose so the panel's edge keeps up; only the time is shorter.
- Hover reveal of a row's menu: up to .52s -> .28s. Chevrons .3-.5s ->
  .22-.32s.
- Popovers: pop-in .42s -> .24s; pop-out was .22s on an ease-in curve,
  now .15s ease-out.
- The new-dot started from scale(0); it starts at scale(.5), opacity 0.
- Sheets, sidebar sub-lists, modals (.57s -> .44s open, .38s -> .30s
  close), Context tiles and fades, plugin cards: 460-620ms -> 240-400ms.
- Theme crossfade .35s -> .25s; copied/new-account pops .36-.5s -> .26-.3s.

Run on the Linux VM (magpie-desktop, WSL), both engines, every language:
- Whole GUI suite at this change: 21559 pass, 431 fail of 21990. The run
  overlapped another session's suite (15-minute load 39). #5559 has 478
  of 21666 red on this VM at main.
- 17 files that touch the changed motion (model-chip-steady,
  page-width-steady, zero-priced-free, segs-press-redraw, rest-try-now,
  provider-fetch-again, codex-predictions, side-toggle, tray-cell-click,
  menu-input-scroll, agent-details-ready, agent-expand-steady,
  held-animations, group-morph, header-centre, inner-scroll-contain,
  recovered-file), concurrency 2, at the parent e6cdeac9c and at this
  change: 230 pass / 154 fail on both, and the 128 failing test names are
  identical (diff empty). They are filed: #4388, #4600, #4689, #2624,
  #3479, #5559.
- i18n-keys' "a plugin's words are its own" is red at the parent too
  (plugin i18n strings also said in Go files); not touched here.

At the pushed head (rebased on 999ba6a00): go test -run Budget|Asset|Embed
./internal/gui ok on mote.

Not run: a clean whole-suite baseline at the parent on an idle machine
(mote was running two other sessions' suites), and nothing on macOS
WebKit or the real tray panel; the feel was not watched in the real app.
2026-11-07 22:04:06 +08:00
yetone 30ae0e3f92 context: Tuned for you draws only the advice rows it knows (Linka)
Linka on Discord (v0.1.3199, a Docker magpie added as a Remote magpie):
Usage › Context showed "undefined is not an object (evaluating 'r.cost')".

Cause: since v0.1.3120 (6b91c2ea5, fcc0daa23) /api/tune sends "few"
rows, a setting put in with too few calls to weigh, with no compact
and no ttl. A page from before then reads `(a.compact || a.ttl).cost`
and throws on such a row. No Go code relays /api/tune from a Remote
magpie, so the throw needs a page from v0.1.3119 or earlier against a
newer server, such as a window left open while the container updated
(the page reloads only when /api/update is asked). Today's page
survives few rows but still threw on a null agent or row ("null is
not an object (evaluating 'a.advice')") and on a row with no setting.

loadTune now keeps only the agents and rows that are objects, and the
rows with a compact or ttl replay or few: true, each with a setting
object. Every reader of advice (adviceRow, tuneCard's totals,
renderTune's filter, the few checks) reads that normalized tuneData.
Two long comments in context.js were cut to pay for it. The core
script budget is not raised.

Run (mote):
- context-tune-shapes.test.cjs (new), Chromium and WebKit, en and zh,
  900 and 420px: 20 of 20 ok.
- context-tune, i18n-keys, TestCoreScriptBudget: ok, except i18n-keys'
  "a plugin's words are its own", red on main as #5332, #5426, #5482.
- Every context*.test.cjs and routing-context-fold.test.cjs at this
  head and at origin/main 82403f9f6: 484 ok / 2 red here, 464 ok / 2
  red there. The red on both is routing-context-fold's WebKit
  ResizeObserver loop error (#5586).
- The whole GUI suite under the suite lock is still running. Its reds
  so far are on pages this change doesn't reach. Each one that is red
  on main too gets its own issue.

Broken by hand: the new test run against v0.1.3119's assets
(MAGPIE_ASSETS) fails 20 of 20, with Linka's exact text in WebKit
("undefined is not an object (evaluating 'r.cost')") and "Cannot read
properties of undefined (reading 'cost')" in Chromium. Against the
assets of origin/main before this change, its unknown-shapes case
fails in both engines on the null agent.

Not tried: Linka's real Docker setup, or a real old page left open
across a server update. The Go suite was not run, since there is no
Go change.

Reported-by: Linka (Discord)
2026-11-07 12:13:15 +08:00
yetone fcc0daa23e usage: Tuned for you tells Claude Code's cache here with no calls, and an hour of the user's has Use 5 min
linkaww (Discord, #help) set Claude Code's prompt cache to 1 hour from
Usage > Context > Tuned for you and asked how to go back to 5 minutes. On
the computer that sends its requests to a Remote magpie the card was
empty, so there was nothing to see or undo.

Cause: the card's rows came only from advice, which needs 50 calls read
from this computer's session files, or from a knob tune put in itself
(TuneKept, v0.1.3120). A Remote-magpie client with too few calls read
here, or a 1 hour it didn't put in through magpie (set on the other
computer's card and copied, set by hand, or stashed by a version before
3120), had no row. The setting itself is Claude Code's settings.json on
the computer where Claude Code runs (promptCacheTtl,
subagentPromptCacheTtl); a Remote magpie's requests read B's, not A's.

Now:
- agent.TuneCacheHere reads Claude Code's two cache lifetimes on this
  computer whoever set them: the main conversation's always, the
  subagents' when something sets it, nothing when there is no ~/.claude.
  adviseOf adds them to the kept knobs, so Claude Code's card shows with no
  calls at all, each row's Now saying 1 hour, 5 minutes or Default.
- A row with too few calls at 1 hour that magpie didn't put in has
  Use 5 minutes (tooltip: Replaces your 1 hour; Undo puts it back); after
  it, Undo gives the hour back from the stash. A variable that comes first
  (CLAUDE_CODE_PROMPT_CACHE_TTL, FORCE_PROMPT_CACHING_5M) still locks it.
- A row with too few calls no longer reads "Already the leanest".
- The three Use buttons share one helper, which pays for the new one:
  context.js is 82 bytes smaller, TestCoreScriptBudget's budget untouched.
No new strings.

Run (mote, via mote-run):
- go test ./internal/agent ./internal/gui -count=1: agent ok; gui's only
  reds are TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 on mote)
  and, before the helper, TestCoreScriptBudget (fixed as above); after:
  -run 'CoreScriptBudget|Tune' ok.
- context-tune.test.cjs in Chromium and WebKit, all five languages, 360
  and 1100 wide: 24 of 24 ok. i18n-keys: every test ok but "a plugin's
  words are its own", red on main for three strings in other files
  (#5332, #5426, #5482).
- gofmt -l clean; go vet darwin (touched packages), GOOS=linux -tags
  nogui ./... and GOOS=windows ./... ok; builds for all three ok.
Broken by hand:
- old internal/gui/tune.go: TestTuneTellsTheCacheHere red ("the user's
  own 1h, no calls: rows []") and TestTuneKeepsWhatItPutIn red.
- old context.js: the new GUI test red in both engines (Now read "—"
  where Default is expected).
Not tried: a real Remote magpie pair (two computers) with linkaww's
settings, and a real Claude Code session reading the 5m after the press;
the whole GUI suite ran after the push, not before (suite lock held).

Reported-by: linkaww (Discord)
2026-11-06 18:51:39 +08:00
yetone 6b91c2ea5b usage: a cache or window Tuned for you put in keeps its Undo with too few calls
linkaww on Discord (11-06): "之前在用量 - 上下文把Claude Code缓存改成了1h
请问在哪里改回5m". Usage › Context › Tuned for you is the one place in
the GUI that sets Claude Code's promptCacheTtl, subagentPromptCacheTtl and
a model's autoCompactWindow, and its row (with Undo) came only from advice,
which needs 50 calls in the range. On Today, or a quiet week, the row and
the way back were gone, and an agent with no calls had no card at all.

agent.TuneKept lists the knobs tune put in (its stash, read back as ours,
not under Long conversations). /api/tune adds each one that has no advice
row as a few row, and keeps an agent with none of its own calls when it
has one. The card draws a few row as In use with Undo and "Not enough
calls in this range to tune on", and no curve; the card's totals skip it.
A value the user wrote themselves is not listed. Codex's compact is left
out: Settings changes it.

Run (mote, at this tree):
- go test ./internal/agent ./internal/gui -count=1: agent ok. gui is red only
  in TestMainWindowCorners, which is red the same way on a fresh origin/main
  92f5fc8fe (#3949). TestTuneKeepsWhatItPutIn and TestCoreScriptBudget pass
  (core 1,533,750 at this commit, budget 1,533,802, not raised).
- node --test of context-tune, images-codex-one, chatgpt-image-chip and
  settings-lines-wrap, in Chromium and WebKit, in en, zh, zh-TW, ja and de,
  at 360 and 1100 wide: 322 pass, 0 fail. i18n-keys is red only in "a
  plugin's words are its own", the same on origin/main 8ee85c59f (#5332,
  #5426).
- GOOS=linux go vet -tags nogui, GOOS=windows go vet, go vet (agent, gui),
  go build ./..., gofmt -l: clean.

Broken by hand:
- TuneKept's result dropped in gui/tune.go: TestTuneKeepsWhatItPutIn fails
  ("no calls: kept []").
- Without the tuneCard guard, the new context-tune case is red in both
  engines: the card throws on a few row and draws nothing.

Not tried: a real Claude Code run reading the put-back value, or the real
app (the live ~/.claude is off limits).

Reported-by: linkaww
2026-11-06 13:36:23 +08:00
yetone 775630dac9 usage: the compaction picker says each window against the setting now
hayden4608 on Discord (#feedback): "上下文压缩阈值建议这里应该以当前选中的为
基准更直观 而不是以最省token的为基准". Usage › Context's "Other window…"
menu said every value's tokens past the leanest, so the window one had
set (ticked in the menu) read "+N tokens" like any other, and choosing
between them meant subtracting two notes in one's head. The reader
picks away from the setting in use, so that is the baseline now:

- each value says "−N tokens (−x%)" or "+N tokens (+x%)" against the
  setting now's own point on the curve (the replay's cost at the current
  value when the curve has no point there);
- the setting itself says "Your setting now";
- "Fewest tokens" stays, beside the leanest value's numbers (timed: the
  cheapest, as before), so where the minimum is is still shown;
- the menu head says it: "Compact at · against the setting now, from
  your calls of the range".

The chart and the "{pct} fewer tokens" line already compare with the
setting now and are unchanged. New strings in zh, zh-TW, ja and de; the
old head's key is replaced. docs/subsystems/agent-wiring.md says the new
baseline.

context-tune.test.cjs: the menu notes in every language at 360 and
1100 wide, against 300K set (−150M/−11% at 250K, −420M/−30% plus
Fewest at 160K, "Your setting now" at 300K), and again after 250K is
put in (250K is the setting, 300K +150M/+12%); the timed case against
120K set (100K −90M/−9% plus Fewest, 240K −20M/−2%).

Run on mote (mote-run), this tree before the rebase:
- context-tune: 120/120 chromium, 120/120 webkit
- i18n-keys 4/4 and compact-one-value 6/6 in each engine
- go test -run 'Budget|Script|Asset|I18n|Lang' ./internal/gui: ok

Broken by hand: the old context.js under the new test fails 20
subtests in chromium (both menu tests, every language and width).

Not tried: the real app with a real replay; the full GUI suite and
go test ./... (run after the push).
2026-11-05 01:06:30 +08:00
yetone e4bc3eeb6f gui: the context window card's head keeps its title, icons and model apart at every width
packinggoods on Discord, in #feedback: in a narrow window the Routing
page's "Context window" head drew the provider's icon over the end of
the title. The mono model id (remote-magpie/claude/cla...) and the Live
pill sat beside it. The cause was .ctx-fold, the title's button when the
card can fold. It had min-width:0, so it shrank under the route, and the
title's nowrap text ran on under the icons.

The title no longer shrinks (flex:none). The route and the state now go
together in .ctx-end, and the head wraps. Where the title leaves them too
little room they take a line of their own, ending at the right, and the
model id is cut there with an ellipsis. A folded card stays one line. At
520px and below it drops the agent's name and the lab part of the route.
At 420px and below it drops the route and the state's word, keeping the
state dot and the bar. The fold button keeps an outer height of 20px
(margin -1px), so opening the card doesn't move the page.

New test, ctx-head-narrow.test.cjs. It uses the reporter's model, live
and counted, with and without the agent, with and without a known window.
It runs en, zh, zh-TW, ja and de, at 1100 down to 340px, open and folded,
in Chromium and WebKit. It checks that the title's text is whole, that no
drawn parts overlap (boxes clipped to their overflow ancestors), that an
icon is never part-cut, and that nothing runs past the card.

Run at this head (rebased on a fresh origin/main), on mote, both engines:
ctx-head-narrow, ctx-route, context-window, routing-context-fold,
routing-ctx-still, routing-ctx-fold, routing-live-patch and i18n-keys:
188 pass, 0 fail. The whole GUI suite is running on WSL (Linux, both engines)
and had not reported when this was pushed. Mote was busy with three other
sessions' full suites. The owner's rule is to ship a verified fix at once.
Any red it finds that this change caused gets an issue.

Broken by hand: ctx-head-narrow on the old context.css/js is 52 of 52
red (e.g. "open at 580px: the title is whole ... cut:true", "title and
lab icon overlap").

Not tried: the real Wails app (WebKit on macOS, WebKitGTK on Linux,
WebView2 on Windows).
2026-11-04 01:39:01 +08:00
yetone 0872bc2a0e context: a request's text and reply from the request archive (wangbinyq)
wangbinyq on Discord: with the request archive on, clicking a block of
the context window card still said "只保留最近 10 个请求的原文", since the
card read only the last 10 bodies magpie keeps in memory.

What changed:
- /api/context/text tries memory first, then the request archive's copy
  when the route names one (Route.Archive, the route found in the trace
  or in the history file of the card's ?day=, HistoryRoute looks a day
  either side). gateway.ArchivedPromptText parses it as PromptText does
  and masks it through maskedCopy, as the body in memory is; it is
  marked from "archive" and the card says so.
- New /api/context/reply: the reply to the request, from the Recent
  calls (Server.ReplyBody) or the archive's Response. gateway.ReplyPieces
  reads it into thinking/assistant/call pieces (conversationOutput, split
  out of conversationTurn) after redact.ScrubJSON, and masks every piece
  through maskedCopy. The card's text view has a Reply button beside
  Close that shows it and goes back to the part.
- What is shown is what the archive stores, masked as the memory copy
  would be, nothing more. A body or reply that can't be masked shows
  nothing (404 "unread"); one the archive cut short isn't parsed ("cut");
  one it names and doesn't have says so ("missing"), and one with no
  archive copy keeps the old "only the last 10" line ("off"). A failed
  bucket read is an error, not "gone".
- The archive read is capped at archiveReadMost and the last copy read is
  kept 5 minutes, so the items opened one by one read it once.
- ctxtext.js takes the route (id and time) instead of the id; context.js
  passes it (its one-line change paid for by a comment cut, core budget
  not raised). New strings in zh, zh-TW, ja and de.
- docs/subsystems/gateway-routing.md (Prompt) and gui-shell.md.

Run on f3335dd1b (main has since d73f2254d, textcalls_anthropic.go and
its test only, none of these files), on mote (macOS 27):
- go test -run 'TestArchivedPromptText|TestReplyPieces|TestPromptText|
  TestConversation|TestContext|TestCoreScriptBudget' ./internal/gateway
  ./internal/gui: ok.
- Whole ./internal/gui and ./internal/gateway (before the last rebase,
  same change): ok except TestMainWindowCorners/macOS_26_SDK (#3949) and
  TestCodexPoolSaysTheClientsVersion (#4807, fixed on main by 17f2387e1
  since).
- GOOS=linux go vet -tags nogui and GOOS=windows go vet of both: ok;
  gofmt -l clean.
- GUI, both engines, every language, 1100 and 420 wide: every file that
  reaches the context card (context-text, context-map, context-window,
  context-map-live, context-scroll-end, context-scripts, context-tune,
  ctx-route, compact-one-value, routing-ctx-*, routing-context-fold,
  routing-live-patch, routing-return-cost) plus i18n-keys: 514 of 518.
  The 4 reds are context-map's webkit 420px "two tiles overlap", red the
  same on origin/main f3335dd1b run alone (5 of 10 webkit there), #3488.
- The whole GUI suite is running on the Linux box (wsl-run) as this is
  pushed; mote had another session's full suite on it.

Broken by hand (each went red):
- maskReplyPieces skipped: TestReplyPiecesAreMasked (phone unmasked).
- ArchivedPromptText's masking skipped: TestArchivedPromptTextIsMasked
  and TestContextTextFromTheArchive (phone in the 200 body).
- ctxtext.js's "missing" reason dropped: context-text.test.cjs, 10 of 10
  chromium.

Not tried: a real archived request in the running app, the bucket
(WebDAV) archive with a real server, and a reply cut short by the
archive's size in a real call.
2026-11-03 13:34:35 +08:00
yetone a63766b071 context: Use on Codex's window reads "In use" over 7 and 30 days too (hoobnn)
hoobnn on Discord (#general, after v0.1.2572): on Usage > Context, Use
on Codex's Compact at showed "In use" with Undo over Today, but over 7
or 30 days the card never said "In use".

Cause: adviceRow checked `same` (Now equals the advice) before
`applied` (magpie put the advice in). Over 7 and 30 days the moved
models' Now reads the advice after Use, so the chip said "Already the
leanest for how you work". Today's calls were Codex's own models, so
Now stayed and `applied` won. Now `applied` is read first, in every
range; adviceRow is the only place the verdict is drawn (Claude rows
and TTL rows go through it too).

Test: context-tune's new "Use on Codex's window is In use with Undo
over Today, 7 and 30 days" (every language, 360 and 1100 wide), and
three existing assertions that wanted "Already the leanest" after Use
now want "In use".

Run:
- Red on the old code (mote, base 9621168c4, old context.js + new
  test): 20 of 30 subtests per engine red, all of 7 and 30 days,
  "Expected 'In use', actual 'Already the leanest for how you work'";
  the three updated tests red too. Today passed.
- Green at da275848b (wsl-run; mote is out of disk, ENOSPC on Go
  builds and browser launch): go test -tags nogui -run
  'TestCoreScriptBudget|TestTune' ./internal/gui/ ok; node --test
  context-tune.test.cjs i18n-keys.test.cjs 244/244 in Chromium and
  WebKit, en/zh/zh-TW/ja/de.
- origin/main moved 3 commits since (85e37162e), none touching
  context.js, its test, tune.go, i18n.js or internal/tune.

Broken by hand: putting the old order back turns the new test red
(above).

Not tried: the whole GUI suite (a broad WSL run of the context files,
i18n and the zh-TW/ja/de files was killed from outside at ~91 tests,
none failed by then). hoobnn also said Undo was missing over 7 and 30
days; on the old code Undo showed there (the test's wait for Undo
passed), so that part was not reproduced. hoobnn's real Codex config
was not tried.

Reported-by: hoobnn (Discord)
2026-11-01 22:09:06 +08:00
yetone c903c3a411 usage: Use on Codex's window lands over 7 and 30 days, a model's own Compact at named apart (hoobnn on Discord)
hoobnn on Discord (11-01): "观测-用量-上下文里,在7天或者30天的选项里,点击
应用codex的上下文,没生效。" Over 7 or 30 days the range held calls on a
model whose provider has a Compact at of its own (430K); today's didn't.
Tuned for you's "Now" was the largest compaction point over every model
in the range, so it came from that model. Use put the advice in Long
conversations, which did move Codex's other models (Codex's list had
them at the advice), but the card still read 430K and then turned held
("compacts at its own 430K, which comes first"), so nothing seemed to
happen. And with Long conversations at magpie's default, a range of
only such models offered a Use that could move nothing.

codexWindow (internal/gui/tune.go) now reads "Now" from the models Long
conversations moves, and lists each model with its own Compact at as
Apart (largest first). Only a range whose every model has its own is
held (Own), whatever Long conversations says. The card names each
model kept apart under the row: "{model} compacts at its own {value},
which this doesn't move", in en, zh, zh-TW, ja and de.
provider.CompactSetIn is CompactSet with the caller's settings and
group finder, as CompactFor takes them.

Siblings: Claude Code's knob is per model (no max over models), so it
has no such mix. 1, 7 and 30 days go through the same codexWindow;
the GUI test covers 7 and 30 and the Go test the 1-day sample.

Run on mote at d614f2172 plus this change, then at this head (on
7b6b7492a) again: TestCoreScriptBudget, TestTune*, context-tune and
i18n-keys, all ok.
- go test -tags nogui ./internal/provider ./internal/agent
  ./internal/codexcat: ok. ./internal/gui: ok but two tests red the same
  on a clean origin/main 9097687a3 (3 of 3 and 1 of 3), both filed:
  TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, #4739) and
  TestColdTurnsTaken (#4510). TestTuneCodexUseLandsInEveryRange (new) puts
  two providers in a sandbox HOME, one with its own 430K, reads the
  advice for 1 model and for both, applies through agent.TuneApply as
  /api/tune/apply does, and checks the card and Codex's model list
  (codexcat): the other model at the advice, the own one at 430K.
- go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet
  for internal/gui and internal/provider; gofmt -l clean.
- node --test context-tune (178 pass, both engines, en/zh/zh-TW/ja/de,
  360 and 1100 wide), i18n-keys, gui-zh-tw, gui-de: pass. gui-ja: one
  red, "ja has every zh string", the #4532 string, filed as #4580 and
  fixed in its own commit next.
- TestCoreScriptBudget passes with no raise (two comments in
  context.js cut to fit: 1,533,023 of 1,533,105).

Broken by hand: with tune.go's Apart taken out, the new Go test is red
("only the model with its own 430K: own <nil>, now 430000" and "after
Use 120000: now 430000, own own/gpt-own-1m"); with the old context.js
the new GUI test is red, 42 of 42 (40 cases, both engines).

Not tried: hoobnn's own config on a real Codex; a profile-level
model_auto_compact_token_limit in config.toml (TuneRead reads the
top-level key as Locked, not a profile's); the whole Go suite and the
whole GUI suite (run after the push).
2026-11-01 15:19:32 +08:00
yetone 4794767846 routing: back on Routing from another page, the page isn't laid out and drawn again whole (#4652)
xisdumpling (dumplings04605 on Discord), Windows, 0.1.2507: with a
history day of 180 to 298 requests picked, coming back to Routing
stalls the page and the sidebar's highlight. Measured first, with
routing-return-cost.test.cjs (250 rows, a picked day, a request's story
open), which counts what the return does, not how long it takes.

Causes found, each fixed and each red by hand when put back:
- The request list was windowed only from 300 rows, so a day of 180 to
  298 had every row in the page. Now from 100 (WIN_MIN); the live list
  keeps 60, so it is never windowed.
- Out of sight a view is 0 wide. The ResizeObservers in the routing
  client (byWidth, the meta width) and context.js's card sizes took that
  as narrow, flipped the narrow layouts while away and flipped them back
  on return. A 0 width now keeps the layout it had.
- A hidden list re-windowed itself for a 0-high view, so the return
  placed rows and ran metaFit again. It keeps its window while hidden.
- resume rebuilt the whole stage on return. sync("back") rebuilds only
  when what the stage was built from (route, pin, day, purpose, lang,
  the requests and their accounts) changed, and records it after the
  rebuild.
- The visibility observer's group reload was not quiet and redrew the
  groups. It is quiet now.
- A providers refresh while on Routing redrew the hidden Providers page.
  It is read and drawn when Providers opens (providersBehind).
Not a cause: the nav highlight's rAF reading offsetTop only waited on
the busy main thread; it is one small layout now.

Before and after, the "back on Routing" step (Chromium layout metrics
from CDP; class flips and redraws from MutationObservers, both engines):
- mote, macOS: 25 layouts / 34.9ms of layout, 24 class flips, Providers
  redrawn 13 nodes, groups 4, stage kept 0 of 3, 250 rows, 7818 nodes
  -> 9 layouts / 3.2ms, 0 flips, 0, 0, 3 of 3, 11 rows, 1367 nodes.
- Windows (xiaomi-gpu, win-run): 25 layouts / 146.4ms, 24 flips
  -> 9 layouts / 7.1ms, every check passes. WebKit's counts match.
The test asserts no flips, no redraws, the stage kept, under half the
rows in the page and at most 12 layouts; wall time is logged, not
judged. The page looks the same: no CSS or markup change.

Run:
- routing-return-cost: red on origin/main 8ac1c7a56 in both engines,
  green with this on mote and on Windows (win-run), both engines.
- Broken by hand, each red: the byWidth 0 guard, the meta width guard,
  the hidden drawList return, sync("back"), the quiet group reload, the
  Providers deferral, WIN_MIN back at 300, and context.js's cardSizes
  guard (seen through the ctx-card).
- go test ./internal/gui -run Budget on mote: ok, no budget raised.
  Rebased on 2b067434d the core was 278 bytes over its 1,533,105; this
  change's comments and renderProviders' scroll comment were cut to
  1,533,072, app.js 1,311,935 of 1,316,874.
- All 142 routing*.test.cjs files on mote, both engines, every
  language, concurrency 3, at load 40 to 70 from other sessions: 2052
  tests, 29 red in 9 files. Each of those files run serially at origin/main
  and with this shows the same reds (rule-drag, rule-remove, row-swap,
  order-unknown: #3789, #3096, #3094, #3799, #4585, #4494), and so do
  steady, steps-cap and story-shrinks (#3412, #4585); rules-line's
  webkit de 1100 went red once with this only (#4585, #4560).
- purpose-filter (108 rows, windowed now): 14 of 14.
Not run: the whole GUI suite. mote had another session's full suite and
several more runs at load 60 to 75 the whole time; it runs after the
push and its result goes on #4652.
Not tried: the real Windows app; only Playwright on the Windows box.
2026-11-01 11:24:02 +08:00
yetone e1aec53895 routing: each session sending at once has its own context window, named by its title (tjhhhh on Discord)
tjhhhh runs several agent sessions at once. The Routing page's context
window card followed whichever request came last, so it jumped from one
session's prompt to another's. The card still tells of the request it
picked. Under it, while two or more sessions are live, a strip now
shows one small block per session (renderCtxSessions):
- keyed as the card's line of prompts is (sessionKey, else the
  conversation);
- named by the agent's title for the session (sessionName), else its
  folder's last level, never a bare id;
- holding that session's newest reading through context.js's stack bar,
  exported as window.ctxStack.

A session is live while a request of it is under way, or while its
newest request is within 15 minutes of the newest overall. At most six
blocks show, newest session first. A block keeps its place while the
sessions take turns, because blocks are ordered by each session's first
request. The block the card tells of is lit (aria-pressed), and a click
on a block picks that session's newest request. The card's footer names
the session by its title too. New words are in every locale in
plugins/routing/i18n.js. The strip reuses the card's tokens: no select,
no coloured border, no gradient.

The strip sits under the card, not over it. Over it, the strip's first
appearance moved the card, and routing-ctx-still ("the cache kept its
place") went red in both engines. It is green at base ccc791231, and
green again with the strip under.

What was run (mote, through mote-run):
- New routing-ctx-sessions.test.cjs: two engines, en/zh/zh-TW/ja/de at
  1100 and 390px, plus one session alone and one with no title. Red on
  origin/main, since there is no strip there. Broken by hand: ordering
  blocks by newest request instead of first request turns the
  "keeps its place" check red. Green, 4 of 4 tests, at the final tree.
- routing-ctx-still: red with the strip over the card, green with it
  under (tests 391/392, both engines).
- Whole GUI suite, at the first version (strip over the card), under
  load 25 to 30 from other sessions: 16892 tests, 16595 pass, 297 fail
  in 49 files. That version's own red was routing-ctx-still (fixed
  above). Every other red file has an issue:
  - Filed before: agent-panel-name-width #4203, context-map #3488,
    gui-ja #4580, i18n-keys "Unmarked" #4524, header-centre #3479,
    key-replace #4126, menu-input-scroll #3402, mobile-web #3952,
    model-chip-steady #4388, models-works-only #4391, page-width-steady
    #4541, phone-connect-menu #3524, plugin-card-update #3079,
    plugin-move-unserved #4392, provider-fetch-again #3292,
    provider-levels-scroll #4394, provider-models-rest #4396,
    provider-picks-stay #4397, provider-typed #4461, recovered-file
    #4320, remote-magpie #4398, rest-try-now #2564, routing-row-swap
    #3799, routing-steady #3412, the routing rule-drag, rule-remove,
    rules-line and upstream files #4585 and #4494, s3-sync #3413,
    searcher-pick #4274, segs-press-redraw #4189 and #4566,
    usage-agents-hide #3414, warm-now #4322.
  - Filed with this commit: editor-advanced-align #4615,
    gateway-key-models #4616, group-found-skip #4617, images-codex-one
    #4618, import-row #4619, market-have #4620, model-copy-id #4621,
    nav-timeout #4622, number-units #4623, omarchy #4624, tencent-cloud
    #4625, usage-ledger #4626, routing-order-unknown #4627,
    routing-steps-cap #4628, routing-story-shrinks #4629.
- The files this change can reach (routing-*, context-*, i18n-keys,
  gui-ja), alone at concurrency 2 on the first version against base
  ccc791231: 54 fail on the head and 34 at the base. The only red that
  was on the head and not the base was routing-ctx-still. The rest were
  routing reds under load that show on both.
- The same files rerun with the strip under the card: 2331 tests,
  35 fail. routing-ctx-sessions and routing-ctx-still are green. Each
  red has an issue: context-map webkit 420px "two tiles overlap"
  (#3488, the same at base), gui-ja (#4580), i18n-keys "Unmarked"
  (#4524), routing-many-keys (#4082), routing-row-swap (#3799),
  routing-steady (#3412), routing-order-unknown (#4627),
  routing-steps-cap (#4628), routing-story-shrinks (#4629), and
  rule-drag, rule-remove, rules-line and upstream (#4585).
- TestCoreScriptBudget went red after the rebase: the core was over by
  266 bytes, which is the new stackBar helper in context.js. The budget
  was not raised. stackBar was written tighter and the comments around
  it cut, and context.js is now 1 byte under its size at origin/main.
- Rebased on origin/main 2e9df9b1b, on mote:
  - `go test ./internal/gui`: TestCoreScriptBudget passes. Two reds are
    already filed: TestSettingsSaveKeepsWhatItDoesNotSend (#4514, red
    on main) and TestMainWindowCorners (#3949, macOS 27).
  - routing-ctx-*, context-*, i18n-keys and gui-ja: 337 tests, 8 fail.
    routing-ctx-sessions is 4/4, routing-ctx-still 2/2, and every
    context-* other than context-map is green. The reds are context-map
    "two tiles overlap" (webkit 420px in every language and chromium
    zh 420px, #3488), gui-ja (#4580) and i18n-keys "Unmarked" (#4524).
- Rebased again on origin/main e8347401f, which changes the core
  budget and fixes #4524. This is the pushed tree. TestCoreScriptBudget
  is ok, and routing-ctx-sessions, routing-ctx-still and i18n-keys pass
  44/44.

Not tried: a real gateway with several live agent sessions sending at
once (only the page's fixture feed was used), the Linux WebKitGTK app,
and the whole GUI suite at the final tree (only the files above,
which the change can reach).
2026-11-01 02:44:37 +08:00
yetone 80af3b86a4 context: the card's head names the agent and the model's lab
The owner asked for the agent's name and the model's icon on the
context window card, and picked design A from a mock-up: in the head,
right of the title and before the state pill,

  [agent icon] Claude Code › [lab icon] anthropic/claude-sonnet-5-5

- context.js: the head's model is now a route (.ctx-route): the agent's
  icon and name (agentIcon, agentLabel, as the Usage page names it), a ›,
  then the model's lab icon before its id. labIcon picks the lab from
  the id after its provider prefix (Claude, OpenAI's gpt/o-series/codex,
  Gemma, Gemini, DeepSeek, Qwen, Kimi, GLM, Grok, MiniMax, Doubao,
  Mistral, Llama, MiMo, Step, Hunyuan); an id it doesn't know gets no
  icon, so a wrong logo never stands for a model.
- context.css: the name in --fg-2 at 500, the › in --faint, the agent's
  icon 14px and the lab's 12px; the model id keeps its ellipsis. In a
  card 420px or narrower the agent's name and the › go and its icon
  stays; folded and that narrow, the model goes as it did before.
- core_budget_test.go: lowered to 1,532,958, the core after this and the
  text viewer's move to ctxtext.js (the commit before), on origin/main
  0fe9f97c1.

Tests: ctx-route.test.cjs, Chromium and WebKit, en/zh/zh-TW/ja/de: the
agent's name and icon, the lab icon for Claude, an OpenRouter-prefixed
GPT, DeepSeek and GLM, none for an unknown model, the route still on
the folded head's one line, the name gone and the icon kept at 400px,
nothing past the head, no page error.

Run at this head:
- the full GUI suite on mote (6 wide) before the last rebase: 16,938
  tests, 283 red in 50 files. Those 50 files again at 2 wide: 292 red,
  and at origin/main 2cca11176: the same files red (model chips, rule ⋯,
  Settings redraw, fetched editor; #4600), context-map's 420px "two
  tiles overlap" among them (#3488).
- after the rebase on origin/main 0fe9f97c1, on mote: go test
  ./internal/gui: only TestSettingsSaveKeepsWhatItDoesNotSend (#4514)
  and TestMainWindowCorners (#3949) red, as on main; Budget ok. The
  ctx*/context* GUI files, old-webkit and i18n-keys: 346 tests, 6 red:
  context-map 420px (#3488) and i18n-keys "Unmarked" (#4524).
- rebased again on origin/main 20482d71f (two commits, 21 lines of
  GUI assets): TestCoreScriptBudget ok there.

Broken by hand, each red, then put back:
- labIcon returning nothing: 42 of 52 red ("the model's lab icon");
- the narrow rule removed: 12 red ("a narrow card leaves the name out");
- the route hidden when folded: the folded case red in every language.

routing-ctx-still.test.cjs is red on Windows 16 of 16 ("used held
still", the big figure's width 60.97 to 61.5), the same frames at
origin/main a4151142a alone (#4494).

Not tried: the real app on Windows (WebView2) and Linux (WebKitGTK).
2026-11-01 02:07:59 +08:00
yetone 9a9967ac28 context: a part's text viewer is loaded when a part is first opened
The context window card opens a part to the text the request sent there
(readText, longText, picture, pieceView, openCtxText). That viewer is a
dialog the user opens by a click, yet its 7KB were in context.js, which
index.html loads on every page as part of the core. It moves as it is to
ctxtext.js, which context.js imports on the first open, as signsheets.js
and navlamp.js are imported; the card hands it the helpers it shares
(fmtK, partName, itemName, itemLabel, tagOf). A failed import says so in
the status line. The core is 7,005 bytes lighter, which makes room for
the next commit (the card's head naming the agent and the model's lab);
the budget is lowered there, to the total after both.

old-webkit.test.cjs lists ctxtext.js among the scripts loaded later.

Run at this tree (1e15a7a3b plus this), on xiaomi-gpu (Windows), both
engines: context-text, context-map, old-webkit 55/55; i18n-keys red on
"Unmarked" (plugins/routing vs internal/usage), the same at origin/main
a511b11d8, #4524. go test -tags nogui -run "Budget|Asset|Embed"
./internal/gui on mote: ok.

Broken by hand: the import pointed at a file that isn't there, and
context-text went 10 of 10 red in Chromium; put back.
2026-11-01 02:07:00 +08:00
yetone 5d955a4d4b tune: Codex can take the compaction advice in the background, its own limit kept (herman_hong)
herman_hong on Discord: Tuned for you advises Codex compact at ~120K.
A foreground compaction kept them waiting, so they had set 384K by hand.
Now that Codex compacts in the background, they want the advice there
and the 384K kept as the backstop.

Codex has this since 0.163.0 (checked in codex-rs at rust-v0.166.0, not
in 0.162.1): [features.async_compaction] enabled and
model_async_compact_threshold_percent, an integer share (1 to 100) of
the model's window, 65 by default. It is Stage::UnderDevelopment, runs
only with remote compaction v2 (which magpie already sets on its
provider), and starts none once the foreground limit is reached. magpie
already writes it from Settings' Background compaction (#2490), with
the version gate and the user's own keys kept. This drives that setting
from tune:

- agent: knob TuneAsync ("async_compact") on codex. TuneRead gives the
  share, TuneApply turns Background compaction on at it (stashing what
  Settings had the first time), and TuneUndo puts that back unless the
  user changed it since. The foreground limit (Long conversations, or
  the user's model_auto_compact_token_limit) is never touched. Async
  keys the user wrote in config.toml come first (codexAsyncOwn): the
  row says so and Apply errors. A table magpie wrote itself doesn't
  count as the user's.
- gui/tune.go: advice.async holds the advice as a share of the window,
  rounded down. With timed compactions it uses the token-cheapest
  window, since a background compaction keeps no one waiting. It is
  offered only when it would start before the foreground limit (the
  lesser of the limit now and 90% of the window). held lists Codexes
  too old for a share.
- context.js: the row gets a text button, "Use 120K in the background",
  whose tip gives the share and says the foreground limit stays. After
  Use a chip says so, with Undo background. A config.toml of the
  user's, or a Codex too old, gets a one-line caveat and no button.
  The too-old line is shared with Settings' row (codexHeld). No select,
  no layout change. zh, zh-TW, ja and de are in i18n.js.
- The core script budget goes up by 1,571 bytes for the row
  (core_budget_test.go says why). app.js is 278 bytes smaller.

Run (at this change on origin/main 6893cfbe3; rebased on d0a61b856,
whose new commits touch none of these files, and TestCoreScriptBudget,
TestTune*, TestCodexAsync* run again there: ok):
- gofmt -l: clean.
- mote-run go vet ./internal/agent ./internal/gui, plus GOOS=linux
  -tags nogui and GOOS=windows vet of both: ok.
- mote-run go test -count=1 -timeout 45m ./internal/agent
  ./internal/tune ./internal/provider: ok. ./internal/gui: the new
  tests and TestCoreScriptBudget pass. TestSettingsSaveKeepsWhatItDoes
  NotSend is red on clean origin/main too (#4514). Eleven AppKit window
  tests (TestMainWindowCorners, TestPanelCloseHidesIt, ...) were killed
  at their 30-40s on mote at load ~25; this change touches no window
  code.
- wsl-run node --test context-tune, codex-async-compact and i18n-keys:
  the new test passes in chromium and webkit, in all five languages,
  at 360 and 1100. It checks the label, the tip, the POST body
  {knob: async_compact, value: "30"}, the chip and Undo, the locked
  and held caveats, and no overflow. i18n-keys' "a plugin's words are
  its own" is red on main (#4524).

Broken by hand (each went red, then restored):
- codexAsyncOwn always "": TestTuneCodexAsyncOwn red in all 4 cases.
- asyncOurs ignoring the set share: TestTuneCodexAsync red (it would
  undo over the user's 50).
- codexAsyncAt keyed on WaitBest, and always ok: TestCodexAsyncAt red
  (timed cheapest, foreground, 90%).
- context.js posting without the knob: the GUI test red, knob
  "compact" where "async_compact" was wanted.

Not tried: a real Codex 0.163+ turn compacting in the background
through magpie, and a real account's /api/tune. When the models' windows
differ, the share comes from the advice's window, so the tokens are
approximate; the tip shows the share Codex gets.
2026-10-31 17:12:16 +08:00
yetone 6d154ef1e1 context: scripts (curl, Bun, python-httpx…) are one Scripts card, not an agent each
A request whose User-Agent names only an HTTP library or an SDK (curl,
Bun, node-fetch, undici, python-httpx, requests, aiohttp, Go-http-client,
okhttp, the OpenAI/Anthropic SDKs, …) or nothing at all got a Context
scorecard of its own, as if it were an agent (theforeveriris on X: "Bun",
"curl", "python-httpx" cards). usage.IsLibrary names those clients;
contextOfRecs folds them and "other" into one "Scripts" card at read
time, so older history reads the same way, and the card's meta line and
tooltip list the libraries by count. The cached day records are not
changed. No setting: it works as is. The Usage page's Agents list still
shows each library by name, with its Hide and Count-as-agent controls.
i18n for zh, zh-TW, ja, de. Existing context.js comments were condensed
so TestCoreScriptBudget holds without a raise (core scripts -28 bytes).

Run, at this head (rebased on 40af66027):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  (mote) for usage and gui; earlier the whole tree on all three, exit 0.
- mote: go test -count=1 -tags nogui -timeout 45m ./internal/usage
  ./internal/gui: ok, ok.
- Windows box: context-scripts + i18n-keys 26/26 (chromium, webkit,
  5 languages, 360 and 1100px). Before the rebase, every reachable file
  (context-*, compact-one-value, group-context, routing-context-fold,
  routing-ctx-fold, routing-ctx-still, i18n-keys, gui-de/ja/zh-tw,
  header-relang): 333/349; the 16 reds are routing-ctx-still, red the
  same on origin/main 40af66027 on that box, listed in #4124.
Broken by hand: IsLibrary false and no fold -> TestIsLibrary and
TestContextScriptsAreOneCard red (cards python-httpx, claude, Bun, ...);
the JS label/clients removed -> context-scripts.test.cjs 0/22.
Not tried: a real app run with real curl/Bun traffic; Linux WebKitGTK;
GUI files on mote (its browsers were busy with another suite).
2026-10-30 16:05:58 +08:00
yetone dfc08e8824 gui: one NO_SCROLL for 90 focus calls, one statusErr for 68 failed calls (#3685)
Room for #3685, which did not fit the core script budget. The budget
is not raised; two repeated forms move into one name each.

- NO_SCROLL: `{ preventScroll: true }` was written out at 90 focus
  calls (89 in app.js, 1 in plugins.js). It is one const at the top of
  app.js now.
- statusErr(e): `status(e.message, "err")` was written out for 68
  failed calls (app.js 61, plugins.js 3, context.js 4), 15 of them as
  a `e => status(e.message, "err")` callback that now passes statusErr.
  renderSync is left alone: `status` is a local string there (#4066).

Saves 2,016 bytes: core 1,536,751 of 1,537,034 and app.js 1,312,975 of
1,315,316 with #3685 on top. quota-refresh-order.test.cjs evals parts
of app.js in a vm and gets both names as stubs.

The idea is Coffemon's (JoeyWu-tech) e7af88774, which no longer
applied to main; it was redone on the current tree.

Landed by yetone in a batch of Coffemon's patches from the issues.
What was run, go1.26.8, on origin/main cc81ad4ea, then again at
70a0c387c (gofmt, the three vets, the changed tests, umask 077):
- mote (macOS 27): gofmt -l clean; go vet, GOOS=linux go vet -tags
  nogui and GOOS=windows go vet ./...: ok. edit and testenv at umask
  077; agent, provider, library and gateway with an empty .git above
  TMPDIR; davsync, imagemcp, plugin, library, edit, testenv whole; the
  changed tests in agent, provider, gateway and gui; the timing tests
  -count=10 (gateway, davsync, imagemcp) and -count=5 (agent): all ok.
  TestCoreScriptBudget ok: core 1,536,751 of 1,537,034, app.js
  1,312,975 of 1,315,316, no budget raised.
- Red on the old code: on origin/main, TestWriteAtomicReadOnlyHardLink
  at umask 077 and two Reasonix tests under an empty .git; on Linux
  (wsl-run) TestProgram at umask 077 with the old program.go. With
  each fix's code taken back to main's, the Gemini imageConfig tests,
  TestPluginToldWhereTheAgentWorks, TestSkillRepoTraced,
  TestTaggedHooksAlone, TestMainURL/TestMainView and update-auto,
  plugin-github-hooks, plugins-more-discover, plugin-namesake were
  red. Broken by hand: claudeKeyed always true (both
  OwnEndpointNeverAsked tests red), claudeAsk a no-op
  (TestClaudeFirstWriteAsksTheProxy red), GitAt taking any .git folder
  (the three TestGitOnDisk tests red).
- GUI: 123 files (plugins*, update-*, panel/tray/start/context, i18n,
  gui-zh-tw/ja/de and every file that evals app.js parts) in WebKit on
  Linux (wsl-run). 11 files had reds (click-scroll, panel-fold,
  plugin-card-update, plugin-github, plugin-move*, segs-glide,
  tray-totals, update-*), and run again side by side they fail the
  same on origin/main d80d75f30 (79 pass, 26 fail here; 78 and 27
  there). They are click-scroll guards ("the click must not scroll
  the page"), varying by language from run to run (#4385).
  copilot-ghe's route-after-close red is #1949, seen on main 244d80e23
  too. In Chromium on mote, Chromium segfaulted partway through files
  (#4125): context-map, context-scroll-end and context-tune fail the
  same on origin/main 0911a65e7, so the batch's own files
  (plugin-namesake, update-auto, plugins-more-discover,
  plugin-github-hooks) ran in Chromium on Linux: 62 of 62.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./..., mote)
  at 472a0608f (on 70a0c387c): every package ok but internal/gateway,
  whose five reds were #4362's (Antigravity turned-away and
  TestCodexSpentGrokFailingIsTold), fixed on main in d80d75f30. After
  the rebase on 244d80e23 the five pass, and gofmt, the three vets
  and the targeted runs above were run again: ok. In Linux the
  sign-in, copilot, plugin-github*, plugins-more-discover,
  plugin-namesake, plugin-gateway, update-auto, quota-refresh-order
  and i18n files ran in both engines: 475 pass, 4 fail (copilot-ghe
  #1949, plugin-github's click scroll, both red on main too).
- Rebased again on c7171a256, over its budget fix e94bf7a08: gofmt, vet of
  gui, gateway, provider and plugin, TestCoreScriptBudget (core
  1,536,265 of 1,536,586 with the batch's last commit, statusTErr and settingsErr), the Gemini,
  GitOnDisk and plugin tests, and in Linux both engines i18n-keys,
  update-mirror, plugin-namesake, plugins-more-discover,
  plugin-github-hooks and update-auto (138 of 138): ok.
Not tried: the whole GUI suite (mote's WebKit wouldn't launch and its
Chromium segfaulted, #4125); macOS WebKit; the real app's window.
2026-10-30 15:53:22 +08:00
yetone 5143bf593a tune: Codex's "Now" is read the same way in every range, and a model's own Compact at is not "In use"
hoobnn (Discord #feedback): Usage > Context's Codex card read differently
for Today and 7 days. 7 days: "Now 380K", "Not the leanest" and a Use
220K button. Today: "Now 430K -> Fewest tokens 170K" with a green "In use".

Two causes:
- codexWindow dropped what magpie tells Codex (told) for the whole range
  as soon as one call was on a model outside the catalog or with an
  unknown window (Codex's own gpt-5.x beside a provider's). "Now" was
  then guessed from the prompts' peaks (380K) over 7 days, while today's
  calls, on catalog models only, read told (430K). told is now the
  largest value over the models magpie knows, in every range.
- Long conversations held magpie's 170K and the advice was 170K, so the
  row said "In use", but a provider's or model's own Compact at (430K)
  comes first and is where Codex runs. The advice now carries Own
  {model, value}; the card shows "{model} compacts at its own {value},
  which comes first" in place of "In use" and hides Use and Other window,
  as it does for a locked setting. Undo stays. New string in en, zh,
  zh-TW, ja, de.

Run (at this tree, rebased on origin/main 296f66a74):
- mote: go test ./internal/gui -run TestTune: ok. go vet ./internal/gui
  ./internal/tune, GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./..., go build ./... and -tags nogui: ok. gofmt -l clean.
- WSL GUI: context-tune (Chromium + WebKit, every language, 360 and
  1100 wide), i18n-keys, gui-zh-tw, gui-ja, gui-de: 125/127 before the
  rebase; the one red, webkit "a window of the reader's own" zh-TW
  360x760 (boundingBox() null while the row re-rendered, a test I did
  not touch), passed 3 of 3 alone and is filed separately.
Broken by hand: the old tune.go turns TestTuneCodexNowIsTheSameInEveryRange
red (170000 vs 1000000 with Codex's own model beside, 440000 vs 430000);
the old context.js turns "a model's own Compact at isn't called In use"
red in all 10 language/width cases.
Running at push (shipped at once per owner): full go test -tags nogui
-timeout 45m ./... on mote and the whole GUI suite in WSL; reds get
issues.
Not tried: hoobnn's own config. That the 430K comes from a provider's
own Compact at is read from the code (only ModelCompacts lifts told over
a CompactAt of 170K); the advice differing by range (timed "Tokens +
wait" over 7 days, "Fewest tokens" today) follows the data and stays.
2026-10-29 16:31:37 +08:00
yetone a4e929212f context: a part of a few tokens on the map is a tile one sees, not a strip under the gap (AIGCFREE on Discord)
The floor under a part's tile was an area (700px²), so a part laid in a long
row beside large ones met it as a strip: 49 tokens of memory beside 72K, the
window unknown, came out 193×3.6px, under the tiles' 3px gap, and hidden. A
part's tile is now 16px across both ways: one thinner has its value raised by
as much and the parts are laid again.
2026-10-29 08:49:27 +08:00
yetone a0ba8e1f2e grok: each model's context_window follows Long conversations, and one set by hand stays through a sync (uk.jent)
uk.jent (Discord #feedback) reported that magpie writes every Grok Build model's context_window as the model's whole window. They wanted about 300K without editing dozens of models, and they lost hand edits on each sync, because SetTOMLTables replaces the [model."magpie/..."] tables whole.

Grok Build now uses Long conversations, the mechanism Codex and Claude Code already use. grokWindow gives:
- min(window, Compact) when the model or provider has its own threshold;
- otherwise settings.Working(window): 272K by default on longer windows, the typed size, or the whole window with Full context.

What magpie wrote is stashed under grok:<path>:windows, and grokOwnWindow uses it to tell a hand edit apart:
- A value that differs from what magpie last wrote is the user's, and it stays.
- In a config written before the record, a value other than the model's whole window is the user's.
- Disconnect forgets the record.

The agent sheet's Long conversations row now shows for Grok Build (AGENT_PREFS). Its texts, the provider editor's hint, the Context tab's note and `magpie model compact` now name Grok Build, in en/zh/zh-TW/ja/de. setCompact and setAsync now share prefWrite. That dedupe keeps app.js under its budget, which is not raised.

Behaviour change: a Grok Build model whose window is over 272K now gets 272K by default, as Codex does, unless Full context is on.

Run on mote, at this head (c893c2229, rebased on fe05f0a72):
- gofmt -l: 0 files.
- go vet ./internal/{agent,gui,cli,settings}: darwin, plus GOOS=linux and GOOS=windows with -tags nogui. All ok.
- go test -tags nogui -timeout 45m ./internal/agent ./internal/gui ./internal/cli ./internal/settings: all ok.
- GUI agent-prefs, compact-at, compact-one-value, context-tune, context-window, gateway-mode, i18n-keys, settings-general: 202/202 in Chromium and WebKit. The new cases cover Grok's sheet in five languages at 1100 and 440, and in the 360 panel.
- At the pre-rebase head, 104 GUI files the change can reach: 1590/1622.
  - 29 of the reds were browserType.launch timeouts at load 85. Run again one at a time, every one passed, and so did usage-fold.
  - context-map's WebKit 420px "two tiles overlap" is red on origin/main fe05f0a72 too, run alone. It is recorded on #3488.

Broken by hand:
- With the keep logic removed, TestGrokKeepsAWindowSetByHand and TestGrokKeepsAWindowSetBeforeTheRecord go red ("pro 1000000 (set by hand to 300000)").
- With grokWindow returning the whole window, TestGrokKeepsAWindowSetBeforeTheRecord and TestGrokWindowFollowsLongConversations go red ("compact at 300K: pro 1000000").

Not tried:
- A real Grok binary reading the written config. Grok 1.0.67's own help documents model.<id>.context_window as driving auto-compact.
- Linux/WSL and Windows runs. Only cross-OS vet was run.
- Grok App still writes the whole window, and neither agent writes the context_windows choice list: #4117.
2026-10-29 04:43:22 +08:00
yetone f201183047 tune: the compact window is Long conversations, one value for both agents
7eleven (Discord #help): the Usage page's "Tuned for you" compaction
value and the agents' sheet "Long conversations" window were two values
that could disagree. Codex's tune wrote model_auto_compact_token_limit
into config.toml beside the catalog's context_window that Long
conversations writes; Claude's read its own env.

One source of truth: settings.CompactAt / FullContext. Tune's compact
row for Codex and Claude Code now has source "long": its Current is
settings.Compact(), Use calls provider.SetCompactAt (Sync writes Codex's
catalog and Claude's CLAUDE_CODE_AUTO_COMPACT_WINDOW as before), Undo
puts back the CompactAt/Full it stashed under tune.long.compact. So a
value set on either page shows on the other and writes the same config.
writeCompact marks claude.compact_long when the env value came from
settings, so Claude's row reads it as ours, not as the user's.

Migration (Codex Sync, local place): an old tune.codex.compact stash
whose limit is still the one tune wrote moves into Long conversations.
At default or Full it takes tune's value; with a value the user set it
takes tune's only when smaller. config.toml gets the user's earlier
limit back or loses the key; the stash is forgotten. A limit the user
changed after tune wrote it, or wrote themselves, stays and reads
Locked. A provider's Compact at or the user's own Claude env stays
Locked too.

Run (mote, at this tree):
- go vet on agent, provider, gui, tune; GOOS=linux go vet -tags nogui
  ./...; GOOS=windows go vet ./...; go build ./... and -tags nogui: ok
- go test -tags nogui ./internal/agent ./internal/provider
  ./internal/tune ./internal/gui: ok (TestCoreScriptBudget within the
  budget, not raised; context.js is 33 bytes smaller)
- GUI: compact-one-value.test.cjs (new; Chromium and WebKit, en zh
  zh-TW ja de) and context-tune: 104/104 at the rebased head
Broken by hand: the Codex long branch, the Claude long env check and
the Sync migration call each turned red TestClaudeCompactAt,
TestCodexHomeEnvTakesThePick, TestTuneCodexCompact,
TestTuneCodexOwnLimit, TestTuneCodexMigrate (4 subtests),
TestTuneClaudeLong and TestTuneCodexMigrateOnSync. Old context.js and
i18n.js turn compact-one-value red ("You set 272K").
Not run: full suite, Go or GUI (shipped at once per owner; the GUI suite
is still running on mote, reds get their own issues).
Not tried: a real Codex or Claude Code session reading the written
config; the migration on Windows/WSL places (it runs for the local
place only).
2026-10-28 13:52:08 +08:00
yetone f1537d9f95 context: the map counts on as a live request grows, and keeps its tip
The owner asked for the rest of what flohoeller's context map on X does,
keeping the A1 colours. On a live request's redraw:

- Every token count (the big number, the short head, the legend, each
  tile's value) counts on from what it said to the new value over 620ms
  (ease-out), instead of jumping. morph rolls any element with data-n;
  a tile's value rolls as the tile glides. With motion reduced, or on a
  first draw, the value is simply set.
- A tile pointed at keeps its tip through the redraw: the tip is told
  again with what the tile holds now and kept over it while it glides
  (followTip). Before, every redraw closed it.
- A tool's gathered results say how many ("exec_command ×20"), and the
  small files gathered into one tile name the folder they share
  ("api/ · 6 files") where they share one; otherwise "N more" as before.
  "{n} files" is translated (zh, zh-TW, ja, de).

A frame's time can be before the roll's start, which made the first
frame count back (40K, 39.8K, 40.7K); the progress is clamped at 0.

coreScriptBudget: 1,530,631 to 1,533,445: 2,810 bytes of context.js
(which the Routing page draws as well as Usage) and 4 bytes 84c50f032
added to app.js without raising it, which left TestCoreScriptBudget red
on main (1,530,635 > 1,530,631). With no room added.

Run:
- New tests/context-map-live.test.cjs, chromium and webkit, en zh zh-TW
  ja de, at 1100 and 420px, plus motion reduced: 22/22. Broken by hand:
  closing the tip in fill went red ("the tip closed as the request
  grew"); rolls forced quiet went red ("the count jumped: 48K").
- Every context, routing-ctx and i18n GUI file (context-map, -picks,
  -scroll-end, -text, -tune, -window, group-context, i18n-keys,
  routing-context-fold, routing-ctx-fold, routing-ctx-still, and the new
  one): 268/268.
- go test ./internal/gui: ok (220s) before the rebase onto 84c50f032;
  at the pushed head TestCoreScriptBudget, TestAppScriptBudget and the
  TestI18n tests: ok.

Not run: the full Go suite (two other sessions' suites were running on
this machine); the rest of the GUI suite.
2026-10-25 18:28:06 +08:00
yetone 3a47e377e0 usage: a call whose vendor counts no cache is left out of every hit rate (#3464)
#3464 (zeewell on X): Kiro caches on its side, but its replies give only
credits and a context share, never cache tokens. Every hit rate outside
the Routing page read those calls' CacheRead of 0 as a miss. A Kiro-heavy
day showed "hit rate 6%" when the counted calls hit 90%.

The plugin already says so (opencode-kiro-auth 0.1.16 sends
usage.magpie_cache_unknown), and the gateway already kept it as
RouteUsage.CacheUnknown for Routing. This carries it the rest of the way:

- gateway: Usage.cacheNotCounted() (the vendor said so and no try
  reported a cache token) goes into usage.Record.CacheUnknown on every
  path that records a call: the gateway's own record, the OTel attempt
  path in observe.go, and trace's routeUsage.
- usage: Record.CacheUnknown is kept as ledger row flag 8192
  (rowCacheUnknown; grepped, no other flag uses that bit). Totals sums
  such calls' prompt into cache_unknown and counts them in
  cache_unknown_calls. Totals.HitRate leaves that prompt out of its
  denominator, and gives no rate when nothing is left.
- Old records: calls kept before the plugin said so carry no flag. A
  Kiro call (provider kiro or kiro-plugin) with no cache counted is read
  as uncounted (usage.CountsNoCache): in the ledger's row read, in
  Totals, and for Routing's history in internal/gui/trace.go
  (cacheCounted). The rule is scoped to Kiro's two ids, so another
  vendor's 0 stays a miss (tested).
- GUI: cacheHitOf in app.js drives the tray panel's card, the Usage
  page's agent rows and cache tile, the requests' Cache hit rate card and
  each ranking row. When only uncounted calls are left it shows "—" or
  nothing instead of 0%. Otherwise it says "{n} requests left out: their
  vendor doesn't count the cache". A request row's cache cells show "—",
  and its details say the vendor doesn't count the cache. The Context
  page (context.go, context.js) shows no cache for such a call and doesn't
  score it as a miss.
- No budget raised. This adds 625 bytes to app.js (1,320,224 to
  1,320,849, under its 1,321,336); d08b6118b had already moved the
  masking page's maskWho, maskProv and stillMotion out to
  plugins/redact, which an earlier version of this change did too.
- Strings in zh, zh-TW, ja and de. docs/subsystems/provider-plugins.md
  now describes the ledger side and what is not covered.

Not covered, filed: hit rates read from the agents' own session files
(the TUI and CLI session lists, the Sessions tab's totals) still count
Kiro's 0 as a miss (#3470). Found on the way: System One's calls are
recorded without their cache tokens (#3471).

Run at this tree (on origin/main e57e78563, fetched just before; the
54-file GUI run was at a84d2ec80, and the 14 files that main's
redact page change since could reach were run again here):
- gofmt -l . prints nothing. go build ./... ok. go vet ./... ok,
  GOOS=linux go vet -tags nogui ./... ok, GOOS=windows go vet ./... ok.
- go test -count=1 -timeout 45m ./internal/usage ./internal/gui
  ./internal/gateway: all ok (gateway 388s), TestCoreScriptBudget
  included.
- GUI, 54 files (ledger-*, panel-*, i18n-*, context-*, request*,
  usage-card*, usage-ledger and the masking/redact files),
  concurrency 2: WebKit 439/452, Chromium 444/457. The new
  ledger-cache-unknown test passed in both. Again here (ledger-*,
  masking-*, redact-*, mask-*, usage-ledger): WebKit 104/117,
  Chromium 109/122, the same reds. The reds, both already
  red alone on main before this change:
  - redact-words-any-case, 10/10 in each engine (#3500)
  - usage-ledger "newest live route needs no return-to-live button",
    en and zh in each engine (#3104)
- At earlier bases, with the same change: usage-agents-hide (#3414),
  usage-checkin's WebKit Qoder tab (#3091), usage-fold (#3415),
  usage-focus-steady (#3501) were red, each red alone on main too;
  usage-card-refresh read a row before it was laid out, under load
  (#3509); context-picks (#3483) and
  context-map's tile overlap (#3488) in Chromium. Filed while doing
  this: TestUsageReadAfterAppendHashesNothingOnAFineClock goes red
  about 1 in 20 on main aa3112f4e (#3511); it passed in this run.
- Red on the old code: the new Go tests in usage, gateway and gui, and
  ledger-cache-unknown.test.cjs (the old page shows "hit rate 6%"
  where this shows 90%). Each changed piece was broken by hand and
  turned a test red. The exception is the OTel attempt path in
  observe.go, which no test reaches.

Not tried: a real Kiro account through the GUI.
2026-10-25 01:23:42 +08:00
yetone 83234fe920 gateway, gui: the skills an agent lists are their own part, not memory
The owner (10-24, on the Routing context map's "技能 / 记忆 · 9.6K"):
为什么这里又叫技能,又叫记忆?Skill 跟 Memory 应该是不一样的东西. The
gateway put Codex's <skills_instructions> in the memory part beside the
instruction files and reminders, so the tile said Skills of Memory.
Claude Code's skill list wasn't seen at all: it sat in its environment
message, counted as the system prompt.

- gateway: PartSkills ("skills") comes after tools. Codex's
  <skills_instructions> goes there. So does Claude Code's list, from
  "The following skills are available for use with the Skill tool:" to
  the next blank line, taken out of whatever text holds it: its own
  prompt, a harness message or a reminder.
- Routes kept before this (routing history) are read with an item
  tagged skills moved out of memory into the skills part, so old
  requests read the same way. The text view re-reads the body and finds
  them under skills too.
- Usage's context baseline counts skills, as it did inside memory.
  memory-heavy is now instruction files and reminders alone.
- gui: the card has a Skills part (slate, --c7), with its note in en,
  zh, zh-TW, ja and de. The text view's "no longer kept" line is one
  helper instead of two copies of the sentence, which makes the room for
  it under the core script budget, with no room added.

Run (darwin):
- go test ./internal/gateway -run 'Text|Prompt|Context|History|Skill|Route'
  ok; go test ./internal/gui ok; go vet both, gofmt clean.
- New: TestPromptOfClaudeCodeSkills (on testdata/workdir's real Claude
  Code 2.1.296 body: 1502 tokens of skills out of the 2130-token
  environment item), TestSplitSkillsEnds, TestSkillsApartOfKeptPrompt.
  Broken by hand (splitSkills and skillsApart made no-ops): all three
  red.
- GUI, chromium and webkit: context-map 22/22 (new: the skills tile's
  tip names Skills and not Memory in every language, and it isn't
  memory's colour), context-window 24/24, context-text 20/20,
  context-scroll-end 14/14, routing-context-fold 24/24,
  routing-ctx-still 16/16, i18n-keys 4/4.
Not run: the whole GUI suite (load ~400 on the box); a live Codex or
Claude Code request through the real app.
Not changed: the "system prompt, tools and memory" wording of the
baseline's tags, which now count skills too.
2026-10-24 21:03:52 +08:00
yetone 7edf5b0a3d gui: the context window is a map of tiles by default, the block grid a switch away
After flohoeller's "Context map" on X. The Context window card (Usage ›
Context, and Routing's request card) drew its window as 400 cells. It now
draws it as a map:
- Each item is a tile sized by its tokens, inside its part's area
  (squarified, parts in their usual order).
- The tile has a soft fill of its part's colour, its name, and
  "tokens · part".
- The free space is a hatched tile that names its share.
- The used share is drawn on a gentle curve (share^0.35), so a window
  8% full still has tiles to read. The free tile states the real share.

Small items:
- Items too small to read go in one "{n} more" tile.
- A part whose items would leave a strip thinner than 14px is one tile.
- No tile is laid under 700px².

Hover and click:
- A hovered tile tells its item, part, tokens and share (a part's tile
  lists its largest five) and dims the others.
- A row or the legend lights its tiles.
- A clicked tile opens its text, as a cell does.

Motion:
- Tiles come in with a short stagger (opacity, scale .94, blur), over
  560ms with the iOS ease.
- A live update keeps the same nodes and glides them to their new rects.
- Tiles that are gone fade out.
- With motion reduced, or on a still pane, nothing moves.

The block grid is kept. A small segmented switch at the end of the legend
(Context map / Block grid) picks the look for every card, remembered in
localStorage magpie.ctxLook. The card eases to the other look's height.
The new look is the default, and the old one stays one click away (UI
restraint, owner's ask).

The text view shows an image the request sent inline (the gateway's Src,
previous commit), where it said "An image: magpie doesn't show it here".
It fades in, and a click opens it larger with a FLIP scale. An image with
no Src, or one that fails to load, keeps the old note.

Words: "Context map" and "Block grid" in zh, zh-TW, ja and de.

The core budget goes to 1,549,478, the new size with no room added:
context.js is drawn by the Routing page as well as Usage, so it is the
core's own (+14.4KB).

Tests:
- Seven existing tests read the grid's cells. They now pin
  magpie.ctxLook=grid.
- New context-map.test.cjs, in both engines, en/zh/zh-TW/ja/de, at
  1100 and 420px:
  - The map is the default, with a free tile.
  - Every tile is inside the map, none overlap, and none is a sliver.
  - Hover gives the tip and dims the others.
  - A refresh keeps the nodes.
  - A click opens the text.
  - An inline image loads (naturalWidth 2) and opens larger. One without
    Src is named.
  - The switch to the grid survives a reload, and the map comes back.
  - With motion reduced, nothing animates.

Run at this head (rebased on 1f8f80e4a):
- context-map, i18n-keys, context-window, context-text, held-animations,
  routing-live-patch, routing-ctx-fold, routing-ctx-still and
  routing-context-fold, Chromium and WebKit: 130 pass, 0 fail.
- go test ./internal/gui/: ok (TestCoreScriptBudget at the new budget).
- gofmt -l internal/: nothing. go vet: ok, with GOOS=linux -tags nogui and
  GOOS=windows.

Broken by hand, each red in context-map.test.cjs (restored after each):
- pieceView never showing the picture.
- The grid as the default.
- The thin-strip rule removed ("two tiles overlap").
- drawMap ignoring calm() (the reduced-motion test).

Looked at: screenshots in light and dark at 1100 and 420px, at 8% and 90%
full.

Not run: the whole GUI suite (it runs after the push), and the real Linux
app (WebKitGTK).
2026-10-24 18:40:01 +08:00
yetone 1acd79cdfc usage: a compaction window picked past the leanest band isn't called the leanest, and offers the band (yapechan on Discord)
yapechan (Discord #general, 10-17 05:21Z): after picking another auto-compact
threshold outside the cheapest range, Context still said "已是最适合你用法的
最省配置"; they asked for the hint to change and for a button that sets it.

Cause: /api/tune does read the value the user set (TuneRead -> Current). With
the agent's compactions timed, tune.Compact's advice never waits longer than
the window now, so a larger window comes back as its own advice (best ==
current) and the row's chip said "Already the leanest". A probe of
tune.Compact on TestCompactTimedWaitsLeast's fixture: 400K picked -> best
400K at +16% tokens over the cheapest (250K); 1M -> best 1M at +96%.

Fix (context.js, adviceRow): the leanest band is the curve's windows within
3% of its cheapest, tune's own sameCost. A timed row whose window costs over
3% past the cheapest now says "Not the leanest: {band} spends the fewest
tokens" (info chip, not the green one, also when magpie set the value), keeps
the caveat, and has a "Use {value}" button for the band's largest window, the
one of them that compacts least; its tooltip says it means more compactions
to wait on. A window inside the band still says it is the leanest, with no
button. Untimed rows are unchanged: their "same" already means within 3%.
New strings in zh, zh-TW, ja and de.

What was run (macOS, load average 300-375 throughout):
- New test context-tune.test.cjs "a window picked past the leanest band isn't
  called the leanest": both engines x 5 languages x 360/1100px, 92/92 pass
  for the whole file at this head. Broken by hand: old context.js -> FAIL
  "expected 'Not the leanest: 230K–270K…' actual 'Already the leanest…'";
  band test made unreachable -> same FAIL in WebKit; chip class back to
  "applied is good" -> FAIL "expected 'ctx-chip info' actual 'ctx-chip good'".
- GUI files run one at a time, all ok: context-picks, context-scroll-end,
  context-text, context-tune, context-window, gui-de, gui-ja, gui-zh-tw,
  i18n-keys, usage-range, account-alias, account-arrange.
- Whole GUI suite NOT completed: a combined run of all 794 files died
  partway (2358 test points, 37 not ok, all page.goto/90s timeouts in
  unrelated pages under the load); a per-file rerun did ~33 files in 30
  minutes and was stopped. Its two reds (account-alias, account-arrange,
  timeouts) pass alone.
- gofmt -l: clean. go vet ./..., GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: clean.
- go test -tags nogui -timeout 45m ./... under pipefail at 161030972 (this
  change on 72ed518bc): every package ok except internal/agent (45m timeout,
  2703.8s, #2544), internal/gateway (45m timeout, 2717.0s, #2108) and
  internal/gui TestSetAnswersWhileDevinAndProvidersHang (10.0s, then 55.1s
  alone; #1375). No Go code differs from main; numbers added to each issue.
2026-10-17 23:06:58 +08:00
yetone 3c7ec4ba24 gui: Usage is a plugin's page, its code, markup and words in plugins/usage (P2)
P2 of docs/subsystems/plugin-runtime.md, the fourth page after Sessions,
Library and Routing, and the largest part of app.js.

- The Usage page's code (~3000 lines: the Overview's cards, the
  Requests ledger and heatmap, the Sessions tab, the Agents list) moves
  from app.js to assets/plugins/usage/page.js; its markup, index.html's
  <main id="view-usage">, is client.js's part html. app.js 25756 →
  22675 lines (1,355,376 → 1,198,239 bytes).
- page.js builds on app.js at the top level (its timers, ?view=usage's
  tab and filters), so it is the one plugin script that loads after
  app.js. index.html: kernel.js, the plugins' other scripts, app.js and
  the scripts beside it, each page.js, then start.js, which is app.js's
  old tail (magpie.start(), navHides, OPEN_VIEWS, the first page shown,
  load()), so the first page has its code. TestBuiltinClientsLoaded
  holds that order.
- Hooks: open loads it, refresh(again) is load()'s read of it, reload is
  Refresh now, costs redraws costs on a currency change, tab says the
  tab for focusQuotaCard. app.js calls those through magpie.call. The
  allowance cards, quotasOpened, panelQuotaFocus and panelUseFocus stay
  in app.js: the tray panel draws them too.
- plugins/usage: Essential, Requires window, no InUse. Off, its nav tab
  goes and so do the ways to it (data-feature="usage": the panel's Open
  Usage, Routing's View usage); show("usage") gives way to Agents; the
  panel's Allowances tab stays. builtins.test.cjs switches it off and
  checks each.
- The 173 strings only Usage says move to plugins/usage/i18n.js;
  i18n.js 15032 → 14344 lines. "{n}s" and
  "All sessions" stay: context.js says them too since #1591.
- context.js: with context.js now in before the first page is shown,
  the page's open and load()'s first refresh both reached loadContext,
  and the second drew "Reading…" again over the advice the first had
  just drawn, so its curves never played their entrance (context-tune,
  3 of 3 red). loadContext draws the waiting pane once for the same
  days. Its dead last line, which loaded the tab once context.js came
  in late, goes.
- context-window.test.cjs's "arrives after the state" becomes "loads at
  once though context.js is slow": start.js now waits for it.
  usage-stale-answer reads page.js beside app.js. quota-refresh-order
  (#1630) cut app.js at the period picker's comment, now in page.js; it
  ends at the next comment that stays (5 of 5; without keepRefreshedQuotas'
  call, 2 of 5 red).
- docs: plugin-runtime.md, gui-shell.md.

Run, at this tree on origin/main af27b70b4 (main's keepRefreshedQuotas
and quotaRefresh changes, #1630, stay in app.js beside loadQuotas: the
tray panel draws those cards too):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -count=1 ./internal/gui ./internal/pluginrt ./plugins/...: ok
  (-skip TestMainWindowCorners, #1936); gateway and usage as above.
- usage-card-refresh, quota-refresh-order, builtins, editor-picker-clicks,
  context-window, usage-stale-answer: Chromium and WebKit green.
- The full GUI set: see the Routing commit; every Usage red there is the
  same on main or red only under load.
2026-10-15 01:32:13 +08:00
yetone eb7199e120 gui: Routing is a plugin's page, its script, style and words in plugins/routing (P2)
P2 of docs/subsystems/plugin-runtime.md, the third page after Sessions
and Library.

- routing.js and routing.css move to assets/plugins/routing/ (client.js,
  routing.css). Its part's html is the page's head and boxes that were
  index.html's <main id="view-routing">; the rest is drawn by
  routingPage, run at mount since it builds on app.js. It keeps itself
  after that as it did (its own hidden, the language, focus), so its
  hooks are dirty and discard, a routing group being edited, which
  show() and the window's close ask through magpie.call:
  window.routingDirty and discardRouting are gone.
- plugins/routing: Essential, Requires window and gateway, in use while
  the user has a routing group (not Auto, not Hidden), since the page is
  where it is edited. The gateway routes the same with it off.
- With it off, what leads to the page goes too: the nav and panel tabs
  and the panel's section (data-feature="routing"), the guide's Open
  Routing, Providers' "Make a routing group of …", the Usage list's
  View routing and its time as a link, the context card's Latest
  request. A panel left on its Routing tab shows Agents.
- What other pages use of it stays on window: openRoute (context.js),
  kindName, swapWhy, routedWhy (Usage's Requests), newGroupWith
  (Providers), panelRoutingShown (the panel).
- The 505 strings only Routing says move from i18n.js to
  plugins/routing/i18n.js (4 languages); i18n.js 17048 → 15032 lines.
  The plugin's own name and line stay in i18n.js: the Plugins page
  says them with the plugin off (TestBuiltinsTranslated).
- Tests and comments that named routing.js name the new path (gateway's
  antigravity_rest and loop_guard, codeassist.go, usage.go,
  web_compress, group_member_info, assets_revalidate, font-cascade,
  win-fonts, three routing-*.test.cjs). builtins.test.cjs and
  builtins_test.go count seven built-ins and switch Routing off: its
  tabs go, the page shown stays.
- docs: plugin-runtime.md, gui-shell.md, gateway-routing.md.

Run, first on origin/main 3ec45e715, then after rebasing onto af27b70b4
(main's routing.js, css, app.js and i18n.js changes since were carried
into the moved files; its new Routing words, as the rules' conditions,
are in the plugin's i18n.js):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -count=1 ./internal/gui ./internal/gateway ./internal/usage
  ./internal/pluginrt ./plugins/...: ok (gateway 1800s under load,
  -timeout 45m; gui with -skip TestMainWindowCorners, #1936).
- All 193 GUI test files, 3 at a time at load ~250, Chromium and WebKit,
  at the Usage commit on 743fcc035: 185 and 186 green. Every red run
  alone here and on a just-fetched origin/main c524bc018:
  - the same on main: routing-model-rest (#2115), routing-wb-restricted
    (#1905), usage-agents-hide (11 of 16 in both, #2211), usage-fold
    (#2163: 12 of 14 here, 9 of 14 on main over 7 runs, the same 4px),
    quota-count-wrap and quota-name-translated in WebKit (#2228);
  - red only under load, green alone on both: routing-flood (#2215),
    routing-log-icons, usage-ledger (#2211), and three plugin-* files
    whose tree was rebased under them mid-run.
- days-fit, failed-open, side-calls and burst-speed, red on main after
  cf455ebd5, are fixed before this commit (#2134, d692b2548).
2026-10-15 01:32:12 +08:00
yetone e1dcd1e1d7 tune: a compaction window advised never makes you wait longer on compactions, and says the wait (HirotaNagai on X)
Tuned for you advised the compaction window by tokens alone, so a smaller
window that compacts far more often could be advised however long each
compaction keeps the user waiting.

What changed
- sessions: a call now carries how long a compaction took (Call.Compact).
  Claude Code's compact_boundary line gives compactMetadata.durationMs,
  which goes on the first call after it that isn't an error. Codex compacts
  by a call of its own (the token_usage_record a compacted line names), and
  that call's own time is the compaction's. Older rollouts with no such
  record stay untimed. callCacheVersion is now calls-v13.
- tune: with 3 or more compactions timed for a model (minTimed), Facts.took
  is their median in seconds, and each window's Point.wait is its
  compactions x took. When compactions are timed, the advice never takes a
  window that compacts more often than the current one. Of the windows that
  don't, it takes the cheapest, and of those within 3% of that (sameCost)
  the one that compacts least. Tokens and seconds share no unit the files
  measure, so magpie doesn't trade one for the other at a guessed rate. The
  token-cheapest window is reported (cheapest, wait_cheapest) so the user
  can pick it. A model with fewer than 3 timed compactions is advised as
  before, with no wait shown.
- GUI (Usage > Context): when timed, the advice is labelled
  "Tokens + wait". The explanation says what a compaction took, the wait at
  the advice against the window now, and the cheaper window that would wait
  longer (if it saves 3% or more). The caveat says tokens and waiting only.
  The picker shows each window's wait, with "Fewest tokens" on the
  cheapest. Untimed rows are unchanged. The new strings are in zh, zh-TW,
  ja and de.
- docs/subsystems/agent-wiring.md describes the timing sources and the
  rule.

What was run
- go test -tags nogui ./internal/sessions ./internal/tune ./internal/gui
  ./internal/agent pass.
  - internal/agent ran before the rebase. It took 1416s under a load
    average of 120-300 and passed with -timeout 40m (the default 10m timed
    out mid-suite). Its Tune/Compact/CacheTTL tests pass on their own.
  - sessions, tune and gui ran again after rebasing on origin/main
    331c27703. fcd6f3519, the head this was pushed onto, touches none of
    these files.
  - internal/gui's TestProviderListReadsSettingsOnce failed 1 of 3 runs
    under load (7.0s against its 2s bar). It passed 6 of 6 on this branch
    and 9 of 9 on origin/main 4048ead7f, and it doesn't touch this code.
    Filed as #2185.
  - TestCallsClaudeCompactTook and TestCallsCodexCompactTook check the
    timings, also after Reset.
  - TestCompactTimedWaitsLeast checks the advice from 1M, 600K and 150K.
    With the timed rule disabled it fails ("advised 260000 makes 36
    compactions, more than 4 now").
  - TestCompactUntimedUnchanged checks that 2 timed compactions give the
    same advice as none, with no wait.
- GUI: context-tune, i18n-keys and context-window pass, 97/97 in Chromium
  and WebKit, in en/zh/zh-TW/ja/de at 360 and 1100 px. The new timed test
  fails against the old assets ("Fewest tokens" where "Tokens + wait" is
  expected).
- gofmt -l is clean. go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./... are clean.
- Real data, from copies of the owner's 4 Codex rollouts and 8 Claude
  transcripts in a sandbox HOME:
  - Compactions took 28-46s (opus-5-5), 85-139s (fable-5-1) and 52-121s
    (Codex gpt-5.6-sol).
  - gpt-5.6-sol keeps 230K. Before this change it was advised 70K: 44%
    fewer tokens, but about 3.5h of waiting against 30m.
  - opus-5 moves 200K to 190K, with 6% fewer tokens and the same wait.
  - Untimed models are unchanged.

Not tried: the live app with real accounts. The replay assumes a
compaction takes the same time at every window, since the files only time
compactions near the window the user ran with.
2026-10-14 20:03:53 +08:00
yetone bfef5d51b5 gui: Routing is back to v0.1.1231's layout; reverts dae2618ad (#1354)
v0.1.1233 shipped community PR #1354 (dae2618ad), which put "How the
last request was routed" in a right column beside the stage on wide
windows, split the context card into overview/contents columns, and
replaced the context card's own head with one lazily built disclosure
header. Two users on Discord asked for the old page back: wongxy
("这是哪个人才要改成这样的,丑死了", "UI方面的需求响应要克制一点", with a
screenshot of the new page) and molvqingtai ("v0.1.1231 没有这个问题").
The owner delegated the call: Routing goes back to v0.1.1231's look.

Only the lazy construction of the context body was a candidate to keep,
as it is invisible. It doesn't separate cleanly: it is built on the new
unified header (ctxSummary in the closed state, ctx-body/ctx-overview in
the open one), which is itself the visible change. So this reverts
dae2618ad whole: assets, its doc section, its README entry, the new
routing-context-layout test, and the test edits that existed only for
the new layout (wheel-scrolling to rows the right column pushed down,
mobile-web's skip of Routing in the pixel comparison). No later commit
on main is a follow-up of it.

Later commits touching the same files are kept: 20350dafa's subagent
reason in routing.js and README entry, a7a38193f/5fc2f87d1's gui-shell.md
lines, 00afcf97a's README entry. routing.css and context.js are now
byte-identical to v0.1.1231; routing.js differs only by later features
(#1068 folders, subagent reasons).

Run (worktree on origin/main 3ec45e715 + this revert):
- Routing page screenshots against v0.1.1231's assets with one counted
  request (the .rt card): Chromium and WebKit, en/zh/zh-TW/ja/de, 1100
  and 420 wide, plus 1440/1800 in en/zh: 0 pixels differ in all 28.
  origin/main differs in all of them (the folded header, the columns).
- node --test routing-*, panel-routing*, group-fold, held-animations,
  phone-rows, context-*: 1025 of 1034 pass. The 9 reds are
  routing-keys-fold's "a request that comes flies to the fold" (WebKit,
  and Chromium de) and routing-model-rest's "Try now" reach. Both files
  run alone fail the same way on origin/main bda271999 (12 fails there,
  11 here, different cases of model-rest each run), at load average
  ~350 from other sessions; filed as #1612 and #2115.
- mobile-web (pixel baseline) with BASE_REF=dae2618ad^: every phone
  case and Routing's desktop compare pass; the 8 reds are all Settings,
  changed since by #2073's colorblind switch, not by this.
- gofmt -l, go vet (darwin, linux nogui, windows) and
  go test -tags nogui ./internal/gui pass.
Not tried: the native Wails window; the complete GUI suite.
2026-10-14 18:07:59 +08:00
Zhu Wang dae2618ade gui: make the Routing context lazy and align wide cards (#1354)
* gui: make the Routing context lazy and align wide cards (#1354)

Rebuild the context and wide-layout change on main e1b70c13 following
the Oct 13 review. Keep the complete request story, original heading,
visible stage caption and main's unchanged line/logo retention.

Use one context header, construct its body only while open, migrate the
existing fold choice and retain live card updates and the text viewer.
Align the stage/story and overview/contents splits within the page's
existing width cap. Keep the narrow stage sizing and prevent flex shrink
from moving the header when context contents appear.

Three-platform vet and builds and the sandboxed nogui suite passed.
Base assets fail the new context test because a closed card constructs
the detail grid (1 instead of 0). Focused disclosure checks passed;
the complete GUI suite is still running and is tracked in the PR body.

* gui tests: exercise the new Routing layout with user scrolling

Open the lazy context explicitly for its retained-animation check and wait for page entrance animations as well as cells. Reach the group Cancel button and history day with user wheel input rather than relying on forbidden click scrolling. Until the baseline contains the new Routing wrapper, keep its intentional desktop layout out of the unchanged-page pixel comparison; the focused layout matrix covers it and mobile fit still checks Routing.

Validation: group-fold and held-animations passed all 8 cases; phone-rows passed all 10 cases across five languages and both engines; mobile-web passed all 30 cases. git diff --check and JavaScript syntax passed. The complete GUI suite is still being recorded on unchanged d6d5738a assets. Library switch failures are independently reproduced on e1b70c13 assets and tracked by upstream #1609; they are not claimed as passing.

* gui tests: scroll to narrow Routing history before selecting it

The visible full request story can leave a historical request below a narrow window. Reach the day and request row with wheel input before selecting them, while retaining the app scroll guard and all cancellation and failure-colour assertions.

Validation: all 37 checks in routing-agent-gone and routing-agent-hue-not-red pass across both engines, four/five languages and 420/1100px widths. The whole GUI run had exposed the two WebKit German 420px click-scroll failures. git diff --check and JavaScript syntax passed.

* gui: keep context disclosure usable while the next prompt is read

Keep the last available live prompt separately from the render key. Opening or closing the unified header can redraw that carried context while a new request has no prompt yet; clearing a render key for a disclosure no longer removes the entire card. Explicitly picked requests still start fresh, and unavailable or completed requests clear the carried data.

Validation: before the fix, the new pending-prompt disclosure regression fails because the carried context becomes invisible. After the fix, all 134 context disclosure, saved-choice, Usage-link, live patch, every-frame and provider-logo checks pass in Chromium and WebKit across five languages and desktop/phone widths. Native macOS, Linux nogui and Windows builds, syntax and git diff --check pass. The complete GUI run is recorded separately with unresolved existing failures linked in the PR description.
2026-10-14 15:27:59 +08:00
yetoneandump45nose f2c30a8859 usage: the tags over the Context curve's dots never print over each other either (#1549)
The previous commit keeps the axis labels apart. The tags over the dots
had the same fault: a setting one step from the advice printed its
"+3%" on "Leanest", and a setting one step from the costliest value
printed "+147%" on "+150%". The tags now go by the same rule, "Leanest"
first, then the setting now, then the costliest: one within 16% of the
axis of a tag that matters more and at about its height (20 of the
plot's 100 units) keeps its dot and tooltip but not its tag.

Run: context-tune's overlap test gains a row whose setting sits one step
from the advice, checks the tags' boxes as well as the axis labels', and
runs in German ("Sparsamste", the widest "Leanest") as well as English,
at 360 and 1100px. With the previous commit's context.js it fails in
chromium and webkit ('en 360px: tag "+150%" overlaps "+147%"'); with
this one it passes. The axis test alone failed on main before the
previous commit ('360px: "160K" overlaps "170K"'). context-tune,
compact-at and context-window: 80/80. 56 context/usage/language GUI
files in both engines: 652/654; the two reds are usage-ledger's route
export (passes 3 of 3 alone, filed as #1876) and, in an earlier run,
usage-sum-whole at 780px in German (#1864, noted there); neither reads
context.js.

Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
2026-10-13 06:18:27 +08:00
ump45nose 9f54b6428e usage: the Context tab's curve no longer draws the leanest value's label over the axis's first one when they sit a step apart (#1549, Ti800)
The axis labels the advice's value, the setting now and the range's two
ends. One that sits within 16% of the axis of one that matters more (the
advice first, then the setting now, then the ends) is left off, so two
labels are never drawn over each other: 170K one step from 160K read as
"1170K".
2026-10-13 06:18:27 +08:00
yetone 0102915fe0 gui: Tuned for you lets a compaction window be picked, each with its estimated extra tokens and compactions (#1860)
MrMengJ applied the advised 200K auto-compaction window and wanted 250K or
300K instead, seeing what each costs against the cheapest. A compaction
row now has "Other window…", which opens the app menu (never a native
select) with every value of the curve the card already replays. Each says
its estimated extra tokens over the fewest (or "Fewest tokens" / "As few
tokens") and about how many compactions it would have made over the range.
The head says it is estimated from the reader's calls. The one picked is put
in through /api/tune/apply like Use, with Undo.

tune.Point gains compacts, counted by the same replayCompact that prices
the point, so tokens and compactions come from one model.

Run: go test ./internal/tune ./internal/gui; TestCompactCurveCountsCompactions
(compactions fall as the window grows; the last point is close to
Facts.Compacts). gofmt -l; go vet internal/tune on darwin, linux -tags
nogui, windows. GUI: context-*, gui-zh-tw/ja/de, compact-at, click-scroll,
i18n-keys in chromium and webkit, 144 pass. The new context-tune test covers
5 languages at 360 and 1100px: menu inside the window, 300K ticked, notes
for 250K and 160K, picking 250K posts apply with no page scroll, Escape
posts nothing. On HEAD~ assets context-tune fails 22 of 23.
Not run: against a real Claude Code settings.json (the apply path is
unchanged from Use).
2026-10-13 04:31:07 +08:00
yetone 6e5f4fc97f gui: Tuned for you names its advice "Fewest tokens" and says a compaction window is a token estimate, not what the agent keeps (#1854)
cnlove7777777-art: the card called 230K -> 150K "best for you" on token
savings alone, while compacting sooner may lose more of a long coding
task. A retention benchmark isn't built now; the card says what it
measures instead:

- the advised value's label is "Fewest tokens", not "Best for you";
- a compaction row that advises a change adds "A token estimate only: it
  doesn't measure how well the agent keeps the task after a compaction.
  The lower the window, the more often it compacts." Not on a window
  already the leanest, nor on the cache lifetimes.
- zh, zh-TW, ja, de translations; agent-wiring.md says the same.

Run: context-tune.test.cjs (new assertions on label and caveat) passes in
Chromium and WebKit, 360 and 1100 wide, en/zh/zh-TW/ja/de; on
origin/main's assets it fails 11 of 12. context-*.test.cjs, gui-zh-tw,
gui-ja, gui-de, compact-at, i18n-keys: 99 pass, 0 fail. Not tried in the
real app window.
2026-10-13 04:31:07 +08:00
yetone 31c1e3ab1c gui: dates, times and numbers read in the GUI's language, not the system's, so a Chinese Mac set to English no longer shows Routing's days as 10月11日 周日 (#1843)
What changed: intlLang() was the GUI's tag for Intl, but returned
undefined for English ("the system's own formats"), and about 60 calls
in app.js, routing.js, library.js, plugins.js, caller-keys.js and
context.js formatted with no locale, [] or undefined anyway. All of
those follow the system's locale, so with magpie set to English on a
zh-CN Mac, Routing's day pills read "10月11日 周日" (the report), and so
did request times, reset/until titles on Accounts and Usage, plugin and
library dates, the restore notice, and key rest times. Now intlLang()
always returns a tag: zh-CN, zh-TW, ja-JP, de-DE for those languages,
and for English the system's own English (en-GB keeps day-month) or
plain "en" on a system in another language. Every date, time and number
formatting call in the assets takes intlLang(); the `intlLang() || "en"`
and `documentElement.lang || undefined` variants are folded into it.
<html lang> stays "en" for English. Routing's clock formatters, made
once, are made again when the language changes.

Tests: dates-gui-lang.test.cjs runs English on a zh-CN browser, English
on en-GB, and zh, zh-TW, ja, de on en-US, in Chromium and WebKit at
1100 and 390px: Routing's day pills (in the bar and under its menu) and
a request's time must read in the GUI's tag and not the browser's.
TestDatesFollowGUILanguage (Go, so CI runs it) fails on any formatting
call in the assets given no locale, [] or undefined.
github-token and reset-each-title computed their expected text in the
browser's locale, i.e. they encoded the bug for zh/ja/de; they now ask
intlLang().

Run: with routing.js put back to origin/main the new GUI test fails 10
of 12 (all but en-GB, where the system's English is right either way);
with intlLang() returning undefined for English the English cases fail.
TestDatesFollowGUILanguage fails on origin/main's routing.js (lines 244,
688, 1925, 2230, ...) and passes on the fix. gofmt -l clean; go vet
./internal/gui on darwin, GOOS=linux -tags nogui and GOOS=windows ok;
go test -tags nogui ./internal/gui ok. Full GUI suite (621 files,
concurrency 6): 51 failures in 21 files; rerun alone, the same 8 files
fail the same way on an origin/main 552e974f2 copy (gui-ja,
library-mcp-tools, pick-skills, profile-in-use, routing-group-fold,
routing-sessions, searcher-pick, text-size), signin-proxy failed once
under load ("element was detached", de 380) and passes 3/3 alone, the
rest pass.
Not run: not tried in the real app on a zh-CN Mac; no Windows or Linux
webview run.
2026-10-13 02:14:10 +08:00
yetone 18e82adc62 gui: the window's pages down a sidebar in groups, the open page's tabs under it, and a button to have the header's tabs instead
From 1024 points wide (SIDE_AT) the window lays its pages down the left
as a Mac app's sidebar: Work (Agents, Sessions, Library), Models
(Providers, Routing, Gateway), Insights (Usage), Extend (Plugins), with
Settings and the gateway's address at the foot. The open page's own tabs
(Usage, Library, Plugins, Settings) are listed under it, opening and
folding on an iOS-like spring, and the page's strip is hidden. The header
becomes a breadcrumb, and pages whose head held only tools have them in
the title bar. Graphite: the open page is in the text's ink, not purple.
A pressed row darkens and never shrinks. The selection under the tabs
sets off as the row is pressed, on a 0.3s curve (it felt behind the
finger), and is the list's only shape: a sub-row hovered or pressed has
no ground of its own, which showed a block under the finger before the
selection slid there. The page's tab is clicked at once, so what is
typed next goes to it.

The title bar's button (or ⌃⌘S, Ctrl+Shift+S), there at every width,
picks the sidebar or the header's tabs. The choice is kept in
localStorage magpie.navLayout (side or top) at every width, so it is laid
out from the first frame; picked in a narrow window the sidebar is 184
points under 860. The two trade places in
a view transition: the sidebar slides, each tab flies to its place, and
the page slides as one. Without view transitions or under reduced
motion, the change is at once.

With nothing picked, narrower than 1024 the page beside a sidebar would
be narrower than Usage's requests table needs, so the header's tabs come
back. A resize
drops what a click held (heldWidth). Usage's KPI strip goes two to a line
by the room the page gives it (a container query), and Japanese counts
wrap there. Tests whose window is 1024+ were updated for the sidebar,
and docs/subsystems/gui-shell.md says how it works.

Run: sidebar.test.cjs and side-toggle.test.cjs 16/16 in chromium and
webkit, in en, zh, zh-TW, ja and de. Each was broken by hand (press
shrink, address cut, press glide, sub-row ground, view transition, kept
choice) and went red. Every page at 560 points with the sidebar picked,
zh and de, both engines: nothing scrolls sideways. session-identity's
ledger row sits under the footer beside the sidebar; WebKit's click
doesn't scroll to it, so the test wheels it up first. Animation frames were checked from a recorded video. The 105
affected GUI files in both engines; their reds were rerun alone and fixed
(filter-ime: the sub-row's click now at once; session-identity, above) or
fail the same on main (tray-logos). The full GUI suite in chromium, on
the rebase onto d5cae267a, was cut short at 352 tests on the owner's
"ship": 6 reds (account-alias, account-models, codex-auto-review,
codex-credits, context-text) each pass alone, here and on main d5cae267a,
so they are timing under the full run's load and are to be filed. After
rebasing onto e4e22b23e: sidebar, side-toggle, session-identity,
filter-ime, library-instr-busy, usage-speed-count and view-scrollbar,
50/50 in chromium and webkit. go build ./... passes.
2026-10-12 00:41:34 +08:00
yetone a98ab77fde gui, gateway: a context window's part, cell or item clicked opens the text the request sent there (masaka)
masaka on Discord asked to see the whole context behind the context window
card: click the agent's prompt, or any other part, and read it.

What changed:
- gateway: the trace keeps the last 10 request bodies in memory only
  (promptBodies; at most 32 MiB each and 64 MiB together, oldest dropped
  first), masked as the vendor got them. For a model the user let have
  the request unmasked, the masked copy is kept all the same. Never
  written to disk, never in telemetry. Route.Prompt and the routing
  history keep names and sizes only, as before.
- gateway: Server.PromptText re-reads a part's items and their text from
  that body (prompt_text.go). promptBuilder gains a keep mode that records
  each item's pieces: system text, tool definitions laid out as JSON, each
  turn's user/thinking/assistant/call pieces, tool results, and images
  or sealed reasoning named with their size. Sizes are unchanged.
- gui: GET /api/context/text?id=&kind=[&item=] (no-store; 404 "not kept"
  when the body is gone or another process serves the gateway).
- gui: in the card, a legend part, a waffle cell or a content row
  (click, Enter or Space) opens a wide modal: one item alone with "All of
  {part}", or the part's list 100 rows at a time, each item's text
  fetched when it is opened and shown 20000 characters at a time, with
  copy buttons. Strings in zh, zh-TW, ja and de.
- docs: gateway-routing and gui-shell subsystem pages; the site's start
  page (en, zh, ja) says the text is kept for the last 10 requests in
  memory and sent nowhere. The README Privacy is unchanged, since nothing
  more is sent.

What was run:
- go test -tags nogui ./... (temp HOME). internal/gateway hit the 10m
  default under the full parallel run, in TestRequestTailAfterOldLimit,
  which takes 57s alone on the base commit too; the package run alone
  with -timeout 30m: ok (700s, the machine shared with other runs). Every other package: ok.
- New tests TestPromptTextIsWhatWasSent, ...KeepsOnlyTheLastBodies,
  ...ChatPieces, TestContextTextAPI. Broken by hand: keeping the unmasked
  body fails (the key shows), and dropping keepBody fails ("not kept").
- gofmt -l; go vet, GOOS=linux and GOOS=windows go vet on internal/gateway
  and internal/gui.
- GUI: tests/context-text.test.cjs in Chromium and WebKit, en/zh/zh-TW/
  ja/de, at 1100 and 420px: legend, row, cell and keyboard open the text,
  long text grows on demand, the page never scrolls, and a gone body is
  named. It fails with the click wiring removed. Under a load average of
  ~140 one case failed once: the test read the list while the dialog
  still said "Reading…". Reproduced with a 400ms reply, fixed by waiting
  for the list; the mock now always answers after 200ms. A second case
  ("a click doesn't move the page", 662 vs 605 on the contents row) came
  from taking the page's top while a wheel scroll was still easing: the
  test now wheels to the row like the other cases, and wheelTo waits for
  three equal looks. Four full runs at load ~150 then passed (80 cases). context-window,
  i18n-keys, held-animations and the modal tests (dialog-backdrop-drag,
  editor-short-window, readable-focus, ux-safety, whats-new, add-sheet,
  api-key-theme) pass in both engines.
- Real use: a sandbox magpie (own HOME, ports 3486/3487, the Codex login)
  served a real `claude -p` (Claude Code) request on codex/gpt-6-luna
  that read a file. In its web UI, Usage > Context: each of System
  prompt, Tools, Memory, Files and Conversation, a waffle cell and a
  contents row opened the request's real text (Claude Code's system
  prompt, 21 tool definitions, the CLAUDE.md reminder, main.go's Read
  result, the turn with its thinking and call). No page errors.
2026-10-11 00:49:01 +08:00
yetone 05ed5e69ba context: Tuned for you's curves draw themselves once, not again each time the pane is redrawn
The Context tab redraws the whole pane whenever the advice answers, the
routing history answers, the state changes or a setting is put in. Only
loadContext marked the pane "still", and only when a new history replaced
an old one, so on opening the tab every curve played its entrance two or
more times (the owner saw them play "好多次"), and the history's cards
replayed theirs when the advice came in after them.

renderContext now remembers whether its last draw showed the history and
the advice: what was on the pane already holds still (.still for the
history, .tune-still for the advice), and only what is new plays. A range
change clears both, so the new range's draw plays once.

Run:
- new test "the advice's curves play their entrance once" (chromium,
  webkit): red without the change (8 draws of 4 curves in both), green
  with it.
- context-tune, context-window, context-scroll-end, group-context,
  routing-ctx-fold, routing-ctx-still: all pass in both engines.
- routing-context-fold: 2 WebKit failures, the same on origin/main without
  this change (the sticky header covers the fold button), filed as #1529.
2026-10-11 00:22:41 +08:00
yetone 27e69702e1 context: Tuned for you draws each setting's cost as a curve over the advice, its waste shaded, the window set now saying how much more
The small sparkline had no scale: it couldn't show how much a setting
costs over the one advised. The curve is now the row's width and measured
from the advice's own cost (tune takes the largest window within 1% of the
cheapest, so the cheapest point is not the level): the area over the
advice's dashed level is what the other settings spend past it, the window
set now and the costliest say how much more (+%), and the advice is marked
Leanest. The cache lifetimes get the same chart for their two choices, and
it shows at a phone's width too. The section note sits closer to its
heading and further from the cards.

Run: context-tune.test.cjs in Chromium and WebKit, every language, phone
and desk widths (22/22), with checks on the set window's +% and the
advice's level; a shot of the owner's real 7-day /api/tune.
2026-10-10 18:25:14 +08:00
yetone 9e665491ec context: Tuned for you — each agent's settings worked out from the user's own calls, for the fewest tokens, put in on a click and undone on another
The Context tab now replays the period's calls of each agent against the
settings that decide what they cost, and shows, per agent and per model,
the value that would have used the fewest tokens for how this user works:
Claude Code's auto-compact window per model (modelSettings.<model>.
autoCompactWindow), its main and subagent prompt cache lifetimes
(promptCacheTtl, subagentPromptCacheTtl: 5m or 1h), and Codex's
model_auto_compact_token_limit. Each row says where the value comes from
now (the agent's default, the user's own setting, one magpie set, or a
variable that comes first and locks it), why (how fast conversations grow,
what a compaction leaves, how long the user pauses), the cost curve, and
the saving. Nothing is written until "Use …" is clicked; what was there is
stashed and Undo puts it back, unless the user changed it since. A window
the user set past the model's own is shown capped, as Claude Code caps it
(min(setting, model window)), so no saving is claimed that wouldn't happen.
Advice under a 3% saving is "already the leanest".

On the owner's 7 days (88K Claude Code calls, 956 Codex): opus keeps 200K
(their 500K is capped to it), fable 5.1 200K → 160K saves 5% (2.56M
tokens), both cache lifetimes and Codex's 272K are already the leanest.

Run: go vet ./... and go test ./... pass (internal/tune, internal/agent
TestTune*: user-set values kept, env locks, undo after a user edit, TOML
key order). context-tune.test.cjs passes in Chromium and WebKit, en/zh/
zh-TW/ja/de, at 360 and 1100px (22); context-window, context-scroll-end
pass. Full GUI suite: library-servers-bulk and market-have failed once
under load and pass alone; market-have fails on origin/main 494dedcf too
(1 of 8 runs). Claude Code 2.1.296 in a sandbox config dir shows
"Auto-compact window for Fable 5.1: 160k tokens (from settings)" for the
written modelSettings key. The real-data advice was read from the owner's
own ~/.claude and ~/.codex, nothing written.
2026-10-10 15:05:53 +08:00
yetone 666c0fa4fd routing: the context window holds still while requests stream in, and the prompt-cache card shows the last request's hit, dimmed, or a dash with the reason instead of "——命中" and an empty bar (dumplings on Discord)
dumplings reported that on Routing, every new request made the context
window jitter and flash, and that the prompt-cache card read "——命中",
glued together, with an empty bar under it.

Causes, measured with a frame sampler while requests stream through
start/read/done:
- A live request's story is shorter than a finished one's. "Is
  answering…" becomes "answered in 4.0 s…", which wraps onto two lines
  at phone width. The log head also gains View usage and Replay once the
  request is done. So the card under it moved up and back down on every
  request: 45px at 420px wide, 6px at 900px.
- The state pill ("Live" or "Counted") changed width, which moved the
  model name beside it by about 11px.
- While a request was under way the cache card dropped to "—" with a
  0% bar, then came back. That was the flash.
- A flex item's leading space is dropped, so " hit" and " / 272K" were
  glued to the figure before them.

Fix:
- routing.js holdStory keeps the log head and steps at the tallest
  height seen while following live, at this width and language. A
  picked request, a replay or a past day is drawn at its own height. A
  ResizeObserver on the steps measures again as soon as the width
  changes. Without it, a scrollbar appearing before the first request
  left a stale height and a 6px shift (seen in WebKit under load).
- context.js stacks all three state words in one grid cell and shows
  only the current one, so the pill keeps one width.
- While the next request is under way, the cache card keeps the last
  request's figure, dimmed (.was), with "The last request's · this one
  is on its way". When there is nothing to show, it gives a faint "—"
  and the reason ("Read once the vendor answers" or "The vendor didn't
  say"). The bar stays hidden but keeps its space. The remembered
  figure resets when the agent or session changes.
- .ctx-big gets a gap. Width and opacity transitions are turned off
  under reduced motion.
- The three new strings are added in zh, zh-TW, ja and de.

Verified:
- The new tests/routing-ctx-still.test.cjs streams two requests and
  checks that the card, model, state, used, cache, figure, bar, grid,
  legend and foot rects never move by more than 0.5px. It also checks
  the figure-to-word gap and both empty states.
- It runs in Chromium and WebKit, at en 420/1100, zh 420/1100,
  zh-TW 900, ja 900 and de 420. It narrows the viewport by 10px after
  load.
- On the old assets it fails 16 of 16 (the card moves 6–52px). It also
  fails with only the ResizeObserver removed.
- routing-live-patch now expects the held figure ("97%") on live steps
  instead of "—".
- Under --test-concurrency=4 in both engines: 578/578 pass across
  routing-*, context-*, click-scroll, group-context, panel-routing and
  gui-de/ja/zh-tw.
- go test -tags nogui ./internal/gui passes.
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gui are
  clean.
2026-10-10 10:13:43 +08:00
yetone c17cbfa161 routing, gui: the folded context window shows a thin bar of what fills it beside how full it is, one line high whatever a live request puts in it, and a request opened from the Usage page's Context tab shows its card unfolded, it alone (PILIPALA @NXirg2 on X, Jeremy.Zhou on Discord)
On af798bd1's fold: folded, the head carries a bar of the window's
parts (system, tools, memory, files, results, chat), morphed with the
head so a live request changes its widths only; the folded head is
pinned at the open head's 20px and doesn't wrap. "Latest request" and a
point of the session line on the Usage page's Context tab open the
request with { context: true }: its card shows unfolded for it, the
next request takes the reader's choice (magpie.ctxShut) again, which is
left as it was; folding that card by its title keeps it folded.

routing-context-fold (new): folded at 1920x1080, 1440x900 and 440x900
in en, zh and de, one line with the bar, the stage and (at 1440 and
wider) the request list in view, nothing running over; opening doesn't
move the page; the Usage page's request opens unfolded for itself only.
routing-live-patch's folded cases: the card, head and bar are the same
nodes across live requests and the card's height never changes. Both
fail on af798bd1's assets. No new strings.
2026-10-09 02:22:10 +08:00
yetone af798bd1bf routing, gui: the context window's card folds to its head, with how full it is beside the title ("114K / 272K · 42%"), and stays folded for the next request and after the page comes back, so the request list under it has the room (0xBCD18E on X: 这个"上下文窗口"的板块非常占"上下"高度,还不能折叠,下面只能展示三行)
ctxCard takes opts.foldable (Routing passes it; the Usage page's cards
don't): its title becomes a button with a chevron, aria-expanded, and a
click toggles .shut on the card, which hides all but the head. The choice
is kept in localStorage (magpie.ctxShut). The head is morphed in place, so
the click reads the button from the event, and the card that is there
keeps .shut across live patches; a new card takes it from the saved choice.

Verified: routing-ctx-fold.test.cjs (new), at 420 and 1100 wide in
Chromium and WebKit, 3/3 each: open, then folded to one line (<60px) with
the figure, the list under it up by >200px, nothing runs over at 420px;
another request picked is still folded; after a reload still folded;
opened again, 400 cells and the same height as before. It fails on the old
code (no .ctx-fold). routing-*, context-*, usage*, group-context,
click-scroll, panel-routing, old-webkit, gui-ja/de/zh-tw: WebKit 371/371;
Chromium 370/371 once at --test-concurrency=4, routing-blocked's "picking
the request moved the page", which passes 3/3 alone and in two more
routing-* runs at the same concurrency (196/196 each). Not filed as caused
by this change; seen once under load.
2026-10-09 01:40:02 +08:00
yetone 3d34c2d747 routing: live, the next request is patched into the context window that is there, so its cells don't come in again and the card no longer goes and comes back, moving the request list under it (Zhenzhen on Discord)
Each new request in a session emptied the card while the gateway read its
prompt (the box collapsed to 0, everything under it jumped up), then drew a
new card whose 400 cells scaled in again, then a third card when it was
done; a request under way had no Prompt cache stat, so the grid moved
again when it came. Now ctxCard returns a card with ctxUpdate: the grid's
cells are made once and only their classes change, the head, stats,
legend, contents rows and foot are morphed in place, and an under-way
request keeps the cache stat's place with "—". Routing patches the live
card, keeps it in place while a live request has no prompt yet, and still
draws a request the reader picks afresh.

Verified: routing-live-patch.test.cjs (new) feeds two requests in three
steps each, at 420 and 1100 wide, in Chromium and WebKit: the old rows,
card, grid, cells, legend and contents rows stay the same nodes, the grid
and card keep their height on every ResizeObserver frame, the view never
scrolls. Without the change it fails: the card reads '' while the request
is under way, the card/grid are new nodes, the box goes 884 -> 0 -> 789
-> 884. routing-*, context-*, click-scroll, panel-routing, old-webkit,
gui-ja/de/zh-tw, usage* pass in both engines; go test ./internal/gui and
GOOS=linux/windows go vet pass.
2026-10-09 00:08:21 +08:00
yetone 0b7a740ee6 gui: Usage's Context tab names its agents when the state answers after the routing history, not by their ids until the history changes
context.js draws each agent card and session row with the agent's name and
icon from the state (agentLabel, agentIcon). When /api/context answered
before /api/state, the cards were drawn by the agents' ids ("claude", a
generic icon). The state's arrival calls loadContext again, but a read that
brought the same history returned early ("the same answer keeps the pane"),
so the ids stayed until the history itself changed.

The "same answer" key now holds what the pane is drawn with besides the
history: each agent's id, name and icon from the state. Once the state is in
the pane is drawn again (still, without its entrance animations); a refresh
with the same history and the same agents still keeps the pane.

This is one of context-window.test.cjs's failures under load and alone: its
Claude Code card is found by hasText "Claude Code", which the card titled
"claude" never matches (":129 locator.innerText: Timeout 5000ms ...
.ctx-agent hasText 'Claude Code' .ctx-grade-word"). "codex" matched "Codex"
since hasText ignores case, which hid it on the other card.

New test in context-window.test.cjs: /api/state is held until the two cards
are drawn, then they must read "Codex, Claude Code".
Run:
- New test on origin/main f00ed290: red in Chromium and WebKit (the names
  never come). With the fix: green in both.
- context-window.test.cjs and context-scroll-end.test.cjs whole: 38/38.
- No t() strings changed; no Go changed.
2026-10-08 17:32:10 +08:00
yetone 6485f5ecb5 gui: the Routing page, and Usage's Context tab with a session open, scroll to their end in WebKit: their narrow and wide layouts go by classes set from each box's width, not container queries (#1249)
In WebKit (the macOS app's WKWebView, and Playwright's WebKit) the Routing
page stopped well short of its bottom (wizzy-yang on #1213). Each time the
page was drawn again while it was scrolled near its end, WebKit cut its
scrollTop back to a shorter range. The page has query containers in it
(.rt, .rt-accts, .rt-more, .rt-col), and the cut happens during a redraw.
Seen at 440x620: 575 of 585, and up to a whole screen short when a part
was redrawn. Chromium is unaffected. With container-type set to normal on
those boxes the page reaches its end, and the cut goes away. Replacing a
container with its clone at the end reproduces it in WKWebView too.

Each box's width now sets a class, the same way container queries would
have chosen a layout:
- routing.js sets the classes from a ResizeObserver: max560 on .rt and
  .rt-accts, max460 on .rt-accts, max520/min1150 on .rt-more, and
  max440/max760 on each .rt-col.
- context.js does the same for each .ctx-card: max520 and max420.
- A rule that names the box goes through :where(), so it keeps the
  specificity it had inside its query.
- The class is set on the next frame, as quotaFit does: set in the
  observer's own call, it changes the box's height, and WebKit reports
  that as a ResizeObserver loop.
- A redrawn ctx-card starts with the width the last card in its place had
  (routing or session). It doesn't lay out wide for a frame and then
  narrow, which would itself pull the page up.
- The Safari 15 @supports fallbacks are dropped. They chose a layout by the
  window's width, and ResizeObserver covers that Safari.

Sibling: Usage → Context, with a session open, has the same bug. Each
timed read redraws the card, and WebKit pulled the page up by up to 946px
at 420 wide (682px at 1100). It is fixed the same way. The other query
containers were checked at their end with a synthetic redraw and were not
affected: Library's .lib-row.with-agents and Agents' .row.agent .who.
Sessions (.sess-pane) also jumps in WebKit as it refreshes, but it still
does with its container removed, so the cause is something else. It is
left alone here.

Run:
- routing-scroll-end.test.cjs (new): 440x620, 600x700, 900x500, 1200x600
  and 1400x700, en and zh, Chromium and WebKit, with the trace redrawing
  the page. It also checks the stage, request and column layouts. On the
  old CSS all 10 WebKit cases fail (twice); with the fix it passes 22/22
  (four runs).
- context-scroll-end.test.cjs (new): 420, 700 and 1100 wide, en and zh,
  across a timed read. On the old CSS the WebKit cases fail ("958 of
  1891"…); with the fix it passes 14/14.
- Layout compared with the old CSS: every element's rect on the Routing
  page (group editor closed and open) and in the Context card. Widths
  360–1700, en/zh/zh-TW/ja/de, Chromium and WebKit: 220 + 100
  configurations, none differ, and there are no page errors.
- The macOS WKWebView: a part redrawn at the end left the page 200–238px
  short before the fix and 0 after, at 440 and 1100.
- gui-ja, gui-de, gui-zh-tw and i18n-keys pass.
- Full GUI suite (concurrency 4): 3719/3733.
  - Pass alone: azure-endpoint, remote-magpie, signin-again and
    routing-sessions.
  - mobile-web compares with origin/main, which had moved on; against
    this commit's parent it passes.
  - panel-arrange fails the same way on the parent.
  - context-window's chromium 1100px hover flakes under load on the parent
    too: 5 of 16 parallel runs, against 1 of 16 here.
- go test ./internal/gui; GOOS=linux and GOOS=windows go vet
  ./internal/gui.

Not run: the reporter's own machine, or an old Safari 15 WebKit.
2026-10-08 15:57:08 +08:00
yetone fd29653d4e context: a window opened on the Context tab loads it at once, not at the refresh's first tick five seconds on
context.js comes after app.js, and app.js shows ?view=usage and reads the
state before context.js is there: when /api/state answered first, both
paths called window.loadContext while it was undefined, the TypeError went
to the status line, and the tab stayed empty until the 5s refresh (found
as context-window's webkit de 1100px flake, 2 of 6 runs). The calls are
optional now, and context.js loads the tab itself when the page opened on
it, as plugins.js and library.js do. The new test holds context.js until
the state has answered: it fails on both engines without the fix and
passes with it; context-window passes 22/22, the case that flaked 10/10.
2026-10-08 12:53:27 +08:00
yetone 586f2bce8f context: magpie inspects the context window of every request, session and agent
The gateway reads each request's prompt into its parts (system prompt,
tools and MCP servers, memory, files, tool results, chat), measured
against the model's window and calibrated to the tokens the vendor
counted. Routing shows a request's window as a card: a 400-cell grid by
part, a hover naming what is largest in a cell, and the contents by part.
The Usage page's Context tab scores each agent out of 100 (cache reuse,
how lean it starts, how fast it grows, how reliably it answers), tags it
(lean, cache-friendly, mcp-heavy, compacts, near-full…), and draws each
session's growth with its latest request's card.

Older Safari (15) gets media-query and solid-colour fallbacks for the
card's container queries and color-mix.
2026-10-08 05:36:17 +08:00