Skip to content

fix(native-chat): a failed Codex turn shows its error, not a raw thread-status row - #23704

Merged
brennanb2025 merged 6 commits into
mainfrom
brennanb2025/codex-status-no-row
Sep 30, 2026
Merged

brennanb2025 merged 6 commits into
mainfrom
brennanb2025/codex-status-no-row

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​60 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​44 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29

ELI5

When a turn in a structured Codex chat failed, the chat showed a red row reading "codex · notification:thread/status/changed" directly above the row with Codex's real error message. That row meant nothing to a person: it was Codex telling Orca "this thread has stopped running", which is bookkeeping. It no longer appears. The real error row, and the turn ending as failed, are unchanged.

What Changed

The problem: every failed Codex turn in a structured chat (the chat view, not a terminal pane) put a red "codex · notification:thread/status/changed" row into the transcript. You saw it when you expanded the failed turn's "Worked for …" group, right above Codex's own error sentence (for example "unexpected status 401 Unauthorized …"). It looked like a second, unexplained failure.

Why it happened: just before a failed turn's error notification, Codex sends thread/status/changed with the status systemError. Orca's Codex translator (the code that turns Codex's messages into chat rows and session state) already read this notification for state: it is how Orca learns the thread stopped running, which releases messages still waiting on that turn. But after reading it, the translator also handed the notification to Orca's catch-all for messages it does not render. That catch-all turns anything that looks like a failure into a red row showing the raw message name, so that an unknown failure is never silently hidden. It saw systemError and printed the row.

What is different for you: a failed Codex turn now shows only Codex's error row. The turn still ends as failed, and the chat still accepts your next message. Nothing changes for turns that succeed. Chats saved before this change keep any of these rows they already recorded; only new rows are affected.

Mechanism: Orca already has a registry of message kinds that a provider's translator fully handles, so the catch-all must not print them. Until now it only listed Claude's background-task messages. This PR turns it into one list per provider and adds Codex's thread/status/changed to the Codex list. After reading a thread/status/changed notification for state, the Codex translator tells the catch-all that this frame is covered, the same way the Claude translator does for each background-task message it handles. The catch-all then writes nothing for this notification, for every status value (idle, active, notLoaded, systemError). The translator's state handling, including the "thread stopped running" report, runs before the catch-all and is untouched. The Codex list is type-checked against Codex's own notification names, so a misspelled entry fails to compile.

Why

Every value of this notification describes thread state: loaded, running, idle, or stopped by an error. None carries text meant for a reader. When a turn really fails, Codex's sentence arrives on the separate error notification, which already writes its row and fails the turn.

Registering the notification reuses the one place Orca already declares "this translator handles this message; don't print it", instead of adding a second filter beside it. Alternatives considered: hiding only systemError keeps a special case for a notification whose values are all state; weakening the catch-all's failure check would hide real failures from messages Orca does not know yet; an early return inside the Codex translator (this PR's first version) worked but put the rule in a place no other provider uses.

Interaction with #23684 (still open; it shows a run of Codex stream retries as one warning row that updates in place): that PR treats any other row the chat draws as the end of a retry run. On #23684's branch alone, the red thread-status row sits between the last retry and Codex's error, so it is what ends the run. With this PR that row is gone, and Codex's error row, which comes right after, ends the run instead. The visible result is the same: one retry row, then the error. The two branches conflict only in the import block at the top of codex-structured-journal-generic-frames.ts; whichever merges second keeps both sets of imports.

Differences from the common pattern

Other Codex clients treat this notification as state only and never show it as a transcript row; Orca now does the same.

  • Intended: Orca exempts the notification through its covered-message registry. Orca has a catch-all that prints messages it does not recognise and those clients do not, so the registry is how Orca says a message is handled and must not be printed.
  • Intended: rows already saved in old chats are not removed. The chat history is a record, and rewriting it is out of scope for a display fix.

Linked Issue

None; reported internally.

Visual Proof

Checked live in the desktop app with a real Codex (0.157.0) in a structured Codex chat, two failed turns per build. The turns failed for a real reason: Codex's request came back 401 Unauthorized because the test profile's Codex had no sign-in. The chat's model was set to an id that does not exist, which is why a "Model metadata … not found" warning appears. Before is main at fed1eca; after is this PR at e4535e9 (later commits only tighten a type, narrow the covered flag to the thread-status notification, and fix comment and test wording). Both builds also carried #23552 (still open), which the test setup needs so a test Codex cannot change the real Codex settings on the machine; apart from that, the two builds differ only by this PR's five files. The separate red "Reconnecting… N/5" rows are Codex's retries and are what #23684 addresses; they are not part of this PR.

Before: the expanded failed turn shows a red "codex · notification:thread/status/changed" row directly above Codex's 401 error row.

Before: the expanded failed turn shows a red "codex · notification:thread/status/changed" row directly above the 401 error row

After: the retries go straight to Codex's 401 error row, with no thread-status row.

After: the expanded failed turn goes from "Reconnecting... 5/5" straight to the 401 error row, with no thread-status row

Before: after a second message, the first turn still shows the thread-status row above its error.

Before: the first failed turn shows the thread-status row above its error, followed by the second message and its failed turn

After: the chat accepts a second message after the failure; neither failed turn has a thread-status row.

After: the first failed turn ends at the 401 error row with no thread-status row, followed by the second message and its failed turn

Chat journal counts across the two failed turns: before has 2 thread-status rows, 2 error rows, and 2 turns ending as failed. After has 0, 2, and 2.

Testing

  • codex-structured-journal-translation-streams.test.ts: no row for each of the four status values, and a failed turn (status systemError, then error with willRetry: false, then a failed turn/completed) journals exactly one status row with Codex's message, ends the turn as failed, and reports the thread stopped running. These replace a test that asserted the old row.

  • provider-frame-disposition.test.ts: the registry covers Codex's thread/status/changed; a covered frame writes nothing; the same frame without the covered flag still reaches the catch-all as a failure, so the catch-all's own check is unchanged for everything else.

  • Written first against the unmodified code: the systemError case and the failed-turn case failed with the exact red row. Reverting only the fix turns the same tests red; restoring it turns them green.

  • The existing "thread stopped running" tests in codex-structured-journal-translation.test.ts pass unchanged, so the state effects are the same.

  • 14 explicit test files (all Codex structured-journal translation suites, the provider-frame registry and catch-all suites, the Codex turn-wait and goal-row suites, and the Claude background-task and retry-row suites): 213 tests pass. Removing only the Codex registry entry turns 3 of them red.

  • The registry's provider keys are type-checked against the provider table, so a misspelled provider fails to compile instead of silently bringing the row back.

  • Forcing the covered flag off turns 2 of the stream tests red.

  • oxlint on the changed files and tc:node.

  • Live desktop QA with a real Codex; see Visual Proof.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Main process only; no wire, renderer, or mobile change. It behaves the same on local, SSH, and WSL hosts, because the translator runs where the Codex app server's messages are recorded. Subagent threads lose the same meaningless row; their error rows are unchanged. In every captured Codex run, a systemError status is followed by an error notification carrying the reason; if Codex ever reported systemError with no error after it, the chat would now show no row for it, where before it showed only the raw message name.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…ad-status row

Codex reports `thread/status/changed` {systemError} just before the `error`
frame of a failed turn. The translator read it for session state, then let it
fall through to the generic-frame fallback, whose payload check reads
`systemError` as a failure and printed "codex · notification:thread/status/changed"
in red above the real error row.

The translator now owns the notification: it reads the stopped-running verdict
exactly as before, then journals nothing for any arm (idle, active, notLoaded,
systemError). The error row that follows still carries Codex's sentence and
still fails the turn.
…yped-translator registry

The translator already reads every thread status for session state. Listing
the kind beside Claude's background-task frames makes that ownership visible
where the fallback consults it, instead of a second method check in the
translator.
…atus-no-row

# Conflicts:
#	src/main/codex/codex-structured-journal-provider-verdicts.ts
#	src/main/codex/codex-structured-journal-translation.ts
…nst the provider table

A mistyped provider key compiled and silently brought the row back. Also
retire the renamed constant from a Claude test comment and say which path
the classifier-only fallback test covers.
…atus it read

The covered flag means this exact frame was handled; passing it for every
notification would silently hide any Codex kind later added to the registry.
Also say why a state-only kind may be listed, and retitle the cross-provider
coverage test now that Codex has entries.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status for head ea9c3e1 (still a draft).

Problem this fixes: a failed Codex turn in a structured chat showed a meaningless red "codex · notification:thread/status/changed" row right above Codex's real error. After this PR only the real error row appears; the turn still ends as failed and the chat still takes the next message.

Live check with a real Codex 0.157.0, two failed turns per build (a 401 because the test profile had no sign-in). Before is main fed1eca, after is this PR at e4535e9; both builds also carried #23552 so the test Codex could not touch the machine's real Codex settings. Journal counts: before 2 thread-status rows, 2 error rows, 2 failed turns; after 0, 2, 2.

Before: the red thread-status row sits directly above the 401 error row.

Before: the expanded failed turn shows a red "codex · notification:thread/status/changed" row directly above the 401 error row

After: the retries go straight to the 401 error row.

After: the expanded failed turn goes from "Reconnecting... 5/5" straight to the 401 error row, with no thread-status row

Review since the last update:

@brennanb2025
brennanb2025 marked this pull request as ready for review September 30, 2026 08:09
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Changes how failed Codex turns are reported in chat.

The PR appears safe to merge; the examined failure path retains the readable error and failed-turn outcome.

Summary

This PR treats Codex thread-status notifications as state-only frames, removing the raw failure row while retaining the separate error row and turn outcome.

  • Adds provider-specific typed-translator coverage for the Codex notification.
  • Tests suppression across status values and preservation of failed-turn reporting.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Codex thread/status/changed] --> B[Update thread state]
  B --> C[Covered-frame check]
  C --> D[No transcript row]
  E[Codex error notification] --> F[Error transcript row]
  E --> G[Failed turn outcome]
Loading

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor test-quality suggestion inline.

Reviewed changes

  • Per-provider typed-translator registry — CLAUDE_TYPED_TRANSLATOR_KINDS becomes TYPED_TRANSLATOR_KINDS, a ReadonlyMap keyed by provider, with Claude's five background-task kinds preserved and Codex's notification:thread/status/changed added, typed against CodexAppServerNotificationMethod.
  • Codex translator tags the frame as covered — the notification fallback path now passes { coveredByTypedTranslator: event.method === 'thread/status/changed' }, so the fallback's pre-classification early return suppresses all four status arms before hasProviderError can promote systemError.
  • appendUnhandled option passthrough — CodexJournalGenericFrames.appendUnhandled gains an optional options parameter and forwards it (with an explicit DEFAULT_JOURNAL_PAYLOAD_LIMITS) to unhandledProviderFrameJournalItem.
  • Tests — parametrized no-row coverage for the four status arms, a failed-turn test asserting exactly one error status row and a failed turn, and registry tests for the covered and uncovered paths. Four changed suites pass locally (88 tests) plus pnpm tc:node.

The mechanism is sound: the fallback's coverage check runs before classifyProviderFrame, which is what stops the systemError promotion. The state read (codexThreadStoppedRunning / reportPrimaryThreadStoppedRunning) is untouched and still runs first. Well-formed status notifications only travel the notification path, so the untagged appendUnhandled callers do not reopen the row.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

})
})

it('covers a kind only for its own provider — a Claude kind from Codex still falls back', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test's name promises provider scoping, but it never passes { coveredByTypedTranslator: true }. The fallback's early return at unhandled-provider-frame.ts:95 requires that flag, so hasTypedProviderFrameTranslator is never consulted here and the assertion would still pass if codex wrongly listed a Claude kind. Assert hasTypedProviderFrameTranslator('codex', 'message:system:task_notification') === false, or call with the covered flag and expect a non-null result.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 24f3914c-295b-452d-8d2c-f7785f99e963

📥 Commits

Reviewing files that changed from the base of the PR and between 7afa4ee and 78e5db9.

📒 Files selected for processing (7)
  • src/main/claude/claude-structured-journal-translation-background-tasks.test.ts
  • src/main/codex/codex-structured-journal-generic-frames.ts
  • src/main/codex/codex-structured-journal-translation-streams.test.ts
  • src/main/codex/codex-structured-journal-translation.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.test.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.ts
  • src/main/native-chat/agent-session-wire/unhandled-provider-frame.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Codex thread/status/changed frames are now included in typed-translator coverage. The Codex journal appender accepts optional options and passes them with default payload limits to the unhandled-frame item builder. Journal translation marks thread-status notifications as covered, and tests check that statuses do not create journal rows and that failed turns record an error status and failure outcome.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 78e5d

The change removes raw Codex thread-status rows while preserving error messages and failed-turn outcomes. No actionable merge-blocking risk is identified; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and covers the user impact, mechanism, rationale, visual proof, testing, and compatibility considerations. However, the required Linked Issue section explicitly states “Non… Add the actual linked issue under “Linked Issue” and replace “Fixes #” with the appropriate issue reference. Also mark the build and validation checklist items accurately, or state that CI will cover them if they were not run locally.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: failed Codex turns no longer display a raw thread-status row and instead show the actual error.
Full details: Description check

Explanation

The description is detailed and covers the user impact, mechanism, rationale, visual proof, testing, and compatibility considerations. However, the required Linked Issue section explicitly states “None,” although the template requires an actual issue link.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025
brennanb2025 merged commit 7cae036 into main Sep 30, 2026
60 checks passed
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