Commit Graph
8 Commits
Author SHA1 Message Date
yetone 80ae904c23 routing: routing groups get a page of their own, beside Routing
The owner asked for the groups to leave the Routing page (11-06): under
the live stage and every request they were a long scroll down, and New
group with them. The design was reviewed before this was built.

- New page, Routing groups (#view-groups), drawn by the routing plugin's
  same script (routingPage), so the editor, its dirty/discard and every
  group action are unchanged. Toolbar: filter, "N groups · M on",
  Templates, Import, Select, and New group as the filled button. The list
  is right under it, and a Settings section under the list holds Found
  groups (with Exclude providers…) and Names in agents' lists.
- No Export button: each group already has its own Copy to share.
- Routing keeps the live stage and the requests. A request's group opens
  the groups page at its row.
- The sidebar has a Routing groups tab right after Routing (from 1024
  points). The header's row has no room for one: at 860px the extra tab
  pushed the logo out (brand.test). There the tab is hidden, Routing's
  tab is lit for both pages (markNav), and Routing's head has a
  "Routing groups ›" button, hidden beside the sidebar.
- Every way in now goes to the groups page: the guide's Open routing
  groups, the panel's and the provider editor's Make a routing group
  (window/main?view=groups&newgroup=…). mainView still takes
  view=routing&newgroup from an older panel.
- Words: "Routing groups", "Open routing groups", "Once saved, make a
  group of them in Routing groups.", and the editor's names note now says
  the setting is under the list, in zh, zh-TW, ja and de. "Open Routing"
  stays for the Agents page's button.
- Docs: providers-accounts, gateway-routing, plugin-runtime, gui-shell
  and reference say "Routing groups page" where they mean the groups.
- Core budget: the core's scripts are 1,533,774 of 1,533,802, paid for
  by three show()/setGatewayMode comments cut in app.js. No raise.

Tests: routing-groups-page.test.cjs (new) covers the page in Chromium and
WebKit, en/zh/zh-TW/ja/de, at 1280, 640 (window) and 420 (web): no
groups on Routing, the tab or the head's button by width, the lit tab,
toolbar order, New group primary and in sight, list then Settings, no
sideways scroll, no native select, no left-border accent; a request's
group to its row; quotas redrawn with an open editor left alone. The
trace tests (routing-compact, -pause-folder, -rule-models, -folder) open
Routing, then show the groups; routing-editor-foot and
name-suffix-where-named scroll by wheel, as the scroll guard lets a
reader; builtins expects the groups tab beside the sidebar only.
Removed: routing-groups-jump (the head's "Routing groups ↓" that scrolled
down to them, gone with them), routing-pointer-pin and routing-steady
(the groups kept in place under requests streaming in above them: no
request is above them now). Their guarantee that what redraws leaves an
open editor and its typing alone is routing-groups-page's quotas case;
Routing's own lists keep their keepInView.

The groups page's jump: a request's group, or a pool's "Several keys"
chip, opened the groups page and scrolled the row to the centre, and the
next frame show()'s backAfterLoad put the page back where the reader
last left it, then brought the focused segment in by "nearest": in
WebKit the pool sat half under the window's foot (routing-mode-goes, 9
of its 10 WebKit cases). goRouting now jumps at once on a page it opens and
marks it arrived(). The wheel in routing-many-keys turns over the keys:
at the page's foot, now shorter, the mouse rested over the requests list
(.rt-reqs, overscroll-behavior: contain), which took every wheel up, and
the test stopped with 2 keys in sight. That is #4082's cause.
routing-days-fit's fixture has 12 requests, a day that fills the window,
since the day bar held needs room under it.

Run on mote (macOS 27, load 25 to 65), Playwright 1.62.0:
- Go: go vet, gofmt -l and go test ./... at the rebased head (650bf8412
  base) ok except TestMainWindowCorners (#3949); internal/gui again
  after the last edits: the same, TestCoreScriptBudget ok (1,533,773 of
  1,533,802, no raise).
- GUI, the 262 files a change here can reach, at the head and at the
  base: the reds at the head are the base's, with their issues:
  menu-input-scroll #3402, provider-mask #5109, context-fold and
  order-unknown (webkit) #3479, header-centre #3479, i18n-keys
  #5332/#5426/#5482, account-eye #5052/#4244, call-headers webkit de
  #5045, codex-predictions #2624, codex-auto-reset webkit de #4790,
  routing-* under load #5088, and zero-priced-free, last-page,
  reasoning-speed, routing-row-swap/-tag-whole/-story-shrinks/-steps-cap
  and routing-intent-entry, red at the base the same way.
- After the last edits: the 11 files with a way to the groups page or
  its scroll (group-*, routing-groups-page, routing-mode-goes,
  routing-groups-off, routing-provider-off, routing-many-keys,
  click-scroll), 175 of 176; the one red is routing-many-keys webkit's
  wire at the foot, red at the base in 8 of 12 (#5543). brand,
  gateway-mode-sessions, header-zoom-fit, header-centre,
  inner-scroll-contain and mobile-web: the same 11 reds at the head and
  the base (mobile-web compares with origin/main through git, which a
  mote-run copy hasn't).
- Rebased on ecc26a339, again: gofmt -l, go vet ./internal/gui and
  TestCoreScriptBudget ok; 10 GUI files (i18n-keys, routing-groups-page,
  routing-mode-goes, sidebar, brand, menu-first-second, library-bar-more,
  click-scroll, name-suffix-saved, unlisted-models) 211 of 212, the one
  red i18n-keys' "a plugin's words are its own", red the same at
  ecc26a339 (#5332/#5426/#5482).
- Broken by hand: without the groups page's CSS rule, brand and
  routing-groups-page go red (32 fails); with the old goRouting,
  routing-mode-goes is red in 9 of its 10 WebKit cases.

Not tried: the whole GUI suite on Linux (WSL magpie-desktop) at this
head; a run at an earlier head is under way and has the Linux reds
#4120/#4121 name. Not tried in the real macOS app, only Playwright's
WebKit.
2026-11-06 23:11:43 +08:00
ggbdpq d1b0b34430 gui tests: sidebar's unroll is counted as its animations are made
"the list opens and folds as it plays" sampled getAnimations() once
after the click to see the list's unroll still playing. Under a machine
load of ~175 that one sample landed after the whole play was over: a
finished animation is out of getAnimations(), so the test read "not
animating" and went red once (8be402816's GUI run; it passed on rerun).
The list unrolls for 460 ms and its rows come one after another for 636
ms in all - the round trip from the click through the element wait to
that one sample is not bound to that window.

The animations made are counted instead: Element.prototype.animate is
wrapped ahead of the click, and the assert reads that the nav-sub's own
unroll was among them. An animation made is a fact that stays put, so
the sampling race is gone. The assert is not looser: an opening with no
animation still fails it.

Run (playwright 1.62.0, idle machine):
- this file: 10 runs, 160/160 ok (Chromium and WebKit)
- nav-sub-unroll, sidebar-glide and sidebar-tab-top together: 2 runs,
  136/136 ok
- a 700 ms wait put between the click and the old sample turned it red
  with the reported "the list unrolls" assertion; with this change the
  same wait passes, and cutting navSubEnter's animations off turns it
  red again
Not tried: a machine at load ~175 (the load figure is the report's; the
delay injection stands in for it).

Siblings: provider-advanced-fold's boxMoves() reads getAnimations()
once after its own click the same way; it has no observed red, so it
stays as it is.

Fixes #2950

Generated-by: GLM-5.3-Flash (ZCode)

Review (at the pushed head, mote, playwright 1.62.0): agent-expand-steady,
sidebar and lightweight together, Chromium and WebKit, 30/30 ok.
navSubEnter animates the nav-sub box itself, so the wrapped animate sees
it. The sibling named above is filed as #5417.
2026-11-06 05:53:50 +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
yetoneandggbdpq 95a4180c0b gui tests: the sidebar lists expect Masking's tab, and Built-in wheels to rows it can reach (#3498)
e698a688 gave Insights › Masking a sidebar tab (data-view="masking",
between Usage and Plugins, shown while the redact built-in is on, as it
is in the fixtures). builtins, gateway-mode and sidebar kept the old
lists. ggbdpq's patch on #3498 (5db37861) adds masking where the nav puts
it; ported as written, with the deepEquals left exact.

With the lists fixed, builtins was still red, in its scrolling. Its
wheelTo moved the mouse to the list's top corner. After the first turn
that corner had scrolled out of view, so the second turn scrolled nothing.
At 420 the rows wrap and Usage's row sat at 884px under a 672px fold, with
view-plugins at scrollTop 400 of 747 (measured). In WebKit, Observability's
row is below the fold, and a click's own scroll is put back
(scrollOnPurpose), so the click never landed. wheelTo now turns the wheel
over the visible part of the list until the row is in view, five turns at
most, and asserts the row was reached. Observability is reached the same
way before its click.

Run at this head (origin/main 9fc382e66):
- builtins.test.cjs, chromium and webkit: 4 of 4, twice. With the list
  patch alone: 2 of 4 (wheelTo timeouts).
- gateway-mode.test.cjs: 6 of 6. sidebar.test.cjs: 18 of 18.

Not run: the whole GUI suite.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-26 03:40:44 +08:00
yetoneandchiperman 6874095b15 gui: the sidebar's gateway line is drawn from boot.js, before the providers' read (#3429, chiperman)
After a refresh the sidebar's gateway line came in about 1.5s late: it
was drawn only by sideGwRead, which waits 1500ms before it reads
/api/providers. chiperman's commit (c1f457a1b) has boot.js carry where
this process's gateway listens, and app.js draw it at once. Ported with
changes:
- api.go puts sideGateway in boot.js only when this process serves the
  gateway (served.Load() != nil), with the URL from gateway.URL(), the
  one /api/providers reports, and marked boot. Another magpie serving
  the port: nothing is sent, and the providers read decides as before.
- app.js starts sideGwAt from boot.js, so the first layoutNav draws it;
  chiperman's separate renderSideGwBoot is folded into that. A value
  from boot.js is read again at 1500ms like before, so /api/providers
  has the last word: served is set before the listen succeeds, so a
  listen that failed, or a gateway stopped since, shows "Gateway
  stopped" then. Without the re-read the boot line could stay stale.
- app.js is 45 bytes under its budget, which is unchanged.
Not fixed here, and pre-existing on main: Settings' address Apply leaves
the line on the old port until a reload (#3531). Seen in real sandbox
apps on main (3483 -> 3486) and with this change (3481 -> 3485).

Tests: TestBootSaysWhereItsGatewayListens (gui) checks boot.js's
sideGateway for 127.0.0.1:3481 and for 0.0.0.0:3483 shown as 127.0.0.1,
and none when this process doesn't serve. sidebar.test.cjs gets the
line from boot.js before any providers read, and a new subtest: the
boot.js line for 3425 is read again and turns to "Gateway stopped" on
3490 once providers says so, with one read.

Run on origin/main 46c418832 at this commit:
- Real app at the pre-rebase c28576084 and origin/main beside it,
  sandbox HOME, `go build -tags dev`, MAGPIE_DEV_UI
  127.0.0.1:3482, gateway on 3481 (main's on 3483), both engines,
  load and two reloads each: main shows the line 1885-2015ms after
  load; this change 70-216ms. One providers read in each.
- gofmt -l: nothing. go vet (darwin) of gui/gateway/cli,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -count=1 -timeout 45m ./internal/gui/ ./internal/cli/
  ./internal/gateway/: ok (gui 133s, cli 39s, gateway 405s) (TestCoreScriptBudget among them).
- GUI, both engines: sidebar, refresh-page, gateway-port, mobile-web,
  compact-at, routing-kind: 64/76; the 12 reds are sidebar's page list
  missing Insights › Masking, red on origin/main too (#3498). With that
  list given "masking" for the run only, sidebar is 18/18.
- Broken by hand: sideGwAt = null fails 10 sidebar subtests ("the
  gateway's line from boot.js"); the old `!sideGwAt` guard fails the
  new subtest in both engines; `false &&` in api.go fails
  TestBootSaysWhereItsGatewayListens.
- Whole GUI suite at the pre-rebase pair c28576084: see the #3425
  commit before this one; every red file has an issue (#3557 and #3558
  filed for it, #3535 earlier).
- Not tried: Linux or Windows real app.

Co-authored-by: chiperman <34889778+chiperman@users.noreply.github.com>
2026-10-25 12:06:13 +08:00
yetone 17a2b00efb gui: the sidebar's open page moves from row to row on a spring, as iOS's selection does
The owner asked for the sidebar's pages (Providers, Routing, Gateway…)
to slide from one to the next like their sub-tabs do, "like iOS".

The open page's row is now marked by one shape (.nav-top-hl) that
navTopGo moves on a damped spring (NAV_SPRING: SwiftUI's response
0.42s, damping 0.84; navTopStep, four sub-steps a frame, dt capped):
- it sets off as the row is pressed, and comes back if the press
  leaves the row or the page refuses to be left;
- being physics, a press that changes its mind turns it with the speed
  it has, never a jump;
- it follows its row while Usage's tab list folds above it and lands
  where the row ends up;
- it is put in place, not sent, when the window opens on a kept page or
  the rows move under it at rest (ResizeObserver); away while Settings
  is open, it fades back in on its row; reduced motion jumps; the
  header's tabs keep their .thumb and draw none.
The rows give up their own ground (open, hovered, pressed) to it.
#nav is position: relative in the sidebar for it, so .seg's centring
left/top are reset (without that the whole list sat 105px right).

Tests:
- sidebar-glide.test.cjs (new): Chromium + WebKit, en + zh, 1024 and
  1440, plus 900 (header): at rest on its row and the list in the
  sidebar, no ground hovered, press sets off before release and comes
  back off the row, Providers→Usage→Agents by frames (≥3 moving
  frames, overshoot < 3px) landing on the row, Settings hides it and
  Routing brings it back, reduced motion jumps, no page errors.
  Broken by hand: without the left/top reset the list check goes red;
  before the "not seen yet" rule the boot slid from Agents (red).
- sidebar.test.cjs: a pressed page row no longer darkens itself (the
  shape comes to it); Settings still must.
- routing-idle-frame.test.cjs counted every self-asking rAF callback as
  Routing's loop, so navTopStep after the click read as 33 Routing
  frames. It now counts only callbacks no global holds (app.js's are
  globals; Routing's frame is in its plugin's scope). Broken by hand:
  Routing's loop made to always ask again → 4 red; green on main's
  assets and on this change.
- TestCoreScriptBudget: app.js 1,343,324 / core 1,535,084 with no room
  added; the sidebar is the window's shell, not a page a plugin can take.

Run:
- Full GUI suite at 183fa169b (this change on 3b10a403d), alone on the
  machine but at load ~216: 11942 pass, 104 fail. The 25 red files
  rerun at load ~10 on this change and on 3b10a403d: the same reds on
  both except routing-idle-frame (fixed above); plugin-card-update,
  segment-press-dialog and sidebar-overlay-scrollbar pass alone here
  (segment-press-dialog red alone on main: #3416). Reds on main, filed:
  #3402 #3403 #3404 #3405 #3406 #3407 #3408 #3409 #3410 #3411 #3412
  #3413 #3414 #3415; already filed: #3350 #3099 #3096 #3094 #3091
  #3104 #3001. codex-predictions and codex-auto-reset were red only at
  load ~216 and passed in both reruns.
- At the pushed head (rebased on f3eb92924): sidebar, sidebar-glide,
  nav-sub-unroll, side-toggle, side-width, header-relang,
  sidebar-tab-top, settings-tabs-stick, omarchy,
  sidebar-overlay-scrollbar, click-scroll, routing-idle-frame,
  plugin-card-update, segment-press-dialog, i18n-keys: 230/230;
  go test -tags nogui -run 'TestCoreScriptBudget|I18n|Docs'
  ./internal/gui: ok; gofmt -l clean.

Not tried: the real Linux app (WebKitGTK); this uses only rAF and
transforms, no view transition. Not run: the full Go suite (only
internal/gui's budget/docs tests; no Go code changed).
2026-10-24 02:21:45 +08:00
yetone 92fbabb47e gui: the Providers page draws the last list at once and the fresh one behind it
#1519 (fatkun): the Providers page asked /api/providers each time it
opened, and after a start that read takes seconds (every account's
sign-in, every agent's model), so the page showed skeletons that long.

Now, as the Agents page draws the last state:
- the app reads /api/providers once in the background after the start
  (prefetchProviders), and the page's first opening uses that read, or
  waits on it, instead of asking again. The sidebar's gateway line
  reuses the same read (sideGwRead), so a start still makes one read.
- the server keeps the list it last built in the cache folder
  (providers-state.json, 0600; lastproviders.go) without the gateway's
  recent calls and lanes or any provider's headers, proxy or extra body.
  /api/providers?last=1 serves it at once; the page draws it while the
  fresh read is out, and the fresh one replaces it.
- a row clicked on a kept list waits for the fresh one rather than
  opening an editor that would be drawn again under the reader's hands.

Tests:
- TestLastKnownProviders (internal/gui): red when the stripping of
  Headers/Proxy was broken by hand ("the kept list holds hdr-secret-1519
  / proxy-secret-1519"), green restored.
- providers-last-known.test.cjs (new): the kept list drawn before the
  fresh read answers, then replaced; a row click waits. With
  kept.last = false by hand the row-click case was red in all 5
  languages.
- sidebar.test.cjs: the narrow case now guards one /api/providers read
  in total, still one after widening to 1200px (the sidebar reuses it).
  Red on the old assets (0 reads), green on the new, both engines.

Run:
  go test -timeout 45m ./internal/gui
  ok  	github.com/yetone/magpie/internal/gui	528.667s
  gofmt -l internal/: nothing; go vet ./internal/gui, GOOS=linux and
  GOOS=windows go vet -tags nogui ./...: exit 0
  GUI, chromium and webkit, every language, wide and narrow:
  providers-last-known 20/20, sidebar 8/8, provider-proxy 4/4,
  agents-last-known 3/3, last-page 1/1 in each engine.
  provider-advanced-fold: 1-3 of 25 red per run, the same on the old
  assets (#2552).
  Chromium full GUI suite (before the kept.last and sidebar-test edits),
  under load ~200: 5681 tests, 55 red in 23 files; each was rerun alone
  and either passed or was as red on the old assets. routing-model-rest
  runs, old vs new: old 4, 2, 7 red, new 3, 3 red; routing-request-
  metrics two runs: old 1, 0 red, new 0, 2 red, each red at 23-29s
  (load ~240; the same test red on old).

Not verified: a real cold start on Windows; the webkit full suite (59
provider/sidebar/start files run: 516 tests, the reds there pass alone or
are #1863).
2026-10-20 20:23:56 +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