Commit Graph
13 Commits
Author SHA1 Message Date
yetone 24d315fa85 routing: the request list can be grouped By key, each gateway key's calls under its name
acezan (#help on Discord) asked to see API use on the Routing page the way
it shows each agent's, live and in the history. The list's group bar gets
a third button, By key, after By request and By session. It shows once
Settings has a gateway key (/api/caller-keys). Each head is the key's
current name (else the name the route kept, else its id), with its agents
dim beside it and the usual count, tokens, in progress and cost. Calls with
no key (from this computer, or kept before 75fb76186 named the key) go
under "No gateway key". A row's tooltip names its key too. The choice is
kept in localStorage (magpie.routingGroupBy), and the old
magpie.routingBySession still works. Text added in zh, zh-TW, ja and de.

click-scroll counted two group buttons and now counts three, with By key
hidden when there is no key. purpose-filter clicked .last() for By
session and now picks [data-by="session"].
reference.md and gateway-sessions.md describe By key and Route.CallerKey.

Run (WSL magpie-desktop: mote's disk is full, ld errno=28):
- routing-by-key.test.cjs: 20/20 in chromium and webkit, in en, zh,
  zh-TW, ja and de, at 1100 and 420. Red 20/20 with client.js and
  i18n.js at the parent (waits for By key).
- 254 Routing-related GUI files at concurrency 4. Every red was rerun
  serially, with this change and at origin/main 73c98ebc2.
  - Only purpose-filter and click-scroll were this change's; both are
    fixed above and green now.
  - The rest are red at main too, or flake there: #5045 call-headers,
    #4385 click-scroll wheel, #5049, #1745, #4689, #3402, #4623, #1937,
    #3773 idle-frame (10 frames, passes on rerun), plus routing-rule-*,
    zero-priced-free and others under #4121/#4400.
- Windows: go test ./internal/gui. Reds are #4115/#1827, plus
  TestPluginAgentMissingSaysSo and TestGatewayHeldByAContainer, red at
  main too and filed now as #5324.
Not tried: the real app, the whole GUI suite, the tray panel (no By key
there). A key renamed after a row was drawn shows its old name in that
row's tooltip until the row is drawn again.
2026-11-05 14:47:18 +08:00
yetone ce8b67de37 gui tests: a page's first load gets a minute, not a click's 5s (#4470)
claude-switch-only set page.setDefaultTimeout(5000) and then called
page.goto with no timeout of its own, so Playwright held the first load
of app.js, i18n.js and the plugins to the 5s bar meant for clicks. On a
busy box (a whole-suite run at load 130-160) that load took longer and
goto timed out. The same pattern is in 988 GUI test files (1174 pages):
every one of them now also sets setDefaultNavigationTimeout(60000) on
the same page, right after its default, so goto, reload and waitForURL
wait on the load itself with room, while clicks and waits keep their
short bar. group-from-model-add's own 20s navigation bar is raised to the
same minute. claude-switch-only also gives its first provider row (drawn
from the page's first reads) a minute before clicking it.

nav-timeout.test.cjs (no browser) reads every GUI test file and names
each page given a default under a minute without a navigation timeout of
at least a minute, so a new file can't bring the pattern back.

What was run (WSL magpie-desktop, Playwright 1.62.0, load 70-260 from
other sessions):
- node --check on every file in internal/gui/tests: all parse.
- nav-timeout.test.cjs against origin/main's test files: red (names the
  1174 pages); against this tree: its only reds were my own probe copies
  of the old files, since removed.
- By hand: claude-switch-only with app.js served 7s late (a busy box's
  first load), --test-name-pattern "1100 en": origin/main's file 4 of 4
  red with "page.goto: Timeout 5000ms exceeded"; this file 4 of 4 green.
- claude-switch-only.test.cjs, both engines, en/zh/ja/de, 1100 and 420:
  32 of 32. group-from-model-add, usage-access-key-card and i18n-keys:
  green. agent-plugin-agents: Chromium green; WebKit's de 420 subtest red
  on a 5s waitForFunction at line 115 (a wait after load, not the
  navigation), at load ~230.

Not tried: the whole GUI suite (about 1000 files; the change is one
mechanical line per page), Windows or mote (mote's browsers, #4125).
2026-10-31 02:09:18 +08:00
yetone 0ee31d4736 gui: Routing and Usage keep the reader's place when wheeled as they open, heard late or never (issennknight)
issennknight on Discord (macOS 13.7.8, v0.1.1902), after f92db4cdd:
"路由 用量 页面 刚点开并滚动页面时会抖动复位".

Two causes, both in the window's own scroll guard, which every page
takes:

1. A load landing under the wheel (show()'s back on the page's first
   reads, loadProvidersNow's put-back after render) called backToReader
   with the place last heard of. The page hears of a scroll a frame or
   more late (WebKit scrolls off the main thread; a loaded Mac), so each
   load took the reader's last steps back and stopped their coast.
   backAfterLoad now keeps a view that has gone on the way the reader's
   own scrolls go (readerWay, set from each of theirs) as theirs, and
   puts back only a move against it (a redraw's clamp).
2. On macOS 13's WebKit (16.6) the page never hears the wheel. Every
   gesture's first scrolls were put back until three the same way made
   a run (puttingBack): a shake at the start of each gesture, a page
   just opened included. The first run given back is now remembered
   (localStorage magpie.unheardWheels, for the next start too); from
   then on a scroll at rest waits 120ms before it is put back
   (waitsBack), and a second the same way within 80ms, the page's
   height unchanged between them, is the reader's at once (code's two
   scrolls in a row, 100ms apart in view-wheel-unheard, are both put
   back). A lone
   scroll (a redraw's, code's) is still put back, 120ms later; one
   under a click's hold at once, as before. What the wait puts back is
   recorded as an at-once put-back is, so a wheel heard later than the
   wait (a loaded machine) still gives it back (givesBack).

Not changed: the browser's scroll anchoring. It lowers scrollTop as data
comes in above with what's on the screen still; the test tells that from
a put-back (view up and what was under the pointer going down with it).
Nothing between v0.1.1902 and 425a61322 touched this guard (68 commits;
none in backToReader, readerScrolls, readerLeaves, puttingBack or
overflow-anchor), and no view has smooth scrolling.

Size budgets: app.js 1,313,704, the core 1,532,830 (main's plus 1,969), both the guard's own,
with no room added.

Tests:
- New view-open-wheel.test.cjs: Usage and Routing, opened and opened
  again, the first data held until the wheel is going; the page told of
  each scroll 80ms late (late) or never (unheard, a capture listener
  stopping the wheel, learned on the Agents page first); every frame's
  place and every write moving a view up are recorded. en, zh, zh-TW,
  ja, de; 420 and 1000 wide; Chromium and WebKit. 162/162 on this tree
  (mote).
- Broken by hand: on the base's assets (425a61322) 117/162 red: late
  Routing 31, late Usage 4 (210 to 180 under the wheel), unheard all 80
  ("nothing put the view back up": 30, 30, 30 put back each gesture).
  With backAfterLoad but no waitsBack, the unheard half was 80/80 red
  the same way; with waitsBack but readerAt unset taken as no move, red
  too (found by logging each write's stack), fixed to 0 as backToReader
  reads it.
- click-scroll.test.cjs: new subtest, a wheel heard 250ms late with
  the unheard wheels learned still scrolls the view. Red in both
  engines (Windows, 2 of 2 runs) with the wait's put-back not recorded,
  24/24 green with it (3 of 3). Found from the whole suite's first run:
  under WSL's load, click-scroll's late-heard wheel subtest went red in
  webkit, which learned the unheard wheels from a run put back.
- Also tried and dropped: .view { overflow-anchor: none }. It only
  silenced a scrollTop-only check; anchoring moves nothing on screen.
- TestCoreScriptBudget ok (mote); gofmt -l clean.
- After the rebase onto 2f5548371: TestCoreScriptBudget and the
  app.js budget ok (mote); view-open-wheel, view-wheel-unheard,
  click-scroll on mote under another session's suite (load 16 to 35):
  192/192 once, and 1 of 80 unheard subtests red once (#4132: under
  load the driver's second wheel comes after waitsBack's 120ms).
- Rebased onto c3462d5fe (main's GUI changes: context.js, i18n.js,
  the Codex auto-reset title; none in the scroll guard). app.js budget
  ok (mote). TestCoreScriptBudget is red by 670 bytes at c3462d5fe
  itself (1,531,531 > 1,530,861, #4133, taken by another session); this
  commit adds its own 1,969 to both, so the core stays 670 over, not
  more. The four scroll files on WSL: chromium all green; Linux WebKit
  red in click-scroll, view-wheel-unheard and view-wheel-after-click as
  at 2f5548371, and 7 of 80 view-open-wheel unheard subtests (a first
  gesture's put-backs before the run is learned, the #4132 class). On
  mote at load 81 (another session's full GUI suite) 14 of 113 red,
  mostly 5s click timeouts; not counted as a run.
- Whole GUI suite at this tree, WSL magpie-desktop (mote had another
  session's suite): 14,519 tests, 14,263 pass, 256 red. Every red file
  is named on #4120 / #4121 (Linux reds at main) or was run alone at
  2f5548371 and is red there the same: routing-rule-models,
  recent-calls-more, searcher-pick, usage-ledger-chart, list-sort
  (#4131), click-scroll's late-heard wheel, inner-scroll-contain,
  view-wheel-after-click and view-wheel-unheard in WebKit on Linux
  (base 9 to 10 red, this tree 4 to 9). Recorded on #4120.
- Tried and dropped: a check in waitsBack's timer for a view gone on
  further untold. It took a code scroll whose event was still pending
  under load as the reader's (view-wheel-unheard webkit red on mote).

Not tried: a real macOS 13 WebKit 16.6 (none here). The unheard case is
an emulation (wheels stopped before the page), the same one
view-wheel-unheard and view-wheel-after-redraw use. The first gesture
of a fresh install on macOS 13 still shakes once, until the run is
seen.
2026-10-29 11:26:47 +08:00
yetone 45303db0e3 gui tests: click-scroll's late wheel is looked at once the page has heard it and the reader's moment is over, not after a fixed 400ms (#1660)
"a wheel the page hears of after its scroll is still the reader's" failed
once in Chromium on a loaded machine.

Cause: the subtest delays the app's wheel listener by 60ms (the busy page
of the subtest), then waited a fixed 400ms before looking at the view,
and 100ms after a scroll by code. The listener opens a 250ms moment in
which scrolls are the reader's (readerScrolls(250)). That moment starts
when the page hears the wheel, not when the wheel happens. When the
machine ran the 60ms timer more than ~150ms late, the code's scroll that
followed fell inside that moment and stood ("code's scroll is put
back"). Later still, the view was looked at before the wheel was heard
("the late-heard wheel must scroll the view").

Fix: the wrapper counts the wheels the page has heard. Each wheel is
looked at once the page has heard it and performance.now() has passed
purposeUntil, the end of the reader's moment. The code's scroll is
looked at three frames on, since it is put back at the frame it is told
of. The wait of 100ms before the last wheel stays as a minimum gap: what
was put back from 50ms before a wheel counts as that wheel's own
(givesBack). The page is unchanged.

Run (injected: the late wheel's delay raised from 60ms, the test copied
to the scratchpad with only that number changed):
- Before, Chromium:
  - 200ms: 4 of 22 cases red, "code's scroll is put back".
  - 500ms: 4 of 22 red, "the late-heard wheel must scroll the view".
  - 60ms: green.
- After:
  - 200ms Chromium: 22 of 22.
  - 500ms Chromium: 22 of 22.
  - 500ms WebKit: 22 of 22.
- Broken by hand: with givesBack left out of the wheel listener, the
  test is red on "the late-heard wheel must scroll the view".
- A first try with no gap before the last wheel went red: the code's
  scroll was handed to the wheel. That is why the 100ms stays.
- click-scroll.test.cjs, both engines, 20 runs: 440 of 440 cases passed, with a load average of 12 to 17.
2026-10-12 03:25:47 +08:00
yetone 9bb68615b0 gui: a scroll not the reader's made just before a click is put back, not kept as where the reader was (#1554)
skill-install-agents-all.test.cjs was red on main in Chromium at 420px
(en, ja, de): the install picker's All chip, clicked, left the Library
view 5px down.

Cause: the browser tells the page of a scroll at the next frame. The test
clicks while the Library view is still sliding in (view-in, translateY
5px), and Playwright's click scrolls the chip into view first; with the
view 5px taller than it is high at 420px, that scroll takes the view to
its 5px foot. The click came in before that scroll's event, so the click
guard took its snapshot (held.chain, held.top) at 5px and every hold()
after kept it there, the scroll event included. A real click can do the
same: WebKit scrolls a field focused on the press, or code scrolls just
before the click, and the scroll was adopted as the reader's.

Fix (app.js, the click guard): before taking a click's snapshot, a view
not scrolled by the reader (no purposeUntil window, no scrollbar drag)
is put back where the reader left it (backToReader), as the scroll
listener would have done a frame later. A click in quick turn after
another still holds that one first, as before.

The guard is shared by every view, so every picker and button is covered;
the library picker needs no change of its own (the MCP editor's picker is
in #modal, outside any view).

Tests:
- click-scroll.test.cjs: new "a scroll the page hears of after the click
  is still put back" (scrollTop += 40 and a click in one task). Red on the
  old app.js in Chromium and WebKit (expected 2020, actual 2060), green
  with the fix.
- sessions-manage-paging.test.cjs scrolled with Playwright's
  scrollIntoViewIfNeeded and clicked Show more before the next frame, so
  it passed in Chromium only through this bug (the guard puts that scroll
  back a frame later; it was red in WebKit on main). It now scrolls with
  the reader's wheel; green in both engines.
- docs/subsystems/gui-shell.md says a click is taken where the reader
  left the view.

Run: skill-install-agents-all.test.cjs red before (en/ja/de 420px,
"view:5,0"), green after in Chromium and WebKit, every language;
click-scroll.test.cjs green in both engines; 306 GUI test files that
assert on scrolling or touch the library/skills/MCP, then the other 253,
both engines. Failures seen there were rerun alone: purpose-filter (WebKit,
1px, #1291) and search-api (WebKit zh, #1442) fail the same on the old
app.js; the rest pass alone. No Go changed.
2026-10-11 12:14:35 +08:00
yetone d9d59435f4 gui: a wheel or touch scroll the page is told of only after the view scrolled stays the reader's, not put back as code's (a busy Mac lost the wheel step; panel-arrange's wheel to the foot went back to 0 in WebKit under load)
WebKit scrolls off the main thread, and under load the view's scroll event
fires before the wheel that caused it (probe: scroll at 518ms, wheel
dispatched at 521ms with timeStamp 517ms). The scroll guard took the scroll
as no one's and put it back. Each put-back is now kept for a second, and a
trusted wheel or touchmove made before it was put back, going the same way,
gives it back. A scroll by code put back before the input was made stays put
back.

click-scroll.test.cjs "a wheel the page hears of after its scroll is still
the reader's" delays the app's own wheel listener by 60ms (the trusted
event kept), with nothing clicked and with a click held, and checks a
code scroll before the wheel stays put back. Without the fix it fails in
Chromium and WebKit: "the late-heard wheel must scroll the view".

Run: click-scroll, context-scroll-end, tray-cell-click, panel-arrange in
Chromium and WebKit, all green. panel-arrange 28 parallel WebKit runs
(load avg ~150-200): origin/main 20/28 runs failed (:89 wheel undone x4,
:147 Done x25); old app.js plus the test fix, 5/28 runs failed (:89 x6);
both fixes, 27/28 and 28/28 (the one failure a page.goto load timeout),
Chromium 28/28. Full GUI suite, both engines: the remaining failures are
login-import, routing-sessions and plugin-market, which fail or pass the
same way alone on origin/main. go test -tags nogui ./internal/gui ok.
2026-10-08 19:14:10 +08:00
yetone 82a36a35c7 click-scroll test: Live and a day, and the room kept for a click, are checked where the accounts sit beside the requests (1440px) — red on main since 5d871723 (#860)
5d871723 moved the Routing page's two columns from an 860px to a 1150px
Routing area. At the test's 1100px window the accounts now go below the
requests, so scrolling the view to its end takes the date bar out of sight
first, and "Live and a day, picked in turn, stay under the pointer" and
"the room kept for a click goes as the reader scrolls back" failed in
Chromium and WebKit on every run ("what's clicked must be in sight").
b2345078 and 76d82528 shipped saying they fail the same on origin/main.
Those two subtests open the page at 1440px, the layout they were written
for; the rest stay at 1100, one column, as before.

Verified: git bisect (69665a69 good) names 5d871723; the file fails 2 of 9
per engine on origin/main and passes 18 of 18 three runs in a row with
this change (Playwright 1.63, Chromium and WebKit).
2026-10-07 04:30:26 +08:00
tsuixl 189a4b95ac 修正滚动测试的日期按钮定位与触底判断 (#807) 2026-10-05 07:44:06 +08:00
XYenon 6582aa75a5 gui: connection instructions and editor help are readable, model ids can be selected without picking their row, and keyboard focus comes into sight — the connection labels read at 3.66:1 in light mode and their help was fainter still; they, editor labels and help, settings descriptions and model descriptions use the existing fg-2 rather than changing the muted or faint palette. Gateway model descriptions, the ids in Names & levels and error or warning messages allow text selection, with a selection in a model row leaving it intact and an ordinary click still picking it. Enter and Space can focus another field while the click guard puts the page back, leaving that field out of sight; after the guard settles, a trusted keyboard action that moved focus to a different element reveals it only when needed, through scrollOnPurpose, with Tab and pointer scrolling kept as before. readable-focus tests the contrast in light and dark, mouse selection, ordinary model picks, Tab and Shift+Tab, Enter and Space, and pointer clicks staying put; its three cases fail on the old assets in Chromium and WebKit. click-scroll's date buttons are scoped to .rt-days .rt-day, retaining every scroll assertion. The new tests, click-scroll, settings-groups, gateway-model-info, phone-web and settings-shortcut pass in both engines; go test -tags nogui ./internal/gui, go vet -tags nogui ./..., go build -tags nogui, JavaScript syntax checks and git diff --check pass. (#826) 2026-10-05 04:35:28 +08:00
yetone dbe2f01e7c routing: the requests sit right under the stage, sized to stay in sight with it (Image #23: 这一块离那个路由动画距离太远了,用户点击了这里都不知道发生了什么) — the groups and the providers with several accounts or keys came between them, so a request picked in the list played on a stage scrolled out of sight above. They now come after the requests, and the list is as tall as leaves the stage in view above it (216–420px), scrolling on its own rather than the page. Picking a request no longer sends the list back to its top in WebKit (it was emptied and refilled, which reset its scroll). click-scroll.test.cjs brings a row into the list before picking it, as a reader would; Chromium and WebKit pass 2026-09-29 18:11:10 +08:00
yetone 2ed6dd0520 routing: a request clicked in the Requests list leaves the page where it is (点击这里的任何一个空间都会自动滚动到页面的最顶部,这是重大bug) — picking a request scrolled the view up to the stage on purpose (scrollIntoView with the reader's click in hand, the one scroll the click hold lets through), and the stage is at the top of the Routing page, so every row clicked threw the reader to the top. It no longer scrolls: the row stays under the pointer and the stage and its story change above it; the 'errors your agent saw' count does the same. Live, a day and Replay them all were already held. Tested: a new click-scroll.test.cjs case clicks three rows of a day and Replay them all, each must stay within 1px, in Chromium and WebKit; it fails on main (picking request 3 moved the page 393px) and passes with the change; menu-scroll.test.cjs passes 2026-09-29 16:58:02 +08:00
yetone b95dab91d8 agents: "Show 7 more" unrolls the rows downwards (Image #22: 点击这里为什么是向上展开) — a click holds what was clicked where it is on the screen (v0.1.377), and the button sits under the rows it opens, so as they grew above it the view scrolled to keep it put and the page rode up past them. A control marked data-unrolls is held by the part it is in instead: the rows open down and the button goes down with them. click-scroll.test.cjs checks it in Chromium and WebKit (it fails without the change) 2026-09-29 16:29:33 +08:00
yetone 73af4c282c gui: a click never moves the page, held for every view in one place (为什么点击一个控件总会滚到页面顶部,能否从根上解决) — picking Live after a day emptied the requests' list, the page got shorter than where the reader was, and the browser pulled it up; any code could also call scrollOnPurpose() and scroll on a redraw, a tab switch or a filter. Now what the reader clicks stays where it is on the screen for the next 4s: the element clicked, or once it's drawn again its nearest neighbour or parent, is held in place against content above it changing, and when content below it shrinks, room is kept at the view's foot (a .view-room spacer, gone once the reader scrolls back up) so the page isn't clamped. Code scrolls only with scrollOnPurpose(e) given the reader's own event, and without one the scroll is refused. The wheel, touch, keys and dragging are the reader's and scroll as before. The Routing page's days stay reachable with no live requests, and the library tabs no longer reset to the top. New click-scroll.test.cjs (Live/day switching with the view scrolled to its end, a jump, growth, redraws and helpers with no event, a scroll asked for, the room kept and removed, the wheel) passes 12/12 on Chromium and WebKit; the old code fails it (picking Live moved the page 294px); menu-scroll 22/22 2026-09-29 13:22:00 +08:00