DisconnectPreview builds its dry-run sandbox with os.MkdirTemp and
cleans it with a bare `defer os.RemoveAll(tmp)` (internal/agent/preview.go).
Two consequences reported by OldSuns: when the removal fails (on Windows
the dry run's bun host still holds magpie-bun.exe after cmd.Run returns)
the error is dropped and the sandbox - each with an 86 MB bun re-downloaded
into it - stays in the temporary directory for good; 12 dirs / 985 MB in
the report, 99 dirs in ggggggggggz's. And nothing ever reclaims sandboxes
left by a killed magpie, unlike the cursor snapshots, whose
sweepCursorSnaps removes stale magpie-cursor-* copies.
The change: DisconnectPreview sweeps magpie-preview-* folders older than
an hour (a live preview lasts seconds; the dry run is bounded at 20 s)
before creating its own, the way the cursor snapshots do; cleanup goes
through removePreview, which retries while processes are still letting go
of files (5 tries, 0.1 s-0.5 s apart) and logs the error instead of
dropping it when it still cannot remove the folder. Only the reported
prefix is swept; the other magpie-* temp prefixes have their own
lifecycles (#2321, cursor_snapshot.go).
Each sandbox also holds a copy of magpie's config folder's files
(logins.json, providers.json and the rest, copyTop), so a sandbox the
removal left behind kept the user's sign-ins in the temporary folder for
good. The sweep takes those too.
Reported by OldSuns, ggggggggggz and track23; the fix is skygunner's
branch fix/3136-agent-magpie-preview-86-mb (98e5e7bc7), ported as it is
apart from the test: it now sweeps a temp dir of its own (TMPDIR, TMP and
TEMP set to t.TempDir()) instead of the machine's, where it could take
another magpie's stale sandboxes.
What was run (on the ported tree):
- TestDisconnectPreviewSweepsStaleSandboxes with sweepPreviews() taken
out by hand: red ("a stale sandbox is still there after a preview").
- go vet ./internal/agent/ for linux, windows and darwin: ok.
- go test ./internal/agent/ on mote: ok 170.4s.
- Windows (xiaomi-gpu, win-run): go test -run
'TestDisconnectPreview|TestRemovePreview|TestPreview' ./internal/agent/:
ok 7.8s.
- On mote, the built binary's agent-disconnect-dry-run for opencode,
claude and codex under an empty sandbox HOME, then with a plugins.json
naming an OpenCode plugin: nothing downloaded, the sandbox stayed at
8-12K.
Not reproduced: the 86 MB bun and the pnpm install inside a sandbox. The
reports are from v0.1.1223; on main the dry run started no plugin host in
the cases above, so nothing here changes where bun comes from. The
sandboxes it left are what this removes.
Refs #3136
* refactor(agent): connect Aside as a native provider with verified settings
* fix(agent): offer explicit offline Aside model and disconnect actions
Offer Save for next start after an initial runtime read failure, using a
structured API error instead of saved runtime state. Keep refusals and
failed readbacks on the live error path.
Add a separate offline disconnect confirmation that restores the checked
file plan, clears restore records and removes the provider last. Bind the
confirmation to its preview revision and roll back ordinary write failures.
Cover offline API and browser flows, cancellation, stale plans, missing
CLI, restore metadata and native provider spelling. Keep state file-only.
Check for a key/value match before indexing its value boundary. Compact
JSON arrays and TOML table headers can contain secret-related words
without matching that pattern.
Cover both cases in TestMask.
- The opened row follows the boards: what to do in the agent, running copies with the old list, Claude Code's tiers (each with its own effort beside its model again, #536), the model list by whose models they are with what's hidden, the model new sessions start on, what connecting costs (Gemini's Google sign-in), and the files put back on disconnect, shown line by line.
- Disconnecting asks first and shows the lines it puts back. Secrets are masked, and a config of tens of thousands of lines diffs in a fraction of a second.
- Connecting prefers the agent's own subscription when magpie serves it (Claude, Codex).
- The dry run goes through proc.
- Every model hidden still keeps the row connected, with the way back to the list (#356).
- Routing groups are named in Chinese.
- Phone widths: the pickers and squares wrap inside the opened row, and the name stays beside its logo.
GUI tests moved to the new rows: connected fixtures carry refs and open the row from its link. tier-effort and mobile-web each found a real gap and now guard the fix.
Tried in a sandbox HOME with the owner's real accounts:
- Claude Code: connected, a request answered, and disconnect restored the settings exactly.
- OpenCode: a request answered.
- Gemini CLI: connected.
- Codex: connected.
- Model list picks were saved.
go vet, builds (darwin, GOOS=windows, GOOS=linux -tags nogui) and go test -tags nogui ./... under a temp HOME pass. The agent GUI tests pass except cli-update's tight-row case, menu-scroll and old-webkit, which fail on main too.