Skip to content

fix(codex): a Codex row keeps its working and waiting bar when the model errors mid-turn - #2977

Merged
superkoh merged 7 commits into
mainfrom
worktree-codex-session-status-indicator
Dec 5, 2026
Merged

superkoh merged 7 commits into
mainfrom
worktree-codex-session-status-indicator

Conversation

@superkoh

@superkoh superkoh commented Dec 4, 2026

Copy link
Copy Markdown
Owner
  • What it does — A Codex row keeps its working / waiting bar when the model errors in the middle of a turn, instead of losing it and showing "?" (Status unavailable) until the tab moves to another thread.

  • What a user sees change

    Case Today After
    Codex's reply stream drops and Codex reconnects by itself ("Reconnecting... 1/2" in the terminal) the row loses its bar and shows "?"; a toast says "Reconnecting... 1/2"; this lasts until the tab moves to another thread the bar keeps breathing (working), no toast; the turn ends as usual
    A turn fails for good (HTTP 400, used-up quota, context too long) a toast with the error; the row loses its bar and shows "?" for good the same toast; the row goes to waiting; the next turn works and shows working as usual
    A child agent's thread fails its badge reads "state unknown" its badge reads waiting
    A Codex tab you close while its turn fails a toast no toast
  • Runtime code — +16/−9 lines under src/.

  • How to see it in the shipped app — no easy way from the app: it needs Codex's connection to the model to drop mid-reply. When that happens to a Codex tab, its row keeps breathing while the terminal shows "Reconnecting...".

  • Confidence to ship as-is — high: the exact frames Codex sends (error with willRetry, systemError, turn/completed failed) were measured on the real codex-cli 0.169.0 app-server, and the unit test feeds those frames through the real observer and the real run-state.

  • Hand-test before merging — no.

Why

CodexObservation read every error notification and every systemError thread status as "Koloft can no longer see this session" (observation: 'degraded'), which drops the row's run-state class. Both are only about one turn (CODEX§39, measured here):

  • a reply stream cut short is retried inside the same turn, each try sending error with willRetry: true;
  • a turn that fails for good sends systemError, error with willRetry: false, then turn/completed failed; the next turn/start works normally.

Now systemError counts as a turn that ended (main thread and child agents), and an error that does not say willRetry: true only shows its message as a toast (as before), skipped for a tab being stopped. The degraded mark stays for what it means: a TUI that lost its connection, or a thread opener that failed.

Each kind of tab

  • Codex on this Mac and Codex on a remote machine: fixed, both use the same CodexObservation.
  • Claude Code and Antigravity: not touched; they do not read Codex's app-server frames.

What ran

Suite Result Why that one
codexObservation.test.ts (new case red first: 3 degraded events before the fix) 41/41 the changed observer
npm run test:unit:changed 24 files, 553 passed everything importing the changed files
test/e2e/codex-session.spec.ts + test/e2e/remote-codex.spec.ts 88/88 Codex row states on this Mac (including the "Status unavailable" badge case) and on a remote machine
typecheck, format:check, check:comments, check:agent-words, check:agent-imports, check:agent-removal pass the fast checks
Probe: real codex-cli 0.169.0 app-server, fake Responses provider, 5 cases (ok, stream cut, 500 then ok, 400, 400 then a new turn) as written in CODEX§39 the facts the fix rests on
scripts/code-review.mjs 2 rounds × 2 of 2 round 1: a failed turn lost its toast and child systemError stayed unknown — fixed; round 2: toast for a stopping tab and an error without willRetry — fixed

Did not run: the whole e2e suite (no change reaches other flows); the fake codex sends neither error nor systemError, so the new path is covered by the unit test, not e2e.

Out of scope

  • A failed turn still reaches the butler, Discord and the Inbox as a normal finished turn — sessions: a Codex turn that failed reaches the butler, Discord and the Inbox as a turn that finished #2973 (it was like that before this change too).
  • The failed-turn toast does not name its tab (it did not before either).
  • A systemError that is not part of a failing turn (e.g. a thread that cannot load) now reads as waiting — inferred, not checked; no such case was seen.
  • Whether codex 0.161–0.168 sends willRetry — not probed; an error without it is told, as before.

…del errors mid-turn

Codex sends an `error` notification for every retried reply stream
("Reconnecting... 1/2") and a `systemError` thread status for a turn that
failed for good. Both are about one turn, not about Koloft losing sight of
the session, yet both marked the tab "Status unavailable": the row lost its
run-state bar until the tab moved to another thread. Now a retried turn stays
working, a failed turn ends like any other, and the next turn works as usual.

Measured on codex-cli 0.169.0 and written down as CODEX§39.
A turn whose `error` says `willRetry: false` shows its message as a toast
again, without marking the tab "Status unavailable"; a retried stream still
shows nothing. A child agent whose thread goes `systemError` now waits, as
the main thread does.
@superkoh
superkoh merged commit 6ffdceb into main Dec 5, 2026
5 checks passed
@superkoh
superkoh deleted the worktree-codex-session-status-indicator branch December 5, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant