Repository navigation
feat(native-chat): show when a Codex goal is set, changed, or cleared - #19923
Conversation
Codex never emits the model's `create_goal` call as an item, so `thread/goal/updated` is the only truthful evidence that a goal exists. Both goal notifications were classified `status-chrome`, which meant no typed handler read them and no row was written -- the only thing reaching the reader was the model's own prose. That prose can be wrong: in a session where no goal was ever created the model still wrote "Goal created: ...". Classify both frames as timeline-substantive and give them a sentence, so the reader can tell a goal that exists from one the model merely claimed. Status is translated rather than echoed, and an unrecognised future status still reads as "Goal updated: <objective>" instead of the bare opcode. Codex re-sends the goal as its token and time counters climb, so rows are deduped on what a reader would notice -- objective, status and budget. A live session sent the same goal three times in one turn with only accounting moving.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe change adds Codex goal-row rendering, signatures, generation tracking, and substantive timeline classification. A Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to Resumed goal histories can lose lifecycle ordering when the fallback sink path is used. This should be corrected before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 936b0f37-20f1-4f71-ab5c-797be93df3a3
📒 Files selected for processing (7)
src/main/codex/codex-goal-journal-rows.test.tssrc/main/codex/codex-goal-journal-rows.tssrc/main/codex/codex-structured-journal-generic-frames.tssrc/main/codex/codex-structured-journal-goal-rows.test.tssrc/main/native-chat/agent-session-wire/provider-frame-disposition.tssrc/main/native-chat/agent-session-wire/unhandled-provider-frame.test.tssrc/main/native-chat/agent-session-wire/unhandled-provider-frame.ts
💤 Files with no reviewable changes (1)
- src/main/native-chat/agent-session-wire/unhandled-provider-frame.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
Important
The new codex-goal-journal-rows.ts is treated as a binary file by git, so its diff renders as "Binary file not shown", none of it is reviewable inline, and the PR's orca-pr-loc summary undercounts it. One-line fix.
Reviewed changes
- Reclassify goal frames to
timeline-substantive—thread/goal/updatedandthread/goal/clearednow reachunhandledProviderFrameJournalIteminstead of being swallowed as status chrome. - New
codex-goal-journal-rows.ts— builds a per-status sentence (Goal set:/Goal paused:/Goal blocked:/Goal complete:/Goal stopped — usage limit/Goal stopped — token budget spent) with a forward-compatibleGoal updated:fallback, plus a dedup signature over objective/status/budget only. - Goal-row dedup in
CodexJournalGenericFrames— arepeatsLastGoalRowgate drops repeat frames while token/time counters climb, keyed per thread and bounded byMAX_CODEX_GENERIC_TURN_BUCKETS. - Tests — two new unit files pin sentence shapes, signature stability, dedup timing, per-thread isolation, and the non-goal path; the one assertion that asserted goal frames were dropped is removed deliberately. All
63touched tests pass.
⚠️ codex-goal-journal-rows.ts is a binary file
The signature separator uses three literal NUL bytes, which makes file report the module as data and git classify the entire new file as binary. The consequence is concrete: GitHub renders no inline diff for the PR's main new module, and the orca-pr-loc comment already misreports prod as +33 lines when the module is ~70 lines on its own — every future edit to this file will keep producing binary diffs.
Technical details
# NUL-byte separator makes the new module a git "binary" file
## Affected sites
- `src/main/codex/codex-goal-journal-rows.ts:69` — the signature template literal uses three
literal NUL (`\0`) bytes between `${status}` / `${budget}` / `${objective}`.
## Required outcome
- The file is plain text at runtime-equivalent behavior: it renders as a normal diff, and
the `orca-pr-loc` summary counts its lines.
## Suggested approach (optional)
- Replace the three literal NUL characters with the escape sequence `\0` (backslash-zero in
the source text), which yields the identical runtime string but keeps the file text-clean.
`JSON.stringify([status, budget, objective])` is an equally clean alternative.ℹ️ Nitpicks
isCodexGoalFrameMethod(src/main/codex/codex-goal-journal-rows.ts:32) is exported but never imported — dead code; drop it.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…t a raw NUL A literal NUL byte in the source made git classify the file as binary, which hid its diff from review. The string built at runtime is unchanged.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Replaced the literal NUL signature separator with the
\u0000escape —codex-goal-journal-rows.tsis now plain text, so its diff renders inline andorca-pr-loccounts its ~70 lines. The string built at runtime is byte-for-byte identical, so the dedup behavior and all 63 tests are unaffected.
This resolves the prior review's binary-file concern cleanly. The dead isCodexGoalFrameMethod export noted previously is unchanged by this commit and not re-raised here.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 41405470-f876-455e-8648-99c926054eeb
📒 Files selected for processing (6)
src/main/codex/codex-goal-journal-rows.tssrc/main/codex/codex-structured-journal-goal-admission.test.tssrc/main/codex/codex-structured-journal-goal-rows.test.tssrc/main/codex/codex-structured-journal-goals.tssrc/main/codex/codex-structured-journal-limits.tssrc/main/codex/codex-structured-journal-translation.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta against the prior pullfrog review)
- Extracted goal lifecycle handling into a dedicated
CodexJournalGoalsclass — goal rows now admit outsideCodexJournalGenericFrames, so the generic per-turn row cap can no longer suppress the first goal evidence. - Made goal rows retry-safe — dedup state is committed only after both append and publish succeed, so a backpressured append or publish retries with a stable identity and neither loses nor duplicates the row.
- Keyed dedup on the provider's goal generation —
codexGoalGeneration(the goalcreatedAt) joins objective/status/budget in the signature, so a cleared-then-recreated goal still surfaces a fresh row. - Bounded per-thread state with LRU eviction (
MAX_CODEX_GOAL_THREADS = 64) and wiredclear()/dispose()into session teardown. - Tests — a new admission suite covers retry idempotency, the generic-cap interaction, status cycles, LRU eviction, and clear/dispose. This also consumes
isCodexGoalFrameMethod, resolving the prior dead-export nitpick.
I traced the routing end to end: goal frames carry a method with no id, so codex-app-server-record-dispatch.ts routes them through onNotification → notification events, which goals.handle intercepts; the provider-frame arm never sees them, so no dedup path is bypassed. Retry idempotency holds because the journal upserts by identity (agentJournalItemKey), and state is only remembered on full success.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta against the prior pullfrog review)
- Made goal-row identity resume-safe — the item identity is now
codex-goal:<thread>:<signature>:<occurrence>(all SHA-256 digests), so a recreated translator on session resume looks up the durable journal and skips a goal state it already wrote instead of appending a duplicate row. - Added journal-backed lifecycle transitions —
StructuredAgentSessionEventSink.tryAppendLifecycleTransitiondefers the append until the journal binds, then resolves the real identity (or a no-opnull) against the restored journal;appendCodexLifecycleTransitionwraps it with a fallback to the prior append+publish path for sinks without the method. - Added
AgentSessionJournal.latestItemIdMatching— an allocation-free scan of the reduced state that returns the highest-sequence matching item without sorting a full snapshot. - Added resume coverage — a new
codex-structured-journal-goal-resume.test.tssuite (accounting-only updates trigger no scan, backpressure retries stay idempotent, and re-sent statuses don't duplicate after translator recreation) plus journal-store and sink tests for the new surface.
I traced the resume path end to end: parseAgentJournalItemKey round-trips the clientMessageId faithfully (the digest components are :-free, so the :-split in goalStateFromItem is unambiguous), the in-memory occurrence drift after a resume-skip is cosmetic (the journal chain is authoritative for dedup and occurrence is never compared across the two), and both identity forms are fixed-size 64-hex digests so the size guard in tryAppendLifecycleTransition cannot fire.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: e0426bf0-ddda-4cfc-93a5-a953f71801e5
📒 Files selected for processing (7)
src/main/codex/codex-structured-journal-goal-resume.test.tssrc/main/codex/codex-structured-journal-goals.tssrc/main/codex/codex-structured-journal-sink.tssrc/main/native-chat/agent-session-journal/journal-store.test.tssrc/main/native-chat/agent-session-journal/journal-store.tssrc/main/native-chat/agent-session-wire/structured-agent-session-event-sink.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-event-sink.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta against the prior pullfrog review)
- Ignored empty goal-clear snapshots —
persistedGoalIdentitygained arequirePreviousflag, threaded fromhandle()asevent.method === 'thread/goal/cleared'. Athread/goal/clearedthat arrives while resuming a thread whose durable history holds no prior goal now resolves tonulland writes no row, instead of emitting a spuriousGoal cleared. - Regression test —
codex-structured-journal-goal-resume.test.tspins that a cleared snapshot with no prior goal occurrence produces zero writes and zero publishes, before and after journal bind.
The guard sits in the deferred identity resolver, so it applies uniformly to live and resume paths. A genuine clear after a real goal still writes a row because the prior goal item makes previous non-null, so the requirePrevious branch is never taken; a repeat clear is still caught by the existing previous?.signature === signature dedup. I traced state.items (journal-reducer.ts) to confirm it is only pruned by tombstone or epoch replacement, not by DB compaction, so latestItemIdMatching reliably retains prior goal evidence for the normal path.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta against the prior pullfrog review)
- Preserved goal rows across Codex rewinds —
structured-rewind-retained-turns.tsis nowstructured-rewind-retained-host-rows.ts;isRetainedHostLifecycleRowrecognizes both turn rows and goal rows, andmergeRetainedHostLifecycleRowssplices each back beside the provider item it followed. - Fixed the rewind-recovery proof —
expectedItemsnow filters retained items toprovider === 'codex' && threadId === target.threadIdinstead of!isRetainedTurnRow, so host-owned rows no longer poison the provider-proof comparison. - Dropped
tokenBudgetfrom the goal signature — rows are keyed on the visible objective and status only, so a budget-only change no longer emits a duplicate row. - Replaced
latestItemIdMatchingwith epoch-cached durable state —CodexJournalGoalsseedsdurableStateByThreadonce per journal epoch via the newAgentSessionJournal.visitItems, clears transient state on epoch roll (rewind), and the sink exposesjournalEpoch()to detect that roll.
I traced the rewind paths end to end: every host-written row (turn provider:'legacy'; goal, generic-frame, compaction, prompt, subagent, exit-settlement, and non-message codex items provider:'orca') is excluded by the new provider === 'codex' filter, leaving exactly the message items Codex re-emits, so the proof matches by construction. Epoch detection is correct on both live and deferred paths (journalEpoch() returns null while unbound, and seedDurableState re-scans when durableEpoch !== journal.epoch).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Final review statusFinal head:
Remaining visual gaps are limited to accounting-only repeats, clear/pause/block/limit rows, restart/resume/rewind, and SSH. Applicable paths have focused test coverage; no code or Electron defect remains. |
|
Electron QA at In a real structured Codex chat (GPT-6-Astra, Medium), requested creation of “Verify 2 + 2 equals 4”, then completion after checking the arithmetic. The rendered transcript shows exactly one Goal set row and one Goal complete row, separate from assistant prose. Both raw disclosures open successfully. Durable journal sequences 5 and 6 contain Remaining gaps: this short live run did not independently capture an accounting-only notification repeat, clear/pause/block/limit transitions, restart/resume/rewind, or SSH. No claim of live coverage for those cases. Screenshots were inspected directly; Gemini was not used. |
|
Additional Typed Both raw disclosures match durable This closes the slash-picker/composer coverage gap; the other limitations in the earlier QA note remain. No code changes. |






Before / After
Before: when a goal was set on a Codex chat, nothing in the transcript said so. The only trace was the model's own prose — and that prose can be false. Driving the app-server directly produced a session where the model wrote "Goal created: keep the current scratch directory tidy" while the server held no goal at all. A reader had no way to tell a real goal from a claimed one.
After: a row appears when a goal is set, when its status changes, and when it is cleared —
Goal set: <objective>,Goal complete: <objective>,Goal cleared. The row is written from the provider's own notification, so it is evidence rather than a claim. Codex re-sends the same goal as its token counters climb; those repeats are suppressed, so only a change a reader would notice produces a new row.Visual proof
A real Codex structured chat in the app on this branch. The goal was created by asking Codex in prose ("Set a goal for this session: keep the scratch directory tidy…"), which makes the model call
create_goalitself. Typing/goalis still refused on the structured route on this branch — "/goal is not available in chat sessions" — that refusal is a different PR's fix.Codex set the goal, did the work, and closed it out, so one turn produced both rows:
The same session with each row's disclosure open, showing the
thread/goal/updatedframe the row was written from. Between the two frames the counters climbed (tokensUsed0 → 12126,timeUsedSeconds0 → 33) whilestatuswentactive→complete, so the second row exists because the status changed — exactly the distinction the signature is keyed on.Problem
Codex never emits the model's
create_goalcall as an item, sothread/goal/updatedis the only truthful evidence that a goal exists. Both goal notifications were classifiedstatus-chrome, which meant no typed handler read them and no row was written. The only thing that reached the reader was the model's prose — which, in the session above, described a goal thatthread/goal/getsaid did not exist.Change
Classify
thread/goal/updatedandthread/goal/clearedastimeline-substantive, and give them a sentence — the same shape this file already uses for compaction and config warnings.Goal set:,Goal paused:,Goal blocked:,Goal complete:,Goal stopped — usage limit,Goal stopped — token budget spent.Goal updated: <objective>rather than falling back to the bare opcode, which is what a plain reclassify would have produced.Deduped on what a reader would notice. Codex re-sends the goal as its token and time counters climb — a live session sent the same goal three times in one turn with only accounting moving — so rows are keyed on the visible objective and status; budget and accounting remain available in the raw disclosure without creating identical transcript rows. Without this the transcript would gain a duplicate row every time accounting ticked.
Verification
Payload shapes in the tests are taken from a live Codex app-server session, not invented.
codex-goal-journal-rows.test.ts— sentence per status, unknown-status fallback, cleared, missing objective, and the signature ignoringtokensUsed/timeUsedSeconds/updatedAtwhile separating the visible objective and status.codex-structured-journal-goal-rows.test.ts— one row on appearance, no repeat while counters climb, a new row on status or objective change, cleared-then-new-goal, per-thread isolation, and non-goal frames still unaffected.unhandled-provider-frame.test.tsasserted goal frames were routed away from the timeline. That is the behaviour this PR reverses, so it is removed deliberately rather than adjusted.pnpm tcexit 0 ·pnpm run check:code-quality:changed0 new findings across 6 files ·pnpm test src/main/codex src/main/native-chat/agent-session-wireotherwise green.The new file now writes its signature separator as
\^@rather than a raw NUL byte. The raw byte made git classify the file as binary, so its diff was hidden from review and its 70 lines were counted as 0 by the LoC summary above. The string built at runtime is unchanged.Note for whoever sees CI red
codex-app-server-connection.test.ts > surfaces a synchronous 'server request' handler failure as a terminal exitis timing-flaky on main, not from this change. Interleaved runs on the same machine: base failed 2 of 4 while this branch passed 4 of 4; across all runs base was 2/13 and this branch 2/10. Worth a separate look.