Commit Graph
2 Commits
Author SHA1 Message Date
yetone 1c6dc247ed codex: the Codex app restarts once for magpie's list named after it started (not_4O4 on X)
not_4O4 (X, magpie 0.1.4012, Windows): the ChatGPT app's Work tab
listed GPT alone, in a new window and in a new project on D: too.

The app-server reads model_catalog_json only as it starts. codex-rs
app-server model_catalog.rs reloads only when needs_reload is set,
which happens on an account change alone. The app keeps one
app-server for all its windows, and on Windows it runs from login
(StartupTask). So a list magpie named after the app-server started
never reached the picker. That happens when the list first becomes
known (the backend answering, or the models_cache stand-in from
327da691a) or when Codex moves from WSL to the Windows config.
magpie's restart follows only the route (codexAppRoute), and the list
is kept out of the route on purpose (#4550). On Windows StaleCopies
reports no app copy, so no Restart was offered either.

Now deskList stashes when it names the key (codex.desk_at, Agent.DeskAt,
provider.CodexAppDesk). codexAppDeskStep marks the app's app-servers
that started before that time as stale, once for each naming, and they
are ended at idle like a Connect's, with RestartApp off too. The time
is kept while the key is taken out and named again in one change (a
model picked in magpie, a reset), and dropped once deskList takes the
list out as not wanted. Left alone:
- an app-server whose start can't be read;
- the takeover's, where the reset names the list again as it ends, in
  the same look or a later one (c.back) (#4550);
- a new list written into a file already named.

Run:
- Real Windows app-server (OpenAI.Codex 26.1106, codex-cli
  0.167.0-alpha.4.1, sandbox CODEX_HOME, cwd D:\cxproj): model/list,
  then model_catalog_json written, config/read, model/list on the same
  process: still the 12 GPT models. A fresh process listed magpie's.
- win-run: TestCodexDesktopList* in internal/agent ok. A temporary
  test started the Store package's codex.exe app-server: codexAppServersOn
  listed it, and codexServerStart read its start; the test file was not
  committed. TestCodexAppRestartedForTheListNamed ok.
- mote (load 25-33 over 18 cores; mica's disk full):
  TestCodexAppRestartedForTheListNamed, TestCodexAppLeftRunning*,
  TestCodexAppServer*, TestCodexAppSwitch*, TestCodexAppCrash*,
  TestCodexDesktopList* ok. go vet for darwin, windows and linux on
  internal/agent and internal/provider: ok.
  go test ./internal/agent ./internal/provider: internal/agent ok;
  internal/provider red at TestWalletCapHolds only, a midnight
  boundary on mote's clock unrelated to this change, filed as #6474.

Broken by hand, each red:
- the desk step marks nothing stale: ended [], want [60];
- no takeover guard: ended [102] at the reset;
- no c.back guard: ended [103] a look after the reset;
- a new time at each naming: TestCodexDesktopListNamedAt red at the
  magpie model pick.

Not tried:
- the real ChatGPT app's window on Windows: ending its app-server and
  watching the picker list magpie's models. ssh sees no interactive app.
- A key named by a magpie before this one has no time, and nothing is
  restarted for it. Restarting then would restart every running Codex
  app once at the update, the ones that work too. Such a user quits
  the app once.
2026-11-13 16:01:06 +08:00
yetone add927e604 codex: the Codex app beside the ChatGPT sign-in lists magpie's models too
laddieyao (Discord #general, 10-27): with Codex joined to magpie beside
its ChatGPT sign-in, the Codex desktop app's model picker showed OpenAI's
GPT models alone, while the Codex CLI listed magpie's. The /models
request does reach magpie's gateway and its answer holds magpie's
models. ChatGPT.app 26.1013's picker then narrows app-server model/list
to the models a Statsig config (107580212, use_hidden_models /
available_models) names, while Codex is on its built-in provider, unless
Codex reads its list from a file (model_catalog_json,
hasConfiguredModelCatalog) or names a provider of its own. The CLI has
no such filter.

Where the Codex app is installed (codexReaders has an "app"), and only
joined/beside the sign-in (not magpie as Codex's provider, not account
failover alone), magpie writes the list it hands Codex at
/backend-api/codex/models to ~/.codex/magpie-desktop-models.json and
names it with model_catalog_json. Codex is still on its built-in
provider. With a catalog named Codex asks for no list, so magpie asks
the backend itself, with Codex's live sign-in (provider.CodexLiveList):
its entries go in verbatim, base_instructions and all, merged as the
gateway merges them (codexMerged, factored out of codexModels: picked,
hidden, window, V1, AutoReview edits), magpie's models after them.

- A list not known (not asked yet, or the backend failing) is unknown:
  the file as it was stays, never an empty list; a key naming a file
  that is gone goes, as Codex loads no config then.
- Written via temp+rename at Join, set, settle and every Sync (so a
  change of magpie's models, picks or hidden models rewrites it, as
  SyncCatalog runs on them); the backend list is asked again hourly
  (5 min after a failure) and a change syncs again.
- A model_catalog_json of the user's own stands; none is written beside.
- magpie API, the app gone, or unwire take the key and the file out;
  unroute never restores the desk file as the user's catalog.
- connectinfo counts the file, so a running app on an old list reads
  as needing a restart.
- CLI-only machines: unchanged, the live /models path as before.

Run:
- Real account, sandbox HOME (copy of auth.json, chatgpt Pro; live
  ~/.codex untouched): Join wrote model_catalog_json and the file with
  the real backend's 10 entries (gpt-6.1-sol ... codex-auto-review, each
  with base_instructions) plus relay/claude-opus-5.5 and
  relay/claude-sonnet-4-5. Then the real app-server bundled in
  ChatGPT.app (codex 0.163.0-alpha.10.2, CODEX_HOME sandbox, base URL
  pointed at a dead port) model/list returned all 12, relay models
  visible, and config/read showed model_catalog_json set, which is what
  the app's picker checks to skip its filter.
- New tests: TestCodexDesktopListBesideSignIn, ...CLIOnly,
  ...KeepsTheirs (internal/agent), TestCodexDesktopCatalog
  (internal/gateway).
- Broken by hand, each went red: deskList a no-op (all three agent
  tests), the user's-own branch removed (KeepsTheirs), the gone-file
  branch removed (KeepsTheirs), the keep-last-good rule broken in
  codexDeskRefresh (TestCodexDesktopCatalog).
- go test -tags nogui -timeout 45m ./internal/agent ./internal/gateway
  ./internal/provider ./internal/cli at bc0a99bb6 (on 68bbcc01c):
  agent, gateway, cli ok; provider red on TestUnreadLogins...
  (synctest crash, #3632) and three TestFetch* tests (#3854), both red
  the same at origin/main 68bbcc01c / 5a3292354 run alone, both filed.
- Rebased over e7f21dba5 (Disconnect keeps a hand-set catalog): the
  conflict in unroute merged (the desk key counts as no catalog of the
  user's), and -run 'CodexDesktop|Disconnect|Unwire|Catalog'
  ./internal/agent ok. The packages' run at the final head could not
  build: the machine's disk was full (other sessions).
- gofmt -l clean; go vet ./... on darwin, GOOS=linux, GOOS=windows ok.

Not tried: clicking the real desktop app's picker (the app-server
answer and config were checked, not the GUI); the Windows Store app
(its readers get no version but count as the app; not run there); a
backend list change rewriting the file while the app runs (the app
needs reopening to read a new file, which connectinfo's restart notice
covers).
2026-10-27 18:38:27 +08:00