Commit Graph
14 Commits
Author SHA1 Message Date
yetone 326e72f4c5 routing: the "No session ID" group folds like the others, and one button folds or opens every group (zzzkl on Discord)
zzzkl: the Routing page's 未提供会话标识 group couldn't be collapsed. Its
head was a div with no click handler, no arrow and no aria-expanded,
because only a group with a key could be folded (`g.key ? "button" :
"div"`). closedSessions is keyed by the group's key, and "" is a key a Set
holds, so the no-session group now uses the same button, arrow and
handler as the rest.

Also, as asked: an icon button in the request list's existing header row
(.rt-fold-all, beside Replay) folds every group while any is open, and
opens them all otherwise. It shows only when the list is grouped (by
session or by key) into two or more groups. It has a tooltip and an
aria-label only, no text: "Collapse all" / "Expand all". Those two words
moved from plugins/library/i18n.js to the core i18n.js (zh, zh-TW, ja,
de), since Library and Routing now both say them (i18n-keys: a word used
by two plugins is the core's). The core script budget doesn't count
i18n.js or plugins/, so it isn't raised.

routing-sessions and inner-scroll-contain found group heads by
`button.rt-session` with a key; they now filter .rt-session by text, as
the no-session head is a button too.

Run (mote, node --test, Chromium + WebKit):
- routing-fold-all.test.cjs (new): 2 engines x 1100/420 x en, zh,
  zh-TW, ja, de. It covers the no-session group folding on click, the
  fold-all button folding then opening every group, its tooltip in each
  language, and it being hidden with one group.
- i18n-keys, i18n-en-no-cjk, routing-sessions, inner-scroll-contain,
  skill-fold-all, routing-row-swap, routing-rule-drag,
  routing-order-unknown, routing-many-keys, in one run at concurrency
  3 with routing-fold-all: 170 tests, 157 ok, 13 red. Every red is also
  red on a clean origin/main 8bfc551ee checkout run alone (concurrency
  1, 42 tests, 14 red), and each already has an issue:
  i18n-keys "a plugin's words are its own" ("View routing", "No session
  ID" said by Go tests, #5332), routing-many-keys "2 keys in sight"
  (#4082), routing-order-unknown webkit de 420 (#4627),
  routing-row-swap (#3799), routing-rule-drag chromium (#3789, #5088).
  routing-fold-all, routing-sessions, inner-scroll-contain,
  skill-fold-all and i18n-en-no-cjk are all ok.

Broken by hand: on the old client.js, routing-fold-all fails with "the
no-session group can't be folded" (and finds no fold-all button).

Not tried: the real app's WebKitGTK on Linux, or Windows WebView2.
2026-11-05 22:07:46 +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 a8224019af routing: a day of thousands of requests draws only the rows in sight, and its numbers are measured again on a new width only (#2524)
UNscientific-9 (#2524): picking a day on Routing's request list froze the
page for seconds with thousands of rows. renderLog built a row for every
request of the day (~20 elements each, up to 2,000 a day) and put the new
ones in among the old row by row, so both days' rows were in at once.
Beside that, metaFit was run by a ResizeObserver on the column's every
change of size; the meta-under mark it sets changes the column's height,
which measured every row's numbers again (the reporter saw 8 runs in 8s,
~200ms each).

Now:
- A list of 300 or more items is windowed: only the rows in and near
  sight are drawn, between two aria-hidden gaps as tall as the rows above
  and below. A drawn row's height is measured and kept; one never drawn
  counts as the average. Scrolling or a resize draws the rows then in
  sight, once a frame, and the first row in sight stays where it was.
- The columns stay as wide as before: for each shape of row not drawn
  (its time's digits, model and kind, its numbers), one unseen, inert
  zero-height probe row stays in the grid, so the auto columns size by
  it. The digits are tabular, so a probe stands for its shape.
- A list made mostly anew (another day) is put in with one
  replaceChildren, not row by row among the old ones.
- metaFit runs on a change of the column's width only. When it moves the
  numbers under or back, the list is drawn again for the new heights.
- A row's clock uses one cached Intl.DateTimeFormat.
Under 300 items the list is drawn whole, as before.

Not done here, from the reporter's list: drawAll still runs renderHist on
a static day at each poll. Measured with a live request arriving every
250ms while a 2,000-row day was shown (scratchpad dayidle.cjs, chromium,
4s): frame callbacks 330 / 211 ms total / 9 ms longest before, 90 / 52 ms
/ 4 ms after. A guard there would have to know every input of renderHist
(now(), lifted rests, names), so it was left out. Trimming prompt.parts
from the payload is on the server, not here. The renderer crash on
repeated switches was not reproduced.

Measured (scratchpad dswitch.cjs, 2,000 rows a day, 1280x900, five day
switches each, wall ms / longest block ms, load average ~220-290):
- chromium before: 379/304 454/374 452/374 474/389 427/376, rows=2000,
  ~39,740 elements
- chromium after: 56/22 61/20 56/19 74/21 410/17, rows 17-21, ~1,520-
  1,600 elements (the 410 is wall time under load; its longest block 17)
- webkit before: 565/461 624/493 639/526 625/516 616/516, rows=2000
- webkit after: 117/37 95/25 93/30 128/26 138/25, rows 17-21
- same grid columns and list height after as before, in both engines:
  chromium "89.4375px 94.1875px 661.078px 181.297px", scrollHeight 61602;
  webkit "89.4375px 94.1875px 641.078125px 181.296875px", 61602

Run:
- tests/routing-day-window.test.cjs (new), chromium and webkit, en zh
  zh-TW ja de, 1280px and 420px: 30 tests, 30 pass. It picks a 2,000-row
  day, checks the rows drawn are bounded and the list is as tall as all
  of them, scrolls to a wide model far down (columns unchanged, not cut),
  holds a row still across frames mid-list, reaches the last row and picks
  it, switches day, and goes By session to the list's foot. The second
  test grows the column taller three times and counts reads of the
  numbers' boxes: 0, and >0 on a new width.
- Same test on the old assets (MAGPIE_ROUTING_ASSETS, the routing
  client.js/css before this change), chromium en: 3 fail, "a day of 2000 put 2000 rows in
  the list" (both widths) and the measure test (12000 reads, not 0).
- Broken by hand: WIN_MIN 300 -> 300000 fails "a day of 2000 put 2000
  rows in the list"; the width guard taken out fails "156 !== 0" in both
  engines. Both restored.
- tests/routing-sessions.test.cjs: its 2,001-request history test now
  scrolls to a session's group instead of expecting all 2,001 rows in the
  DOM. 8 pass, 0 fail (chromium and webkit, en and zh).
- routing-*.test.cjs, panel-routing*.test.cjs and every other GUI file
  that reads the request list (claude-auth-status, claude-subagent-tag,
  dates-gui-lang, click-scroll, codex-subagent-model, codex-credits,
  desktop-subagent-model, key-nourl, phone-rows, reasoning-speed,
  remote-group-served, purpose-filter, search-instead, rest-try-now,
  search-mcp, vision-mcp), both engines, every language, concurrency 4:
  1412 tests, 1390 pass, 22 fail. 18 of those are routing-bodies,
  routing-keys-fold, routing-model-rest, routing-request-metrics and
  routing-wb-restricted, which fail the same way on the old assets
  (#2658, #2559). The other 4 (rest-try-now chromium en 1100 and ja 420,
  routing-log-icons webkit zh, routing-time-went chromium de) pass when
  their files run alone: 64 tests, 64 pass.

Not tried: WebKitGTK and the Windows WebView2 app (where the reporter's
seconds-long freeze was on Windows); the numbers above are Playwright's
Chromium and WebKit on macOS.
2026-10-20 20:23:53 +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 1e405be3fc gui tests: routing-sessions' suggestion groups answer the names ask with the titles their trace carries, as the gateway does; the Claude Code row has the page ask 300ms after it draws, and the empty answer took the titles away under load (#1307) 2026-10-09 01:02:51 +08:00
yetone 8576e3cc33 gui tests: routing-sessions leaves the held live trace for a reload to cancel; letting it go just before the reload had the page ask again while going away, which WebKit turned away "due to access control checks" as a page error (#1307) 2026-10-09 01:02:51 +08:00
yetone 4b8bfd4676 gui: Routing's By session heads a Claude Code (and every other agent's) session with its own name, not its UUID (#1293, luzhuang)
Only Codex sessions were named (from Codex's index). The page now also asks
POST /api/gateway/session-titles for the other agents' sessions it lists,
as agent:id keys, and sessions.Titles reads each from the agent's own files
the way the Sessions page does: the name given in magpie, else the agent's
own title (Claude Code's ai-title / custom-title), else the first prompt.
Each key is asked once; the names are kept on the page, so a live update
that replaces the rows keeps them. A session with no file here keeps its id.

TestSessionTitlesNameOtherAgents fails without the change (titles = map[]),
and routing-sessions' "other agents' sessions show their own names" times
out waiting for the name without the routing.js change.

Run: HOME=<temp> go test -tags nogui ./internal/gui ./internal/sessions;
go vet for darwin, linux and windows; the 72 routing GUI test files in
Chromium and WebKit (491 pass, 0 fail). No new t() strings.
2026-10-08 18:49:16 +08:00
yetone 76dc5aed48 gui: Routing flies a request still under way when the page's first frame came before the trace, and the Requests table's sideways scrollbar goes once the table fits; GUI tests brought up to date with the app
Two app bugs, found where GUI tests failed on main in Chromium:
- Routing: the page's first frame looked for requests to fly before the first trace had come in, found none, and nothing flew them after it came, so a request still under way when Routing opened never reached its member's row (routing-try-fixed failed every run). The first trace now flies those under way when a frame has already been drawn, as coming back into sight does (underWay, shared with resume).
- Usage › Requests: a table that had come to fit its window (led tight) kept #ledHScroll's bar under it with nothing to scroll; ledGrow now redraws the bar on every resize, not only when it leaves columns out (usage-speed "no sideways scrollbar").

Stale or racy tests, the app right:
- library-own-folder, list-sort, shared-skills and nine other Library tests counted the loading skeleton's rows (the "5 vs 4 rows" and the empty lists were the skeleton, not the repo group headers); they wait for .lib-body:not(.lib-skel). library-own-folder's 61px scroll was Playwright's own retry on a button still sliding in, not the app (no scroll setter ran): it waits for the entrance to finish.
- sessions-overview measured the picked bar while the folder's overview redrew the bars; it measures once the overview is in.
- menu-scroll: its agent needs wired and a ref to show a model picker, and the page now asks plugins/updates, usage/quotas, agents/install and whatsnew.
- routing-sessions' large-history tests failed from local midnight until the UTC offset passed: the fixture's times were UTC while the gateway writes local times with their offset, which openRoute takes the day from.
- ledger-hscroll and view-scrollbar measured scrollbars in Chromium launched with --hide-scrollbars; they launch without it, as menu-scroll does.

routing-try-fixed and usage-speed fail without the app changes and pass with them (checked by putting origin/main's routing.js and app.js back). go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass (TestHostJSCancellation timed out once under the full run's load and passes on its own, 3 runs).
2026-10-06 03:20:34 +08:00
Zhu Wang 4c5a30dc0e gui: Routing shows request cache rates and output speeds, with metrics chosen as they are ticked (#941)
Keep the compact request rows, add weighted session rates and token breakdown tooltips, and give the request list more room beside accounts.

Verified with Chromium and WebKit in English and Chinese: request metrics, columns, effort rows and changes, burst speeds, session estimates, and shared menus. The request-metrics test fails on main because the cache-rate metric is absent.
2026-10-06 02:23:28 +08:00
Zhu Wang a77883ec91 fix(routing): label Codex background prompt suggestion groups (#859)
* fix(routing): label Codex background suggestion groups

* fix(routing): complete suggestion translations and regression coverage
2026-10-05 13:19:49 +08:00
Zhu Wang 6dd0079b86 fix(routing): group Codex image title requests with their chats (#797) 2026-10-05 00:14:23 +08:00
Zhu Wang a13923a1e3 fix(routing): automatically group Codex title requests with their chats (#768)
* fix(routing): associate Codex title requests with applied chat titles

* fix(routing): address automatic title grouping review
2026-10-04 18:56:31 +08:00
Zhu Wang 2e77c546d7 routing: label Codex background memory groups (#753) 2026-10-04 14:06:29 +08:00
Zhu Wang 1adb2b571e feat(routing): group requests by session with names and estimated costs (#396)
* feat(routing): group requests by session with names and estimated costs

* fix(routing): address session view review feedback

Preserve Luna Reserve and other header fallbacks for ordinary Codex turn metadata; reuse metadata and the kind across trace and native accounting. Default to By request and persist the grouping choice. Store only token accounting fields in route history while retaining legacy JSON compatibility.

Add regressions for helper precedence, native kind accounting, history compatibility and grouping preferences.
2026-10-01 20:50:15 +08:00