Commit Graph
18 Commits
Author SHA1 Message Date
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