1ccacad63281094de8a3372d5a507d38f9969e5c
93
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
58fb070953 |
settings: named proxies, chosen as inherit, direct or a saved one anywhere a proxy is (@tsingchao on X)
Settings > Network keeps named proxies (name, address, optional login)
with a Test that says reachable and the latency. Everywhere a proxy can be
chosen (global, plugin downloads, a provider, a key, a Claude account) now
has a Saved mode beside the others; the value is "@<id>". Addresses typed
before are read exactly as before, nothing is migrated or overridden.
netproxy.Parse/Resolve/Redact/EnvWith/Dispatch resolve a reference at the
lowest layer, so a proxy edited once reaches the gateway, usage reads,
sign-ins and the plugin host at the next request; Claude Code's
settings.json env (a snapshot) is rewritten by provider.ProxyEdited.
A reference this computer lacks fails closed (DeadProxy), says the proxy's
name in the request error and as "Proxy missing: {name}" on the provider
row, and never goes direct. The password lives in settings.json (0600), is
never read back by the page, logged, or put in Settings sync. The list
rides with the providers part of a sync (Bundle.Proxies, MergeProxies by
id, passwords only with keys). A proxy in use can't be deleted (409).
The saved list's page code is in proxies.js, loaded when Settings draws it;
app.js grew by Saved-mode helpers only, paid for by 16 long comments cut
(core budget unchanged, no raise).
Run (mote refused ssh all session, so Go and GUI went through win-run on
xiaomi-gpu, Windows 11; gofmt and darwin/linux-nogui/windows go vet were
clean on mote before it went down, at the pre-sync tree):
- go test settings, netproxy, backup, settingsapi, davsync: ok on Windows
(earlier on mote: also gui, provider, plugin with real Bun, gateway).
- saved-proxies.test.cjs 20 of 20 (chromium+webkit, en zh zh-TW ja de,
420px) twice more on Windows; provider-proxy-missing.test.cjs 20 of 20.
One webkit de 420px run of saved-proxies failed once under 4-way
concurrency and passed 3 of 3 alone; not reproduced.
- TestCoreScriptBudget ok after the move (it was 3.4KB over before).
Red on this tree and on origin/main alike (Windows run, not mine):
settings TestSharedCheckedReadsOnceAndKnowsUnknown; provider
Codex keychain/Git tests; plugin TestHostRunsAsMagpieBun, TestPiPackage;
gui TestGatewayHeldByAContainer and others; old-webkit "compat.js is the
first" (headerpresets.js) and ":has() (Safari 15.4)" on origin/main
|
||
|
|
71c4ef2d07 |
gui: Bark push target for every alert, and a daily spend summary (EV_John_Liu on X)
Settings > Usage has a Bark row: a server (default https://api.day.app, or
a self-hosted one) and the device key, then Test and Remove. Every alert
that goes through notifier.sendAs (allowance, balance, reset reminder, task
done, masking, sign-in) is also pushed to Bark when a key is set, whether or
not the system lets this computer notify. A second row, once a key is set,
turns on a daily summary at a time of day: today's cost and request count,
and each window or balance near its cap (the Allowance alert's share, else
80%), capped at 8 lines. It is pushed once a day (a restart does not resend;
a failed push is retried every 15 minutes; one more than 6 hours late is
left), in the page's language (en, zh, zh-TW, ja, de).
The device key is a key: the page only gets barkKeySet, never the key; it has
its own route (POST /api/settings/bark, key omitted keeps it, "" removes it),
a Settings save carries it (settingsapi.Merge), and a backup or sync without
keys leaves it out and keeps this machine's. No log line or error names it
(the Bark client replaces it with "..." in what the server or client says).
bark.js is a lazy module so app.js (budget) gains one line.
Run (mote, at the pushed tree before the rebase onto
|
||
|
|
281a7e024f |
sync: a computer can follow the server, taking its setup and sending none (Ramon317317 on X)
Ramon317317 asked for a main profile: one computer the others take their
setup from, so they never drift apart. Sync merged both ways only;
Restore is a one-time pull and an agent's own fields cover agents only.
A computer can now be set to follow the server (Settings -> Sync -> This
computer: Both ways / Follows the server; /api/davsync/follow-server;
`magpie webdav|s3|github follow on|off`). It is chosen per computer and
kept in sync.json (Config.FollowServer, kept by Configure like AutoEvery).
A following computer:
- takes every changed part from the file, whichever side is newer;
- never writes the file: no push, no merged sign-in, no rebuild of a
damaged file;
- keeps a change made on it in the sync folder, as a join does, and the
notice says it was replaced because this computer follows the server
(Notice.Followed; GUI and CLI);
- still keeps an unset part on the server from emptying its own, and own
agent fields and agents only here;
- refuses to follow a server with no file yet, sending nothing.
The computer followed stays two-way; nothing changes for anyone who
doesn't pick it. Usage sharing is unchanged. docs/subsystems/sync-backup.md
says so.
app.js stays inside the core script budget (TestCoreScriptBudget) with
no raise: renderSync's comments are cut down to pay for the row.
Run (mote, at this head):
- go build ./...; go vet ./... (darwin), GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./...; gofmt -l clean.
- go test ./internal/davsync ./internal/cli ./internal/gui: ok (cli
with the route guard fix committed beside this one).
TestFollowServer (empty server, join, own change replaced and kept,
both changed, unchanged sync, Configure keeps it, back to both ways)
and TestFollowServerSendsNoSignIn are new.
- GUI (node --test, Chromium and WebKit): sync-follow-server (new; en and
zh, 900px and 400px: name, sub, picked segment, the post, the notice,
no scroll, no overflow, no select, re-pick posts nothing), plus
sync-auto-restore, sync-note-show, sync-own-fields, sync-not-backup,
sync-other-kind, sync-signins, sync-spin, i18n-keys, i18n-en-no-cjk,
gui-zh-tw, gui-ja, gui-de: all pass.
Broken by hand:
- push guard removed: TestFollowServerSendsNoSignIn red ("sent its
sign-in: 1 puts").
- follow branch off: TestFollowServer red ("b's own change stayed:
[deepseek=k1 kimi=kb2]").
- the row's click not posting: sync-follow-server red, 8 of 8.
Not tried: a real WebDAV, S3 or GitHub server (fake servers only); two
real computers; Windows run of the tests (vet only). The full suite starts
after the tag.
|
||
|
|
9e51c5c2a8 |
gateway keys: account groups a key may use or keep out (LeiWang_2000 on X)
LeiWang_2000 asked for account groups, so a gateway key can be limited to
a group of accounts, or keep a group out, instead of picking accounts one
by one (on top of v0.1.3504's "Keep accounts out").
An account group is a named set of accounts of any providers, kept in
account-groups.json beside caller-keys.json (access.AccountGroup). A key's
account list names one as "@<id>" (use only its accounts) or "!@<id>"
(every account but its). identityOf expands the groups of the key and of
its issuer on every request, so every route that reads the Identity
(AllowsAccount, HeldModels, the routes' model checks) holds to the group
as it is now: a membership change reaches every key naming it at once, and
an account signed out since matches nothing. Fails closed: a group gone,
or a used group with no account, holds the key to nothing
(heldToNothing); unreadable groups refuse a key naming one and leave other
keys alone. A group a key names can't be removed (the error names the
keys); ReplaceAccount moves a rotated key in the groups too. Groups are
backed up and synced (WebDAV) with the gateway keys. A magpie older than
the mark reads "@<id>" as an account of no provider and fails closed.
CLI: `magpie gateway-key groups add|set|rename|remove`, and
`gateway-key accounts <id> @Work` / `!@Work`.
GUI: an "Account groups" editor (modal, rows of name + accounts picked in
the app menu) from the keys' header; the key's account menus list the
groups as options; the badge says "Work" / "Not Work". No layout change to
the rows.
Tests:
- internal/access TestAccountGroupHoldsAKey / ...AnIssuedKey: save rules,
name->id, used+kept-out refused, held/kept-out allows and models, a
change reaching both keys, rotate, remove refused, empty group, groups
gone, unreadable groups.
- internal/gateway TestGatewayKeyAccountGroupsKeyedRoutes: a held and a
kept-out key on 7 routes, flipped by a group change, and nothing asked
once the group is gone.
- internal/cli TestGatewayKeyAccountGroupsCLI.
- GUI gateway-key-account-groups.test.cjs: 5 languages x chromium/webkit
x 1100/440.
Broken by hand (each red, then restored):
- identityOf not expanding groups: access test red, gateway test 403.
- a gone/empty held group not becoming heldToNothing: access test red
("held to an empty group"), gateway test asked kA with the group gone.
Run on mote at this tree: gofmt -l clean; go vet darwin (touched
packages), GOOS=linux -tags nogui ./..., GOOS=windows ./... clean;
go test -count=1 access, cli, gui (size budgets included), backup,
davsync, gateway: all ok;
GUI: every gateway-*.test.cjs plus i18n-keys, i18n-en-no-cjk, key-page,
plugin-kernel, readable-focus, chromium + webkit: 571 of 574 at
--test-concurrency=6. The 3 reds: gateway-caller-keys and
gateway-key-models chromium en (the 560px read, red on main too, fixed in
the next commit), and gateway-key-groups zh once, 12 of 12 alone (#1974).
Rebased on
|
||
|
|
e4197144a8 |
perf: every package's package-level regexps compile on first use
v0.1.3516 made gateway's and redact's patterns lazy. The other 299 package-level regexp.MustCompile calls, in 148 files across agent, provider, gui, library, codexcat, sessions, usage, plugin and the rest, now go through lazyre.New too, so a launch that never reaches them (`magpie statusline`, run by Claude Code on every message) doesn't compile them. Fields, maps and params that held them are *lazyre.RE. Measured on mote (M5 Pro), sandbox HOME, v0.1.3516-equivalent build (t42) against this one (t43): - GODEBUG=inittrace=1 sum: 7.39 MB / 69,837 allocs -> 4.62 MB / 46,765 - `magpie statusline`, 3 runs each: instructions retired ~212M -> ~176M, peak memory footprint 19.2-19.4 MB -> 16.8-17.0 MB Run: go vet ./... (darwin) ok; GOOS=windows go vet on each of the 30 changed packages ok; GOOS=linux go vet ok except ., internal/cli and internal/gui, which stop in wails v3's cgo files when cross-compiled (the same at main). New TestAllLazyPatternsCompile at the root compiles all 574 registered patterns (ok), so a bad pattern fails a test rather than a first use. Not run before push: the changed packages' own test suites; they run on mote after it. |
||
|
|
f411bd304c |
davsync: a part the server file holds nothing in never empties a joining computer (#5642)
Three computers syncing the Library alone: the main one's providers and
routing groups were gone minutes after it joined. An empty computer had
written the folder's file first, and a join takes the remote setup whole,
so its empty providers, groups, settings and library cleared what the
joining computer had (mirror, displaced copy kept in the sync folder).
On a join (no last sync on record), a part the server file holds nothing
of its own in (unset: no providers or groups, the default settings, no
profiles, an empty library) is the folder never having had one, not a
removal: a computer with that part set up keeps it and sends it up.
After the join an emptied part is a removal and spreads as before. The
check is on content, not a hash of an empty bundle: a fresh computer
writes the default settings and an empty-but-present library, which a
nil-bundle hash misses. Agents (which agents a computer has) are left
as they were.
Not changed: providers, settings and profiles still have no tick of
their own; with the Library ticked alone they still sync. A tick per
category is a feature of its own, not this fix.
Run:
- TestSyncEmptyFirstKeepsLaterSetups (new): red with the new case
disabled ("a after joining's providers: []"), green with it; it walks
b-empty-first, a joining with a provider, a group, a theme and an MCP
server, b taking them (key kept on a), a keeping them, and a removal
after the join reaching b.
- go test -tags nogui ./internal/davsync/ ./internal/library/ on mote.
- gofmt -l on the changed files: nothing.
Reported-by: tan-yong-sheng (yetone/magpie#5642)
Reported-by: gua2100 (Discord)
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
c8eb7b3877 |
search: a search API's keys are a list, each switched off, moved and removed on its own
Web search took one key per API in one field (辰林鸭~ on Discord: only one
Tavily key). Settings › Models › Web search now lists an API's keys under
it as a provider's accounts are: each masked on its own row with a tick
(off / on), Show, Copy and Remove; several pasted at once (commas,
semicolons, lines), the reply saying how many were new and how many it
had; the order changed by dragging or Alt+↑/↓. A resting key says why and
until when on its row ("asked last until 14:05: rate limited"), from the
gateway's rest (SearchKeyRest, SearchQuota.Ref); rotation on 401/403,
402/432/433 and 429 (#1477) is unchanged.
provider.SearchAPI keeps Key as the keys on, comma-joined, so the gateway
and an older magpie never ask one switched off; keyList is written only
while a key is off. A Key that differs from the list (an older magpie, a
sync) wins, its keys on in its order, the list's off keys after. The last
key on can't be switched off or removed. The GUI names a key by
SearchKeyRef (a hash): POST /api/settings/search-keys (add, ref+on,
ref+remove, arrange) and /api/settings/search-key with ref. Saving an API
with no key keeps its keys, off ones too. Backup and WebDAV sync carry
the off keys, or leave them out with the rest. `magpie search` says
"+N off". docs/subsystems/gateway-routing.md has "The keys as a list".
Run (mote, at this tree, base
|
||
|
|
0f0484c515 |
davsync: a WebDAV server that breaks on a conditional read is read without one (123pan, #4993)
After the first sync, magpie reads the backup with the version last seen
(If-None-Match, or If-Modified-Since on a server without ETags) so an
unchanged file costs a 304, not a download. 123pan answers that GET 500
after about 30 seconds (the reporter's curl: a plain GET 200, HEAD 200
with a valid ETag, GET with If-None-Match 500), and every sync failed
with "reading magpie.magpie-backup from the WebDAV server: HTTP 500".
A conditional read answered 5xx is now asked again without the
conditions, and the version is marked NoCondRead (kept in the sync
state), so that server is not asked with a condition again. The ETag the
plain read returns is still sent as If-Match on the write, so a write
from another computer in between is still refused as changed. A plain
read that fails is reported as before.
Changed from the contributor's patch: the mark is set on every version
a plain read returns, not only on the fallback read's. In the patch a
sync that read plainly saved an unmarked version, so every second sync
sent the condition again and waited 30s for the 500. The sync test now
runs three more syncs and checks no condition is sent, and checks that
the merged write carries the plain read's ETag as If-Match.
Run (mote): go test -tags nogui ./internal/davsync/ (ok, 56s);
go vet -tags nogui ./internal/davsync/; gofmt -l (empty).
Broken by hand: with the fallback disabled, both new tests fail with the
reporter's own error ("reading magpie.magpie-backup from the WebDAV
server: HTTP 500"); with the contributor's version of get,
TestSync123panConditionalRead fails ("3 conditional GETs after more
syncs, want 1").
Not tried: a real 123pan account (the fake answers as the reporter's
curl showed); whether 123pan honours If-Match on PUT (writes were never
reached in the report).
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
1826c4bd99 |
providers: a Remote magpie that is this magpie says so and is left out, unless kept (hanslin1666)
B uses A through a Remote magpie provider, and sync carries that
provider to A, where it points at A. Each of its models was one of A's
own, listed again beside it and taken by A's found groups, and a request
through it passed through A's gateway twice.
A fetch of a Remote magpie's list now reads its models' magpie_via: when
the magpie that listed them (the last entry) is this magpie's own
catalog.Self, remote-self.json keeps the provider id and the address it
answered at (noteSelf). Another lister, or a list with no via, takes
the record away; an empty list or a failed fetch changes nothing; a
provider moved to another address is not self until a fetch there says
so. The file is this computer's own, never in a backup or sync.
Such a provider is left out (SelfLeftOut in On, SwitchedOff and
remoteMagpies): not in /v1/models, the catalog or a found group. A
request naming one of its models, an agent's pick synced from B, is
served here with the remote's id taken off (ThroughSelf in Resolve and
ResolveRoute), once through the gateway. A 404 for it says why and how
to keep it.
The Providers row shows "This magpie" (greyed while left out), with the
reason as its title; the editor has a note and a "Use it anyway" tick
(KeepSelf, POST /api/provider/keepself). KeepSelf belongs to the user
and to this computer: Mirror and Restore keep the local value (false for
a provider new here), davsync's hashes blank it, and a provider save
keeps it. Strings in en, zh, zh-TW, ja, de.
Docs: providers-accounts.md (two magpies row), sync-backup.md (what
stays on each computer).
Run at this tree on origin/main
|
||
|
|
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. |
||
|
|
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 |
||
|
|
1dead5dc7b |
provider: magpie's own Codex account switches leave the Codex app running unless Restart the app is ticked (atom0964)
atom0964 on Discord (#help) has two ChatGPT Plus accounts in magpie, with Codex always signed in to the first and Only switch Codex's sign-in both off, on Smart routing. The Codex desktop app kept restarting by itself. They tried several combinations of the ticks and it still did. Why: with both off, SwitchWhenSpent signs Codex in to the next account at 98% and back to the first below 90%. Each switch was noted for the Codex app (codexAppSpentSwitch), and KeepCodexAppOnItsProvider ended its app-server once no turn ran; the ChatGPT app shows that as an error and relaunches (#4550). With Codex kept on the first account there is no switch, but the used-up takeover (magpie made Codex's provider for a used-up account and given back once it has room; |
||
|
|
cc22efebb7 |
davsync: a 403 on the write names the folder it went to, and a full quota (#4927)
The error for a write the server refused, with the address's folder listing fine, said the account couldn't write in that folder (/dav) - but the write went to magpie's own folder inside it, and the listing never proved anything about writing. On 坚果云 (Nutstore) the refusal is usually the free tier's upload quota used up, which answers 403 on a PUT with everything else fine (#4927), so the old text sent the user to check a thing they can't check. The error now looks at magpie's own folder first: there, the server refused to change files in it, and the text says so and mentions the quota; missing, the server refused to have magpie make it, and the text says to make the folder by hand, or put an existing folder in the address. Review, changed from ggbdpq's patch: the folder is named with path.Join(dir, folder). The patch's dir+"/"+folder said "//magpie" for an address with no folder of its own (dir "/"). The test now covers that address too. Broken by hand at the reviewed head: dir+"/"+folder back, TestDAVWriteRefused red; dav.go reverted to its parent, red; restored, green. Run at the pushed tree (this stack of nine on origin/main |
||
|
|
2ab9235711 |
agents: an agent's picks can be kept to this computer, as an MCP server can
chenxiang0010 on Discord: 「agent当前选择的模型可不可以像mcp那样 只对当前设备生效」.
Sync carries every agent's picks (model, effort...) between computers;
an MCP server has an opt-in "This computer only" that sync and backup
files never carry. Agents now have the same: the row's menu (right-click
or ...) has This computer only, off by default, so an upgrade changes no
pick on any computer.
- settings: AgentsHere, this computer's own (KeepOwn), and kept by a save
of the Settings page (settingsapi.Apply), which doesn't send it.
- davsync: each kept agent adds "<id>.*" to the own set (withHere, isOwn),
so a sync neither pushes its fields nor brings the server's; a Restore
from the server leaves them. sync-state.json records the list as of the
last sync (Here): hashes before a sync use it and after use the current
list, so turning it on or off is no change on either side, and a changed
list forces the sync past its early returns. Turned off, the next pick
goes up again. Other agents still sync both ways; the implicit own
fields (hayden4608) are unchanged.
- backup.Restore skips a kept agent in a backup file.
- gui: POST /api/agents/here; the row says "This computer only" beside
the version (hidden in the tray panel and in a narrow row), menu ticks.
Core words moved from the library plugin's i18n into core i18n
(zh/zh-TW/ja/de). Comments in renderAgents cut to pay for it under the
core budget (no raise).
- cli: the route is named under stage 3 (no command yet).
- docs/subsystems/sync-backup.md describes it.
Run on mote, at the base
|
||
|
|
1cb4d43013 |
profiles: a saved profile renames, in its details, the TUI and magpie rename (#2721, erlinerd)
erlinerd's patch on #2721 (profile.Rename, /api/state profile/rename, a Rename button in the details), reviewed against main and adapted: - profile.Rename trims both names, refuses an empty, taken or missing name and leaves profiles.json as it was, renames by case only (home -> Home), and keeps what the profile holds. - GUI: Rename turns the details' name into a field. Enter renames through profileAction, so the chip is renamed at once, pending, and rolled back with the error if magpie refuses; the details stay open under the new name, with In use kept. Escape or a click away puts the name back. The field lives in profilerename.js, imported on press, so the core script stays under its budget (no raise; 50 bytes under after comments in app.js were cut). While the field is open In use, Apply and Rename hide so a 360px panel's field has room. - TUI: ctrl+e on a profile renames it on the name line. - CLI: `magpie rename <old> <new>`; a flag is never taken for a name. - WebDAV: a rename syncs as the old name gone and the new one in (davsync test). Run on mote at 47672f11c (on |
||
|
|
3ed3605ba0 |
netproxy: a global proxy switch drops the idle connections of the sync and the icon fetch (#4824)
ggbdpq's patch (gua2100 on Discord), reviewed and landed with test changes. What changed - netproxy.Watch gives the dispatch's per-request check for a moved global proxy (#4523) to transports magpie keeps for itself. The sync (davsync) uses http.DefaultTransport, so when one of its requests finds the proxy moved, it now drops the idle connections itself. Before this, only a DefaultClient request dropped them, and a backup kept going through the old proxy's HTTP/2 connection. - FetchIcon now closes the pool of the client that only the fetch used. Nothing closed it before. - Review changes: the davsync test restores settings.json afterwards, and the icon test's wait for idle is bounded at 20s, not 2s, to leave room under load. Run at the pushed head (on mote, base |
||
|
|
a73df419d8 |
davsync: a GitHub blob POST on a slow but live line is no longer cut off at 30 s
What changed: the stall watchdog saw a request as one whose body may outlast the whole metadata limit only by method (GET, PUT), and gave every other request a flat 30 s (#657's rule held for WebDAV and S3, whose remaining requests move a few KB at most). GitHub's uploads ride a POST: each blob POST hauls up to 16 MiB of file as about 21 MB of base64, and a flat 30 s needs 550 KB/s to get one part through (#4576: on a slower line the sync failed on the same POST at every attempt, automatic, at start and manual, and never recovered -- the usage day file froze in the morning while the machine kept working). A request hauling a big body (64 KiB or more) now gets the same moving-aware budget as a PUT: the watchdog is put back each time bytes move, and after the body is all handed over the answer gets 60 s on top of as long as the write took. The metadata requests (the GitHub tree, commit and ref POSTs and PATCH, WebDAV PROPFIND/MKCOL/MOVE/DELETE -- kilobytes at most) keep their 30 s in all. Run: TestGitHubSlowBlobUploadIsNotCutShort (a 272 KB base64 body through a line at 320 KB/s, watchdogs shortened to 1 s/300 ms) fails on the old code with "the server didn't answer in 300ms (POST)", the shape of #4576's error, and passes now; TestGitHubSmallPostKeepsTheLimit pins the small POSTs to the old limit either way. go test -tags nogui ./internal/davsync, vet and builds for darwin, GOOS=linux and GOOS=windows pass. Not tried against a real slow line to GitHub. Generated-by: GLM-5.3-Flash (ZCode) |
||
|
|
da275848b6 |
tray: Windows shows a card's number in its icon (Benjaminliang_1 on X)
Windows' notification area shows no text beside an icon, so with a card in the tray the icon itself is now the first card's figure: the first row of the first card whose first row is a percentage, used or left as Allowance display has it, its digits alone (trayIconFigure). It is drawn in Segoe UI Semibold (Go's bold if the font can't be read) at SM_CXSMICON, white on a dark taskbar, near black on a light one, as tall as fits, centred by its ink, three digits narrowed into the square (trayNumberIcon). It is drawn again when the figure, the icon size or the taskbar theme changes (SystemThemeChanged wakes the loop); the tooltip still lists every card. A balance or magpie's totals are skipped; with no such card, or no cards at all, the icon is the bird as before. Settings > Usage > Tray icon number (settings.TrayNoNumber, Windows only, on by default, kept per computer) keeps the bird when off; Menu bar windows is now shown on Windows too, since it picks the row the number comes from. The number row sits after Menu bar cost, so the bird > pace > cost order the other tests pin holds. Linux and the Mac are unchanged. New words in zh, zh-TW, ja and de. app.js stays in the core budget with one comment shortened, no raise. Run at this commit on origin/main |
||
|
|
1576ccdbbc |
davsync: the sync setup is read once a request, not on every Providers poll
/api/providers asks archiveState, which asks davsync.S3Bucket and so
Load, on every poll, and Load opened sync.json each time, most often a
file that isn't there. In a profile of 200 lists against a copy of the
owner's real config it was 0.19s of 4.07s.
Load now reads the file's bytes through filememo (once until it
changes, remembered missing while a request holds it) and unmarshals a
Config of its own for each caller. Configure and Restore write through
edit.WriteAtomic, which forgets already; Off removes the file and now
calls filememo.Forget too, so sync turned off in a request is off for
the next Load in it.
Run (on mote unless named):
- go test -count=1 ./internal/davsync ok (36.9s); ./internal/gui red on
TestMainWindowCorners only (macOS 27 on mote, #3949); GOOS=linux and
windows go vet ./internal/davsync ok; gofmt clean (here).
- New TestLoadReadOnceARequest, -count=3 ok: 20 loads in one held
request read once, a caller's change stays its own, and Off is seen
at once. Broken by hand: Load reading the file each time -> "read 20
times, want 1"; no Forget in Off -> "still on after Off".
- Here, 200 GET /api/providers on the sandbox with the real config
copy (offline, proxy :9): davsync.Load 0.19s -> gone from the
profile; total CPU within this machine's noise (4.53s -> 4.62s).
- Then rebased onto
|
||
|
|
a511b11d8b |
sync: an agent's model set back on a computer after a sync stays that computer's (hayden4608)
hayden4608 on Discord syncs two computers through GitHub, both with
Codex, and wants each one's Codex default model kept apart. Until now
the agents part carried every agent field ("codex.model", effort,
provider...) as one set: A's pick went up, B's sync brought it over B's,
B's pick went up again and A's next sync took it back. The two
computers fought, and the only way out was turning "agents' models"
off for every agent.
Now a sync that brings an agent field over this computer's value
records what it brought (Brought) and what it wrote over (Replaced,
only when that was picked here, not itself brought). If the user then
sets the field back to the value the sync replaced, the field is this
computer's own (Own): it leaves the hashes, a sync no longer brings it,
and a push keeps the server's value, so the other computer is not
changed either. Every other new pick is an ordinary pick and still goes
both ways, so a computer that changes the model for everyone (and
TestSyncAgentDefaults' reset) still reaches the rest. Nothing to set
up: the user's own act on this computer decides it, and a synced value
never overrides it again.
Settings > Sync lists the kept fields in one row ("Kept on this
computer: Codex model ...") with a "Follow the others" button
(davsync/follow), which brings the server's values on the next sync and
ends the keeping. Restore brings everything and ends it too. The row is
drawn only while sync and agents' models are on and something is kept;
plain row and button, no new layout. app.js grew 623 bytes; the budgets
are raised by that with a note.
Tests:
- internal/davsync/own_model_test.go TestOwnModelStaysOnEachComputer:
two sandbox HOMEs (CODEX_HOME per computer) on the GitHub fixture.
A picks a1, B joins and gets it, B picks b1 (goes up), A gets b1, A
sets a1 back (own; the server keeps b1), B picks b2 + effort +
provider (A gets effort and provider, keeps a1), A picks a2 and a
Claude model (both go up, B gets them), A follows (gets b2), B's b3
reaches A. TestNewPicksStillGoBothWays: alternating new picks always
reach the other computer.
- internal/gui/tests/sync-own-fields.test.cjs: the row in en, zh,
zh-TW, ja, de at 420px, no overflow, Follow posts once and the row
goes, no scroll; no row without own fields or with agents off.
Broken by hand, each red: noticeOwn off (own_model_test:122); any pick
after a sync counts as own (TestSyncAgentDefaults and own test:106);
keepServersOwn off (:166); the bring ignoring Own (:146); withoutOwn
off in the hashes (:143, a notice); Follow off (:182).
Run at this head (rebased on
|
||
|
|
07a3312c53 |
library: sync and backup files carry the subagents
xixi_Sean_ on X asked why Sync leaves the Library's subagents out. There
was no reason: the library part of a bundle now carries them.
- library.Bundle.Subagents (*[]*Subagent): name, description, prompt,
the skills and MCP servers named, the agents ticked. Collect always
sets it, empty too. Applied.Subagents (which files magpie wrote here
and their hashes) stays out: each computer writes the files into its
own agents on the sync Put runs and records its own, so a file the
user edited there, or one of theirs by the same name, stays theirs.
- Put replaces the subagents 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) is unknown and keeps this computer's.
- check refuses a subagent whose name isn't one (it is a file name in
every agent) or comes twice; agent ids are carried as they come, so a
newer magpie's tick for an agent this one can't give subagents to
stays and writes nothing here.
- davsync: an empty list hashes as before the field, so upgrading with
no subagents syncs nothing.
- backup files go through the same Collect/Put; the CLI's backup line
counts subagents. The GUI's sync/export/import ticks say "instructions,
MCP servers, skills and subagents" in every language.
- webdav-settings-refresh's "Agents" tick locator also matched the
library tick's "subagents": it now asks for "Agents' models".
- library.md and sync-backup.md updated. Hooks still aren't carried.
Run (rebased on 0bf5adb11; Go runs at e0c57ffe2, same diff):
- mote: go test -tags nogui ./internal/backup ./internal/davsync
./internal/cli ok; ./internal/library -run 'TestCarry|TestSubagent|
TestLocalServer|TestPutKeeps|TestPutSame|TestRestoreKeeps' ok
- wsl-run (Linux): ./internal/library ./internal/backup ./internal/davsync
whole packages ok
- win-run (Windows): the same three, -run 'Subagent|TestCarry|TestLibrary|
TestSyncLibrary' ok
- go vet -tags nogui for darwin, GOOS=linux and GOOS=windows on the four
packages ok; gofmt -l clean
- GUI (wsl-run, Chromium + WebKit, every language): i18n-keys,
github-sync, s3-sync, sync-auto-restore, sync-not-backup,
sync-other-kind, sync-sign-in, sync-spin, sync-usage-error,
webdav-settings-refresh, library-backups-top, gui-de, gui-ja,
gui-zh-tw, settings-search, settings-sections: 170/173, then
webdav-settings-refresh green after the locator fix. The one red left,
i18n-keys "a plugin's words are its own" ("Unmarked" in
plugins/routing/i18n.js), is on main already: #4524.
mote ran five other GUI suites at load 18, where every WebKit
github-sync case timed out at launch, so the GUI run moved to Linux.
Broken by hand: with Collect not setting Subagents and Put ignoring
them, TestCarrySubagents, TestCarrySubagentKeepsUsersFiles,
TestCarryNewerSubagents, TestBackupFileCarriesSubagents,
TestSyncSubagents and TestNoSubagentsHashAsBefore went red; with Put
treating a missing list as empty, TestCarryOldBundleKeepsSubagents and
TestBackupFileCarriesSubagents went red.
Not tried: a real WebDAV/S3/GitHub remote between two real computers;
the fake DAV server carries it between two sandbox HOMEs.
|
||
|
|
7d4a631480 |
tray: pick which of a subscription's windows the menu bar shows (StrikingRaw on X)
Claude Pro's menu bar card drew its 5-hour and 7-day windows as two
small stacked numbers, and the user wanted one of them alone. Settings ›
Usage › Menu bar windows (under Allowances in the menu bar) lists a pill
per ticked subscription with two or more windows ("Claude Code · All
windows"), opening the app's menu: All windows, then each window. The
choice is settings.TrayWindows, by provider id (every account of it, the
in-use "|*" card too) and by window kind from the span ("5h", "1d", "7d",
"month", "15m", "name:<name>" when the span is unknown), so a vendor
reordering windows changes nothing. Unset shows every window as before;
a pick whose windows are all gone shows every window again, never an
empty card. Only the bar's rows and the Linux label are filtered; the
tooltip still says every window. One row draws at mpRowFont's 11pt
single-row size. Hidden on Windows (its tray shows no text). Per
computer through KeepOwn. The GUI learns kinds from trayKind on
/api/usage/quotas (withTrayKinds; model and aside windows get none). The
row's code is a lazily imported traywindows.js, so the core script
budget is not raised (app.js +4 lines for the call and the prefs keep).
Run:
- mote (macOS): go test -run 'TrayWindow|TrayUsage|WithTrayKinds|
CoreScriptBudget|AppScript|TrayImage' ./internal/gui/ ok;
./internal/settings/ ok; davsync TestSync ok. TestTrayImageOneWindow
draws through AppKit: Claude's card one line ("42%"), both windows two;
the PNGs were looked at.
- mote: gofmt -l empty; go vet ./..., GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./... ok; go build, GOOS=linux go build
-tags nogui, GOOS=windows go build ok.
- magpie-desktop (Linux VM), --test-concurrency=1, BROWSER=chromium and
webkit: tray-windows (en, zh, zh-TW, ja, de; picking All; hidden on
Windows / single-window / no cards; 360px narrow), i18n-keys,
old-webkit, tray-usages, tray-logos, tray-cost, quota-pace: 43/43 each.
After rebasing on
|
||
|
|
93970cae48 |
davsync: the newer-change tests date this computer's change as finely as the other's push (#3420)
When both sides changed a part, the newer stays: this computer's
change wins when changed(p), the part's file time here, is After
remote.Created, the other computer's push, taken with time.Now(). A
file's time comes from the kernel's clock, which moves in ticks (4 ms
at HZ=250 on this Linux box) and is behind time.Now() by up to a tick
or two: of 20,000 files written right after a time.Now(), 19,954 to
20,000 had a modification time before it, by up to 8 ms.
TestSync ("…and the newer one stays") and
TestSyncTeraCloudStillSeesOtherWrites save this computer's change a
few ms after the other's push and expect it to be the newer. A save
inside the push's tick reads as the older, and the other's copy
replaces it:
davsync_test.go:309: newer here: &{... Here:[settings] There:[] ...}
teracloud_test.go:303: a wrote over b's providers without seeing
them: &{... Here:[providers] There:[] ...}
TestSync was red so in 3 of my full suites (10-19, 10-20, 10-23).
Alone on
|
||
|
|
d5d72a82af |
imagemcp, davsync: slow-download tests leave room for growing the download's buffer (#3419)
TestFourKImageByURLIsSaved, TestStalledDownloadSaysWhereTheImageIs and
TestSlowTransferIsNotCutShort shorten a download watchdog to 1 s or
300 ms. Each watchdog is put back when bytes come, and the time it
counts includes this process storing them: FetchImage's buf.Write, and
the GET's io.ReadAll, which in Go 1.26 fills fresh chunks half the size
of what has come. At the real 60 s that is nothing. At 1 s and 300 ms
these went red here, beside a full suite on a Linux box, with the line
never stopped:
big_image_test.go:153: after 4.096s: image 1 was drawn but couldn't
be downloaded (nothing came for 1s, after 4.2 MB)
big_image_test.go:207: image 1 ... (nothing came for 300ms, after
8.2 MB), the 4K image that comes in full
big_image_test.go:207: image 1 ... (nothing came for 300ms, after
0.0 MB), the same
stall_test.go:180: slow download: the server sent and took nothing
for 1s (GET): the line or the server stopped (twice)
A probe beside a full suite wrote 256 KB pieces into a bytes.Buffer up
to 10 MB, as FetchImage does. Of 262,440 writes, 20 were held over
300 ms: 19 grew the buffer from 8 to 16 MB (up to 1.3 s), and one was a
fresh buffer's first write (2.7 s). A goroutine sleeping 10 ms beside
them woke at most 57 ms late, so the time went into the memory, not
into waiting to run. A second probe touched fresh memory: 16 MB was
held up to 454 ms, 4 MB up to 278 ms, 1 MB and 256 KB at most 1 ms.
Now:
- TestFourKImageByURLIsSaved: the stall is 5 s (was 1 s), and the 4K
image comes in 256 KB pieces 200 ms apart (was 100 ms), about 8 s,
so the download still outlasts the stall that plays #1576's 2-minute
cap. The check that it was the slow one is now "longer than the
stall" (was 3 s).
- TestStalledDownloadSaysWhereTheImageIs: the stall is 1 s (was
300 ms), the stuck server sends 1 MB before it stops (was 3 MB), and
the image that comes in full is the small png the other tests serve
(was the 9.8 MB 4K one, whose buffer the 8.2 MB red was growing).
- TestSlowTransferIsNotCutShort: the backup is 2 MB at 512 KB/s, 64 KB
every 125 ms (was 24 MB at 6.4 MB/s), still about 4 s each way under
the same 1 s watchdog; the largest fresh chunk the read back fills is
then under 1 MB.
What was run (tree 8e4ecb44, on
|
||
|
|
4054251865 |
library: an MCP server can be kept to this computer, never synced
huhuy72219405 on X: "能不能把不同设备的mcp区分一下,有些mcp属于本地的, 同步之后其他设备不应该读取到". A server in Library > MCP now has a "This computer only" switch in its editor (Server.Local; CLI `magpie library mcp add ... --local` and `magpie library mcp local <name> on|off`; the TUI keeps it on edit and marks the row). - Collect leaves local servers out (carriedServers), so neither a sync nor a backup file takes one to another computer. Turning a shared server local takes it out of what is carried, so the other computers drop it at their next sync; the flag itself is never carried. - Put (sync, join, Restore, Undo, backup file) keeps every local server, with its agents, and clears Local on what comes in. - Another computer's server by a local server's name goes to Library.Away: given to no agent, not in the hub, carried on as it came, so a push from here never removes it from the computers that have it. settleAway (every change) promotes it once the name is gone here, and drops it once the name is shared here again. - The hub serves local servers like any other (it runs here); subagents aren't carried, so one naming a local server keeps it. Docs: docs/subsystems/library.md, docs/subsystems/sync-backup.md. Run at |
||
|
|
fe05f0a721 |
library: a skill can be turned off on this computer alone, and a sync neither carries that nor turns it on
hanslin1666 on Discord (#general 1565016936344191096) wanted a library
skill off on one computer only ("只在这台电脑上关掉"). The only way to do
that was to untick its agents, and the ticks are what a sync carries, so
every other computer lost it too. A sync from a computer that had it on
also gave it back here.
Skill.OffHere (library.json "offHere", omitempty) turns a skill off on
this computer. No agent here gets it, whatever Agents says. Every reader
that gives a skill to an agent now asks gives():
- syncSkills, including the shared ~/.agents/skills check;
- desktop_skills.go;
- skill_changed.go;
- skill_edits.go;
- behind;
- Targets.
Agents stays what a sync carries, and the page shows those chips faded.
Collect never carries OffHere, so turning a skill off changes no part a
sync uploads. Put keeps this computer's OffHere for a skill it puts, so
a sync from a computer that has it on (or that gives it to more agents)
leaves it off here.
Where to turn it off:
- GUI: a power button on the skill row (aria-pressed). When off, an
"Off on this computer" tag sits on its own line under the name; it
says why and turns the skill on when clicked.
- CLI: `magpie library skill off-here|on-here <name>`.
- TUI: the row says the skill is off.
The strings are in en, zh, zh-TW, ja and de.
Existing users: nothing changes. An older library.json has no offHere,
so every skill stays on, and a skill that was never turned off writes no
key (TestSkillOffHereOldLibraryIsOn).
Not covered:
- a project's skills;
- a library skill whose own folder is inside ~/.agents/skills, which
agents read in place;
- a skill another computer removes (the flag goes with it).
The skill's files in the library folder still update while it is off.
Docs: docs/subsystems/library.md and sync-backup.md.
Run at the parent
|
||
|
|
5ed6669cec |
sync: the account an agent is kept signed in to stays each computer's own
YsiCing on X: with only the library and usage ticked, the default account of a subscription with several followed the other computer: a personal one at home, a work one at the office, set again every day. The providers part always syncs, and provider.Mirror took the other computer's Provider whole, KeepLogin, KeepLoginAs and SwitchOnly with it. Mirror now keeps this computer's three for a provider it has, and a new one comes without KeepLoginAs (an account signed in over there). davsync's hashes blank the three, so changing which account is kept uploads nothing and two computers that differ only in it don't trade the part. The sign-ins themselves (logins.json) were never synced. A backup Restore is left as it is: it is asked for, and brings the backup's choice. Run on mote at this tree: go test -count=1 ./internal/provider ./internal/davsync ./internal/backup ok; go vet for darwin, linux and windows on both packages ok. Broken by hand: with backup.go and davsync.go reverted, TestMirrorKeepsKeepLogin and TestKeepLoginIsNoChange both fail. Not tried: two real computers syncing through a real WebDAV folder. |
||
|
|
a1e91e5002 |
davsync: S3's If-Match/If-None-Match go outside the signature, so a kept ETag no longer turns a working key into 403 (CyberCaius on Discord)
CyberCaius on Discord: S3 backup works, then every sync fails with
"the S3 server refused the access key ID or secret (HTTP 403
SignatureDoesNotMatch)", and edits to the S3 settings "won't save".
The keys work in other S3 clients, and switching to WebDAV and back
to S3 fixes it until the next time.
Cause: the SigV4 signer signs every header on the request, and
7ab91961d's conditional requests added If-None-Match (GET, the ETag
kept in sync-state.json) and If-Match (PUT). SigV4 needs only host
and x-amz-* signed. A server, or a proxy in front of it, that checks
the signature over a condition as it reads it back rather than as it
arrived refuses a signed one with SignatureDoesNotMatch. The first
sync has no ETag kept, so it passes; from the second on every sync is
conditional and refused. WebDAV and back changes stateKey, so the
state starts again with no ETag and one sync works. "Won't save" is
the same 403: /api/davsync/save writes the settings and then syncs,
and the form stays open with the sync's error.
Fix: sendTo signs every header except if-*, and sets the conditions
after signing. The docs page says so.
Test: TestS3ConditionsOutsideTheSignature, where the fake S3 rereads
an If-* header without its quotes before checking the signature. It
syncs three times, saves a second provider and syncs again, and
checks that the conditional GET and PUT reached the server.
On the old s3.go it fails with the reporter's text:
s3_test.go:612: sync 2: the S3 server refused the access key ID or
secret (HTTP 403 SignatureDoesNotMatch)
Run at this head (base
|
||
|
|
a6efe07cd7 |
davsync: a GitHub backup too large for one request goes up in parts (Zhang-Wei, Discord)
Zhang-Wei (Discord, v0.1.1327) saw every GitHub sync fail with "GitHub sync: HTTP 422: Sorry, your input was too large to process. Consider creating the blob in a local clone of the repository and then pushing it to GitHub." Their exported backup is 50.8 MB; with the library's sync off it works. |
||
|
|
93b87d0004 |
davsync: a GitHub backup too large for the Contents API goes up as a blob (Zhang-Wei, Discord)
Zhang-Wei (Discord, v0.1.1318, 102 skills) saw every sync fail with "GitHub sync: HTTP 422: Sorry, the file is too large to be processed" on magpie/magpie.magpie-backup; the last backup that went up was about 19 MB. The Contents API's PUT refuses files well under the 100 MB a blob can hold. A repository with commits is now written through the Git Data API: the ref's head, the file's version at that head (it must still be the one sync read, or errChanged), a base64 blob, a tree on the head's tree, a commit with the head as its parent, and a ref update without force. Still one commit per write or removal, and the version is the blob SHA as before. A ref update that is not a fast-forward is built again on the new head (the blob is kept), up to three times, then errChanged; if the new head changed the backup it is errChanged at once, so another computer's backup goes through the normal merge. A branch deleted meanwhile is an error, not created. Usage files and their removal take the same path. An empty repository has no head to build on, so its first write still goes through the Contents API (one commit, unchanged). If that is refused as too large (422 "too large" or 413), a short README.md in magpie's folder makes the first commit and the backup follows as the second. Reading was already right for large files: the object media type gives encoding "none" over 1 MB and bytes() downloads by blob SHA; the new test covers it at 21 MB. The fixture now serves the Git Data API (blobs, commits, trees, a fast-forward-only ref update) and refuses a Contents PUT over contentsLimit with GitHub's 422 text. docs/subsystems/sync-backup.md says how writes go and names the new tests. Record for this push: 13 commits on origin/main |
||
|
|
5ca37ef86b |
tray: Settings › Menu bar cost off shows magpie's today and 7-day totals as tokens alone, in the menu bar and its tooltip (BussanQ on Discord)
BussanQ asked for the menu bar's today card with the token count only.
A new Settings › Usage › Menu bar row, "Menu bar cost" (On by default,
segs, every OS, shown with or without cards since the no-card tooltip
says the cost too), saves settings.TrayNoCost. Off, trayMoney drops a
total's cost and its count of unpriced calls before trayTotalCard and
trayIdleTip see it, so the macOS cells and title, and the tooltip on
macOS, Windows and Linux, say the tokens and requests alone. A relay's
or subscription's balance card is money itself and stays. TrayNoCost is
per computer (KeepOwn, beside the other Tray* fields), and a change
redraws the tray (api.go). Translated in zh, zh-TW, ja and de.
Run:
- TestTrayNoCost (internal/gui): broken by hand (trayMoney a no-op) it
fails with label "Σ47M · $128 | Σ6.3M · $3.40+", want tokens alone,
plus the tooltip and idle tooltip.
- TestSync (internal/davsync) now sets TrayNoCost on one computer; with
TrayNoCost left out of KeepOwn it fails "b's menu bar: … TrayNoCost:true".
- tray-cost.test.cjs: Chromium + WebKit, en/zh/zh-TW/ja/de, widths 1100
and 420, Mac/Windows/Linux and no cards: 22/22 pass. With trayNoCost
dropped from the prefs it fails "a save of another setting keeps the
cost off". Also green: i18n-keys, tray-bird, tray-logos, tray-totals,
tray-usages, tray-usage-redraw, quota-pace, tray-inuse.
- gofmt -l clean; go vet ./... and -tags nogui for GOOS=darwin, linux,
windows clean.
- go test ./internal/tune ./internal/gui ./internal/settings ./internal/davsync
green at this head, rebased on origin/main
|
||
|
|
758a4084ee |
sync: LAN sharing stays as each computer has it, so turning it on at home no longer turns it on at work (Lullaby on Discord)
Settings.KeepOwn now keeps LAN (sharing on the local network), AllowIPs (the addresses let in to it) and SessionTerminal (the Mac app a session resumes in) from this computer whenever a sync, a join, a Restore, an Undo or a backup file brings settings in. davsync's hashes blanks the same fields, so flipping sharing is no change to push. A backup restored onto a new computer leaves sharing off there: it opens the gateway to the network, so it is turned on by hand, like the port and proxy. The default sharing key is not per computer. It lives in the gateway-key store, which rides the settings part with LANKey and LANKeyID, so every computer holds the same key, and a second computer turning sharing on takes up that key instead of making another one (configureLAN finds it by LANKeyID or k.LAN). Audit of Settings, what stays synced and why: - already own: Window/WindowMaximised, UIFont/CodeFont, Proxy, Port, Dock/DockWindow, Lightweight, KeepAwake/KeepAwakeDisplay, Tray*, GatewayMode, NoWSLAgents, QuotaReads, NoAccountDiscovery, GatewayConversations. - made own now: LAN, AllowIPs (the address list belongs to the network this computer is on), SessionTerminal (another Mac may not have the app). - not in Settings: launch at login (internal/autostart, the OS's own setting) and the listen address (MAGPIE_ADDR, plus Port). Remote access through Tailscale etc. goes through those. - still synced: CORSOrigins (pages and extensions the user uses, and each still needs a gateway key), OTel, Redact*, update settings (NoAutoUpdate, AutoRestart, UpdateMirror, ChinaMirror), alerts, model and agent choices, Theme/Lang/TextSize. These are the user's preferences, not facts about one machine. Older magpie versions still take LAN from the bundle. Only new clients ignore it. Docs: sync-backup.md gets a "What stays on each computer" section, and gateway-routing.md says AllowIPs is per computer. README and site docs don't list what sync carries, and no GUI string does either, so they are unchanged. Run, on origin/main |
||
|
|
707fbb249d |
backup: a settings.json that can't be read stops a backup, an export and a sync, not carried as the defaults to every other computer (#2269, JasonBuildAI)
Collect read settings with settings.Load, which stands the defaults in for a file that is there but can't be read, or doesn't parse with no good .bak. A sync then pushed those defaults as "changed here", and every other computer brought them in over its own theme, language, text size, allow list and per-model settings; an export carried them too. Collect now reads through settings.LoadChecked and stops with its error, as it does for providers.json ( |
||
|
|
58651568b3 |
agent, sessions, provider: a state file that doesn't parse is kept aside, not written over as empty (#2263, ggbdpq)
applied.json, wsl.json and sessions-wsl.json were read as empty when they didn't parse, and the next save wrote that emptiness over them. What magpie had applied to each agent, the WSL distros and the WSL session listing were lost with no copy. stash.json already kept a bad file aside as .bad-<time>. Each of these now does the same through one helper, lastgood.KeepUnparsed, instead of a copy per file: - It does nothing when the file is missing or empty. - When the file doesn't unmarshal into the reader's own type (lastgood.Into[T]), it copies the file aside (KeepBad). - It stops the write when the copy can't be kept. This also fixes the issue's claim about stash.json. Stash judged a file with json.Valid, so `[]`, which a map reader takes as empty, was written over unkept. Its failed copy was only logged, and the write went ahead anyway. Both are fixed (TestUnreadStashArrayKeptAside), and gateway-hidden.json uses the same helper. Siblings found by going through every single-file JSON reader that takes a bad file as empty and then writes it whole: - stepfun-auth - login-returns - quota-history - balance-history - credits-daily - Claude Desktop tiers - plugin updates - usage's computer id - davsync's sync state Each now keeps a bad copy. Caches that are rebuilt from the vendor are left alone; docs/subsystems/providers-accounts.md lists them. Run: - gofmt -l, go vet (darwin -tags nogui, GOOS=linux -tags nogui, GOOS=windows): clean. - go test -tags nogui -p 4 -timeout 40m ./... with the other three commits of this push: see the last one's body. Broken by hand: on the code before this, these fail: - the issue's applied_keep_test.go and wsl_keep_test.go - TestUnreadStashArrayKeptAside - TestUnreadStateKeptAside (10 subtests) - the gateway, usage, davsync and plugin _keep tests TestKeepUnparsed and TestKeepUnparsedFailsWhenItCantBeKept cover the helper. I dropped a test, "not written when it can't be kept", for stash. It passed on the old code too, because a read-only folder also stops the atomic write. Not tried: a real WSL distro. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
e413512d8e |
library: an agent whose CLI is gone (only its config folder left) is no Library write target, and nothing it already has is removed (#2254, ggbdpq)
After an agent is uninstalled, the Agents page shows "CLI not found"
(
|
||
|
|
3a7d0314a9 |
usage: a window's Pace as a number on its card, and in the menu bar when asked (fflake33)
fflake33 on Discord asked for the pace as a figure, "+12%" or "−8%"
against an even pace through the window, on the Usage cards and in the
menu bar.
- provider: QuotaWindow.Pace(readAt, now) is the share used (0-100) less
the share of the window gone by, from Bounds (reset less span; a
month's window a calendar month); none for an unlimited window, one
whose span or reset isn't known, or outside it. WithWindowStarts sets
startsAt on copies of the cards for the GUI (the caches' cards are
left alone); /api/usage/quotas and its refresh send it.
- Usage page: "Pace +20%" on the reset line after the wait (quotaPace,
paceLine), its sign turned with the meter in Left mode, amber while
more is used than an even pace would have, what it means in its
tooltip. Past cycles and windows with no known start show none.
- Menu bar: Settings > Menu bar pace (settings.TrayPace, off by default;
hidden on Windows, whose tray shows no text) puts " +12%" beside each
figure ("42% −14%", at most 10 runes, trayRowMax) and "pace −14%" in
the tooltip. KeepOwn keeps it device-local like the other tray
settings; the Settings save keeps it (prefsKeep).
- Strings in en, zh, zh-TW, ja, de. gui-shell.md says it.
Run:
- go test -tags nogui ./internal/provider ./internal/gui ./internal/settings
./internal/usage: ok; ./internal/davsync: ok (now covers TrayPace;
red with TrayPace taken out of KeepOwn). go test ./internal/gui -run
Tray (darwin, with the tray image tests): ok.
- New TestWindowPace, TestWithWindowStarts (input not mutated),
TestTrayUsagePace (off unchanged, used and left, rows, tooltip).
- quota-pace.test.cjs, chromium and webkit: 4 pass; cards in en, zh,
zh-TW, ja, de at 1100 and 420px, used and left, amber, tooltips, no
sideways scroll, a click moves nothing; the Settings row in all five
at both widths, On posts trayPace, a currency save keeps it, no
scroll; hidden with no card and on Windows, shown on Linux. Red with
paceLine not called, with trayPace out of prefsKeep, and with the
Left-mode sign not turned.
- gui-de, gui-ja, gui-zh-tw, i18n-keys: 12 pass; tray-bird 6, quota-holds
2, quota-read-at 4 pass.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
Not tried: the real menu bar on a Mac or Linux tray.
|
||
|
|
eb22f6355a |
davsync: a computer joining a sync folder keeps the gateway keys the folder's store has never seen (#1737, #1714, ggbdpq)
The gateway-key store rides the settings part, and a first sync brings a part changed only on the server in whole. So a computer with its own gateway keys that joined a folder another computer had set up first had every key replaced by the folder's store (8ugMak1r on #1714 got them back only from the -this-computer copy in the sync folder). On the first sync, before the settings are brought in, the keys this computer holds that the store has neither by id nor by value are added to the store brought in; that merged store is restored here and pushed for the others. A key the folder holds wins; the LAN default key follows the folder's settings as before. After the join a key missing from a store this computer has seen is a removal, as before. ggbdpq's patch (a9605c8a), cherry-picked unchanged. Run (reviewer): TestGatewayKeysJoinKeepsUnseenKeys fails on the old davsync.go (the joining computer's keys are gone, the pushed store holds only the folder's default key, computer B never gets A's key) and passes with it, -race -count=3; TestGatewayKeysJoinWithoutStoreKeepsKeys passes on both. go test ./internal/davsync/... ok. Not tried against a real WebDAV server. |
||
|
|
b8e23db45a |
backup, davsync: an import or a sync installs the plugins and names the subscriptions to sign in to (yapechan)
yapechan on Discord (Windows, Synology WebDAV): after an import or a WebDAV
sync no providers showed on the other computer; adding the same provider by
hand made the synced settings and usage apply. No error, a restart didn't
help.
Cause. A backup and a sync carry providers.json as stored. For a
subscription that is its model picks and settings alone (no endpoint, no
key), and sign-ins are never carried by design; allProviders lists such an
entry only once an account is signed in here. plugins.json was not carried
at all, so a provider served by a plugin (every moved subscription, any
plugin provider) had nothing to come from on the other side. The import
said "N added" and "Needs a key: , " (the picks entries have no name and no
key), and the sync said nothing. API-key providers do come over: tried with
a nogui build in two sandbox HOMEs (DeepSeek, a custom relay, Kimi Code all
listed after `magpie restore`). No Windows-only path issue found.
What changed:
- provider.Carried(keys): the plugins added from npm or git, on/off and
their options (without keys, options whose names look like a key are left
out, as secret headers are). Folder plugins and plugin-auth.json stay.
- backup.Bundle.Plugins (nil from an older magpie). Restore installs the
ones not here through provider.AddPlugins (plugin.Add, then Off and
Options, then HandOver once); it never removes or changes one already
here. A failed install is reported, not a failed restore.
- Result.SignIn / provider.NotSignedIn: the subscriptions brought with no
account here. NeedKey no longer lists picks-only entries (provider.OnlyPicks).
- davsync: the providers part's hash covers the plugins (unchanged for a
setup without any), take/bring carry them, bring installs (logged on
failure), and Status().SignIn names what to sign in to.
- CLI restore and `magpie webdav`/`s3` status print both; the GUI's import
result and the sync row show them (en, zh, zh-TW, ja, de).
- docs/reference.md says what a backup carries now.
Run:
- go test -tags nogui ./internal/provider ./internal/backup ./internal/davsync
./internal/cli ./internal/gui in a sandbox HOME.
- New tests fail with the change broken by hand: TestPluginsCarried
(installed-skip and the HandOver guard), TestNotSignedIn,
TestRestorePluginsAndSignIn ("Needs a key: [ Acme]" without OnlyPicks),
TestSyncPluginsAndSignIn (bring not installing, Status not naming),
sync-sign-in.test.cjs (the lines removed).
- sync-sign-in.test.cjs: Chromium and WebKit, en/zh/ja/de, 900 and 440px,
16/16; it also caught subNames throwing while providers was still null.
sync-*.test.cjs, s3-sync, i18n-keys, gui-ja, gui-de pass.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui on the
touched packages.
Not tried: a real plugin install from a real sync (the installs are stubbed
in tests); a real Synology server.
|
||
|
|
f82aba090b |
davsync, gui, cli: GitHub sync refuses a repository that isn't private (#1130)
The sealed setup is committed on every sync, so a public repository would hand anyone every version of it, the whole history, to try passphrases on offline. prepare now reads the repository's "private" field and refuses before writing when it is false or missing, naming the repository and what to do. The form's hint, the CLI usage and docs/reference.md say the repository must be private; sync-backup.md lists the rule and its verification command now points at ./internal/cli. Run: go test -tags nogui ./internal/davsync/ and the cli tests (TestGitHubCmd|TestWebdavCmd|TestS3Cmd|Help) green; TestGitHubPublicRepositoryRefused goes red with the check removed. GUI: github-sync, s3-sync, webdav-settings-refresh, sync-other-kind, sync-not-backup, i18n-keys, gui-zh-tw, gui-ja, gui-de in Chromium and WebKit, 72/72. Not tried against the real GitHub API. |
||
|
|
cdfe7629a5 |
davsync: GitHub sync's "not a magpie backup" advice names the file where it is, not under magpie/magpie/ (#1130)
fileWhere passed folder+"/"+file to g.at, which already puts the file under the configured folder and magpie/, so the recovery advice told the user to look at <folder>/magpie/magpie/sync.json, a file that isn't there. It now passes the file alone. Run: go test -tags nogui ./internal/davsync/ (green). TestGitHubNotBackup's new assertion goes red with the old path put back. |
||
|
|
1af326806f |
sync: magpie's setup syncs to an encrypted file in a GitHub repository, beside WebDAV and S3 (#1130)
A third sync kind: github://owner/repo[/folder] keeps the same sealed backup WebDAV and S3 keep, as <folder>/magpie/magpie.magpie-backup in a repository the user already has, written through GitHub's Contents API with a fine-grained token of its own (Contents read and write), kept in sync.json apart from the library's GitHub token. The token goes only to api.github.com: a redirect anywhere else is refused, and the passphrase may not equal it. Each update is a commit; an empty repository is initialised by the first backup. Settings › Sync gets a GitHub kind with Repository, Branch, Folder and token; magpie github mirrors magpie s3. Inactive servers of every kind are kept in Config.Servers (Other stays for older clients). Squashed from yetone/magpie#1130 at 6b5b1c693e1a3a23e177b4d376f3f7f70f3bc23d onto main. Merge resolutions: the CLI moved to internal/cli since the PR was cut, so github_cli_test.go moved there (package cli) and the github command, its help line and `magpie help github` were wired in internal/cli/main.go and help_cli.go; README's Sync row kept main's links and took the PR's wording; i18n.js zh-TW kept both sides. |
||
|
|
8792ee063d |
provider: a Volcengine or Tencent access key is kept through sync, restore, a stale editor and a copy, and a plan card without one says what to give (#1821, Edward4226)
The reporter's Volcengine Agent Plan card vanished: providers.json had
lost accessKeyID/secretAccessKey, and volcPlanQuotas skipped a provider
without them before building any card, so nothing said why.
Writers that dropped the access key, fixed at the cause:
- Sync and restore (Mirror, Restore, davsync take) kept this machine's
access key and balance token only when the incoming provider had no
key at all. A magpie before v0.1.1142 (
|
||
|
|
0d58ec8dcb |
davsync: a write a server without conditional PUTs let another go over is merged again at the next sync (#1776)
On an S3 server that refuses If-Match (Aliyun OSS answers 400 NotImplemented), put falls back to HEAD then an unconditional PUT. Two computers writing in the moment between both pass the HEAD, both are told they wrote, and the later file is kept. Worse, the loser's next sync then took the winner's file as having seen its own: its st.Remote was the file it wrote, so its changed parts looked unchanged here and changed there, and the old parts were brought in over its own changes. The edit was lost on the server and on the computer that made it. - version.Blind marks a write the server didn't check (s3.go's fallback). - state.Blind keeps, for such a write, the file's sum and the remote and local part hashes from before it. The next sync that reads another file than that one merges from before the write. What this computer changed counts as changed again and goes back up beside the other's. A 304 or the same file clears it. Restore and Upload clear it. - docs/reference.md says what happens on such a server. No compare-and-swap exists on OSS, so the race itself isn't closed: the other computer's file is kept for up to one sync interval (3 minutes) before this computer's change is merged back. The reporter's AppendObject journal would close it but needs every computer upgraded and OSS-only signing. If the other computer saw this one's write and then changed the same part again, the next sync can't tell that from a write that went over it. It counts the part as changed on both sides: the newer stays, the other is saved, and a notice says so. Nothing is lost. Run: - TestS3BlindWriteGoneOverIsMergedAgain (fake S3 with no conditional writes, two computers): A renames a provider and B sets the theme, B's PUT goes over A's, then A's next sync puts both on the server with no conflict notice, B brings in the rename, and nothing more is written. With the reset taken out (broken by hand), it fails: "A's rename here after its next sync: \"DeepSeek\"". - go test ./internal/davsync whole. Not tried against real Aliyun OSS: the fake answers conditional PUTs the way the reporter quotes OSS (NotImplemented). |
||
|
|
206dc085be |
provider: a magpie run from a terminal that only lists accounts no longer writes logins.json, and every change to it is made under a lock the gateway holds too, so a token the gateway just refreshed is never written back over (#1674, FaintGhost)
Every CLI command that reached Logins() (magpie ls, providers, sessions,
usage) ran rememberLogins, whose 30-second throttle (loginsSeenAt) lives
in the process, so in a new process it never held: each run moved Seen on
for the signed-in Codex and Claude accounts and wrote logins.json back.
loginsMu was an in-process mutex, so that read-modify-write could
interleave with the gateway's renewSavedLogin: the CLI reads, the gateway
writes a refreshed sign-in, the CLI writes what it read. Codex/OpenAI
refresh tokens are single use, so the account would be signed out.
- rememberLogins writes nothing when the only change is Seen and the saved
Seen is less than seenEvery (10 minutes) old (onlySeenMoved, comparing
with what was read, IDs and order normalised as writeLogins writes them;
sortLogins is split out of writeLogins for that).
- internal/filelock (new): davsync's TryLock/Unlock (flock; LockFileEx on
Windows) moved here and davsync uses it; Lock(path, wait) and
filelock.Mutex, a sync.Mutex that also holds the OS lock on a lock file.
A lock another magpie holds is waited for up to filelock.Wait (10s),
then gone on without, as before, so a stuck magpie never hangs others.
- loginsMu is a filelock.Mutex on logins.json.lock, so all 107 existing
Lock sites (every writeLogins is under one) are cross-process with no
change at the call sites. Taking it calls filememo.Look (new), so the
read under it isn't a parse filememo.Hold kept from before another
magpie's write. savedTokenMu holds logins.json.renew.lock the same way:
two magpies never refresh one saved account at once.
- Siblings: caller-keys.json (access.mu: magpie keys from the CLI vs the
window; a lost revoke would bring a key back) and mcp-signins.json
(mcpauth.fileMu, plus mcp-signins.json.renew.lock around renew, since
library's MCP check renews from the CLI too) get the same lock.
plugin-auth.json already has one (plugin-auth.json.lock, shared with
host.js). Not covered: providers.json (33 store sites with no
in-process lock either; user-entered keys, nothing refreshed there),
migrations.json/settings.json (no credentials), and the agents' own
files (~/.codex/auth.json etc.: the agent itself writes them without
any lock of ours, so a magpie-only lock can't make them safe).
Tests:
- TestReadOnlyRunLeavesLogins: Codex and Claude signed in, Seen a minute
old, file time set back; three "new processes" of Logins("")/codex/
claude/All() leave logins.json's bytes and mtime as they were. Seen an
hour old is written; Codex's own refresh is written at once.
- TestLoginsKeepAnotherMagpiesWrite: between this process's read and write
(beforeLoginsWrite hook) a second test process (TestLoginsOtherMagpie,
os.Args[0] -test.run) renews the saved work@ account's refresh token;
both the renewed token and this process's change are in the file.
- TestLoginsReadAfreshUnderLock: with filememo.Hold held, a write
filememo never heard of is seen by a read under loginsMu.
- TestLockAcrossProcesses (filelock): a holder subprocess makes Lock wait
and give up after its wait; killed, the lock is free; a Mutex holds it.
Broken by hand: onlySeenMoved bypassed -> TestReadOnlyRunLeavesLogins
FAIL "a run that only listed the accounts wrote logins.json"; the file
lock taken out of filelock.Mutex.Lock -> TestLoginsKeepAnotherMagpiesWrite
FAIL "the other magpie's renewed sign-in was written over"; Locked hook
emptied -> TestLoginsReadAfreshUnderLock FAIL. Each restored, green.
Ran: gofmt -l (nothing); go vet ./..., GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./...; go build, GOOS=linux go build -tags
nogui, GOOS=windows go build; go test -tags nogui -count=1 ./... under a
temp HOME with pinned caches: all ok but internal/provider, whose
TestReadOnlyRunLeavesLogins failed at that point from its own fixture
(two rewrites of one size given the same mtime read as unchanged by
filememo); fixed in the test, then internal/provider, access, mcpauth,
filememo, filelock and davsync -count=1 all ok, and the three new provider
tests -race -count=10 ok.
Not tried: the reporter's Linux arm64 box with a real systemd gateway and
real Codex accounts; Windows (LockFileEx path) only vetted and built, not
run on the Windows box.
|
||
|
|
aa82288fb6 |
usage: Volcengine Ark's Coding Plan and Agent Plan windows, read with the account's access key (#1427, yayoinoyume)
Ark tells a Coding Plan's or Agent Plan's 5-hour, weekly and monthly
windows only to the account's control plane (GetCodingPlanUsage,
GetAFPUsage on open.volcengineapi.com), signed with the account's
AccessKey ID and Secret, never to the plan's inference key. An Ark
provider's editor now takes that access key, and the Usage page shows the
plan's windows as a card.
From yayoinoyume's feat/volcengine-usage, reviewed and reworked:
- Signing is volc-sdk-golang's (base/sign.go GetSignRequest, 06f9ef66):
signed headers sorted (content-type;host;x-content-sha256;x-date), only
Action and Version in the query. The branch signed them unsorted and put
Region in the query. TestVolcSignMatchesSDK pins two signatures the SDK
made.
- The card is in PlanQuotas beside the Step Plan's (its cache, last
reading, refresh and `magpie quota wait`), not in the subscription
cards. One per access key and plan.
- The plan is the endpoint's: /api/coding asks GetCodingPlanUsage,
/api/plan GetAFPUsage, pay-as-you-go none, in the host's region. The
branch asked both and showed whichever answered.
- Dropped guessed reply fields; the Coding Plan reply is the one
pi-ark-usage, dsh-ark-quota and ArkCodingPlanUsage read. AFP buckets are
read in the forms dsh-ark-quota and arkcli read (Used of Quota or Total,
or Percent), plus Tier; none was seen from a real account.
- An Ark provider is known by its host, not the preset id, so a copy or a
custom provider takes the key too.
- The Secret is never sent to the page (accessKey {id, secretSet}); a
blank Secret keeps it, a save without the ID keeps both, Remove
(clearAccessKey) drops both, an ID with no Secret is refused.
- The pair goes where keys go: AddCopy, Restore, Mirror, backups and
davsync carry it only with keys (withoutKeys), and a keyless restore or
sync keeps this machine's. CLI: access.key, access.secret.
- A changed access key drops the cached cards (ForgetPlanQuotas).
- UI strings in zh, zh-TW, ja and de.
Nothing was tried against the real Volcengine API: there was no access
key. A local fake checked the real request PlanQuotas makes against
volc-sdk-golang's own GetSignRequest (both actions, two regions); it
lives outside the repo, so go.mod is unchanged.
Run: gofmt -l; go vet (darwin), GOOS=linux and GOOS=windows go vet
-tags nogui on provider, gui, backup, davsync and the root; go test
-tags nogui ./internal/provider ./internal/gui ./internal/backup
./internal/davsync . under a temp HOME; node --test
volc-access-key, zhipu-team, gui-ja, gui-de, i18n-keys in Chromium and
WebKit. Fail without the change: TestVolcSignMatchesSDK (unsorted
headers), TestAddCopy, TestBackupBalanceToken, TestNoKeys,
TestTakeBalanceToken, TestSyncBalanceToken (pair not carried),
TestProviderSaveKeepsVolcengineSecret (blank Secret dropped),
volc-access-key (Remove not posted).
Co-authored-by: YAYOI27 <111715843+yayoinoyume@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
be2037285a |
davsync, gui: a server file that isn't a backup is said as what it is, and can be replaced by this computer's setup (JasonLeeForOnly on Discord)
JasonLeeForOnly's WebDAV sync failed with only "not a magpie backup" for
several versions, and nothing on the page got past it. A WebDAV GET of the
backup can come back as a body that isn't the file in several ways; each is
now reproduced with an httptest server that answers the way the real one
does:
Unpacked (WebDAV and S3): gzip with or without Content-Encoding (a proxy
that drops the header), x-gzip, zstd with or without the header, deflate
(zlib or raw), and a header that says gzip over a plain body. Bodies are
told by magic number; a backup is JSON, so either magic is never the file.
Brotli (br) can't be unpacked and is said as itself, with what to turn off.
Said, with no upload offered: an HTML page answered with 200 (Nextcloud
login after a redirect, Cloudflare Access, an AList/OpenList web app, an
rclone directory listing, a captive portal), with its <title> and the
host/path a redirect ended at (query, fragment and user dropped), and
where the WebDAV address is for 坚果云 and Nextcloud; an XML answer, by its
root element.
Said, with Upload as the way out: an empty (0-byte) file, a backup cut
short or damaged (the automatic rebuild is unchanged and still goes first
when its rules allow), another app's file ("format": "…"), other JSON,
and any other file by its content type. Messages carry the size, kind and a
page title only, never the file's contents.
backup.Open now tells ErrNotBackup (doesn't begin like a backup) from
ErrCorrupt (begins like one, cut short). The status carries the kind as
serverFile; Settings › Sync and backup says it in the reader's language,
wraps it whole, and shows "Upload this computer's setup" only when the file
may be replaced. davsync.Upload (POST /api/davsync/upload, `magpie webdav
upload`, `magpie s3 upload`) asks first in the GUI, re-reads the file,
refuses a backup this computer opens, one sealed with another passphrase,
a newer magpie's, a page and an XML answer, keeps the server's copy in the
sync folder (0600, newest 5) and writes nothing if that fails, then writes
with If-Match on the version read. New strings in en, zh, zh-TW, ja, de.
Verified: internal/davsync/not_backup_test.go (TestReadCompressedBackup,
TestReadBrotliSaid, TestServerAnswerSaid, TestCutBackupSaidAndUploaded,
TestS3ReadCompressedObject; Upload-only parts stripped to compile) fails
on
|
||
|
|
b37a082c48 |
davsync: WebDAV sync reads the backup uncompressed, so its ETag matches the write after it (#1362, laiquziru: TeraCloud synced once, then every sync said "the file on the server changed meanwhile")
What: dav.get sends Accept-Encoding: identity, and unpacks a body a server gzips anyway (Go only unpacks what it asked gzip for itself). Why: Go's client asks for gzip on every GET. InfiniCLOUD's (TeraCloud's) WebDAV is Apache mod_dav_fs, whose PUT answers with no ETag (mod_dav.c's dav_created: "### insert an ETag header?"), so the sync after the first reads the file in full and pushes over the ETag that read gave. Apache's mod_deflate (DeflateAlterETag AddSuffix, the default) gives the gzip copy "<etag>-gzip", which no If-Match on the file matches: every write after the first was 412, the retry read the same -gzip tag, and the state left the local change pending, so every sync after failed. A read asked for as it is gets the file's own ETag. nginx-style proxies that weaken the ETag (W/"...") on gzip are covered by the same change. TeraCloud behaviour assumed: seen without an account on 2026-10-09 against https://domi.teracloud.jp: OPTIONS /dav/ says Server: Apache and DAV: <http://apache.org/dav/propset/fs/1>; GET / with Accept-Encoding: gzip gives ETag "fb-5d88268abcf08-gzip" + Content-Encoding: gzip, without it "fb-5d88268abcf08"; GET with If-Match the -gzip tag is 412, with the plain tag 200. Not seen: that mod_deflate compresses files under /dav/ (needs an account). The fake (apacheDAV in teracloud_test.go) does: no ETag on PUT, gzip + "-gzip" ETag on a GET that accepts gzip, If-Match strong against the file's own ETag. Real conflict detection is unchanged: If-Match is still sent with the version read; TestSyncTeraCloudStillSeesOtherWrites lands another computer's write between a's read and write on the same fake and checks the 412, the merge over it, and b's file kept aside. Run: - new tests fail on the old code: without identity, TestSyncTeraCloudGzipETag "sync 2 after the first: the file on the server changed meanwhile (2 writes refused, 2 reads sent gzip)"; with If-Match dropped, TestSyncTeraCloudStillSeesOtherWrites "write over a replaced version: <nil>, want errChanged"; without the unpack, TestDAVGetGzipAnyway reads gzip bytes. All pass restored. - sandbox HOME, pinned caches: go test -race -tags nogui ./internal/davsync/ ./internal/gui/ . ok; -race -count=5 on the davsync sync/conditional/ short-write/Nutstore tests ok - gofmt -l clean; go vet (darwin, darwin nogui, linux nogui, windows) of internal/davsync; go build darwin, linux nogui, windows Not run: a real TeraCloud account. |
||
|
|
10f7b4aa3f |
davsync, gui: a WebDAV server whose HEAD says Content-Length: 0 no longer fails every shared usage day as "kept 0 of 6869 bytes", and a usage share that failed is its own red line under the sync status (#1259, mzcinf on 坚果云)
After each PUT, check read the file's size from a HEAD and called anything
shorter a cut write. On 坚果云 every usage write failed that way with 0
bytes kept, three tries each; the 0 can only have come from the HEAD's
Content-Length, since a 6869-byte body that the PUT sends with its
Content-Length (not chunked) isn't cut by a dropping network three times
running. A HEAD that says short is now asked again of PROPFIND (Depth 0)
getcontentlength, the size WebDAV clients of 坚果云 read. The write counts
as kept when that size is whole. When PROPFIND gives no size, the HEAD's
stands. A real cut write is still told as cut, with the bytes PROPFIND
says were kept. The extra request is made only after a short HEAD, so
坚果云's request limit isn't spent on servers whose HEAD is right. The
backup's own PUT goes through the same check, so a 坚果云 user whose
setup changes would have hit the same error on the main sync.
Settings > Sync put "Couldn't share usage: …" in the same grey line as
"Synced · host", so it read as part of a sync that went fine. It is now a
line of its own under the status, in red, wrapped whole at 440px. The CLI
already printed it on its own line.
Verified: TestNutstoreHeadSaysNoLength and TestNutstoreBackupWrite use a
fake 坚果云: HEAD Content-Length: 0, real getcontentlength on PROPFIND,
409 for a read in a missing folder, a chunked PUT refused. Whole writes
sync with no usage error, and each write goes once with one HEAD and one
PROPFIND. A tunnel that keeps half is still told as cut, with the half it kept.
On the old dav.go all three fail ("the WebDAV server kept 0 of 536 bytes
of magpie.magpie-backup", "kept 0 of 6869"). TestDAVShortWrite and
TestUsageSharedShortWrite/TestUsageSyncShortWrite pass unchanged.
sync-usage-error.test.cjs runs in Chromium and WebKit, en/zh/ja/de, at
900 and 440px, and fails on the old app.js ("the status line carries no
usage error: 14:46 已同步 · dav.jianguoyun.com · 用量未能共享:…"). The
sync-*, s3-sync, usage-computers, gui-ja, gui-de, gui-zh-tw, i18n-keys
and click-scroll tests pass, 78/78. go test -tags nogui -count=1
./internal/davsync ./internal/gui pass under a temp HOME. go vet passes
on darwin, GOOS=linux and GOOS=windows. Not tried against a real 坚果云
account: that its HEAD answers 0 is inferred from the error, and that its
PROPFIND gives the real size is how its other WebDAV clients read sizes,
neither seen here.
|
||
|
|
be1ce5d4d2 |
davsync: incomplete S3 listings keep cached usage days (#1243)
Reject truncated listings with missing or repeated tokens and listings that exceed the page limit. On the old code the regression reports successful partial listings and shareWith removes a cached day. Focused tests pass in a temporary HOME. |
||
|
|
30a8ce2915 |
davsync tests: TestSlowTransferIsNotCutShort's watchdog is a second, not 300 ms, over ~24 MB each way
A line that never stops is all this test sends, so a 300 ms watchdog only
catches the runner itself pausing: red on macOS in run 37693090857 at
7.99s, near the end of the GET, where a full run takes 7.23s and 8 runs
under 3x CPU oversubscription here all passed. The server's 40 ms gap is
still 25x inside the watchdog, the PUT's tail is still twice it, and with
allSent's extension taken out the test still fails ("took nothing for 1s
(PUT)").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|