Files
magpie/docs
yetone 72ed121fd2 agent: the Codex row asks for a reopen only when Codex's models change
Qyburn3 on X ("为什么我每天好多次要重启"): the Agents row of a Codex
app already connected said 已接入 · 退出并重开 Codex 应用后生效 several
times a day.

Cause: StaleCopies counts a running copy as behind when a digest of
what magpie writes for Codex changed after it started. That digest took
magpie-desktop-models.json byte for byte. Beside the ChatGPT sign-in
(since add927e60) that file holds the ChatGPT backend's entries as
sent (base_instructions, comp_hash, available_in_plans...), asked for
again each hour, and each entry's details follow magpie's version and
models.dev, so a rewrite with the same models moved the digest and the
row asked for a reopen. The same digest drives KeepCodexDaemonCurrent,
so the CLI's app-server daemon was restarted for it too.

Fix: of Codex's two lists (magpie-models.json, magpie-desktop-models.json)
the digest takes which models they hold, slug and visibility in no
order (listedModels), beside the wiring keys and magpie's table as
before. A list that doesn't parse is still taken whole. A digest an older
magpie stashed is kept at its time when it matches the files as they are
(readsBefore), so the update itself doesn't ask every user to reopen
once more. Claude Desktop's reads already hash model ids only. The file
is still written only when its bytes differ (deskList); a running Codex
keeps working on its startup copy, and new details reach it on its next
start.

Run at this head (ccbefe2a2 + this), through mote-run:
- go vet ./internal/agent, GOOS=linux and GOOS=windows: ok
- go test ./internal/agent -count=1 -timeout 45m: ok (147.6s)
- wsl-run go test ./internal/agent -run 'TestCodexStale|TestChangedAt': ok
- the real ~/.codex/magpie-desktop-models.json (35 models) through
  listedModels in a throwaway test, with every base_instructions,
  priority and comp_hash changed and two entries swapped: same part.

Broken by hand: with the old byte-for-byte reads,
TestCodexStaleNotForAListsDetails is red at "the same models, other
details: 1 stale, want 0"; with the readsBefore carry-over off, red at
"an older magpie's stash, nothing changed since: 1 stale, want 0".

Not tried: a real Codex app beside a real ChatGPT sign-in watched over a
day; whether a list that flips between two model sets (a plugin's
listing failing and coming back) still asks for a reopen each flip (it
does: only the last digest is kept). No GUI change, so no GUI run.
2026-10-31 00:00:11 +08:00
..