issennknight on Discord (macOS 13.7.8, v0.1.1902), afterf92db4cdd: "路由 用量 页面 刚点开并滚动页面时会抖动复位". 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 and425a61322touched 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 onto2f5548371: 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 ontoc3462d5fe(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 atc3462d5feitself (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 at2f5548371, 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 at2f5548371and 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.
Subsystem design references
These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.
| Subsystem | Reference |
|---|---|
| Built-in subscriptions moving to plugins | Provider and plugin ownership |
| Built-in plugins: registry, lifecycle, plugins.yml, presets, settings schemas, the window's kernel (slots, error boundary, kit) | Plugin runtime |
| Plugins that run on the gateway's requests and replies | Gateway middleware |
| Tools that plugins give, offered to every agent as an MCP server | Plugin tools |
| Plugins that await context recall and observe completed replies | Asynchronous gateway request hooks |
| Claude subscription turns across Claude Code runs | Claude subscription bridge |
| How the gateway picks a provider, key or account, and falls back | Gateway routing and fallback |
| Gateway Session Aggregation | Gateway Session Aggregation |
| Connecting an agent's config to the gateway, drift, disconnect, WSL twins | Agent wiring |
| Providers, keys, subscription accounts, refresh and allowance | Providers and accounts |
| Instructions, MCP servers, skills and RTK written into agents | Library |
| One MCP server, magpie, given to every agent in place of the Library's servers | MCP hub |
Tray, panel, window, magpie web and the page's JSON API |
GUI app shell |
| Encrypted backups and setup synchronization over WebDAV, S3 or GitHub | Sync and backup |
A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.
Maintain a reference
Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.
Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.
For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.
Describe a PR's semantic changes
For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.
For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.
This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.
Review a change
- Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
- Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
- Check that changed contracts appear in the owning reference and that source links still resolve.
- Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.
A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.