Commit Graph
7126 Commits
Author SHA1 Message Date
yetone 79decfe71a library: the agents ticked for instructions are given memory's digest
The agents ticked under Library → Instructions get a "## Memory" part in
their instructions: the global memories, the agent's own, and each
project's under the folders it was seen in (memory.Digest), unless
Instructions.NoMemory. The digest changes only when published, so an
agent's instructions (and the prompt cache on them) change mid-session
only then: at once when the user changes memory (PublishMemory(false),
called by the GUI), and once a day from KeepLinked's loop for what
agents saved meanwhile (PublishMemory(true) -> memory.PublishDue).
PublishDue writes nothing while memory has never held anything, so a
user who never uses memory gets no memory.json.

Run (mote-run, whole worktree, with the rest of the memory layer):
- go test ./internal/memory ./internal/library: ok (library 130.9s)
- go vet ./internal/memory ./internal/library ./internal/gui, GOOS
  darwin, linux, windows: ok
- gofmt -l: clean
Broken by hand (mote-run -run TestMemoryDigestInInstructions):
- memoryDigest's NoMemory check removed: red. It first stayed green,
  since the test switched NoMemory on with memory.json deleted; the test
  now gives memory back and sees the part return before switching it off.
- PublishDue's "nothing kept" guard removed: red ("a due publish with
  nothing kept wrote memory.json").
Not tried: a real agent reading the digest in its instructions.
2026-11-10 03:25:44 +08:00
yetone 4f0c587306 memory: a store of what agents learn about the user, shared by every agent
The first part of the memory layer: internal/memory keeps memories in
memory.json (lastgood + atomic writes under a file lock; a file that can't
be read is unknown and never written over). Each memory has a scope
(global, project:<git remote key>, agent:<id>), a kind (profile,
preference, rule, reference, fact, procedure, episode), free tags, an
origin and a status. Saving the same text in the same scope merges into
the memory already there; an agent's save never changes the kind or why
of a memory the user wrote or pinned.

A project is keyed by its origin remote, so every clone and worktree of a
repository shares its memories. Search is word-matched with CJK split
into characters and pairs. The digest agents will be given is published
on demand (a user's change, or once a day), never at an agent's save, so
instructions don't change mid-session; its text names no app or vendor.

Nothing uses the package yet: the MCP server, the Library's digest and
the GUI come next.

Run (on mote): go test -tags nogui ./internal/memory, -race -count=3,
TZ=Asia/Shanghai; go vet for darwin, linux, windows; gofmt -l clean.
Broken by hand: an agent's save allowed to change a user's memory
(TestUsersMemoryNotChangedByAnAgentsSave red) and a digest computed live
instead of published (TestDigestChangesOnlyWhenPublished red).
2026-11-10 03:25:44 +08:00
yetone e369d587c3 dsh: a round hashes dsh's files through a buffer, not read whole
dshFilesSum, which says whether anything a dsh round reads changed, read
every profile's patch list, the home layer, settings, .env, keys and old
config into memory with os.ReadFile only to hash them. Both dsh homes do
a round every 30s at rest, and a patch list names every model magpie
serves (39KB each in the real account here, two profiles), so each round
allocated each file's size again. Now each file is streamed into the
maphash through a pooled 32KB buffer (dshSumFile); the sum is the same as
for the bytes written at once, so a round after the update still matches
the one before.

Measured on mote with a copy of the real accounts (acidle.sh, alloc
between 60s and 180s at rest, the heap dump's own allocations left out):
- t18 (c02a491e8): 9.4MB, of it dshFilesSum 2.1MB
- t19 (this): 7.7MB, dshFilesSum gone from the profile

Test: TestDshFilesSumReadsNoFileWhole (the sum equals the one for files
read whole, a change at the end of a 1.1MB list moves it, and a sum
allocates under 64KB). Broken by hand: with os.ReadFile back it is red,
1149490 bytes a sum for a 1140000-byte list.

Run on mote at this tree (rebased on c02a491e8): go vet ./internal/agent,
gofmt -l clean, go test -timeout 45m ./internal/agent ok (246s).
Not tried: Windows and Linux (os.Open/Read only, no OS-specific code).
2026-11-10 03:20:04 +08:00
yetone c02a491e87 provider: a Codex auth.json is parsed once for its bytes, not on every look
codexWho (email and workspace) and codexLoginIn's user and plan are read
from an auth.json's bytes alone, yet were a JSON parse and a JWT decode on
every call: codexName runs sameLogin over every saved account against each
other, and liveLogin("codex") is asked from four loops at rest
(loginsNow, rememberLogins, heldByCodex, renewLogins). Both now go
through authMemo, a map keyed by the bytes (a hit makes no string and
allocates nothing), emptied at 64 entries so tokens renewed every hour
don't pile up.

Measured on mote with a copy of the real accounts (acidle.sh, alloc
between 60s and 180s at rest):
- t17 (0d99261dc): codexLoginIn 3.08MB, codexWho 2.56MB
- t18 (this): codexLoginIn 0.52MB, codexWho gone from the profile
/api/providers ×40 is the same (117.5MB vs 115.4MB, sampling noise).

Tests: TestCodexWhoKeptByBytes (two accounts and a malformed one read
right twice; a second read, also from another slice of the same bytes,
allocates 0 times) and TestAuthMemoBounded. Broken by hand: codexWho
reading past the memo makes the test red (29 allocs, want 0).

Run on mote at this tree: go vet ./internal/provider, gofmt -l clean,
go test -timeout 45m ./internal/provider ./internal/gui: gui ok; provider
ok on 2 of 3 full runs, the third red on
TestCodexAppWorkspaceSwitchReadsEachWorkspace/reclaimed=false/backHome=true
(ws-team's usage never read), which is #5819, filed on main before this
change; alone, -count=20 passes 20 of 20 both on origin/main and here.
Not tried: Windows and Linux (no OS-specific code touched).
2026-11-10 03:10:48 +08:00
yetone 9d4c338a67 gui: magpie web on a phone no longer scrolls sideways or keeps a band at its foot (#4943)
precis1onz (iOS Safari, dark, English, Usage) saw the page move sideways
and a dark band stay at the screen's foot.

- Sideways: Usage → Requests' "Split by" row (label and five choices) is
  one unwrapped span, 393 to 558px wide at 375 to 430px. It was the only
  thing wider than a phone in any view or language. On the phone layout
  it now wraps inside the screen (app.css, phone block only).
- The band: the Requests table's stand-in scrollbar (#799) is sticky at
  the view's foot, and a touch screen draws no bar in it, so it stood
  there as an empty 12px band. ledHScroll now leaves it hidden on
  (hover: none) and (pointer: coarse); a finger moves the table itself.
  A desktop keeps it as before.

New test, phone-no-sideways.test.cjs: every view (Agents, Sessions,
Providers, Routing, Groups, Gateway, Library, Plugins, Masking, each
Usage tab, Settings' tabs) on an iPhone at 375 in en, zh, zh-TW, ja, de
and at 390 and 430 in en, in Chromium and WebKit, with long ids, emails
and paths; nothing may be wider than the screen and no empty band may
stay sticky at a view's foot. ledger-swipe now expects no bar on a
phone, and that the swipe moves the table.

Run (mote, through mote-run):
- phone-no-sideways: red on the old assets (803d7747e) in every run,
  led-split too wide plus the empty #ledHScroll at the foot; green on
  the new in both engines, again at the rebased head with ledger-swipe
  and usage-ledger-leave.
- mobile-web 14/14 in both engines with a real git base in the copy,
  so the desktop layout matches the base.
- Every GUI file the change can reach (1485 tests, both engines): the
  reds are all red on base and filed: mobile-web desktop subtests in a
  copy without .git (#5013), phone-connect-menu 420 (#4706),
  usage-agents-hide (#2276), usage-computers sync tick in Chromium
  (#5224), usage-fold (#3415), usage-ledger Requests (#5048).
  ledger-swipe in WebKit flakes on base too (#5223).
- go test -tags nogui ./internal/gui ok (size budgets), also at the
  rebased head; gofmt clean; go vet for darwin, linux and windows ok.

Not run: the whole GUI and Go suites. The run was queued over two
hours behind mote's suite.lock and never started; the change touches
no Go code.
2026-11-10 03:00:30 +08:00
yetone 198c16d0c4 gui: a window set aside, counted of a total, takes a new cap of its own
9won on Discord: WorkBuddy's Credits and Extra credits (and the intl
build's) could not be given a cap. The plugin sets those two aside
(the account stops at "Total credits"), and 51bdc985b let a window set
aside keep a cap set on it before, but offered no new one. Routing
already holds at such a window's own cap (WindowCaps.own, allowanceOf),
so only the meter refused.

Now a window set aside with a total (limit > 0) is a button too. Its
menu has no "Account's cap" item, since such a window never counts the
account's cap: "No cap on this window" is first and posts 0, and the
note says it has no cap. A window set aside with no total (Loomy's
永久积分, a bare balance) stays plain: there is no share or spent
amount a cap could read.

app.js pays for itself by five comments cut shorter; no budget raised
(TestCoreScriptBudget ok again at the rebased head, on origin/main
c3f91f449).

Run on mote: node --test window-cap (chromium and webkit, 420 and 1100,
en zh zh-TW ja de): 120 pass; window-cap-pool 40, account-cap 16,
i18n-keys 4 pass. go test ./internal/gui: ok after the last comment cut
(TestCoreScriptBudget 5 bytes over before it, the only red).
Broken by hand: the old guard back, window-cap's new test 20 of 20 red.
Not tried: a real WorkBuddy account with a cap on Credits.

Reported-by: 9won_25273 (Discord)
2026-11-10 02:56:16 +08:00
yetone c3f91f4496 i18n: de's fixed-amount cap tooltip names {window} as often as English does
40cbdaa7e's German for "{window} has a cap of its own: … used {n} of
{window}, until it renews" said {window} a third time ("bis {window} sich
erneuert"), so gui-de's "de has every zh string, with its placeholders and
tags" has been red on main since. It now says "bis es sich erneuert", as
the percentage cap's German beside it does, and "Klicken" as that one does.

Run on mote (macOS 27): gui-de and i18n-keys 7/7, TestCoreScriptBudget ok.
Red before: the same gui-de test failed on a clean origin/main 0d99261dc
copy (one {window} too many).
2026-11-10 02:55:09 +08:00
yetone f2341e232a providers: the page says when subscription accounts are off, and leads to the switch
Subscription accounts (account discovery) are turned off in Settings ›
Privacy, and every subscription then stops working, but the Providers
page said nothing of it (the scattered settings audit after netube99 on
X). A line over the list, in the deprecation notices' quiet style, now
says they are off, with Settings › Privacy opening the switch, lit, and
Back to Providers. With MAGPIE_NO_ACCOUNTS set it says so instead. While
they are on there is no line. The core script budget is paid with three
comments cut, no raise.

Run on mote (macOS 27), Chromium and WebKit:
- new providers-discovery-off.test.cjs (every language, 1100 and 420
  wide), account-discovery, i18n-keys, settings-back: 76/76.
- TestCoreScriptBudget and the app.js budget: ok.
- every file touching #movable (deprecated-subscriptions,
  deprecation-notice, library-chip-fan, plugin-move, plugin-movable-review,
  retired-move): green. plugin-move-unserved's "Try again takes the models
  unticked" is red 4/4, the same 4 at a clean origin/main 0d99261dc copy
  (the editor's model chip never shows); not this change.
Broken by hand, each red: no line drawn; the link opening Sign-in pages'
row instead; the MAGPIE_NO_ACCOUNTS wording dropped.
Not tried: the real app window.
2026-11-10 02:52:51 +08:00
yetone 0d99261dcc sessions: the page leads to Settings › Privacy's session history
Which agents' session history magpie reads is set in Settings › Privacy,
and the Sessions page it is about led there only through its first ask's
words (the scattered settings audit after netube99 on X). Its head now has
a Settings › that opens Privacy at those rows, lit, with Back to Sessions.
Gateway mode reads no agent's history and has no such rows, so no link.

Two things it found on the way:
- Privacy's session-history rows are drawn again when their read comes
  back (loadSessionReads), which took the light off a row a link had just
  lit; in Chromium it was gone before it showed. The redraw now keeps the
  light on the row at the same place.
- The link takes ~70px of the head (en), and eight agents' tabs, which
  fit a 1200px page (面条 on Discord), had 34px to spare. The search
  now gives way to the tabs, down to its 110px least, before the agent
  menu takes them; a narrow window's grid head is as before. The fit
  watches the head, not the tabs' box the search's width changes, so no
  ResizeObserver loop.

New test sessions-to-settings.test.cjs: the link's words, inside the head,
over nothing, the page fits; it lights Privacy's row; Back returns to
Sessions; none in gateway mode. Every language, Chromium and WebKit, at
1100 and 420 wide. sessions-toolbar now counts the link among the head's
controls that must fit.

Run on mote: every Sessions GUI file (13), gateway-conversations,
gateway-mode-sessions, i18n-keys and settings-back: 192 of 192.
Broken by hand: without the link, sessions-to-settings red; without the
redraw keeping the light, red in Chromium (timeout on the lit row);
without the search giving way, sessions-toolbar red ("a wide window keeps
the one-click agent tabs").
Not tried: the real app window.
2026-11-10 02:33:07 +08:00
yetone 8016b9fcad providers: the page counts the catalog instead of copying it
providersState read provider.Catalog() only for its length and its
routing groups, and Catalog copies every listed model's Entry (1.6 KB
each): catalogKeeping was 11.5MB of 128.5MB allocated over 40 asks of
/api/providers on the real account. provider.CatalogGroups gives the
groups (the caller's own copy) and the count Catalog would have, by
the same Unlisted and group-unlisting rules, with no model copied.

Measured on mote with the real account copy (aalloc.sh, 40 asks,
alloc_space delta): 128.5MB (v0.1.3452) -> 115.4MB, -10%; 213.4MB
before v0.1.3446.

Run: go vet ./internal/provider ./internal/gui; go test -count=1
-timeout 45m ./internal/provider ./internal/gui (ok, ok) on mote. New
TestCatalogGroupsIsCatalogs compares it with Catalog with no groups, a
group listing alone beside an unlisted provider, and that group off;
counting the unlisted models too, by hand, makes it fail in all three.
Not tried: Windows and Linux (no OS-specific code).
2026-11-10 02:29:21 +08:00
yetone 8295db7d10 providers: hostOf shares hostnameOf's parsed URLs
b53f4e7c4 kept hostnameOf's answers, but its sibling hostOf (the
host with its port, lowered, which the import and preset checks ask of
every base URL) still ran url.Parse on each poll: net/url.parse was
11MB of 146.6MB allocated over 40 asks of /api/providers on the real
account. Both now read one cache of parsed URLs (hostParts, reset at
512 entries).

Measured on mote with the real account copy (aalloc.sh, 40 asks,
alloc_space delta): 146.6MB (v0.1.3450) -> 128.5MB, -12%; url.parse
11MB -> 3MB (the rest is tencentPlanRegion, minimaxHost and
openCodeGateway). CPU for 30 asks 0.56s -> 0.53s.

Run: go vet ./internal/provider; go test -count=1 -timeout 45m
./internal/provider (ok) on mote. New TestHostOfKept fails with the old
hostOf put back by hand (2 allocations) and checks the port is kept,
the host lowered and an unparsable URL is "". Not tried: Windows and
Linux (no OS-specific code).
2026-11-10 02:23:23 +08:00
yetone a1f2c37ea8 gateway: a key's limit editor says Key limits is off and turns it on
A gateway key's limit is the Key limits built-in's (budget). With it
switched off, the editor under the key's row drew as usual, and Save was
refused with "turn the plugin on" without saying where (the scattered
settings audit after netube99 on X). The editor now has a line, shown
only while budget is off (data-feature-off), saying "Off in Plugins ›
Built-in" with a Turn on that switches it on in place; the line goes and
the editor stays open with its draft.

New test gateway-key-limit-off.test.cjs: off, the line shows inside the
editor with its words and the page fits; Turn on posts {id: budget, on:
true} once and hides it; on, it is hidden. Every language, Chromium and
WebKit, at 1000 and 420 wide.

Run on mote: gateway-key-limit-off 20 of 20; gateway-key-limit,
gateway-key-limits, gateway-key-cycle and i18n-keys 38 of 38.
Broken by hand: without data-feature-off the line shows when on, red;
without Turn on's call the line never goes, red (timeout).
Not tried: the real app window.
2026-11-10 02:17:02 +08:00
yetone a09e967f53 providers: with no account removed, Hidden makes no account
Hidden read every sign-in (Accounts: Codex, plugins, Claude...) and
then kept those the user removed. The Providers page asks it twice a
poll (directly and through Excluded), and most users removed none; the
real account has none, so ~0.6 MB a poll was made for an empty answer.
It now looks at the saved file first and returns nil when nothing in it
is hidden.

Measured on mote with the real account copy, 40 asks of
/api/providers (aalloc.sh, alloc_space delta): 169.8MB (v0.1.3447) ->
146.6MB, -14%. CPU for 30 asks (aeach.sh): 0.65s -> 0.56s.

Run: go vet ./internal/provider; go test -count=1 -timeout 45m
./internal/provider ./internal/gui (ok, ok) on mote. New
TestHiddenNoneMakesNoAccount fails with the check taken out by hand
(254 allocations, its accounts 249) and checks a removed account is
still listed. Not tried: Windows and Linux (no OS-specific code).
2026-11-10 02:16:41 +08:00
yetone e9b8b1c83e gui: the core scripts back under their budget after b72256b59
b72256b59 met the budget at its base, but a8aeb2cad, landed meanwhile, put
the core 21 bytes over it at the pushed head (1,533,823 > 1,533,802).
One comment in app.js cut to a line (the config reload on return), no raise.

Run on mote: TestCoreScriptBudget ok at this head (red at b72256b59).
2026-11-10 02:13:34 +08:00
yetone b72256b599 gui: a Back in the title bar after a link into a setting, and a lit row keeps its corners
The owner (11-10): "点击设置链接跳转到设置页面之后,最好有一个返回按钮来返回到上一页,
类似于浏览器的返回按钮。" A link into a setting (openSettingsAt: the Usage
page's and Routing's Settings ›, the Gateway page's, a provider's, Plugins ›
Built-in's) and Plugins › Built-in's link to a page now leave a chevron
Back in the title bar, before the crumb (beside the sidebar) or after the
brand (the header's tabs), named "Back to {page}". It goes to that page:
the provider that was open, or Settings' tab and search. One step, like
a browser's first; going to another page by hand drops it. fitTop counts
it as the header's lead, so the tabs keep clear of it.

And (the owner, 11-10): "绿色边框的四个圆角会被切掉,这个很丑的". A lit row's
inset ring was square inside the list's rounded clip, so the first and
last rows lost their ring's corners. A lit row is rounded as the list is
inside its border (11px; 10px in the panel, whose lists have no border).

New test settings-back.test.cjs: Usage's Settings › lights the row with
rounded corners, Back shows with its name, fits, overlaps nothing in the
title bar, and goes back; Routing's the same; a page picked by hand drops
Back. Every language, Chromium and WebKit, 1100 and 420 wide.

The core's script budget pays for Back with five long comments in app.js
cut to a line each (Back's own, Built-in's rows, the refresh, its spin's
stop, a growing part's hold), no raise; TestCoreScriptBudget ok on mote.

Run on mote: settings-back, i18n-keys, settings-places, title-bar-tools:
53 of 54; the red is title-bar-tools' known WebKit flake (#2740, #4716),
red 1 run in 3 alone, the same at the base.
Broken by hand: without renderBack in show, settings-back red; without the
11px radius, red with row 0 vs list 11.
Not tried: the real app window.
2026-11-10 02:12:18 +08:00
yetone 1eebd1ff3c providers: a known maker price is answered without garbage too
b53f4e7c4 built the price memo's key in a 160-byte stack buffer. A
maker price names every maker catalog, which is longer, so on the
real account every maker-price hit still grew the key on the heap:
pricedOnce was 25.5MB of 186.9MB allocated over 40 asks of
/api/providers. The buffer is now 1 KB.

Measured on mote with the real account copy (aalloc.sh, 40 asks,
alloc_space delta): 186.9MB (t13, v0.1.3446) -> 169.8MB (t14), -9%;
213.4MB before v0.1.3446.

Run: go vet ./internal/catalog ./internal/provider; go test -count=1
-timeout 45m ./internal/catalog ./internal/provider (ok, ok) on mote.
New TestMakerPriceKnownAllocatesNothing asks MakerPriced with the real
maker catalog list; with the 160-byte buffer put back by hand it fails
(1 allocation per ask), and it also fails if that list's key outgrows
1 KB. Not tried: Windows and Linux (no OS-specific code).
2026-11-10 02:10:10 +08:00
yetone b53f4e7c49 providers: a known price and a known hostname are answered without garbage
The Providers list asks the price memo for every model of every
provider on each poll, and the hit built its key as a new string each
time. The key is now built in a stack buffer and looked up through
string(k), which Go doesn't allocate for a map index; it is copied out
only when the price is new. hostnameOf parsed every provider's base URL
with url.Parse on every poll; the hostname is now kept per URL (reset
at 512).

Measured on mote with the real account copy (aalloc.sh, 40 asks of
/api/providers, alloc_space delta): 213.4MB at origin/main (t12),
186.9MB with this change (t13), -12%. CPU for 30 asks 0.64s -> 0.62s.

Run: go vet ./internal/catalog ./internal/provider; go test -count=1
-timeout 45m ./internal/catalog ./internal/provider (ok, ok) on mote.
New TestPricedOnceHitAllocatesNothing and TestHostnameOfKept fail on the
old code (1 allocation each, broken by hand) and pass with it.
Not tried: Windows and Linux (no OS-specific code).
2026-11-10 02:03:51 +08:00
yetone a8aeb2cad2 usage: picked days can start and end at a minute
blrbrzkj on Discord asked to see usage from one time to another, not
only whole days. The range menu has a start and an end time under its
month (empty is the whole day; 9:30, 0930 and 09:30 all read 09:30).
Picked with the days, the period is "2026-10-01T09:30..2026-10-01T18:00";
Enter applies new times to the days already picked. A time that isn't
one, or an end not after the start on one day, is marked and asks for
nothing. The opt says "Oct 1 09:30 – 18:00".

The backend reads either end as a date or a date with its minute
(usage.RangeOf, bounds); an untimed end is its next midnight. A timed
range of 48 hours or less is drawn by the hour from the first's hour.
CSV names drop the colons.

Run (mote): node --test usage-range-times (new, chromium + webkit, en +
zh), usage-range, i18n-keys, credit-days: 26/26 ok. go test
./internal/usage ./internal/gui ok (TestCoreScriptBudget fits, the
periodDays comment cut to pay for its regex); gofmt clean; go vet
native, GOOS=windows (usage, gui), GOOS=linux (usage) ok.
Broken by hand: a timed end read as its day's midnight turns
TestPickedMinutesArePeriod red. The page's own typedTime first clashed
with app.js's hhmm and stopped the Usage page mounting; the GUI run
caught it.
Not tried: the real app with a real ledger; ja/de/zh-TW screens.

Reported-by: blrbrzkj (Discord)
2026-11-10 02:01:37 +08:00
yetone f5a2edfd1c gui tests: a found group's old id reaches the group it was renamed to
00af08e7b made a renamed group answer to its old id (Former), so
TestGroupSaveRenames' "auto-gpt-6-astra is back" went red: FindGroup of
the old id now finds the renamed group, as it is meant to. The check is
now that what answers is gpt-6-astra, never a found auto- group back.

Run (mote): go test ./internal/gui ok, ./internal/usage ok; red at
3d49ac069 before this, 00af08e7b's own suite never ran (its log empty).
2026-11-10 02:01:37 +08:00
yetone 117f56c707 gui: a provider editor of many accounts opens without a layout an account (#5310)
With 600 accounts the Claude provider editor took 7.9s to open in WebKit
(2.3s in Chromium). Each account's segmented control placed itself, and its
thumb, in a microtask of its own: a read after the last control's write, so
every control laid the editor out again. The thumb's place was read from
offsetLeft/offsetTop, scrollLeft and getComputedStyle. In a long list WebKit
answers those by walking every sibling before the element (~0.3ms each at
600 accounts), where getBoundingClientRect, offsetWidth and client/scroll
sizes are cheap.

- segs() queues its control. One microtask (segsFlush) places every control
  due and slides them all together, with each container's controls counted
  once (segsPlace takes a shared map).
- slides() reads every thumb's target, then writes them all. thumbsPut puts
  them all with one reflow.
- thumbTo measures with rects (unscaled by offsetWidth) and reads scrollLeft
  or scrollTop only when the strip overflows.
- thumbNow trusts the place it last put (thumbPlaced) unless a glide is
  running, so it doesn't use computed style.

Measured at 600 accounts (time to open the editor, probe on mote):

| | WebKit | Chromium |
| --- | --- | --- |
| before | 7.9s | 2.3s |
| after | 1.13s | 0.58s |

What's left in WebKit is the editor's own two renders and openModal
(~670ms), which this commit doesn't touch.

The core scripts stay inside TestCoreScriptBudget: comments were cut to pay
for the code, and the budget wasn't raised.

New test: editor-thumbs-batched.test.cjs. It opens the editor with 40 and
with 160 accounts, in both engines and in en/zh/zh-TW/ja/de. It counts
forced layouts and the sibling-walking reads, holds 160 to 40's count +24,
and checks every thumb lies under its option within 1px.

Run at this head (rebased on ab3710de3), on mote:
- TestCoreScriptBudget: ok.
- editor-thumbs-batched, i18n-keys and quota-fit-batched: all ok, in both
  engines.
- tencent-cloud: the "strip scrolled" test is red 4 of 4, as it is on main
  (#4321). It fails before any click, at "the strip scrolls (0px)".

Run on the tree before the last comment trims (base 7e5cebb86):
- The 109 GUI files that touch thumbs, .segs, slide() or segsPlace, plus
  i18n-keys: 2,099 tests, 39 red.
- The 7 files with reds were rerun at both the fix and the base. They give
  the same reds on both (40 at fix, 39 at base; the extra one is skill-where
  webkit, which is red only at base). Each is filed: tencent-cloud #4321,
  settings-groups #5828, gateway-mode #3586, s3-sync #2448, skill-where
  #5154, and masking-records #5830 (new). The panel-usage reds are the same
  32 at fix and base.

Broken by hand, with the new test:
- Old assets: forced layouts 294 → 654 (WebKit), 296 → 656 (Chromium).
- thumbTo reading offsetLeft/offsetTop again: slow reads 650 → 1132
  (WebKit), 787 → 1267 (Chromium).
- thumbNow on computed style again: slow reads 290 → 415 and 352 → 456.
Each goes red.

Not tried: the real app with 600 real accounts. The numbers come from the
page under Playwright's WebKit and Chromium with fake accounts. Not tried
in WebKitGTK either; there is no new browser API and no new motion.
2026-11-10 01:54:04 +08:00
yetone ab3710de3a hooks: onSignIn tells a request hook of an account to sign in again
shannnnnks on X: with several Codex accounts behind the gateway, one is
now and then signed out, and they want the notify plugin to push it.

The magpie that serves the gateway now looks every 2 minutes (first
after 1) at the same sign-in states the desktop alert reads
(provider.WatchSignIns' checkSignIns, so every provider: Claude, Copilot
and plugin accounts that lapsed, and built-ins whose mark says the
sign-in expired or must be done again, Codex's revoked and refused
refreshes among them; accounts in use only). Each account to sign in
again, and each Claude sign-in ending within days, goes to every hooks
file that exports onSignIn, once until the account works again, kept in
signin-hooks.json beside the desktop alert's own file. The event is
{provider, providerName, account, state: "signed-out"|"ending", endsAt?}:
the account is its display label; no token and no vendor reason text.
It is fire-and-forget in the Bun host (gatewayRequest operation
"signIn"), each hook under its own timeout, one that throws doesn't stop
the next. With no hooks file nothing is looked at or marked. A hooks
file may now export onSignIn alone, without onRequest.

Docs: gateway-request-hooks.md (Sign-in notification),
providers-accounts.md, site plugins.html en/zh/ja.

Run on mote at d939dd699 (on origin/main 835439ebf; then rebased on
3d49ac069, whose three commits touch only GUI assets, GUI tests and site):
- gofmt -l internal: clean. go vet of internal/plugin, gateway and
  provider for darwin, linux and windows: ok.
- go test -count=1 ./internal/plugin ./internal/gateway: ok (123s, 950s).
- ./internal/provider: crashed in TestCodexAppWorkspaceSwitchReadsEachWorkspace
  (concurrent map writes in its fake server, #5800, not this change);
  run again with -skip WorkspaceSwitch: ok (130s).
- Red on the old code: with origin/main's host.js both new tests fail
  (TestGatewaySignInHook: "magpie.hooks exports no onRequest";
  TestRevokedAccountToldToHooksOnce: the hook never heard of it).
- Broken by hand: without the HasGateway gate, the gateway test fails
  with "told with no hook".

Not run: the full ./... suite (queued behind ~10 suites on mote's
suite.lock). Not tried: the real app with a real revoked Codex account;
the GUI suite (no GUI file changed).
2026-11-10 01:44:24 +08:00
yetone 769a625548 gateway: its own settings sit under a Settings head, apart from the calls
The owner (11-09): "这两个卡片为什么贴在一起?" The Recent calls list and
the gateway's own settings card touched with no gap. The settings card now
has a Settings row-head of its own above it (the page's 14px head margin),
hidden with the card when the gateway built-in isn't found.

Run on mote: gateway-own-settings.test.cjs and i18n-keys.test.cjs, Chromium
and WebKit, every language, 1100 and 420 wide: 24 of 24.
Broken by hand: with the head and its hide line taken out, 20 of 20 red
(the head's text and the gap of at least 10px are checked).
Not tried: the real app window; the full GUI suite runs with the next commit.
2026-11-10 01:44:17 +08:00
yetone 3d49ac069e usage: a 24 hours period, and the period picked is kept
The Usage page's periods were Today, 7 days, 30 days and All. "Today"
starts at midnight, so early in the day it shows almost nothing
(mahiro233 on Discord). A "24 hours" period now sits after Today and
asks the server for its rolling window, last:24h (#2075), with an
hourly chart. Its empty state says "No calls in the last 24 hours."
(en, zh, zh-TW, ja, de). The menu bar's credit days count it as 2.

The period picked from the list is kept in localStorage and the page
opens on it next time. Picked day ranges aren't kept (they go stale),
and neither is a period the URL brings (?period=7d from the menu bar).

Tests: usage-24h.test.cjs (new; Chromium and WebKit, en and zh, 900px):
24 hours sits after Today and asks for last:24h, its empty note, a
reload opens on the kept pick, ?period=7d is not kept. Five usage
tests counted the period list by index and were moved one along.

Run on mote at be2d2db5c + this change: usage-24h, usage-range,
usage-phone-head, usage-ledger, usage-ledger-chart,
usage-ledger-open-settled, usage-refresh-flight, credit-days,
tray-totals, usage-head-steady: pass 148, fail 6. The 6 are
usage-ledger's "newest live route needs no return-to-live button"
(en/zh, both engines), which fail the same 6 on be2d2db5c without
this change (#3104). i18n-keys ok; go test -run "Budget|I18n|Script"
./internal/gui ok. No budget raised.

Broken by hand: none beyond the index shifts the old tests caught.
Not tried: the real app with a day of real calls.

Reported-by: mahiro233 (Discord)
2026-11-10 01:39:27 +08:00
yetone be2d2db5c3 gui tests: gateway mode's hidden alerts are read through their Alerts list
7d177985f put the four alert rows under an Alerts heading and hides the
heading and its list as one in gateway mode, not each row. gateway-mode's
agentRows still read each row's own hidden, so it went red in both engines
in the full GUI run ([false,true,true,true,true]). A row now counts as shown
when neither it nor its list and heading are hidden. What the user sees was
right; only the test read the old layout.

Run on mote: gateway-mode.test.cjs 6 of 6.
Broken by hand: with the heading and list left out of the gateway-mode
hide, chromium en and webkit en go red on "agents' rows in gateway mode".
2026-11-10 01:28:25 +08:00
yetone 446579d05c site: verify usemagpie.ai in Bing Webmaster Tools
BingSiteAuth.xml and the msvalidate.01 meta on the home page. Bing's
XML check failed to fetch the file (curl as bingbot got 200), so the
meta tag verified it. Deployed (7b23789f), live page checked with curl;
the sitemap is submitted in Bing.
2026-11-10 01:26:23 +08:00
yetone 835439ebf7 gateway: a parallel call sent on an earlier call's index gets one of its own
jiezhengj on Discord: through OpenDesign's chat completions (amr-link,
which turns Responses into Chat itself; deepseek-v4.1-flash, 4 of 25
tries, and the auto group landing there 3 of 44), three parallel calls
streamed as index 0,0,1, the second call's argument fragments at 0 too.
OpenAI's and Vercel's SDKs (and DSH) add fragments up by index, so the
two calls' arguments became `{...}{...}` and the turn ended. opencode-go
on the same model: 0 of 55.

chatTidy, which every Chat SSE reply passes through, now gives a
fragment that names a function under a new id, on an index another call
already has, the next free index, and every later fragment at that
upstream index goes by it; later calls get their own (0,1,2). A
fragment that only carries arguments stays with its index's call
whatever id it has, so an upstream that rotates ids doesn't split a
call. A stream whose calls each have their own index is unchanged
(TestChatTidyGivesCallsAnIndex's indexed case).

Run (mote): go test ./internal/gateway -run TestChatTidy ok; -run
'Chat|Tool|Call|Index|Stream' ok (215s). New
TestChatTidyRenumbersAReusedIndex uses the reporter's frames.
Broken by hand: renumber returning the upstream index turns it red
(5 wrong indexes).
Not tried: a real amr-link stream (no OpenDesign account here); the
full suite runs after the push.

Reported-by: jiezhengj (Discord)
2026-11-10 01:18:22 +08:00
yetone 4c331696ec gui: an overview is summed once per stats and filters
The Sessions page asks /api/sessions/overview on every poll, and each
ask summed every session again (Stats.Overview: days, shapes, tool and
skill use, the top sessions) and encoded it, to the same answer while the
stats stood. The answer is now kept, encoded, by statsForGen's gen (it
moves only when the stats do) and the filters, the last 8 of them; the
Codex top rows' model and effort are added again only when
CodexModelEffort hands back another map (the map itself is held, so a
new one can't take the old one's address).

Measured on mote with the owner's real account copy (network blocked),
30 asks of /api/sessions/overview: 0.92s of CPU on v0.1.3435's tree,
0.24s with this (~31 ms -> ~8 ms an ask).

Run on mote: go vet + go test ./internal/gui, ok. TestOverviewSummed-
OncePerStats is red with the kept answer ignored by hand ("two asks of
the same stats summed 2 times, want 1").
Not tried: the GUI suite; the answer's bytes are json.Marshal plus a
newline, as the Encoder wrote them.
2026-11-10 01:17:43 +08:00
yetone 822817679f gui: the steady GC test waits for the heap's own GOGC, not Go's 100
37c247d1f made the least the heap grows by 16 MB. TestSteadyGCRetunes-
AfterACollection waited for GOGC 100, which holds only for a live heap
under the room; a whole internal/gui run leaves ~22 MB, so it waited
for 100 against 72 and was red in the package run (alone it passed,
which is all 37c247d1f ran). It now waits for steadyPercent of the heap
the last collection left.

Run on mote: go test ./internal/gui, ok (red before at warm_gc_test.go:220,
"GOGC after collections = 72, want 100"); -run SteadyGCRetunes -count=3 ok.
2026-11-10 01:17:43 +08:00
yetone 00af08e7b8 routing: a renamed group still answers to its old id until a new group takes it
xinvxueyuan on Discord asked that renaming a routing group keep the old
group/<id> working (agents and scripts still name it), and that the old
id stop working only when a new group takes that id.

A Group now keeps Former, the ids it had before RenameGroup, newest
last. FindGroup, FindGroupAlso and Resolve (the gateway's known-model
check) fall back to the group whose Former has the id (routedGroupOf).
A group saved or renamed onto an id drops it from every other group's
Former (dropFormer). A save that doesn't send Former keeps the old list.

Run (mote): go test ./internal/provider -run 'Rename|Group' ok;
go test ./internal/gateway -run TestRoutingGroups ok, with a new
check: rename mine->ours, POST group/mine answers 200 through ours.
Broken by hand: routedGroupOf without the Former loop turns
TestRenamedGroupKeepsItsOldID red; Resolve without the fallback turns
TestRoutingGroups red with 404 "knows no model group/mine".
Full provider/gateway/gui/agent run and Linux/Windows vet started on
mote after push; reds will be filed.
Not tried: the GUI showing the old id anywhere (it doesn't list it).

Reported-by: xinvxueyuan (Discord)
2026-11-10 01:08:04 +08:00
yetone 37c247d1fc gui: the heap grows by a quarter between reads, 16 MB at least
steadyGCStart let a window's heap grow by half of what it holds (32 MB at
least) between collections. On a real account's history, ~100 MB live,
that rested at a 171 MB footprint with a 200 MB peak. A quarter (16 MB at
least) costs the polls nothing measurable and gives the memory back.

Measured on mote (macOS 27, M5 Pro) with the owner's real account copy,
network blocked, the v0.1.3435 tree:
- idle 115s: footprint 171 -> 146 MB, peak 200 -> 166 MB, CPU 0.33s both
- 60 busy rounds of state/providers/drift/sessions/overview: CPU 5.12s
  -> 5.14s, footprint 157 -> 151 MB, peak 177 -> 169 MB

Run: go test -run 'Steady|GC|Tight' ./internal/gui on mote, ok; gofmt
clean. TestSteadyPercent's cases follow the new numbers.
2026-11-10 01:05:19 +08:00
yetone 803d7747e7 gateway: an account rate limited till a time its vendor named is not asked again before it (hsjzg58958 on X)
hsjzg58958 on X: a vendor limited an account for 300 seconds, and magpie
asked it again about every half a second as the agent retried, until the
vendor flagged two accounts.

Cause: a candidate resting on a 429 was still "tried all the same" when
it was the last one left (restLast/probeOne), and the last one left was
never rested at all, so every client retry went upstream. Codex on its
own sign-in is relayed by codexUpstreamOn outside the candidate loop and
had no hold at all.

Fix:
- timedHeld/vendorTimed (fallback.go): when every candidate left rests on
  a 429 whose time the vendor named (Retry-After, anthropic-ratelimit-*-
  reset, x-ratelimit-reset-*, resets_in_seconds/resets_at), none is asked;
  the agent gets 429 with Retry-After = when the first is back. A ChatGPT
  account out of its allowance is answered as the backend's
  usage_limit_reached with its x-codex-* windows (Rest.out/outHeader).
- The last one left now rests too on such a 429 (vendorSaidWhen); a 429
  naming no time rests nobody, as before.
- codexHolds (codex_held.go): Codex's own relayed sign-in is held till the
  vendor's time; its retries are answered locally with the stored body,
  x-codex-* headers and Retry-After. Lifted by restarted() for quota holds.
- Not held: LimitRestOff accounts (the user's setting), auto-reset weeks,
  rests "there" (answered by the vendor's own hold), Codex's API key.

Run:
- New TestRateLimitedKeysHeldUntilTheirReset (4 signals x 1 and 2 keys)
  and TestRateLimitedCodexAccountsHeldUntilTheirReset (3 refusals x 1 and
  2 accounts): red at fc9ce34d8 (each key/account asked on every retry),
  green after.
- Broken by hand: held branch off -> every case red (4 extra hits);
  last-one rest off -> 1-key cases red, Retry-After lost; codexHeld off ->
  1-account Codex cases red.
- mote: go test ./internal/gateway -run 'TestRateLimited|TestAllResting|
  TestQuotaHeld|TestGroupSpent|TestCodex|TestRetryAfter|TestHeldLimit'
  ok; TestCodexLeavingModelCompactsLocally updated (the used-up account is
  now asked once, then held) and ok.
- gofmt -l clean; go vet, GOOS=linux -tags nogui and GOOS=windows go vet
  and build ok.
- mote, whole internal/gateway package at the rebased head 46199a6ae
  (on 80161247a): ok but for TestStrictAffinityPassesTheErrorOn, which
  asserted the bug itself ("resting now, it is still the one asked"). A
  strict conversation's account resting till ChatGPT's named reset now
  gets its own usage-limit 429 from the rest, with nobody asked; updated,
  and with TestRateLimited|TestCodexLeavingModel|TestCodexEveryAccountOut
  ok at this head.
- The full ./... suite was queued behind six other sessions' suites on
  mote's lock and not run before the push; queued again at this head.

Not tried: a real vendor account limited live (no account was rate
limited to test on); Codex API-key relay is not held (OpenAI's platform
headers are Codex's own to read); plugin providers are held only through
the shared candidate loop; a held Codex passthrough body's
resets_in_seconds is stale by the time elapsed (Retry-After is exact).
2026-11-10 00:58:01 +08:00
yetone 7db3478275 agent tests: LAZYCAT_APP_DOMAIN is listed as not an agent's folder
TestFolderVarsAreListed has been red on main since ac4af5823 made
gateway/lan.go read LAZYCAT_APP_DOMAIN. It is the domain LazyCat serves
magpie at, not an agent's folder, so it goes in notAnAgent with that
reason; no sandbox needs to clear it.

Run (mote, at this head): go test ./internal/agent -run
TestFolderVarsAreListed -count=1: ok. Red before the change in the full
suite at 7e5cebb86 (agentenv_test.go:124, the message naming
LAZYCAT_APP_DOMAIN).
2026-11-10 00:57:08 +08:00
yetone 7e5cebb86c usage: a model list fetched again unchanged keeps the usage index
Each account's model list is fetched again on every start and every 45
minutes, and saveLive writes it again with only its "fetched" time moved.
Usage keyed the request index (and its file on disk, requests-v1.bin) and
the priced summaries on that file's mtime (statKey(catalog.LivePath)), so
each such save dropped every chunk: every start, and every refresh while
running, read the whole session history again, decoded every call shard
and rebuilt every row.

catalog.LiveKey names a saved list by a hash of its bytes without the
fetch time, made once per parse of the file (readLive's memo). A list
saved before Since was kept is dated by its fetch (LiveSince), so its
fetch time stays in its key. usage's liveListKey uses it for every
provider and Antigravity in readRequestState's meta and in
usagePriceCacheKey (the same mtime key, the sibling), and falls back to
the stat when the list can't be read.

Found by dumping both disk headers on mote: same binary, same sources,
and only the providers' hash differed, run to run.

Measured on mote, a copy of the owner's real accounts, GUI open, network
blocked, the Claude list rewritten as a start's fetch does. Restart of
the same build, t10 (main) against t11 (this):
  CPU in the first ~3 minutes   11.6s -> 2.5s
  allocated                     2.74GB -> 0.81GB
  sessions.loadCalls            771MB -> gone from the top
  footprint                     174MB -> 175MB
The first start after an upgrade that changes usage's code still builds
everything once (requestDiskBinary), as before.

Tests: TestRequestStateKeptAcrossAListFetchedAgain saves the same list
again an hour later and needs readRequestState's meta and
usagePriceCacheKey unchanged, and both changed for another list; on the
old usage code it is red on both. TestLiveKeyOnlyMovesWithTheList and
TestLiveKeyOfAnOldListKeepsItsFetch cover the key itself.

Run on mote at this tree: go test ./internal/catalog ./internal/usage
./internal/provider -count=1 ok; go vet ./... ok; GOOS darwin/linux/
windows go vet ./internal/catalog ./internal/usage ok (./... cross-OS
stops at wails' cgo files, as on main); gofmt clean.
Not run: the full ./... suite before the push (running after), GUI.
2026-11-10 00:36:16 +08:00
yetone 80161247a0 gui: the core scripts back under their budget after ecc16fe97
ecc16fe97 ran TestCoreScriptBudget at fc9ce34d8; 3b550a99c, rebased in
under it, left 19 bytes, and the panel's unpriced wording (249 bytes)
took the core to 1,534,032, 230 over. Four of the quick panel's
comments cut, no raise.

Run on mote at this head: go test -run TestCoreScriptBudget
./internal/gui ok; panel-usage and i18n-keys 8/8; gofmt clean.

Reported-by: tenacious_eagle on Discord
2026-11-10 00:16:39 +08:00
yetone e21b401402 gui tests: group-editor-fits waits for the fold's label column to settle
The advanced fold takes its label column from edAlign, a ResizeObserver
that sets --ed-lab a frame or two after the editor opens. The test
measured the frame before: "the pattern field spans the models' column"
was red 1 of 3 runs on origin/main f37de8cc4 in chromium on mote (770 en,
333 vs 343). It now waits up to 2s for the pattern field and the models
to start at the same x, then asserts as before.

Run on mote: group-editor-fits.test.cjs 5 runs x both engines, 10/10 ok.
Broken by hand: the fold's column 10px narrower than --ed-lab, red.
2026-11-10 00:13:44 +08:00
yetone c6331b427c routing: a group bound to gateway keys is theirs alone (Xerxes754)
Xerxes754 on X asked to bind a routing group to one or two gateway
keys, so other keys neither see nor use it. Before this a key could only
be held to models from its own side (naming group/<id> in its Models);
a key with no limits reached every group, and nothing on a group could
keep it from one.

A group now has Keys (key ids). Set, only those keys, and keys issued
under one of them, may use it:
- groupBarred/groupGiven in key_models.go answer it for every route that
  reaches a group: chat, responses, messages, count_tokens, embeddings,
  images, video, the decider and the subagent and image MCP paths. Any
  other key gets 403 "bound to other gateway keys", naming the group and
  the Routing page, and nothing goes upstream.
- /v1/models and /v1/models/{id} leave it out for any other key, a key
  held to models that names it included. provider.GroupsBound keeps an
  unbound magpie's list as before.
- A keyless request from this computer uses it, as key limits never
  hold one; callerGuard now names a loopback request's key when it
  sends one, so a key used locally is held too.
- SaveGroup keeps the stored keys when a save doesn't name them (the
  CLI, the TUI, the card toggles); an empty list clears them. Ids are
  trimmed, deduped and capped. Sharing a group leaves its keys out;
  importing over one keeps them.
- GUI: Routing, a group's Edit, row "Gateway keys" (网关密钥) with a
  button "Any gateway key" (任意网关密钥) that opens the app menu of the
  user's keys (multi-pick); a bound key since deleted shows "key
  deleted" (密钥已删除). The row shows once there is a key to bind.
  /api/groups lists gatewayKeys (no browser, read-only or issued keys).
  zh, zh-TW, ja, de strings.
- Not covered: a bound group nested in another group is reached through
  the outer one (documented in gateway-routing.md).

Run (mote unless said), at this head rebased on ac4af5823:
- gofmt -l clean; go vet darwin for provider, gateway, gui; GOOS=windows
  go vet for those and access; GOOS=linux go vet -tags nogui; go build.
- go test ./internal/gateway (full package, 905s), ./internal/gui,
  ./internal/access, ./internal/provider: ok. One provider run died on
  workspaceSwitchReadsApart's concurrent map writes in its fake server,
  #5800 already open; the rerun was ok.
- New: TestGroupBoundToKeysIsTheirsAlone, TestGroupKeysKeptBySaves-
  ThatDontNameThem, TestGroupKeysListedAndSaved, and group-keys.test.cjs
  (5 languages x 2 widths x chromium + webkit, deleted key, hidden row).
- GUI on mote: group-keys, i18n*, rt-*, *routing*, *group*, *budget*
  files in both engines: ok. That run found a new group's editor
  throwing on its missing keys (group-editor-align red); the draft now
  gets keys like accounts. group-editor-fits was flaky on origin/main
  too and is fixed in the next commit.
- Whole GUI suite on the Linux box (wsl-run, concurrency 4): still
  running at push; its reds so far are in account-eye,
  accounts-own-signin and accounts-switch-alone (webkit), files this
  change doesn't reach.
- Real binary, sandbox HOME on mote, fake upstream, group bound in
  providers.json: key A lists and uses group/team; key B doesn't list
  it, gets 403 on chat (group/team and "team"), messages, count_tokens
  and responses, 404 on /v1/models/group/team, and still uses fake/m1;
  keyless local lists and uses it; upstream got 3 calls.

Broken by hand, each turned its Go test red: the issuer chain not
walked; an unheld key let through (groupGiven true); a held key's
groupAllowed ignoring the binding; SaveGroup not keeping nil keys.

Not tried: binding from the real app's window end to end (the e2e
bound by file), Windows and Linux runs of the Go tests; the CLI and TUI
can't set keys (they keep them).
2026-11-10 00:13:44 +08:00
yetone ecc16fe979 usage: the quick panel and the Usage page word unpriced calls alike
The quick panel's Cost said "15 个没有价格" while the Usage page's
said "15 次调用没有已知价格,未计入". Both now say "{n} calls unpriced"
("15 次调用未计价"), as the page's other cost heads already did, with
the whole sentence on hover.

Reported-by: tenacious_eagle on Discord

The Usage page's plugin already had the two count keys; they live in the
core's i18n.js now that the quick panel says them too (i18n-keys: no key
twice, a plugin's words are its own). The Overview calls tile says the
same words, so usage-unpriced-sum's tile wording follows.

Run on mote at origin/main fc9ce34d8 + this: gofmt -l internal clean;
node --test i18n-keys, i18n-en-no-cjk, panel-usage, tray-totals,
usage-unpriced-names, usage-unpriced-sum, usage-stat-sub-wrap, currency,
usage-compact-counts 126/126; go test ./internal/gui ok (TestCoreScriptBudget
under its budget, not raised). usage-ledger's "newest live route needs no
return-to-live button" is red alone on fc9ce34d8 too (#3104, #5048).
2026-11-10 00:13:32 +08:00
yetone ac4af58230 gateway: a LazyCat app is shared at its own domain, and a cgroup v2 container is known
mtoolstec on X runs magpie in LazyCat (懒猫微服) and, with "Share on
local network" on, Settings offered http://172.28.3.65:3425: the
container's own address, which nothing outside the box reaches, and no
hint that it was a container's.

LazyCat injects LAZYCAT_APP_DOMAIN (magpie.<box>.heiyu.space) into every
container of an app and serves the app there over HTTPS. The
magpie-lzcapp package sets MAGPIE_PUBLIC_URL=https://{{.S.AppDomain}}
through a manifest template, which only lzcos 1.3.8+ renders; unrendered,
url.Parse refuses the "{" host and publicURL() was "" (the log says
"ignoring invalid MAGPIE_PUBLIC_URL"). A hand-written manifest may not
set it at all. Then ContainerAddrs() needed inContainer(), which knew
only Docker's and Podman's marker files and a runtime's name in PID 1's
cgroup. Under cgroup v2 with a private cgroup namespace (Docker's
default since 20.10) /proc/1/cgroup is "0::/", and a runtime that writes
no marker file got past it, so the container's addresses were listed as
the computer's.

- publicURL() falls back to https://$LAZYCAT_APP_DOMAIN when
  MAGPIE_PUBLIC_URL is unset or invalid (a DNS name only; lower-cased).
  Everything built on PublicURL follows: LANURLs, PublicHost (the
  rebinding Host check), magpie web's links and trusted origin, the
  image MCP base, the CLI's advertised URL. InContainer() is true there
  too (updates go through the image).
- inContainer() also takes a container's init as PID 1 (magpie itself,
  as our image starts it; tini, docker-init, dumb-init, catatonit), and
  a cgroup namespace's root ("0::/") on an overlay root filesystem
  (/proc/1/mountinfo). Neither alone catches a host: a systemd host is
  in /init.scope even on a read-only overlay root, and an init without
  cgroups on ext4/btrfs is not overlay. hostNetwork is unchanged, so a
  container on the host's network still lists the host's addresses.

What the user sees: in LazyCat, "Share on local network" shows
https://magpie.<box>.heiyu.space (and the Gateway URL is that domain).
In any other cgroup v2 container on a bridge network without a marker
file, Settings shows the container hint to set MAGPIE_PUBLIC_URL.

Run:
- TestInContainer (13 fake roots: systemd host, systemd on overlayroot,
  cgroup-less init on btrfs, WSL, markers, cgroup v1, kubepods, cgroup v2
  on overlay, magpie/docker-init/tini as PID 1) and TestLazyCatPublicURL
  (LazyCat domain, mixed case, the unrendered template, MAGPIE_PUBLIC_URL
  winning, bad domains) pass on Linux (wsl-run, magpie-desktop).
- Broken by hand: with origin/main's lan.go both tests are red (4 and 4
  cases).
- Real systems: the WSL2 distro (systemd host, 0::/init.scope) reads
  inContainer=false. Docker 28.2.2 on xiaomi-gpu, debian:12-slim with
  /.dockerenv removed (cgroup "0::/", overlay root, PID 1 sh) reads
  inContainer=true hostNetwork=false; with --init (docker-init) true;
  with --network host inContainer=true hostNetwork=true, so it still
  isn't called a container's addresses.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./..., and the darwin/linux nogui/windows builds pass on mote at
  the first base (ddd6c649b); after the rebase onto 7 newer main commits,
  go vet ./internal/..., linux and windows vet of gateway/gui/cli and the
  build pass on mote.
- Linux (wsl-run): internal/gateway ok (1230s) at the rebased head;
  internal/cli (1707s) and internal/gui (624s), -tags nogui, ok at the
  first base.
- Not run: the full ./... suite. It was queued on mote's suite.lock
  behind ~15 other sessions' runs for 46 minutes and I stopped it; CI
  runs it on this push. No GUI file changed.

Not tried: a real LazyCat box (none here); the env names and the
https domain are from developer.lazycat.cloud/advanced-envs and the
lazycat-contrib/magpie-lzcapp manifest.
- After a last rebase onto fdd38154b (6 commits in usage, library,
  providers, settings and docs; none in internal/gateway), nothing was
  run again.
2026-11-10 00:10:23 +08:00
yetone fdd38154b8 docs: the Usage, Video generation and sign-in links to their settings
gui-shell.md, gateway-routing.md and providers-accounts.md name the
links 22c665d6f, cedacf1ae and 3b550a99c added: the Usage page's
Allowances head to Settings › Allowances, Video generation's how-to
to the Providers page, and a sign-in kept to its link to Privacy's
Sign-in pages row. Library's limit tag (8607a7a02) has no passage in
library.md to change.

Docs only; nothing run.
2026-11-10 00:02:22 +08:00
yetone 3b550a99c7 providers: a sign-in kept to its link leads to the setting that kept it
With Settings › Privacy › Sign-in pages' "Open sign-in pages in the
browser" off, adding an account says "magpie didn't open the sign-in
page, as set in Settings" and gave no way to that setting (the
scattered settings audit after netube99 on X). That line now ends in a
Settings › link that opens Privacy and lights the row. The row stays
in Privacy: it is there for max2020's reason, a vendor seeing which
browser a user signs in from.

app.js's core budget is met by one comment cut beside it, no raise
(38 bytes over before the cut).

Run (mote, through mote-run, Chromium and WebKit): signin-link-only
(every language, both a link-only and an opened sign-in, which has no
link), video-gen-pick and i18n-keys, 78 of 78; TestCoreScriptBudget ok
after the cut.
Broken by hand: no link, signin-link-only red in Chromium.
Not tried: a real sign-in in the app; the whole GUI suite runs after
the last of these changes.
2026-11-10 00:01:15 +08:00
yetone cedacf1aea settings: Video generation's how-to leads to the Providers page
With no model that makes videos, Settings › Models › Images' Video
generation says to right-click a model in its provider's Model settings
and mark it a video model, on another page, with no way there (the
scattered settings audit after netube99 on X). The line now ends in a
Providers › link that opens that page. It is drawn in videogen.js, so
the core script doesn't grow.

Run (mote, through mote-run, Chromium and WebKit): video-gen-pick
(every language it covers, 1100 and 400), signin-link-only and
i18n-keys, 78 of 78; TestCoreScriptBudget and the I18n Go tests.
Broken by hand: no onclick, video-gen-pick red in Chromium.
Not tried: the real app's window; the whole GUI suite runs after the
last of these changes.
2026-11-10 00:01:15 +08:00
yetone 8607a7a029 library: a skill GitHub's limit left unchecked leads to the token's row
A skill check that ran into GitHub's 60-an-hour limit says "Add a
GitHub token in Settings → Network and sharing", in a status line that
fades and a tag's tooltip, and nothing there went to Settings (the
scattered settings audit after netube99 on X). The Not checked tag is
now a link when the limit was the one without a token: it opens
Settings › Network and sharing and lights the GitHub token's row. A
token's own limit has nothing to add there, so its tag stays plain.

github-token.test.cjs swaps its route between rounds with
unrouteAll({ behavior: "ignoreErrors" }): the click leaves Settings'
lazy files being served, and the old unroute made the next round's
handler fulfil a route already handled.

Run (mote, through mote-run): github-token.test.cjs, Chromium and
WebKit, en and zh, 8 of 8; github-token plus every
library-*.test.cjs before the route fix: 1211 pass, the one red that
route race.
Broken by hand: the tag never a link, 4 of 8 red (each limited case).
Not tried: the real app's window; the whole GUI suite runs after the
last of these changes.
2026-11-10 00:01:15 +08:00
yetone fc9ce34d86 usage: hashRows reuses its scratch, within sizes its rows exactly
Startup on a copy of the owner's real accounts (mote, GUI, network
blocked, acgui.sh) allocated ~3.5GB, and two usage functions were near
the top of it:

- hashRows built a fresh 32KB byte buffer and shape map for every chunk
  it hashed: 510MB of the startup's allocations. It now takes them from
  a sync.Pool and clears the map before use. The digest is the same
  byte for byte (checked against the old code on the same chunks).
- rowChunk.within appended into a nil slice, growing it step by step
  (292MB flat). It now counts the rows in range first, returns nil when
  there are none, and makes the slice at that size.

Measured, same real-account copy, t9 (main) against t10 (this):
  startup CPU      13.81s -> 9.77s
  allocated (3m)   3483MB -> 2768MB (hashRows 510MB -> gone,
                   within 427MB -> 244MB cumulative)
  footprint        179MB  -> 175MB

Tests: TestHashRowsReusesItsScratch hashes a chunk again after a bigger
one and must get the same digest, and must allocate under 16KB a call
(min of 5 batches, so other goroutines' allocations don't count). Old
heat_disk.go: red at 32768 bytes a chunk; dropping clear(shapes): red.
TestWithinSizesItsRows needs len = cap = 600 (old code: cap 646).

Run on mote at this tree: go test ./internal/usage -count=1 ok, -race
ok, gofmt clean, go vet darwin/linux/windows ok, gui tests ok earlier.
An earlier usage run went red on a test whose name was lost (the log was
cut by tail); four full runs since are green, and the likely cause, the
first byte check counting other goroutines, is what the min-of-5 fixes.
2026-11-09 23:56:13 +08:00
yetone 3a5e4b62d0 usage: TestRowTokensAndZoneKept compares the zone by name and offset
The test compared got.Time.Location() with its own *time.Location by
pointer. rowZones keeps the first zone it sees for a name and offset, so
under -count=3 the second run got the first run's location back and the
test went red on unchanged code. It now checks the zone's name and
offset (IST, +5:30), which is what rowZones promises.

Run on mote: go test ./internal/usage -count=1 ok; -run
TestRowTokensAndZoneKept -count=3 ok (red on the old test). Broken by
hand: writing the row with an "XST" zone turns it red.
2026-11-09 23:56:13 +08:00
yetone 92be1d779b usage: the allowances' head opens Settings › Allowances
The Usage page draws the allowances, but how they are shown (used or
left, the menu bar's figures) and their alerts are set in Settings ›
Allowances, and nothing on the page said so (the scattered settings
audit after netube99 on X). The allowances' head now has a Settings ›
link, as the Routing page has, that opens that tab and lights the
Allowance display row (now #quotaLeftRow). Wired in the usage plugin,
so the core script doesn't grow.

Run (mote, through mote-run, Chromium and WebKit, every language, 1100
and 420): settings-places, mobile-web (with an origin/main baseline;
the button is taken out until the baseline has it, as rtToSet is),
account-mask, quota-curve, i18n-keys: 89 of 89, twice. A first run had
one red whose name a tail cut off; the next two runs of the same files
were 89 of 89, so it is unnamed and not seen again.
Broken by hand: no onclick, settings-places 2 of 2 red (no row lit);
no #quotaLeftRow, 1 of 1 red.
At the pushed head (rebased on f37de8cc4, which changed plugin pages and
the core budget): Budget and I18n Go tests ok; settings-places,
i18n-keys, plugin-page 30 of 30.
Not tried: the real app's window; the whole GUI suite runs after the
last of these changes.
2026-11-09 23:44:16 +08:00
yetone f37de8cc4e provider: the saved Claude accounts' files are listed once per request
claudeCodePrice and claudeModelsOf listed claude-accounts/*/.claude.json
with filepath.Glob on every call, and each Claude model's price asks.
Building an agent's model list (the window's drift poll rebuilds it each
minute, buildClaudeVia and Pi's list) read the folder once per model. The
listing is now held while a request holds the catalog (heldOf, 1 s), so a
build lists it once; outside a hold it is listed afresh, as before.

Measured on mote, real-account copy, GUI page open in Playwright
Chromium, network blocked, 115 s CPU profile (acgui.sh), v0.1.3425-era
build vs this change:
- filepath.Glob: 50 ms -> gone; agent.buildModels 90 ms -> 50 ms
- total samples 320 ms -> 290 ms; footprint 197 MB -> 172 MB (one run each)

Test: TestClaudeCodeFilesListedOncePerHold saves a folder during a hold
and checks the hold's second listing is the first one (same array), and
that after the hold the new folder is seen. Broken by hand (the old
claudeCodeFiles): red, "listed again within one hold".

Run (mote): go test ./internal/provider ./internal/agent ok; go vet
native (provider, agent), GOOS=linux and GOOS=windows (provider) ok;
gofmt clean.
2026-11-09 23:25:19 +08:00
yetone 623e797fde plugin pages: read a day's usage and share a picture they drew
A plugin's page can now read one day's usage and share an image it
drew. This is for the day card (JungleyYeh on X asked for a "daily AI
statement"); the card itself is an optional community plugin,
@magpie-community/page-day-card.

- A page that asks for the "usage:day" read gets that day as
  magpie.read("usage:day", {date, tz}): totals, each agent and its
  models, the streak and the average active day (usageapi/day.go,
  gui/pageday.go). The Plugins page names the read before it is granted.
- magpie.image.copy(png) and magpie.image.save(png, name) share a PNG
  of at most 16 MB. In the window they go through
  POST /api/plugin-pages/image (pageimage.go): copy puts the picture on
  the clipboard (clipimage.go: osascript PNGf on macOS, PowerShell
  PNG + Bitmap on Windows, wl-copy or xclip on Linux), and save writes
  it to Downloads under a name made safe. In magpie web, the browser
  saves or copies the picture itself.
- The window's side, pageshare.js, is imported the first time a page
  shares a picture. The core grows by its one call only, paid for by
  comments cut, so the budget is not raised.

Tests:
- New: TestDayOf, TestPluginPageReadsADay, TestPluginPageSharesAPicture,
  TestPageImageName and TestClipImageCommand. plugin-page.test.cjs
  covers the bridge, both engines and a refused SVG.

What was run (mote):
- gofmt, plus go vet on darwin, linux and windows: clean.
- Full go test ./... at the pre-rebase base: 369 packages ok, 3 FAILs.
  - TestEveryRouteHasACommandOrIsNamed and TestCoreScriptBudget were
    this change's own reds. The new route now has a parity entry, and
    the share code moved into lazy pageshare.js with no raise.
  - TestGatewayModeStatsNameTheGatewaySessions is #5690, the red in the
    first hour of the day (it ran at 00:32).
- GUI suite (affected and plugin files, both engines): 1160 of 1179
  passed. Every red is filed and none touches this change:
  - i18n-keys "a plugin's words are its own": #5332, #5426, #5482.
  - page-width-steady: #5013.
  - plugin-card-update in WebKit: #3079.
  - plugin-move-unserved "Try again": #4410.
- At this head, after the rebase on bc8b01d60:
  - gofmt clean; go vet ./internal/... on darwin, linux (nogui) and
    windows ok.
  - internal/usageapi, internal/plugin and internal/cli ok.
  - internal/gui: TestCoreScriptBudget, the TestPluginPage* tests and
    the TestPageImage/TestClipImage tests pass.
  - plugin-page and old-webkit (both engines): 12 of 12.

Real use:
- A sandbox HOME with a copy of real usage, through the real GUI
  server, in Chromium and WebKit, light and dark, en/zh/zh-TW/ja/de, at
  420 and 1100 px. The card showed 87.9M tokens, $9.85 and 4076 calls
  with a 22-day streak.
- Picking an earlier day and WebKit's Copy ("Copied") worked, with no
  page errors.
- Not tried at push: Chromium's Copy (its headless clipboard was
  denied) and magpie web's Save as a captured download. A second real
  run that grants both was still queued on mote's suite lock.
- Clipboard: checked live on macOS (osascript) and Windows
  (PowerShell). Not tried live on Linux: WSLg had no display.
2026-11-09 23:19:14 +08:00
yetone bc8b01d603 claude: the short system prompt is set in the Claude Code editor, not Settings › Replies
The scattered settings audit after netube99 on X. Short Claude system
prompt and Claude Code's interactive mode changed only Claude
subscription runs, yet sat in Settings › Models › Replies, while the
Claude Code editor already had its own "Claude Code runs as" switch for
the second, whose card said "Switched here or in Settings › Models ›
Replies".

Both rows now go in a claudeRunList in the Claude editor (PROV_PREFS), so
Settings' search still finds them and Open goes to the editor. In the app
the editor's own "runs as" switch is the one shown, and the duplicate
interactive mode row is hidden by CSS; in magpie web as a gateway, where
that switch is disabled, the row shows (the list gets a gw class from
renderReplies: body.gateway-mode is set only on a change, not at boot).
provPrefsField lets Claude's run list through in gateway mode, without
the warm-ups, which are this computer's. The card and the "off" reason
no longer name Settings (zh, zh-TW, ja, de written with them), and the
bridge's subsystem page names the editor.

Run (mote, mote-run, origin/main ddd6c649b as BASE_REF):
- claude-lean-prompt-setting, claude-tui-setting, claude-mode,
  provider-prefs, settings-places, i18n-keys, bare-ids and mobile-web,
  both engines: 170 of 170.
- go test -run 'Budget|I18n|Strings' ./internal/gui: ok.

Broken by hand (chromium):
- both rows back in Replies: claude-lean-prompt-setting and
  provider-prefs 18 of 18 red;
- the editor's duplicate row not hidden: claude-tui-setting 8 of 8 red;
- no gw class in gateway mode: claude-tui-setting 8 of 8 red.

Not tried: the real app with a real Claude subscription.
2026-11-09 23:14:57 +08:00
yetone 8f72f95304 provider: a group's lookup copies the group found, not every group
FindGroup, FindGroupAlso and GroupFinder built every routing group with
groupsIn, which copies each group and its rules, to return one. The
window's 15-second /api/drift poll asks GroupFinder for each Pi model on
a group (piModelJSON), and the gateway asks once per request on a group.
They now read the groups held (sharedGroupsIn, heldFrom while Hold is
active) and copy only the group found and each group a member comes
through (cloneGroup), so what a caller gets is still its own to change.

Measured on mote with the real-account copy, GUI page open in Playwright
Chromium, network blocked, 2 minutes (acgui.sh):
- piModelJSON allocations: 10.6 MB -> 1.5 MB (v0.1.3420 vs this change)
- process CPU 0.39 s vs 0.43 s, footprint 187 vs 197 MB: within the run
  noise of the once-a-minute catalog rebuilds; the drop is in the profile.

Test: TestGroupFoundCopiesItselfAlone changes a found group, its member's
Via and EffortMap, and checks FindGroup, GroupFinder and Groups still see
the saved ones; then 50 looks must allocate less than 50 copies of every
group (100 groups with rules).
Broken by hand, each red:
- A: sharedGroupsIn -> groupsIn: looks 5384832 B >= copies 4796000 B
- B: no cloneGroup of the found group: index out of range (shared slice)
- C: no clone of a member's sub-group: "a change to a found group
  reached the next look"

Run (mote): go test ./internal/provider ./internal/agent ok;
go test ./internal/gateway -timeout 45m ok; go vet native, GOOS=linux,
GOOS=windows ok; gofmt -l clean.
Not tried: a gateway request through a group with a real account
(the path is the same FindGroup the test covers).
2026-11-09 23:08:13 +08:00
yetone a6e4cf7635 settings: what routing does sits under Models › Routing, and the Routing page opens it
The scattered settings audit after netube99 on X. Ask again after a
refusal, the Retry-After cap and the intent classifier's timeout were
under Models › Replies beside rows about a reply's content, and Busy
models last sat in Network and sharing, far from the routing it changes.
The four are now one Routing section under Models, after Replies, and the
Routing page's header has a Settings › button that opens Settings at that
section with its first row lit. The docs (reference.md, the site's
plugins page in en, zh and ja) name the new place.

Run (mote, mote-run):
- settings-places, retry-after-cap-setting, refusal-retries-setting,
  classify-timeout-setting, model-load, i18n-keys and bare-ids, both
  engines: all pass.
- mobile-web against origin/main fdabddeb4 (a git repo made in the copy
  from git archive, since mote-run carries no .git): 30 of 30. It now
  takes the new Settings › button out of the Routing page until main has
  it, as it does for other new rows.
- go test -run 'Budget|I18n|Strings' ./internal/gui: ok. gofmt clean.

Broken by hand:
- the three rows back in Replies and busyLoadRow left where it was:
  settings-places and retry-after-cap-setting 20 of 20 red (chromium);
- the Settings › button's click handler off: settings-places 10 of 10 red.

Not tried: the real app; the GUI suite beyond these files runs with the
rest of this audit's changes.
2026-11-09 22:42:58 +08:00