faketrader runs VS Code portable on a Mac: /usr/local/bin/code links into
/Applications/Code/Visual Studio Code.app, and the build reads
/Applications/Code/code-portable-data/user-data/User. magpie detected it
but wrote ~/Library/Application Support/Code/User, which that build never
reads. Their patch on #4151 is the base; this takes its rule and makes it
VS Code's own (configurePortable in src/bootstrap-node.ts), on every OS:
- A build is portable when its product.json has no `target` (an
installer's build has one) and its data folder exists: on a Mac
product.json's `portable`, else `<applicationName>-portable-data`,
beside the .app; on Windows and Linux `data` beside the install, also
for a build that updates into `<install>/<version>/resources/app`.
- The build is the one the launcher on PATH is, through a Scoop shim and
every symlink. A launcher whose product.json names another editor (a
fork's `code`) isn't the build's. With no launcher of its own, a Mac
reads the app folders and Spotlight and takes a portable bundle only
when every bundle found is that one; beside an installed bundle, which
one runs is unknown and nothing moves.
- VS Code, Insiders and VSCodium each go by their own bundle and launcher.
- User and extensions come from one place (vscodeDirs): connect, Sync,
profiles and Disconnect use the portable User folder, and Zoo Code is
found by its extension in <data>/extensions and writes its import file
there. Windows' Zoo Code under Scoop looked in ~/.vscode/extensions.
- Disconnect's preview is refused for a file in a portable data folder:
the preview's child keeps PATH, and its launcher would reach the build's
real files, not the copy. That also covers Scoop under home on Windows,
which main previewed.
- An installed build with no portable folder keeps the OS's folder and
~/.vscode/extensions, unchanged.
#3260 and #4009 (Windows): 509d8e7d1 (ggbdpq) already moved Scoop's
`current\data`; this adds the target check, the versioned layout, the
Windows Zoo Code folder and the preview refusal above.
Tests (fixtures under t.TempDir, never /Applications or ~/Library; app
folders and Spotlight stubbed): TestVSCodeMacPortableDirs (stable,
Insiders, product's `portable`, no data folder, Windows' `data` name,
another editor, another channel's folder, unreadable product, installer
target), TestVSCodeMacPortableLinkChain (three links, folders with
spaces), TestVSCodeMacPortableWiring, TestVSCodeMacPortableWithoutLauncher,
TestVSCodeMacPortableLauncherPicks, TestVSCodeMacPortableForkLauncher,
TestVSCodePortableProduct (Windows/Linux: target, fork product, versioned
install, Zoo Code, Scoop preview).
Broken by hand, each went red and was restored: main's rule on darwin
(6 Mac tests FAIL, standard folder used), target ignored (Dirs, Product),
no preview refusal (Wiring, Product), first bundle wins
(WithoutLauncher), fork launcher decides (ForkLauncher), Zoo Code on
home's extensions (3 FAIL). On origin/main the new tests don't compile
(vscodeDirs is new); break #1 is main's Mac behaviour.
Run:
- mote (macOS 27), full suite at this change on 479476784:
go test -tags nogui -timeout 45m -count=1 ./... : 85 packages ok
(internal/agent 405s, gateway 832s, provider 251s), internal/gui red on
two filed tests this change doesn't reach: TestSettingsSaveKeepsWhat-
ItDoesNotSend (SearchAll, #4514) and TestColdTurnsTaken (#4510).
Rebased onto 90c02326b (gui takeover, sessions save, kiro min; nothing
in internal/agent): go build, go vet of agent/gui/sessions/provider and
go test of internal/agent, internal/sessions, internal/provider again
at the pushed head: ok (agent 352s, sessions 110s, provider 228s).
- mote (macOS 27): go test -tags nogui ./internal/agent -run
'TestVSCode|TestZooCode' ok; gofmt -l clean; go vet ./...,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., GOOS=linux
go build -tags nogui, GOOS=windows go build ok.
- win-run (Windows 11) and wsl-run (Ubuntu 24.04): the agent tests above
plus Preview, ok.
- Real use on mote, sandbox HOME, PATH=$SB/bin:/usr/bin:/bin: VS Code
1.144.0 darwin-arm64 from update.code.visualstudio.com unpacked to
"$SB/Apps With Space/Code/Visual Studio Code.app", `code` linked
bin/code -> "link one/code" -> the bundle's bin/code. Without
code-portable-data, `magpie agents` lists ~/Library/Application
Support/Code/User/settings.json; with it, ".../code-portable-data/
user-data/User/settings.json". The real `code --install-extension
zoocodeorganization.zoo-code` put Zoo Code 3.94.0 in
code-portable-data/extensions (no ~/.vscode made), and magpie then
listed Zoo Code at the portable User folder. `magpie vscode
deepseek/deepseek-chat` wrote settings.json and chatLanguageModels.json
there, `magpie vscode default` took magpie out of both, and Zoo Code's
connect wrote its import file under the portable globalStorage and its
disconnect removed the setting; ~/Library/Application Support/Code was
never made.
- Real use on xiaomi-gpu (Windows 11), sandbox USERPROFILE/APPDATA,
PATH=<install>\bin;System32: VS Code's win32-x64 ZIP (its versioned
layout, <install>\2c33b50b16\resources\app) unpacked to "Apps With
Space\VSCode". Without data, `magpie agents` lists ~\AppData\Roaming\
Code\User\settings.json; with data, <install>\data\user-data\User\
settings.json. The real code.cmd --install-extension put Zoo Code in
data\extensions (no ~\.vscode), magpie then listed Zoo Code there,
and connect/disconnect wrote and cleaned that User folder; %APPDATA%\Code
was never made.
Not tried / not handled: VS Code's window wasn't opened to see the model
picker (headless ssh). VSCODE_PORTABLE isn't read: it is the editor's
environment, not magpie's. A Windows or Linux portable build with no
launcher on PATH isn't found (there is no standard place to look). A group
an older magpie wrote in the OS's folder for a portable build stays there;
connecting again writes the portable one. A Claude Code or Codex extension
in a portable build doesn't keep that CLI from showing as gone: #4672.
Co-authored-by: Fake Trader <9635792+faketrader@users.noreply.github.com>
YOUIMARK's Windows has Scoop's VS Code 1.143, a portable build: magpie
showed the editor, but its Dir stayed %APPDATA%\Code\User, which doesn't
exist — code.cmd on PATH was detection enough — so the provider, models
and settings.json magpie wrote went where the build never reads.
Before: vscodeUserDir always took the OS's place for the User folder,
%APPDATA% on Windows; only detection ever looked at the editor itself,
by its launcher alone, so any portable build was found and then read
and written in a folder it doesn't use.
Now: a build whose launcher has a data folder beside it is portable, as
VS Code itself takes a build for portable by that folder alone — a zip's
own data folder, or Scoop's, whose apps\vscode\current\data is the
persisted one, current a junction into apps\vscode. Its User folder is
data\user-data\User there: found, wired, connected and disconnected
there. The launcher is found as detection finds it, and a Scoop shim
stands for the launcher the .shim beside it names, which proc.Unwrap
doesn't read. Zoo Code, which keeps its settings in VS Code's User
folder, is laid out by the same function and follows it. An installed
build's launcher has no data folder beside it, and keeps the OS's place;
so does a portable build before its first run, whose launcher alone is
still detection enough, its writes then making the folder where it
reads. VSCodium portable is left as it was: its data folder is named by
its product.json, which no report asks after.
This is the other half of the branch the Copilot-launcher fix came from
(taken along with 6f435677c, since reworked); it shares no code with
that one — this half is only where a portable build keeps its User
folder, not what magpie takes a copilot launcher for.
Run at this head (parent 841025836):
- New TestVSCodePortableUserDir: an installed build with the launcher on
PATH keeps the OS's User folder; with the data folder beside the
program the build's Dir is data\user-data\User, it is detected before
its first run has made the folder, connecting writes magpie's group in
the data folder's chatLanguageModels.json and disconnecting takes it
out. New TestVSCodePortableScoopShim: the same through scoop's shims
folder, the .shim naming the launcher in apps\vscode\current\bin, and
a shim with no data folder beside the launcher it names staying an
installed build. Both are red with vscodeUserDir taken back to the
OS's place ("the portable build's User folder is .../Application
Support/Code/User", "Scoop's portable VS Code reads ...") and green
with the change.
- go test -tags nogui ./internal/agent -count=1: green but for
TestMothX, which fails the same without this change — this machine's
PATH has a real mothx (fnm), which the test's LookPath finds.
- gofmt -l clean; go vet ./internal/agent for darwin, linux and windows;
go build ./... for darwin and windows, and for linux ./internal/agent
(the repo's linux build fails in wails's own code on this machine
without this change too).
Issue: #3260
Generated-by: GLM-5.3-Flash (ZCode)
Reviewed and run by yetone at the batch head over cac655c14 (this commit,
the four others from ggbdpq's #4495/#4548/#4512/#3260 patches and the
#4548 follow-up), on mote:
- gofmt -l clean; go vet ./... for darwin, linux (-tags nogui), windows;
go build ./... for darwin and windows.
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
internal/gui, with two filed reds: TestSettingsSaveKeepsWhatItDoesNotSend
(#4514), red alone at origin/main cac655c14 too, and TestColdTurnsTaken
(#4510), red only in the full run. Rebased afterwards onto e94fb18b8,
a usage-page change that touches none of these files.
- Windows (xiaomi-gpu): go test -run 'TestVSCode|TestClaudePicker'
./internal/agent ok. TestCopilotFolderFromAnIDEPluginIsNotTheCLI is red
there at cac655c14 too (#1827).
- Broken by hand: vscodeUserDir's portable branch off -> TestVSCodePortableUserDir and TestVSCodePortableScoopShim red. Checked against Scoop: extras/vscode.json puts appsscode