Commit Graph
13 Commits
Author SHA1 Message Date
yetone bceeabd93a gui: a subscription's warm-up, check-in and resets are in its provider's editor
The owner, 11-07: "这些配置难道不是应该在对应的Provider那个弹窗里面吗?为什么会散落在Settings里?"

Settings › Allowances no longer holds Codex's auto-use resets and how
early before one expires, Codex's and Claude's warm-ups, or the daily
check-in of WorkBuddy, Trae CN, MiniMax, Qoder and the plugins that check
in themselves. Each is in its own provider's editor (PROV_PREFS: the lists
move from a hidden holder into the editor's .prov-prefs box and back).
Settings' search still finds them, each a row whose Open goes to the
editor. Task-done alerts stay in Settings. "Codex: auto-use resets" and
"Codex: how early before one expires" lose their "Codex:" in the editor.

In the editor a press inside a part that redraws moved the page: the
modal hold moved the dialog, which can't move once it meets the window's
edge, and lost a pressed element a redraw replaced. The hold now scrolls
the editor's body by what is left, and finds the replacement by its path
or by tag, class and text under its id'd ancestor. In a browser the
editor's body keeps its bar's room, as the app's already did: WebKit kept
the grid's columns from before a bar that came with a grown field, and
the editor scrolled 10px sideways.

Budget: app.js grew with the editor's parts; paid for by comments cut
(curlOf, scrollCloses, unrollSheet, quotaRange, ledGroupSpeed, the
Settings tabs, the warm-up and fold notes), no raise.

Run at this head (704fd85f3 before this message, on origin/main):
- mote: go test -count=1 ./internal/gui/ ok (TestCoreScriptBudget
  included); go vet ./..., GOOS=windows go vet ./... and GOOS=linux go vet
  -tags nogui ./... clean.
- mote: settings-groups and i18n-keys GUI files. i18n-keys' "a plugin's
  words are its own" fails the same on origin/main (#5332, #5327, #5482).
- WSL, both engines, the files this can reach, mine vs origin/main
  8544d5fdb: before the rebase, settings-groups was the one red only here
  (fixed: it now asserts the pressed field stays under the pointer). The
  nine files of account, Codex and editor tests rerun at load ~60 fail on
  both sides with WebKit "access control checks" page errors and measured
  sizes; the sets differ by which language/width hit the load, none by a
  cause in this change. editor-advanced-align is red on main too.
- Broken by hand: the hold following the pressed element itself
  (models-fold and names-fold moved +402px), and updating modalHold.y before
  the cap (provider-remove kept the dialog at 5.89px); both reverted.
Not run: the whole GUI suite to the end (stopped after ~4500 tests at
load 61 on WSL; mote dropped ssh mid-run).
2026-11-09 13:20:30 +08:00
yetone ed0ad52821 gui tests: a picker's item is pressed once the list is drawn for good (#4274)
A model picker draws its list again when its first read of
/api/model-speeds answers (readSpeeds, once a minute and after every
load). searcher-pick's click found the Automatic item after a reload,
the list was drawn again under it, and Playwright gave a null box for
the detached item: "Cannot read properties of null (reading 'x')" at
line 319. reader.cjs's pickItem finds the item again each frame until
its box is the same twice, and presses it there; searcher-pick's click
uses it.

Run on mote (mote-run), chromium, searcher-pick "the provider that
searches..." en and zh:
- origin/main f2f75ee4a: zh red 2 of 3 runs, run alone, the null box
  at line 319 (a diagnostic showed the item there, 32px tall, right
  after).
- this change: en and zh green 5 of 5 each; searcher-pick,
  searcher-then (next commits) and i18n-keys in chromium and webkit:
  46 of 46.
Not tried: webkit 5x alone; the whole GUI suite runs with the next
commits.
2026-11-01 14:43:07 +08:00
yetone a8098a8862 gui tests: reach wheels the page over a point no inner box takes, and the routing editor is pressed once its motion has stopped (#3408, #3409)
Three Routing GUI files were red on main, bisected on mote from
b0b076421:

- routing-model-rest, 20 of 20 red since ca9b5048e (#3764). Its steps
  box now scrolls in 200px, and reader.cjs's reach sent every wheel at
  the view's centre, which sat on that box: the box scrolled, the view
  never moved, and reach gave up ("control did not come clear into
  sight", target y=1048 in a view of 826). Since d74ef5e04 an inner box
  at its end keeps the wheel too, so the pointer over any overflowing
  list stalls reach for good. wheeled now moves the pointer, before each
  wheel, to a point of the view with no box of its own that scrolls
  under it (d74ef5e04 did this by hand for routing-scroll-end alone).
- routing-intent-entry (#3408) and routing-manual (#3409), red since
  91b0be836: a group opening into its editor moves its height and parts
  for ~700ms, and the tests measured where to wheel and press while it
  moved. reader.cjs has a settled(page) now: two frames, then no running
  finite animation; both files wait on it before they measure.
  routing-pause and routing-rule-effort had the same cause (7b007e986).

Run on mote (Playwright 1.62, Chromium and WebKit), one file at a time:
- at the pushed head (rebased on dfb73a04e): routing-model-rest,
  routing-intent-entry, routing-manual, routing-scroll-end,
  inner-scroll-contain, click-scroll: 116/116.
- old code: routing-model-rest 20/20 red at f25871cdd; intent-entry
  and manual red in the bisect from 91b0be836 on.
- broken by hand: the first settled waited on the animations only,
  with no two frames first; routing-manual stayed red in WebKit
  ("element is not stable", then outside the viewport): WebKit lists an
  animation a click started a frame later.
- every GUI file that uses reach or wheelTo (89 files, before the
  rebase and before settled): 1580/1615. The 35 reds are in six files,
  and the same six are red on untouched f25871cdd run one at a time
  (118/150 there): mobile-web (#3952, it needs a .git that mote-run's
  copy hasn't, commented there), usage-ledger (#3104), routing-manual
  (#3409, fixed here), routing-rule-remove (#3094, #3096),
  routing-rules-line (#3593), segs-press-redraw (#3922). rule-remove
  and rules-line don't load reader.cjs.
- a run of the three files under load ~94 had two browsers not launch
  in 180s; routing-model-rest alone again: 20/20.

Not run: the whole GUI suite at the pushed head.
2026-10-28 16:14:28 +08:00
yetone 208bd5c48b gui: Settings descriptions wrap instead of ending in … (arculongus on Discord)
arculongus (English UI, screenshot) couldn't read many Settings rows: the
line under a setting's name ended in "…". The generic `.row .sub` rule holds
a row's line to one line with an ellipsis; a few Settings rows opted out
(`.wraps`) and the rest were cut, among them Image generation's ChatGPT
note, Image recognition MCP server and Web search's Searches for other
models.

Fixed for the class, not the rows in the screenshot: every setting row's
line (`.row.pref .sub`) now wraps whole beside its control. That covers
every Settings part, Plugins › Built-in and an agent's own settings (the
same rows). The control keeps its size (`.prefs .val` is `flex: none`,
max 60%), and nothing else in the layout moves. The window is never
narrower than 560pt, so a row stays a few lines at most. Lines elsewhere (provider
and account cards, chips, URLs) stay one line; their full text is already
reachable through the hover title.

Tests:
- New settings-lines-wrap.test.cjs checks every visible Settings part plus
  Plugins › Built-in, in chromium and webkit, en/zh/zh-TW/ja/de, at
  1000px and 440px. No row's line is cut or nowrap, each control stays
  inside its row, and the page never scrolls sideways (more than 30 rows
  checked). It also checks the three reported rows by name.
- Tests that assumed one-line rows now follow the taller rows:
  - searcher-pick: the help wraps rather than ellipsizing with a title.
  - settings-general: one line only at 1000px, never cut at either width.
  - reader.cjs reach(): goes up to 8,000px, not 2,400.
  - member-model-setting, turn-done, connect-address-kept, tray-cost and
    tray-totals: wheel to the control with reach() before
    clicking, not scrollIntoViewIfNeeded or Playwright's own scroll, which
    the app undoes.
  - update-download, update-restart and tray-totals: a click whose row
    grows a line may scroll, but only to keep the clicked control under
    the pointer (the app's hold, #2134). tray-totals allows 2px, because
    WebKit's whole-pixel scrolls drifted 1.3px over four holds.
  - mobile-web: compares against an origin/main baseline without this
    change.
- Docs: gui-shell.md and gateway-routing.md.

Run (worktree from origin/main a6399dd49, then rebased):
- The new test passes 20/20. Broken by hand: pointed at the old assets
  (MAGPIE_WRAP_ASSETS), it is red 10/10 in chromium and red in webkit
  ("general: a row's line is cut short").
- Whole GUI suite (872 files) in two runs, at concurrency 3-4 and load
  20-150:
  - The 170 Settings-reaching files first: 2515/2575.
  - Then the other 702: 9767/9920.
  - Each red was rerun on settings-wrap-base. The files this change made
    red (settings-general, turn-done, update-download, update-restart,
    member-model-setting, codex-auto-reset-settings, mobile-web,
    connect-address-kept, quota-reads, tray-cost, tray-totals) are fixed
    above and pass on rerun: 86/86, 34/34, 112/112 and 50/50.
  - Also red on origin/main, already filed:
    - redact-words-any-case: #3500
    - s3-sync webkit: #2448
    - usage-checkin Qoder tab: #2549
    - plugin-card-update: #3079
    - builtins and gateway-mode masking tab: #3498
    - fonts webkit: #3227
  - The other files red on origin/main 31bff66be, run alone at a
    comparable count, all have issues: routing-pause #3410,
    routing-rule-effort #3411, routing-rule-remove #3094/#3096,
    routing-intent-entry #3408, routing-live-patch #2174, routing-manual
    #3409, routing-steady #3412, menu-input-scroll #3402, header-centre
    #3479, gateway-caller-keys #2572, gateway-key-models #2648,
    gateway-key-limit #3523, quota-count-wrap #3404, usage-agents-hide
    #3414, usage-fold #3415, usage-ledger #3001/#3104, sidebar and
    gateway-mode #3498, account-discovery #3497, sidebar-overlay-scrollbar
    #1863, account-alias #2984.
  - provider-user-agent failed only on browserType.launch timeouts (load)
    and passed on rerun.
- After the rebase onto b027ca264, these were run again at the pushed head: the
  14 changed or affected GUI files (the new test, the eleven above,
  quota-reads, which main already wheels, and i18n-keys) passed 302/302.
  go test -tags nogui ./internal/gui (budgets included) was ok, with no
  budget raised.
- Before and after screenshots, Settings › Models at 1000px and 700px,
  chromium and webkit, were looked at: the rows that ended in an ellipsis
  now read whole, and each control has the size and place it had before.

Not tried: the real app (WKWebView, WebKitGTK, WebView2). This is a CSS
white-space change with no motion and no new API.
2026-10-25 09:21:42 +08:00
yetone b8ed806e33 gui tests: reach reads the control it wheels to in one call, so a row drawn again between two looks isn't taken for in sight (#2658)
routing-model-rest and routing-wb-restricted were red 1-2 of 20 alone
on a busy machine ("the button can't be reached"). Cause: each test's own
wheel loop read the Try now button with locator.evaluate, which finds the
element in one call and reads it in the next. Routing draws its account
rows again on its own, and a redraw between the two calls handed the
check the button just replaced: out of the page, a zero box at the
window's top, which "bottom < innerHeight - 80" took for in sight. The
loop stopped after one wheel (the failing run's view sat at scrollTop
200 with the button at y 1836).

reader.cjs's shared reach (and wheelTo) had the same two-call read, and
reach threw on a replaced element (closest(".view") null) or returned
early without scrolling. They now read with locator.evaluateAll, which
finds and reads in one call, and look again when nothing matches.
routing-model-rest and routing-wb-restricted use reach instead of their
own loops.

The tests were red before: with an injected redraw (the Try now button
replaced by a clone every 2ms during the scroll), the old
routing-model-rest is 4 of 4 red (chromium en/de, 1100/420), the new one
4 of 4 green. A page-side main-thread hog showed the same [0,null] reads.

Run (macOS, Playwright 1.62.0, load average 60-190 from other sessions):
- alone, both engines, every language and width the files run:
  routing-model-rest 20 of 20, routing-wb-restricted 20 of 20 green.
- under --test-concurrency=6, with every other GUI file that uses reach
  or wheelTo (37 files, 590 tests): 590 of 590 green.
2026-10-21 02:44:26 +08:00
yetone f1e4516da2 gui: Codex's and Claude Code's own settings are in the agent's row on the Agents page, not in Settings
The owner, 10-20: Settings › General held Codex subagents, Long
conversations, Codex background compaction, thread titles, thread
descriptions, composer predictions, the auto-review model and the
memories model, apart from the agents they set; "很割裂、很分散,不直观".

They now sit with their agent (AGENT_PREFS): in its opened row on the
Agents page (a Settings list in connectPanel), in a sheet from the
tray panel's row ("Settings" line, openAgentPrefs) and from the agent's
menu ("{agent} settings"). Each row is the one element moved between
those places, so its handlers and state go with it. Settings' search
still finds them, with a row that opens the agent's sheet
(#agentPrefLinks). A gateway has no Agents page and none of them.
Strings for zh, zh-TW, ja and de; docs (reference, agent-wiring,
gui-shell) point at the new place. app.js 1,277,298 bytes and the core
scripts 1,469,058, so both budgets rise.

Run on 6416d639c (the dialog morph, on origin/main 75e769a9f), macOS,
playwright 1.62.0:
- agent-prefs.test.cjs (new) plus the 10 migrated files (codex-titles,
  codex-descriptions, codex-auto-review, codex-predictions,
  codex-memories-settings, codex-async-compact, compact-at,
  settings-general, bare-ids, gateway-mode) and modal-morph: 152/152,
  chromium and webkit, every language, wide and 420px.
- go test ./internal/gui/: ok after the budget rise.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Two GUI tests leaned on the Agents page's old height and are moved with it:
agent-models-loading clicked "elsewhere" at (900, 650), which is now
Codex's Disconnect button in its opened row, so it clicks the page's lead
line; agent-expand-steady clicked Goose's row while Codex's opened row
(~554px with its settings) pushed it out of a 560px view, so it wheels
Goose's link into sight first (reader.cjs reach). codex-subagents-lead
and agent-models-redraw clicked controls below Codex's opened row and
timed out in WebKit ("outside of the viewport"); they wait for the row to
finish sliding open, then wheel the control into sight. With Settings ›
General shorter, segs-press-redraw's sweep left Usage's warm-up tabs
above the view in WebKit; it wheels them back when they are. panel-effort
opened Kimi's row below Codex's opened one the same way. login-allow's
wheel loop read the shorter General page's button 50ms after each wheel and
clicked beside it (de, 440px); it uses reach. mobile-web shut each agent
picker by tapping the Agents tab, which a picker opened low in Codex's
taller row covers on a phone; it taps the header's name (the lead line
can sit under the header's tabs, and a tap there opened Library), wheels
each row and field into sight before tapping it, and says which agent and
field a step timed out on. All seven pass in Chromium and WebKit.

After the rebase onto main (32 commits on), with the test fixes above:
- go test ./internal/gui/ ./internal/plugin/ ./internal/agent/ ok;
  gofmt -l clean; go vet GOOS=linux -tags nogui and GOOS=windows.
- 95 GUI files (every agent-, codex-, claude-, settings- and modal- file,
  and every file either side changed): 1375 pass; the 8 reds were
  segs-press-redraw, fixed above. The 16 other files that click an
  Agents row: 369/370, rail-tip red on main too (#3091).
- The full suite's reds are listed in the dialog morph's commit; each was
  run alone on this head and on origin/main.
- mobile-web's "desktop matches origin/main" compares Settings and the
  Agents page with main's assets, so it is red until this is on main; its
  phone checks pass in Chromium and WebKit.
2026-10-21 02:06:23 +08:00
yetone 5b8659ec46 gui tests: each wheel lands before the row is looked at again (#2370)
bare-ids (chromium 420 zh-TW, "the click scrolled the page 716 !== 800")
went red under load, and so could its three siblings that wheel a
Settings row to mid-view the same way (codex-auto-review, codex-titles,
codex-descriptions).

Cause, from a logged run under load: each test wheeled 100px, waited
30ms and read the row's place again. On a busy machine the wheel's
scroll hadn't landed in 30ms, so the read was from before it and more
wheels were sent. The view went past the row: #bareIdsSegs sat at
top ~20, under the header (the view starts at ~104). Playwright then
scrolled the control into sight to click it. The app put that scroll
back, as it does any scroll not the reader's (backToReader), and since
the focused button was then out of sight it brought it back with
scrollIntoView({block:"nearest"}), which gave 716. A reader can't click
a control hidden under the header, so the page did nothing wrong. The
test's assumption was the fault.

Fix, in reader.cjs:
- wheeled(): one wheel, then a wait until the view's scrollTop changes.
  It gives up after 1s, when the view is at its end.
- reach() wheels through it in place of its 40ms pause. Three wheels in
  a row that move nothing end it.
- wheelTo(page, locator, y) wheels in 50px steps till the control's top
  is at y, then calls reach so it is clear in sight.
The four tests use wheelTo(…, 200), so the page is still scrolled
before the click, which the test needs to show a move.

Broken by hand: latewheel.cjs, a --require preload, sends each
page.mouse.wheel 80ms late (the call returns at once).
- On origin/main 9d97fd073: bare-ids red in 5 of 10 cases (716 !== 800,
  716 !== 895, 772/781/805 !== 900), codex-titles 2 of 2, codex-auto-review
  1 of 2 (641 !== 600), codex-descriptions 1 of 2.
- With this change: 32 of 32 cases pass, chromium and webkit, with and
  without the injection.
A busy loop in every animation frame (120 or 200ms) also made the old
bare-ids red, 3 of 4 runs.

A first try used reach alone. At 900 the row was already in sight in
zh, zh-TW and ja, so the page wasn't scrolled ("must scroll to the
row"). wheelTo keeps the scroll.

Run at this head, NODE_PATH=playwright 1.62.0:
- the four files, BROWSER=chromium and webkit, both widths, every
  language each test has: all pass.
- every file that uses reach (22) plus click-scroll, at
  --test-concurrency=3: chromium 209/210, webkit 209/210. The two reds
  fail on origin/main as it is:
  - refusal-retries-setting chromium ja 420, "saved again 1 !== 2":
    1 of 6 runs alone on the old code; that is #2258.
  - group-member-weight webkit de 420, 1269 !== 1268: 1 of 4 alone on
    the old code; filed as #2387. With this change it passed 4 of 4
    alone.

Full suite: SUITE_LINE
2026-10-15 23:08:04 +08:00
yetone 62e012b3e2 gui tests: Settings tabs are opened with Enter, not a click that waits on frames a loaded WebKit doesn't draw (#2150)
Cause: quota-reads (webkit de 360) timed out on
`:is(#setTab-usage, .nav-s[data-of=setTab-usage]):visible").click()`. Its
call log ends at "waiting for element to be visible, enabled and stable",
with no "element is not stable" retries, so the tab wasn't moving.
Playwright's stability check compares the box over two
requestAnimationFrame callbacks. WebKit's frames are driven by its UI
process, and on a loaded machine they stall for seconds while the page's
ordinary tasks run on, so the click sat out the whole 5s page timeout over
a still tab.

Reproduced by injecting a delay: SIGSTOP/SIGCONT duty-cycling of WebKit's
UI process (10ms on / 990ms off) around the tab step in a copy of
quota-reads. click() took 3-4s and timed out in 4 of 6 runs.
press("Enter") on the same locator took 2-3s and passed 6 of 6.

Fix: reader.cjs gets openPart(page, id), which presses Enter on the tab or
its sidebar strip entry. Both are <button>s, so Enter clicks them with no
frame to wait for. All 49 call sites of that locator shape across 35 test
files use it now. The other shapes (getAttribute, focus, boundingBox, the
.nav-s strip's own pointer tests) are left as they are, since they test
the tab itself.

Run (playwright 1.62.0, chromium + webkit, each file's own languages and
widths): all 35 changed files, four at a time, at load average ~400 from
other sessions. 450 tests passed. sync-not-backup (#prefs not there yet)
and tray-inuse (a 180s browser launch timeout) failed one test each
before the tab step; alone they pass 20/20 and 4/4.

Not tried: the other rAF-polled waits across the suite (waitForFunction
defaults to rAF polling, and settingsDrawn is one of them). They starve
the same way under this load, but none is named in #2150 or #2151.
2026-10-14 20:00:55 +08:00
yetone 94aa793db0 gui tests: routing-sessions, pick-skills and routing-group-fold wheel to the control they press, as the reader would, since the sidebar moved it out of sight or under a bar (#1672)
Cause: 18e82adc6 (the sidebar). From 1024 points wide the page sits
beside the sidebar, and a width change lets go of what the last click
held (heldWidth). Both are intended: a sidebar like a Mac app's, and a
relayout isn't the click's doing. That commit updated the tests whose
window is 1024+, but missed these three. Each now presses a control that
is out of sight or under a bar:
- routing-sessions ("background memory groups"): after the resize from
  1100 to 560, By request is at y=902 in an 800px window, with scrollTop
  0. Before 18e82adc6 the click's hold kept scrollTop at 296, and the
  button was at y=606.
- pick-skills: pdf's row is at 683-750. That is partly under the sticky
  bar Select brings up (664-712), and the view ends at 732. Before, the
  row was wholly below the view (715-782), and Playwright scrolled it.
- routing-group-fold: with the pool open, the Team and Big folds are
  under the window's foot (en, ja, de).
The app puts back any scroll that isn't the reader's, Playwright's
included. Playwright doesn't scroll a control that is partly in sight at
all. So in WebKit the click waits ("element is outside of the viewport",
"<footer class=foot> intercepts pointer events") until it times out.
Chromium gets through some of these by a few pixels.

Change: reader.cjs gets reach(page, locator). It is inView for any
page: it wheels the control's own .view until the control is wholly
inside it and elementFromPoint at its centre is the control. The three
tests call it before those clicks. Nothing is loosened: every assertion
is unchanged, and the press is still a real click on the control.

Run (worktree on origin/main 31c1e3ab1, playwright 1.62.0, each file
alone):
- routing-sessions: 19/19 in both engines. Before: 18/19 in WebKit.
- pick-skills: 3/3 in both. Before: 0/3 in WebKit.
- routing-group-fold: 20/20 in both. Before: 17/20 in WebKit.
- The bisect for each lands on 18e82adc6.
- inView and every other export of reader.cjs is unchanged. The 37
  resize/scroll files, several of which use inView, are green apart
  from #1863, which fails on 31c1e3ab1 too.

Not run: the full GUI suite.
2026-10-13 03:54:48 +08:00
yetone 8f9bc3fccf gui tests: the 37 other Settings tests act on rows once the page has drawn its last read of the settings, as the masking-rules tests do since #1653 (#1659)
Opening Settings reads the settings twice: the page's own read
(showView), then the window's load() once the state is in. Each read
redraws every row. A test that found a row after the first draw, and
then called scrollIntoViewIfNeeded or boundingBox on it, failed when the
second read landed in between. The errors were "Element is not
attached", or a null box. #1653 fixed the three masking-rules tests and
listed these 37 in #1659.

Each of the 37 now calls watchSettingsReads(page) before every
page.goto, and settingsDrawn(page) right after it. Right after goto is
exact for ?view=settings: at boot, show(view) asks for showView's read
before load() runs. load() sets load.done in the same run that then asks
for its own read, so settingsDrawn's "load.done and every read asked
for drawn" holds only once the second read is drawn. For a test opened
on another page that clicks into Settings later, load is done by then,
the click makes the only read, and the wait passes at once.
watchSettingsReads now watches a page once, however many times it is
opened, since some of these tests open one page several times. The
page is unchanged.

Reproduced with a generic injection (scratchpad inject1659.cjs, loaded
with NODE_OPTIONS=--require). A route added at each goto holds the
page's second GET /api/settings. It lets the read go just as the test
calls scrollIntoViewIfNeeded or boundingBox, or waits on the page with
waitForFunction (which settingsDrawn is), with a 4s timer as a backstop.
This is #1653's injection, made generic.

Before, injected, both engines, all languages:
- 5 files red with the issue's error:
  - github-token: null box.
  - member-model-setting, searcher-pick, search-first and update-wait:
    "Element is not attached to the DOM".
- 4 files red on a check of a row drawn from the first read:
  model-suffix-own, otel, readable-focus and warm-at-times.
- 28 green.

After, injected: 36 of the 37 files green, every held read let go by
settingsDrawn's wait. otel stays red in WebKit at 360px. It is red the
same way with no injection, on origin/main's own copy of the test. That
cause is separate (the narrow nav laid out after setViewportSize
returns) and has its own commit next.

Plain (no injection), both engines, all 37 files: 460 cases passed and
2 failed, both otel's WebKit 360px check above.

The 8 files red under injection before, injected again after,
5 rounds: 390 of 390 cases passed.
2026-10-12 03:25:47 +08:00
yetone 5dfcf43465 gui tests: the masking-rules tests act on Settings' rows once the page has drawn its last read of the settings, not the first (#1653)
redact-rule-row failed in WebKit zh on a loaded machine with
"locator.scrollIntoViewIfNeeded: Element is not attached to the DOM".

Cause: opening Settings reads the settings twice, the page's own read
(showView) and the window's load() once the state is in, and each read
redraws every row (renderRedact replaces #redactList's children). The
test found the row after the first draw and scrolled it; when the second
read landed during Playwright's stability check, the element it held was
gone. Locator clicks retry on a detached element, but
scrollIntoViewIfNeeded and boundingBox act on the element they found.
A probe wrapping #redactList's replaceChildren showed the two draws
(renderSettings < loadSettings, then the same < async load).

Fix: reader.cjs gains watchSettingsReads (an init script counting the
page's GET /api/settings reads, each counted drawn a task after its body
is read, after loadSettings has drawn from it) and settingsDrawn (waits
for load.done, which load() sets in the same run that then asks for the
settings, and for every read asked to be drawn). redact-rule-row and its
two siblings on the same rows, redact-rule-edit and redact-kinds, wait
for it after finding their first row. The page is unchanged: its second
draw is how Settings catches up with the state.

Run (injected: the test's route holds the page's second settings read
until the row is found, and lets it go as the test acts on it):
- Injected, without the wait: 8 of 8 red in Chromium and WebKit, en and
  zh, 1100 and 640px, the issue's exact error. With the wait: 8 of 8
  green.
- redact-rule-row WebKit, 25 runs: 100 of 100 cases green at load ~115.
- redact-rule-row, redact-rule-edit and redact-kinds in both engines:
  50 of 50, and again 50 of 50 (injected 8 of 8) after rebasing
  onto 18e82adc6.

Not done here: 37 other Settings tests use boundingBox or
scrollIntoViewIfNeeded after finding a row and can meet the same second
draw; #1659 lists them, to move onto settingsDrawn.
2026-10-12 00:57:27 +08:00
yetone 70e7e36675 gui tests: a press is made only on a target wholly in sight, so Playwright's click doesn't scroll it the last fraction of a pixel itself (request-archive-usage.test.cjs: "a click moved the page: 860 to 861" in Chromium once the Usage page's archive switch shows, which #1017 makes it do) — reader.inView took a target cut off by up to a pixel at the view's foot as in sight; Fetch from archive spanned 539.80–562.59 in a 562px view (the switch makes .led-head 4px taller, so the 20px wheel steps land the rows elsewhere), and Playwright's click scrollIntoViewIfNeeded'd it 1px before dispatching, before the app's capture-phase click listener took the positions hold() keeps, so the app saw nothing to put back. A raw page.mouse.click at the same point moves nothing; no page code scrolls or focuses there, and overflow-anchor: none changes nothing. inView now wants the target wholly in the view (or, taller than it, its top in sight), and the press test's web ±1 allowance ("settles a row's first opening up to a pixel off") is gone: a click moves the page by nothing. With #1017's diff applied, request-archive-usage.test.cjs failed in Chromium (both app modes) and passed in WebKit; with this it passes 5/5 in both, and 3/3 with the allowance removed. The 32 suites using reader.cjs, request-archive*, usage-*, click-scroll and ledger-* pass in Chromium and WebKit (275/275). No app change. 2026-10-06 21:08:57 +08:00
c0f3fa012a usage: combine gateway and local session requests with model charts and account labels (#239)
* usage: Requests lists the agents' own session-file calls, put to the vendor and account their files prove, charts them by provider, agent or model, shows what was said, and the tray panel gets a Usage tab

The Usage page's Requests tab now covers requests an agent sends with its own sign-in (Claude Desktop's Code tab and Cowork, Claude Code, Codex), which never pass the gateway, and shows more of every request: why it failed, what was said in it, who it was of.

Requests tab: a strip of four totals (tokens, requests, cost, cache hit rate); the trend of one metric — tokens, cost or requests — as columns by the hour, day or week, told apart by provider, agent or model (both remembered), beside a ranking of the same that is its legend and a way in (a click lists only that provider's or agent's requests; a provider picker sits beside the agent's). The ranking is as tall as the chart and scrolls in itself, with no scrollbar: a slim rail in the card's margin shows how much there is and where it is (its thumb dragged, the rail clicked), and the edge with more beyond it fades; under the chart (860px and narrower) it shows whole. A row opens to its details: the vendor's error type and words, request id, endpoint, and what was said in it (input and output, read from the agent's session file when opened, the call that ended nearest the request — nothing stored). A refresh period (off / 5 s / 10 s / 30 s / 1 min) and refresh-now. The Overview says it counts gateway calls only; Requests and the panel say they count both. The tray panel gets a Usage tab (today / 7 / 30 days, provider picker, four totals, a small chart, top five, "Open Usage"), and is as tall as its tallest tab (#124).

Provider and account of a session-file call: never magpie's "claude" or "codex" subscription. Anthropic's when Claude Desktop's session metadata (not Claude-3p) names the account and organization, with that account's email; OpenAI's when Codex's rollout names a provider that is OpenAI's in config.toml — the built-in "openai", or a named one at OpenAI's address or signed in with the ChatGPT account and no base_url (requires_openai_auth) — with the creator account's email when the file records it. Anything else is "Local session", its recorded provider id and session account kept (CSV: session_provider, session_account). The config read is today's: a file names the provider id only.

Gateway: a failed call keeps the vendor's error text and type, request id and endpoint; a Claude subscription's failure uses the status Claude Code reports (api_error_status). A request turned away before any vendor was asked is logged, marked rejected, listed in Requests and left out of every total. The client's own session header is kept as native_session beside X-Magpie-Session, and a session-file call is matched to a gateway record by request id, then by that session, equal tokens and an end within 2 s, only when unique both ways.

Reading: session-file calls live in the session index main keeps on disk, parsed incrementally and outside its lock (Claude Code, Cowork in both Claude folders, Codex); the usage log is read on from where it was; a page builds the ledger once. Days are counted on calendar dates (DST). CSV gains request_id, endpoint, error_message, error_type, source, session_provider, session_account. i18n: one "Endpoint" (终结点), which a second key had turned for Azure's field.

Tested: go vet ./..., go build (also GOOS=linux/windows, -tags nogui) and go test -tags nogui ./... pass. The whole GUI suite in Chromium and WebKit, en and zh (Playwright 1.62.1): all 393 tests pass. On this computer's files (7 days): 3,330 Claude Desktop calls resolve to Anthropic with the account, 1,991 Codex calls on a named ChatGPT-signed-in provider to OpenAI (620 with the account; older rollouts don't record it), 9 Claude Code CLI calls stay Local session.

Co-authored-by: yetone <yetoneful@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* usage: a session-file call of one of magpie's own Codex or Claude accounts is told as that provider, beside the gateway's calls on it — "OpenAI" and "Codex" (or "Anthropic" and "Claude Code") read as two vendors when they were one subscription

Codex: an official route (above) whose creator account and user are one of magpie's Codex sign-ins (the CLI's own or a saved one) is magpie's "codex", with that account's email as the gateway's rows have it. Claude Desktop (not Claude-3p): an account and organization that are one of magpie's Claude sign-ins is magpie's "claude". Only while magpie has that provider signed in; another account, a rollout with no account recorded, or an ambiguous workspace stays OpenAI or Anthropic, and a relay stays Local session.

Tested: TestSessionCallsOfMagpiesAccountsAreItsProviders (the account matched, another account, none recorded, magpie's account through a relay, Desktop in magpie's and another organization, Claude-3p, magpie signed out) and TestLedgerTellsCodexSessionCallsAsMagpiesCodex (a gateway Codex call and a session call of its account one provider of two calls, another account's OpenAI). On this computer (7 days): 3,439 Claude Desktop calls are magpie's Claude, 626 Codex calls its Codex, 1,322 older Codex rollouts with no account stay OpenAI. go test -tags nogui ./... and the usage GUI tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: 修复请求统计缓存膨胀与会话账号误归属 #239

调用明细改为按会话文件分片保存并限制内存缓存,汇总索引仅保留统计数据;网关日志按需读取。

严格匹配订阅账号与用户 ID,排除自定义渠道、非官方端点覆盖、外部 CODEX_HOME 及关闭的供应商。补齐零 token 失败去重、Codex 原始会话 ID、拒绝标记导出和面板显示修复。

通过全量 Go 测试、静态检查、受影响模块的并发检查、52 项浏览器测试及 macOS/Linux/Windows 构建;使用 35 万条合成调用验证索引体积与内存改善。

* fix: 降低请求统计刷新与写入开销并明确本地账号展示 #239

请求分片改为追加帧和字符串去重,分页复用未变化的紧凑快照,采用 LRU 并移出全局锁内的磁盘读取。缓存 Cowork 目录,补齐同前缀改写检测及崩溃临时文件清理。

本地记录仅显示匹配账号或本地会话,明确官方登录标记与请求路由的区别。默认今日与模型维度,Auto Review 复用共享目录定价并单独标注估价参考。

完整 Go 测试、vet、相关 race 和 52 项浏览器回归通过;提供 2000 文件及四个大会话连续追加的可复现性能对照。

* fix: 优化用量徽标与耗时分级并保护分页边界 #239

官方登录、API、订阅和本地会话采用独立颜色与柔和底色,兼容明暗主题。耗时按 10 秒及 30 秒阈值着色,保留估算标识与原始毫秒提示;无有效耗时显示短横线。

限制分页选取范围,避免超大偏移整数溢出及越界空页的无效堆构造。补充阈值、徽标对比度和极端分页参数回归。

* fix: 将账号与来源徽标分为两行展示 #239

* fix: 提高用量表格模型文字对比度 #239

发送模型和已知实际模型使用主题正文次级色,表头与时间同步加深。保留缺失值弱化、转发提示和本地日志来源说明。Chromium 与 WebKit 的中英文、浅深色主题 10 项界面检查通过。

---------

Co-authored-by: yetone <yetoneful@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 17:42:10 +08:00