The reporter wants the Codex app's projects kept however magpie switches
ChatGPT accounts. v0.1.3559 (15acba534) copied the longest list only to
an identity with no list yet, so an account with a list of its own (an
empty one too) never got the others' projects, and a project added on
one account never reached an account that had any.
Now, while the app is closed (the same moments as before: the 3s loop
once the state file or logins changed, and between a reopen's quit and
open), shareCodexProjects gives every identity the file has and every
saved Codex login one list: each identity's local-projects together,
the signed-in identity's copy first, with the ties the other
codexProjectKeys have to them (thread-project-assignments,
project-order, pins, appearances, the app-server id maps one level
down). A folder is one project: the app gives a new project a random id
per account (randomUUID in 26.1103's bundle), so a project of a folder
an identity already has maps onto that one, its threads renamed to it.
Removals: codex-projects.json (beside logins.json) keeps each
identity's project ids and folders as the last look left them. A
project a look saw on an identity that the next doesn't have was
removed there; it goes from every identity with every tie, as do other
projects of its folders, unless the user added that project or folder
again since. No record yet removes nothing. A record that can't be
read or parsed means what was removed is unknown: nothing is written.
The record is written after the state file, and not when the app's
start overtook the write, so that look is taken again. The state file
is still written through temp + rename, only when it is byte-for-byte
what was read, with the first-write backup beside it.
Checked against ChatGPT.app 26.1103.60933's own bundle (downloaded from
its appcast into a scratch dir, unpacked there): the renderer state
schema {owner, inactive:{<hash>:{atoms, globals}}}, selectRendererOwner
parking/loading Object.values of the global-state key table (the
account-scoped keys, codexProjectKeys among them), the local project
schema (id, name, rootPaths, backings, createdAt, updatedAt) and
randomUUID ids for new projects. The live ~/.codex was not touched.
Run (mote refused ssh all session, kex reset; so on xiaomi-gpu):
- wsl-run go vet -tags nogui, GOOS=darwin CGO_ENABLED=0 go vet and
GOOS=windows go vet of ./internal/provider: ok
- wsl-run go test -tags nogui ./internal/provider: ok (281s)
- wsl-run go test -run 'TestCodexProjects|TestCodexRendererOwner|
TestCodexApp' ./internal/provider ./internal/agent: ok
- win-run go test -run 'TestCodexProjects|TestCodexRendererOwner'
./internal/provider: ok
- gofmt -l: clean.
Red on the old code (origin/main's codex_projects.go with a 3-arg
shim): TestCodexProjectsShared (shared with 1, want 2),
TestCodexProjectsRemovalRemembered (0, want 3),
TestCodexProjectsRecordUnreadable (written).
Broken by hand: removals never gone -> RemovalRemembered red; no
folder dedupe -> Shared red; no graft of ties -> FollowASwitch and
Shared red; a tie not renamed to the folder's project -> Shared red;
no MkdirAll for the record -> StepWaitsForTheAppToClose red.
Not tried: the real Codex app switching real accounts (it would share
Electron's userData with the user's running app); the switch is played
by the tests' Go port of 26.1103's selectRendererOwner. No macOS run
(mote down). The first look after this release has no record, so a
project the user removed on one account before it comes back there.