yoshi037070 (Discord, 10-27): when magpie restarted Codex, a new Codex window opened. The switch paths (Connect, Disconnect, failover) already end only the app's own app-server (codexAppStep, proc.End: SIGTERM on macOS, exit 0 on Windows), and the app starts another and keeps its window. The Agents row's Restart beside a Codex app left on the old list did not: on macOS ReopenCodexApp ran osascript "quit" and then `open` on the bundle, and that open is what brought up a new window. Now ReopenCodexApp keeps its check (only a bundle the row lists as left on the old list) and calls provider.RestartCodexApp, which ends each process whose command line starts with <bundle>/Contents/ and is the app's own app-server (isCodexAppOwnServer: an app-server, not --listen), waits up to 10s for them to be gone, and errs when none ran. The app, its window and another program's --listen server are left alone. The confirm says only the app-server restarts and the window stays; the status says "Codex app-server restarted" (zh, zh-TW, ja, de). app.js stays under its budget, with no raise (1,310,458 of 1,310,460 after rebasing on97332140a): the "asked first" comment went and appReopen's shrank. The agent-wiring page says the same. The model picker: the app's restart recovery doesn't refetch its models query; it refetches on the next window focus once the list is over 5 minutes old (staleTime), or when the picker is mounted again. Run (rebased on origin/main, at this commit's tree): - go test ./internal/agent: ok (280s). - go test ./internal/provider -run 'Codex|Restart': ok. Before the rebase, the whole package with -skip TestUnreadLoginsWriteErrorsKeepCredentials (#3632 crashes the binary) was ok except TestFetchAsksASharedBaseOnce and its two siblings (#3854). - go test ./internal/gui -run TestCoreScriptBudget: ok. - GUI: agent-stale-copies in chromium and webkit, 5 languages, 980/440px: 80 pass. i18n-keys: its only red is #3897 ("Runs as"). Before the rebase codex-app-stale passed too. - gofmt -l clean; go vet darwin and windows for agent, provider, gui; linux for agent and provider (gui's linux vet needs wails' cgo here). - Real app: a clone of ChatGPT.app 26.1021.31345 (APFS clone in a sandbox HOME, so the bundle is unique to it) run under that HOME. The real RestartCodexApp ended its app-server 32922 in 3.1s; the same main process (31894) started app-server 34143, and its one window (2273016) stayed the only window. The user's own ChatGPT was untouched. Broken by hand: - reopenApp back to appQuit + appOpen: TestCodexAppReopen red ("did quit …, open …"). - isCodexAppServer in place of isCodexAppOwnServer: TestRestartCodexApp… red (ended [2 3], the --listen one too). - the bundle prefix dropped: red (ended [2 4], another bundle's). Not tried: the picker refreshing in a signed-in app (the sandbox app isn't signed in); Windows has no such Restart (the row's Restart for the Codex app is macOS only; Windows switches already end codex.exe with exit 0 and the app keeps its window,3aead9c62).
Subsystem design references
These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.
| Subsystem | Reference |
|---|---|
| Built-in subscriptions moving to plugins | Provider and plugin ownership |
| Built-in plugins: registry, lifecycle, plugins.yml, presets, settings schemas, the window's kernel (slots, error boundary, kit) | Plugin runtime |
| Plugins that run on the gateway's requests and replies | Gateway middleware |
| Tools that plugins give, offered to every agent as an MCP server | Plugin tools |
| Plugins that await context recall and observe completed replies | Asynchronous gateway request hooks |
| Claude subscription turns across Claude Code runs | Claude subscription bridge |
| How the gateway picks a provider, key or account, and falls back | Gateway routing and fallback |
| Gateway Session Aggregation | Gateway Session Aggregation |
| Connecting an agent's config to the gateway, drift, disconnect, WSL twins | Agent wiring |
| Providers, keys, subscription accounts, refresh and allowance | Providers and accounts |
| Instructions, MCP servers, skills and RTK written into agents | Library |
Tray, panel, window, magpie web and the page's JSON API |
GUI app shell |
| Encrypted backups and setup synchronization over WebDAV, S3 or GitHub | Sync and backup |
A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.
Maintain a reference
Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.
Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.
For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.
Describe a PR's semantic changes
For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.
For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.
This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.
Review a change
- Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
- Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
- Check that changed contracts appear in the owning reference and that source links still resolve.
- Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.
A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.