The previous commit followed a linked ~/.codex/sessions. Two more agents
hand one root to filepath.WalkDir the same way and missed everything
behind a junction or a symlink: WorkBuddy's (and CodeBuddy Code's)
projects folder (buddyFiles) and MiniMax Code's sessions folder
(minimaxCallFiles). The follow-and-rename is now walkLinked, used by all
three, so each names its files under the agent's own folder rather than
the link's target, as JasonBuildAI's change does for Codex. The other
WalkDir calls in internal/sessions walk magpie's own folders or a single
session's folder, not an agent's root.
Run:
- TestBuddyProjectsBehindALink (new): with buddyFiles back on
filepath.WalkDir it fails "WorkBuddy sessions behind a link: 0, want 3";
with walkLinked's rename taken out it fails "a WorkBuddy session behind
a link is named .../002/projects/..., want it under .../.workbuddy/projects",
and TestCodexRolloutsBehindALink fails "a rollout behind a link reads as
.../002". Passes with the change, on macOS (symlink) and on the Windows
box (mklink /J junction), with every TestCodex* test there.
- go test -tags nogui ./... on macOS with this series: every package ok.
- gofmt -l, go vet ./... on darwin, linux (nogui) and windows: clean.
- Windows internal/sessions as a whole: TestCursorEditorCopiedOncePerChange
fails there with and without this (a %TEMP% folder another test leaves;
noted on #1827).
The Codex CLI on Windows leaves every folder under .codex as a junction when
.codex is kept on another drive, sessions and archived_sessions among them.
codexFilesIn handed that folder to filepath.WalkDir, which lstat()s the root
it is given, and to lstat a junction is not to see a folder: the walk called
back once for the root, descended no further, and missed every rollout. The
Codex session was absent from the Sessions page, and its calls, tokens and
cost from Usage and the ledger. On the machine this was found on, whose
~/.codex/sessions is a junction to
D:\CDriveData\C_\Users\黄江南\.codex\sessions, two binaries built from this
tree and from 2a99e7a4 alone read the same .codex as:
magpie usage all, 2a99e7a4: 26563 calls, no Codex row among the agents
magpie usage all, this change: 98736 calls, Codex 72173 of them, 257M, 67%
magpie sessions, 2a99e7a4: 483 sessions, none of them Codex
magpie sessions, this change: 1083 sessions, 600 of them Codex
Follow the link with proc.RealPath, the resolver already kept for Codex's own
install.ps1 junctions - filepath.EvalSymlinks leaves a junction as it is - and
walk what it returns. Each rollout is still named at its path under the Codex
folder, not under the link's target: a rollout's path is read back to the
Codex folder for its config.toml and state_*.sqlite (codexHomeOf, the
provider each session reads as, MoveCodexProvider), and the target holds
neither. On this machine C:\Users\Jason\.codex has config.toml and a
state_*.sqlite while D:\CDriveData\C_\Users\黄江南\.codex has neither, so a
rollout named under the target would read as a provider the user is not on,
and a move offered on it would write nothing Codex reads. A folder that is
not a link is untouched: the root is resolved only where lstat says it is no
folder.
TestCodexRolloutsBehindALink links the fixture's sessions folder to a folder
beside it, a junction on Windows and a symlink elsewhere, and wants the same
rollout keys and sizes, the same session count, a rollout that reads back as
the fixture's Codex folder, and every session's provider read from the
config.toml written there. With the resolver taken back out:
--- FAIL: TestCodexRolloutsBehindALink (2.28s)
codex_link_test.go:65: rollouts behind a link: map[], want map[codex:01a0bdc9-b5fd-7e63-9658-68bc8dce5ecd:833]
with the walk left at the link's target instead:
--- FAIL: TestCodexRolloutsBehindALink (2.14s)
codex_link_test.go:71: a rollout behind a link reads as D:\Temp\...\002, want D:\Temp\...\001\codex
With the change: PASS.
Run, on windows/amd64 over 2a99e7a4 with this change:
- gofmt -l internal/sessions/sessions.go internal/sessions/codex_link_test.go (empty)
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... (each exit 0)
- go build ./..., GOOS=linux go build -tags nogui ./..., GOOS=windows go build ./... (each exit 0)
- go test -tags nogui -count=1 -run TestCodex ./internal/sessions/ (ok, 11s)
- go test -tags nogui -count=1 ./internal/sessions/ (ok, 82s, with TMP and TEMP
pointed at a fresh folder. Without that TestCursorEditorCopiedOncePerChange
fails on %TEMP%\magpie-cursor-fresh, which TestCursorLeftCopiesSwept leaves
behind, having set TMPDIR, which os.TempDir does not read on Windows. It
fails the same way with this change taken back out: a Windows
test-isolation red of that pair, not of this change.)
Not run: the GUI's Playwright suite (no GUI asset changed), and the rest of
go test -tags nogui ./... (internal/sessions is the only package the change
reaches).
AI disclosure: this change was drafted with AI assistance at my request,
under my direction and review.