蛋仔 (danzi002 on Discord, 10-29 and 10-30) switched the Codex app's
used-up account in magpie, auth.json changed, and the app stayed grey
until it was quit and opened: "如果打开了 codex 再不点击任何会话的时候,
我手动切换账号它会重启,如果点了会话再切换账号就重启不了". dd9828f2b
made a switch restart every one of the app's own app-servers once no
Codex turn runs. This one never ran.
Why. Codex reads auth.json once; a 401 reloads it only for the same
account id (codex-rs/login/src/auth/manager.rs, reload_if_account_id_
matches), so only a new app-server takes up a switched account.
codexAppStep waits while any session file written to in the last 30
minutes ends in task_started. Tried with the real codex
0.164.0-alpha.11.1 (ChatGPT.app's), sandbox HOME/CODEX_HOME, a fake
Responses server holding a turn open:
- SIGTERM or stdin closed mid-turn: turn_aborted is written.
- SIGKILL (force quit, crash): the file ends in task_started for good.
- thread/resume in a new app-server, which is what opening the thread
in the app does, appends thread_settings_applied and moves the mtime
each time, nothing else changed.
- a 429 usage_limit_reached ends the turn with task_complete, so being
out of credit doesn't leave one open.
So a thread whose turn a killed app-server left open reads as running
for as long as the user keeps opening it, and the switch waits forever.
Change. proc.Started(pid) reads when a process started (darwin
kern.proc.pid P_starttime, Linux /proc/<pid>/stat starttime + btime,
Windows GetProcessTimes; ErrNoStart elsewhere). codexAppStep and
RestartCodexAppWhenIdle pass the oldest start of the app-servers they
would end; an open turn whose task_started line's timestamp is more
than 2s before it can't be running in them and no longer counts. A
start or a timestamp that can't be read counts the turn as running, as
before. A turn started in a running app-server still holds it: no turn
is cut short.
Run (mote-run unless said):
- gofmt -l internal/proc internal/provider: clean.
- go vet ./internal/proc ./internal/provider on darwin, GOOS=linux
-tags nogui, GOOS=windows: ok.
- go test -count=1 -timeout 45m ./internal/proc ./internal/provider:
ok (6.2s, 110s).
- wsl-run (magpie-desktop) and win-run (xiaomi-gpu): TestStarted,
TestCodexTurnOpen, TestCodexApp*: ok.
- The real killed-turn rollout above, copied into a temp test: open
with since unknown, not open with since after the kill, open with
since before the turn.
Broken by hand:
- codexAppStep passing a zero since (the old behaviour):
TestCodexAppSwitchPastATurnItsServerNeverRan red ("ended [], want
[60]").
- sessionTurnOpen ignoring since: TestCodexTurnOpen red too.
Not tried: the reporter's own app on a real account switch; whether
their app-server was in fact killed (force quit or crash) is not known.
A restarted app-server with the thread left open was not watched
ungreying Send in the real app.
8 lines
145 B
Go
8 lines
145 B
Go
//go:build !darwin && !linux && !windows
|
|
|
|
package proc
|
|
|
|
import "time"
|
|
|
|
func startTime(int) (time.Time, error) { return time.Time{}, ErrNoStart }
|