Commit Graph
4 Commits
Author SHA1 Message Date
yetone 192d2eda81 gui: About's licenses dialog and Sync's Restore and Upload asks load when opened, so the core is back in its budget (#5720)
TestCoreScriptBudget was red on main since 4436b7d98 (Make first under
Smart, CryptoSarom on X), which added 1,080 bytes to app.js and took the
core's scripts to 1,534,166, 364 over 1,533,802 (its parent was at
1,533,086). The budget is not raised (LESSONS: a budget raised whenever a
change reaches it bounds nothing); code that only runs when a dialog opens
moves out instead:

- Settings > About's Open-source licenses dialog (showNotices) is now
  notices.js, imported when View is pressed.
- Sync's Restore from the server and Upload asks (askRestore, askUpload)
  join Sync's forms in syncfiles.js; syncFile imports it for them when
  pressed, and an import that fails says so in the status line.

app.js is 1,307,923 bytes (was 1,311,541) and the core 1,530,548, 3,254
under its budget. old-webkit's list of lazily loaded files names
notices.js; the budget's comment records this.

Run on mote at this tree (on origin/main ed0ab567c):
- gofmt -l internal/gui: nothing; node --check app.js, notices.js,
  syncfiles.js: ok.
- go test -tags nogui -run TestCoreScriptBudget ./internal/gui: PASS
  (red at ed0ab567c, per #5720).
- go test -tags nogui -timeout 45m ./internal/gui: ok (80.9s).
- node --test, chromium and webkit, every language and width the files
  have: about-notices, old-webkit, i18n-keys, auto-backup, github-sync,
  s3-sync and every sync-*.test.cjs: 210 of 212 pass. sync-auto-restore
  and sync-not-backup press Restore and Upload through the new import;
  about-notices opens the licenses. The 2 reds are red the same way at
  origin/main ed0ab567c in a clean worktree, alone: i18n-keys "a plugin's
  words are its own" (#5332, #5426, #5482) and s3-sync webkit en "picking
  S3 must not scroll the page", 3 of 3 (#3413); both commented there.

Not tried: the real app; the whole GUI suite.
2026-11-09 04:37:47 +08:00
yetone 47d5839397 library: sync and backup files carry the hooks
VincentChan on Discord (v0.1.3005) said part of the Library doesn't reach
his other computer through sync. Checked kind by kind what the library part
of a bundle carries: instructions (each set's text, a linked set's file text,
the agents ticked, each agent's own addition), MCP servers, skills and
subagents all go. Hooks didn't: library.Bundle had no field for them, so a
hook made on one computer never reached the other, by WebDAV/S3/GitHub sync
or a backup file.

- library.Bundle.Hooks (*[]*Hook): name, description, event, matcher,
  command, timeout, agents ticked. Collect always sets it, empty too.
  Applied.Hooks (the entries magpie wrote into each agent here) stays out:
  each computer writes them on the sync Put runs, beside the user's own
  hooks, and records its own entries, so an entry the user edited there
  stays theirs.
- Put replaces the hooks with the bundle's, so one taken out on one
  computer goes from the others. A nil list (a bundle from a magpie before
  this) keeps this computer's.
- check refuses a hook with no name, no command, or named twice. The event
  and agents are carried as they come: an event a newer magpie knows is a
  problem on the agent here, not a refused library.
- davsync: an empty list hashes as before the field, so upgrading with no
  hooks syncs nothing.
- The CLI's backup line counts hooks; the GUI's sync/export/import ticks
  say "instructions, MCP servers, skills, hooks and subagents" in every
  language.
- library.md and sync-backup.md updated, and they now name what stays
  this computer's own: projects, skill groups, CopySkills/SkillHow,
  SharedSkills, MCPHub.

Instructions: two sandbox computers through the fake DAV server carried a
named set and a change to it, a set linked to ~/.agents/AGENTS.md and a
hand edit of that file, both computers having their own text first, an
agent's own addition, and an agent installed after the first sync. All
reached the second computer's CLAUDE.md/AGENTS.md (exploration tests, not
kept). So no instructions change here; what VincentChan saw is not
reproduced yet.

Run (worktree at 0e55a7593; origin/main bf60ea596's two commits touch
none of these files):
- mote: go test -tags nogui ./internal/backup ./internal/davsync
  ./internal/cli ./internal/library ok; go vet -tags nogui for darwin,
  GOOS=linux and GOOS=windows on the four packages ok; gofmt -l clean;
  go test ./internal/gui -run 'TestCoreScriptBudget|Words|I18n|Builtins' ok
- GUI (wsl-run, Linux): i18n-keys, github-sync, s3-sync, sync-*,
  webdav-settings-refresh, library-backups-top, gui-de, gui-ja, gui-zh-tw:
  187/187

Broken by hand: with Collect not setting Hooks, Put ignoring them and the
hash not dropping an empty list (the old code), TestCarryHooks,
TestCarryOldBundleKeepsHooks, TestCarryNewerHooks,
TestBackupFileCarriesHooks, TestSyncHooks and TestNoHooksHashAsBefore
went red.

Not tried: a real WebDAV/S3/GitHub remote between two real computers;
Windows and Linux runs of the Go packages.
2026-11-05 11:29:20 +08:00
yetone 5910b51244 gui: Settings › Sync's server form loads with syncfiles.js, out of the core (#5139)
TestCoreScriptBudget was red on main: 1,534,154 bytes of core script
against a budget of 1,533,802. It is fixed by taking code out of the
core, not by raising the budget (LESSONS.md, "a size budget raised
whenever a change reaches it bounds nothing").

davForm, the WebDAV / S3 / GitHub server form that opens under Settings ›
Sync's Edit, is used only there. It moves from app.js into syncfiles.js,
which already holds Sync's Export and Import forms and is imported when
one of them opens. syncFile(f, v) now passes the sync state through,
so renderSync draws the server form through it too: once syncfiles.js
is loaded it is drawn at once, and before that a placeholder is swapped
for it. syncServers, syncNames, syncBar, tick and syncOpen stay in
app.js, since renderSync and autobackup.js use them too.

Core scripts at this head: 1,525,207 (origin/main e928b57f0 had come
down to 1,533,125 on its own, 677 bytes under). app.js is 1,303,483
against 1,316,874. The budget is not lowered: what is left plus 1.5% is
over it, as at #4133. The budget's note and old-webkit's list of lazy
scripts say what moved.

Run on mote (mote-run):
- Whole GUI suite, both engines, every language, at 7fe26671f (this
  change on 0ee424e3e): 20,019 tests, 321 reds in 53 files. Those 53
  files run again at 0ee424e3e and at 7fe26671f (concurrency 2): 297
  reds at base and 289 here, in the same files, with only flaky
  subtests differing. zero-priced-free (20 of 20 red on main) had no
  issue, filed as #5262. plugin-namesake went red only in the full run
  and passed in both reruns. The rest already have issues (#4566
  segs-press-redraw, #3413/#2448 s3-sync, #5035, #2658, ...).
- At this head (rebased on e928b57f0): go test -count=1
  ./internal/gui/ (TestCoreScriptBudget passes), and every sync GUI file
  (auto-backup, github-sync, s3-sync, sync-*, webdav-settings-refresh,
  usage-computers, codex-async-compact), i18n-keys and old-webkit in
  both engines. The reds: s3-sync webkit en (#2448/#3413, red at base
  too), usage-computers' "the sync form's Usage tick" in Chromium zh
  (#5224: 2 of 6 alone here, 1 of 6 at e928b57f0), and
  TestMainWindowCorners/macOS_26_SDK (#3949, red at e928b57f0 too on
  mote's macOS 27).

At the pushed head (rebased on 387b386c8): TestCoreScriptBudget, i18n-keys and old-webkit pass on mote at f280b12e5 plus this change; 387b386c8 touches only internal/agent, internal/sessions and a doc.

Not tried: the real app (WebKitGTK, the Wails window). No change to
what the page draws was intended, so no tag. Not run: the whole Go
suite, and Windows or Linux.
2026-11-04 23:17:05 +08:00
yetone 900ae0fa51 backup, sync: sign-ins go too when picked, sealed, never over a later renewal
qianxunji (#feedback) and curtinp118 on Discord: a VPS restored from a
backup, or a new computer joining sync, had to sign in to every
subscription again. Sign-ins (subscription accounts in logins.json,
Codex's auth.json, plugins' sign-ins in plugin-auth.json) can now go too,
in each place only when picked; all are off by default, so an upgrade
carries nothing new.

- Sync (WebDAV, S3, GitHub): a "Sign-ins" tick in the form, with a line
  saying anyone with the passphrase and the server's file can use the
  accounts, and that an account on two computers can be signed out on one
  when the other renews it. CLI: `magpie webdav|s3|github set sign-ins=yes`.
- Export: "With the sign-ins", off; ticked, the passphrase hint says the
  file holds them. CLI: `magpie backup --sign-ins`.
- Import: "Bring in the sign-ins too, when the file has them", on. CLI:
  `magpie restore --no-sign-ins` leaves them out.
- Back up by itself: "Sign-ins in backups", Off/On. On asks for a
  passphrase (twice) that seals the sign-ins alone (the rest of an
  automatic backup stays unsealed, as before); it is kept in
  autobackup.json (0600), never sent in the view. A backup whose sign-ins
  another passphrase sealed restores without them and says so.

What goes (provider.CollectSignIns, plugin.CarriedAuth): magpie's own
copies only, not an agent's own account, an agent-home row, a hidden or
plugin: row, or a retired built-in. Each record is keyed by agent +
email + org (or the account key); ids two rows share go on neither side.

Restore/import (RestoreSignIns) adds what is missing and updates only
when the incoming copy was renewed later; nothing here is removed.
Before writing over a row it counts every row that could be the same
account (same login, same refresh token, same id): none adds, several
keeps all, one is kept when it isn't magpie's own copy, is held, or is
the agent's live account. Codex's auth.json is written temp-and-rename,
0600, only where Codex is signed out.

Sync merges per record against the last sync's hashes (MergeSignIns):
the later renewal wins; a removal crosses only when the other side still
had it as of the last sync; ApplySignIns re-checks each row's hash
before writing so a renewal in between is kept. A computer with the tick
off sends none, so others remove nothing for it; turning it off, a
Restore, or a replaced server file clears the last-sync record.

Export's and Import's forms moved out of app.js into syncfiles.js,
imported when one opens (as autobackup.js is), so the core is 3.2KB
under its budget with no raise (app.js 3.2KB smaller than before).

docs/subsystems/sync-backup.md has a "Sign-ins, when picked" section;
subscription_signin_test.go's header now says it pins the default.

Run at the pushed head (678d28cba on origin/main bc10a6198):
- wsl-run go test -tags nogui -timeout 45m: backup, davsync, plugin, gui
  ok (TestCoreScriptBudget in it). provider: one red,
  TestCancelledPluginSignInSavesNothing, the late sign-in saved after
  Cancel. It is green 20 of 20 alone, at this head and at origin/main
  alike, and this change adds only new files there whose tests run after
  it; filed as #5047. cli there hung in proc.lookStamp's os.Stat on WSL
  at load 100, so it ran again on mote: one red,
  TestEveryRouteHasACommandOrIsNamed (GET /api/context/reply, #5026),
  the same at origin/main. gateway -run TestCompactionOverByteCapEveryTime
  ok (#4862 on mote's full run). TestMainWindowCorners on mote: red the
  same at origin/main (#3949).
- GUI, on mote: the 16 files that open Sync, plus i18n-keys and
  old-webkit, Chromium and WebKit, every language: 255 of 294 pass. The 39
  reds are segs-press-redraw's searchAllRow (#4566), s3-sync in WebKit
  (#2448) and usage-agents-hide (#3414). The same files at origin/main
  bc10a6198 give the same 39 pass and 39 fail. sync-signins, auto-backup,
  sync-sign-in, i18n-keys and old-webkit alone on WSL: 92/92.
- The whole GUI suite on WSL, stopped at 737 of its tests (1162 files,
  load ~100 there): 9 reds, all WebKit, none in a Sync file:
  account-eye (#4244, #5052), add-button (#4792), account-plugin-user
  and agent-expand-steady. The last two pass at this head and at
  origin/main on mote. The rest of the suite was not run.
- gofmt -l: clean. go vet: darwin (internal/gui, internal/cli),
  GOOS=linux and GOOS=windows -tags nogui for backup, davsync, provider,
  plugin, cli, gui: ok.
- win-run and wsl-run: go test -tags nogui -run
  'SignIns|Carries|AutoBackupSignIns' ./internal/provider
  ./internal/backup ./internal/davsync: ok on Windows 11 and Ubuntu 24.04.
- sync-signins.test.cjs: 20/20, Chromium and WebKit, 1100 and 420px,
  en/zh/zh-TW/ja/de, no horizontal overflow, no page errors.

Then rebased on origin/main 5ee5274bd (12 commits; davsync.go, app.js and
i18n.js merged with no conflict) and run again at the pushed head on mote:
gofmt clean; go test -run 'TestCoreScriptBudget|SignIns|Carries|
AutoBackup|Sync' for gui, davsync, backup and provider: ok; sync-signins,
auto-backup, sync-sign-in, i18n-keys, old-webkit: 92/92.

Broken by hand, each red, then restored:
- RestoreSignIns writing an older token over a newer one:
  TestRestoreSignInsNeverWritesAnOlderTokenOver red.
- The ambiguous-account guard has two layers (more than one match, and
  a single match with another record id); with only the first removed
  the test stayed green, with both removed
  TestRestoreSignInsLeavesAnAmbiguousAccount went red.
- MergeSignIns removing a row renewed here: TestMergeSignInsRemovedOnlyWhenTheOtherSideRemovedIt
  red.
- Codex auth.json written over a signed-in Codex:
  TestRestoreSignInsSignsCodexInOnlyWhereSignedOut red.
- ApplySignIns not re-checking the hash: TestApplySignInsKeepsWhatChangedSinceTheMerge
  red.
- davsync forgetting the last-sync record (st.SignIns = nil):
  TestSyncSignIns red.
- GUI: Export's tick on by default, and auto backup's On posting with
  no passphrase: sync-signins.test.cjs red for each.

Not tried: real accounts carried to a real VPS or second computer (all
Go tests use testenv homes, fake DAV and fake tokens; the Keychain is
never reached); a real vendor's refresh after a carried sign-in, and how
each vendor treats one refresh token used from two machines; the CLI
flags against a sandbox HOME (covered by the cli package's tests only);
auto backup's sign-ins have no CLI switch.
2026-11-03 17:24:19 +08:00