Purfeather found that disconnecting MiniMax Design (an agent a plugin adds)
showed the dialog's generic sentence: /api/agents/.../disconnect-preview
returned changes: []. The preview runs Disconnect in a process whose HOME
(and APPDATA, LOCALAPPDATA, XDG_*) is a temporary copy, but a plugin agent's
stash key is "plugin:<id>:" + the file's whole path, so the copied
stash.json named the file under the real home. The dry run found no stash,
read the agent as not on magpie, and changed nothing.
The same holds for every built-in whose stash key carries its file's path
(Droid, AtomCode, Cline, Qwen, Kimi, Zed, Hermes, Muse, Snow, ...): their
previews found the file wired but not what to put back, and showed magpie's
lines taken out instead of the user's model going back.
The fix is in one place, DisconnectPreview: after copying magpie's files it
rewrites the copy's stash so each key naming a path under home names it
under the copy's home (moveStashKeys/movedKey; a separator must follow
home, and Windows compares without case, since %APPDATA% can spell the
home folder otherwise). The real stash, its key format and the real
connect/disconnect are unchanged, so stashes users already have keep
working and nothing is migrated. A stash that is missing or doesn't parse
is left as it is.
Run at this head (30a0bfe88 + this commit; origin/main had not moved):
- mote: go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
go vet ./...: clean. gofmt -l: nothing.
- mote: go test -tags nogui -timeout 45m ./...: 87 packages ok, exit 0
(internal/agent 381s).
- xiaomi-gpu (Windows): go test -tags nogui -run
'TestDisconnectPreview|TestMovedKey' ./internal/agent: ok, the four new
tests PASS (the case-insensitive branch runs there only).
- mote GUI files that show the preview (agent-changes-before-now,
agent-disconnect-preview, agent-leave-magpie, agent-own-direct,
aside-native, mask-actions): Chromium 60/60, WebKit 34/34.
Broken by hand: with the key rewrite skipped, TestDisconnectPreviewOfAPluginAgent
fails with "the preview doesn't take magpie's entry out: []" (the
reporter's exact empty list), TestDisconnectPreviewOfAPluginAgentsModel
and TestDisconnectPreviewOfDroidPutsItsModelBack fail with no "~" line
putting the user's model back. Restored: all pass.
Not tried: a real MiniMax Design on Windows, or the GUI dialog against a
real magpie; the tests run the real preview path (this test binary as the
dry run's process) with the plugin's agent module as plugins#799 has it.
Paths stored in stash values (not keys) are not rewritten; none of the
values read in a disconnect hold a whole path.
Reported-by: Purfeather