Repository navigation
feat(native-chat): show a Codex chat's goal above the composer, and set it from goal mode - #22377
Conversation
…t it from goal mode Structured Codex chat now treats the thread goal as session state: a banner above the composer shows the current goal (pursuing / paused) with clear, pause/resume and expand; /goal enters a goal mode whose send calls thread/goal/set; the objective is journaled as a user message marked as sent as a goal. The banner is derived from the journaled goal rows, which Codex's resume snapshot refreshes, so a reopened or adopted chat shows its goal. Fixes STA-8159
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 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:
📝 WalkthroughWalkthroughThis change adds thread-goal support to structured sessions. It defines goal data and journal transitions, reads and tracks Codex goal frames, and exposes set, pause, resume, and clear operations through the host and RPC. Native Chat adds Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to Older chat history can show stale goal information, and retrying an uncertain goal request can repeat provider work. Resolve these goal and paging behaviors before merging; the smaller command and test gaps also remain. 🚥 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: fa5e9d01-a894-46d4-b9d9-226190d6d089
⛔ Files ignored due to path filters (1)
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (57)
src/main/codex/codex-goal-journal-rows.tssrc/main/codex/codex-structured-journal-goal-resume.test.tssrc/main/codex/codex-structured-journal-goal-revision.test.tssrc/main/codex/codex-structured-journal-goal-rows.test.tssrc/main/codex/codex-structured-journal-goals.tssrc/main/codex/codex-structured-session-adapter.tssrc/main/codex/codex-structured-thread-goal.test.tssrc/main/codex/codex-structured-thread-goal.tssrc/main/native-chat/agent-session-journal/journal-store.tssrc/main/native-chat/agent-session-wire/structured-agent-session-adapter-router.tssrc/main/native-chat/agent-session-wire/structured-agent-session-adapter.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host-mutations.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host.tssrc/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.tssrc/main/native-chat/agent-session-wire/unhandled-provider-frame.tssrc/main/runtime/rpc/methods/structured-agent-session-gate-classification.test-fixture.tssrc/main/runtime/rpc/methods/structured-agent-session-rpc.test-fixture.tssrc/main/runtime/rpc/methods/structured-agent-session-schemas.tssrc/main/runtime/rpc/methods/structured-agent-session-thread-goal.tssrc/main/runtime/rpc/methods/structured-agent-session.test.tssrc/main/runtime/rpc/methods/structured-agent-session.tssrc/renderer/src/components/native-chat/NativeChatComposer.tsxsrc/renderer/src/components/native-chat/NativeChatComposerActions.tsxsrc/renderer/src/components/native-chat/NativeChatComposerField.tsxsrc/renderer/src/components/native-chat/NativeChatComposerGoalChip.tsxsrc/renderer/src/components/native-chat/NativeChatMessageList.tsxsrc/renderer/src/components/native-chat/NativeChatMessageRow.test.tsxsrc/renderer/src/components/native-chat/NativeChatMessageRow.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/NativeChatThreadGoalBanner.test.tsxsrc/renderer/src/components/native-chat/NativeChatThreadGoalBanner.tsxsrc/renderer/src/components/native-chat/native-chat-composer-types.tssrc/renderer/src/components/native-chat/native-chat-thread-goal-presentation.tssrc/renderer/src/components/native-chat/native-chat-thread-goal-rows.test.tssrc/renderer/src/components/native-chat/native-chat-thread-goal-rows.tssrc/renderer/src/components/native-chat/use-native-chat-composer-submit.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-composer-submit.tssrc/renderer/src/components/native-chat/use-native-chat-structured-composer-send.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-structured-composer-send.tssrc/renderer/src/components/native-chat/use-structured-agent-session-options.tssrc/renderer/src/components/native-chat/use-structured-agent-session-thread-goal.tssrc/renderer/src/components/native-chat/use-structured-agent-session.tssrc/renderer/src/i18n/locales/en.jsonsrc/shared/agent-session-journal-schemas.test.tssrc/shared/agent-session-journal-schemas.tssrc/shared/agent-session-journal-types.tssrc/shared/agent-session-thread-goal.test.tssrc/shared/agent-session-thread-goal.tssrc/shared/agent-session-wire.tssrc/shared/native-chat-types.tssrc/shared/rpc-contract/structured-agent-session-params.tssrc/shared/structured-agent-session-composer.test.tssrc/shared/structured-agent-session-composer.tssrc/shared/structured-agent-session-projection.tstests/e2e/cross-version-wire/structured-agent-session-host-fixture.tstests/e2e/cross-version-wire/structured-agent-session-surface-manifest.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| } catch (error) { | ||
| await withdrawObjective() | ||
| throw error | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Keep the objective row when the provider call throws; the goal may already be active.
The adapter contract says a throw from changeThreadGoal leaves the effect unknown. changeCodexThreadGoal rethrows timeouts and transport losses, and Codex can already have set the goal when that happens. An active goal starts provider work at once. This catch block still tombstones the objective row. The provider can then work toward a goal that the transcript no longer shows as "Sent as goal". A retry reruns the change because replay returns null for non-succeeded outcomes. That rerun re-upserts a row that was already tombstoned.
Withdraw the objective only when the provider explicitly refuses (!result.ok). On a throw, keep the row and rethrow, so the mutation records an unknown outcome. Update the test "removes the objective when the provider request fails outright" to match.
🐛 Proposed fix
- let result: Awaited<ReturnType<typeof ctx.adapter.changeThreadGoal>>
- try {
- result = await ctx.adapter.changeThreadGoal({
- sessionId: ctx.sessionId,
- fence: ctx.fence,
- change
- })
- } catch (error) {
- await withdrawObjective()
- throw error
- }
+ // A throw leaves the provider effect unknown; the goal may be active, so keep the objective.
+ const result = await ctx.adapter.changeThreadGoal({
+ sessionId: ctx.sessionId,
+ fence: ctx.fence,
+ change
+ })There was a problem hiding this comment.
Important
A new client talking to an older remote host hides every Codex goal row from the transcript while the replacement banner cannot render, so goal state disappears entirely for that chat. One regression plus two nits; details inline.
Reviewed changes
- Typed goal state. Journal status rows carry an optional
threadGoal({ state: 'set', goal } | { state: 'cleared' });currentAgentSessionThreadGoalderives the latest transition by sequence andagentSessionThreadGoalElapsedSecondsextrapolates only while a goal is active and a turn runs. - Codex writer / revisions.
thread/goal/updated|clearedframes are parsed into the typed snapshot; counter-only updates revise the existing row in place (same identity) under a 30s throttle viaaccountingOutgrew, and durable state reseeds accounting from the journal. agentSession.threadGoalsession action. Set/pause/resume/clear flow through the standard admission, ledger, and journal path; asetwrites the objective as asentAs: 'goal'user row before the provider request and tombstones it when the provider refuses or the request throws.- Wire additions. Optional
threadGoalon theagentSession.optionsresult (only wheresupportsThreadGoal), an open schema forsentAsand goal state, a 4000-char objective cap, and the method-count / cross-version fixtures. - Renderer. Goal banner above the composer, goal mode via
/goal(picker interception, chip, placeholder), the "Sent as goal" message marker, and omission of goal rows from structured transcripts.
ℹ️ Nitpicks
use-native-chat-composer-submit.ts:47comparesitem.name !== 'goal'verbatim, whileisStructuredAgentSessionGoalCommandlowercases throughcommandParts; a host catalog reportingGoalwould miss goal mode. Curated catalogs use lowercase, so this is cosmetic.isAgentSessionThreadGoalOpen(src/shared/agent-session-thread-goal.ts:72) is exported but only referenced by its own test — the banner usesnativeChatThreadGoalStatusLabel(...) === nullinstead. Either use it or drop it until the mobile banner lands.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| const messages = useMemo(() => { | ||
| const projected = projectNativeChatTaskListFrames(projectMessages(session.messages)) | ||
| // Structured sessions show goal state in the banner above the composer. | ||
| return journalItems ? omitNativeChatThreadGoalRows(projected) : projected |
There was a problem hiding this comment.
The omit gate keys on journalItems, which is always a truthy array for a structured session, not on whether the host can supply the replacement banner. A new client connected to an older remote host therefore strips every grey Goal set:/Goal cleared: row while controller.threadGoal is null, so goal state vanishes entirely — the mixed-version case the wire-compat rules treat as normal.
Technical details
# Goal rows are hidden even when no banner replaces them
## Affected sites
- `src/renderer/src/components/native-chat/NativeChatMessageList.tsx:141` — filter applied whenever `journalItems` is present, which is every structured session.
- `src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx:326` — banner renders only when `controller.threadGoal?.goal` is set.
- `src/renderer/src/components/native-chat/use-structured-agent-session-thread-goal.ts:55` — returns null when the options result omits `threadGoal`.
- `src/main/native-chat/agent-session-wire/structured-agent-session-host-mutations.ts:186` — host reports `threadGoal` only when `supportsThreadGoal` exists.
## Required outcome
- A structured Codex session on a host that cannot report the goal keeps its goal rows visible (or otherwise surfaces goal state) instead of losing both.
## Suggested approach (optional)
- Gate the omit on the same predicate that gates the banner (e.g. pass `threadGoal !== null` / a `showThreadGoalBanner` flag), so rows are suppressed only where the banner exists.
## Open questions for the human (optional)
- If hiding rows on old hosts is intentional, is that acceptable given `/goal` still falls back to prose there?…ver a lost goal-change response - A set while the journal records a goal (any status) clears it before setting, so the new goal starts with its own time and token counters instead of rewriting the old goal's objective in place. - The threadGoal plan answers an unknown outcome from the goal the journal records and reruns otherwise, so one request timeout no longer refuses every later Clear/Pause/Resume as unknown for the mounted session. - The goal-mode chip says "Exit goal mode"; "Clear goal" stays the banner's action on the provider goal. - A typed bare /goal on Enter enters goal mode, the same as picking it. - The renderer reads the goal off the tail of its ordered snapshot; the host's unordered map keeps the by-sequence reader. - Drop the composer's duplicate in-flight guard; the goal controller already serializes changes. - Pin that a counter-only revision reaches a subscriber's live page under its original sequence.
There was a problem hiding this comment.
ℹ️ No new issues in this delta. The two commits since the prior review are a focused, well-tested fix; the earlier mixed-version omission concern is still open in its inline thread.
Reviewed changes — re-reviewed the delta since the prior pullfrog review (56db245).
- Goal replacement clears first: a
seton a thread whose journal already records a goal (any status) now emitsthread/goal/clearbeforethread/goal/set, so the new goal starts from zero counters instead of inheriting the old goal's timer and token count. The clear is sent inline and a refused clear stops before the set, leaving the old goal intact. - Lost-response recovery:
agentSession.threadGoalnow setsrecoverUnknownFromDurableStateand arerunWhenReplayMissingpredicate. Anunknownoutcome is answered from the journal viajournalRecordsThreadGoalChange(clear → goal is null, status → status matches, set → recorded objective matches while active); anything else reruns. Reruns upsert the same objective row, which outranks its tombstone, and per-session serialization keeps concurrent changes ordered. - Rendered-snapshot goal read:
currentAgentSessionThreadGoalscans a rendered snapshot backwards instead of taking the max sequence; the unordered variant moved tocurrentAgentSessionThreadGoalBySequencefor the host journal map. Safe because the renderer reducer always sorts items by sequence and revisions keep their sequence. - Composer goal mode: the bare
/goaltoken now enters goal mode like the picker does; the chip label became "Exit goal mode" so it is not confused with the banner's "Clear goal"; the submit guard now relies on the controller's pending serialization.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: af1d9b26-4d6f-4548-bcb9-5640b0b0a24f
📒 Files selected for processing (15)
src/main/codex/codex-structured-journal-goal-revision.test.tssrc/main/codex/codex-structured-session-adapter.tssrc/main/codex/codex-structured-thread-goal.test.tssrc/main/codex/codex-structured-thread-goal.tssrc/main/native-chat/agent-session-journal/journal-store.tssrc/main/native-chat/agent-session-wire/structured-agent-session-adapter.tssrc/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.tssrc/renderer/src/components/native-chat/NativeChatComposerGoalChip.tsxsrc/renderer/src/components/native-chat/use-native-chat-composer-submit.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-composer-submit.tssrc/renderer/src/i18n/locales/en.jsonsrc/shared/agent-session-thread-goal.test.tssrc/shared/agent-session-thread-goal.tssrc/shared/structured-agent-session-composer.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/native-chat/agent-session-journal/journal-store.ts
- src/renderer/src/components/native-chat/NativeChatComposerGoalChip.tsx
- src/renderer/src/i18n/locales/en.json
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| for (const request of codexThreadGoalRequests(session.threadId, change, replacesGoal)) { | ||
| await session.connection.request(request.method, request.params, { timeoutMs }) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
A refused set after a successful clear is reported as a plain refusal.
When replacesGoal is true, the loop sends thread/goal/clear first. If thread/goal/set then throws CodexAppServerRequestError, the function returns { ok: false, rejected }. The adapter contract says rejected means the provider refused the change. In this case the provider already cleared the previous goal, including its status and usage counters.
performThreadGoalChange tombstones the objective and shows the refusal message. The user reads this as "nothing changed," but the old goal has disappeared from the goal bar.
Tell the caller when a replacement cleared the old goal before it was refused. For example, add the fact to the rejected message so the user is not told nothing changed.
Proposed fix
- try {
- for (const request of codexThreadGoalRequests(session.threadId, change, replacesGoal)) {
- await session.connection.request(request.method, request.params, { timeoutMs })
- }
- return { ok: true }
- } catch (error) {
- if (isCodexAppServerRequestError(error)) {
- return { ok: false, rejected: error.message }
- }
- throw error
- }
+ let cleared = false
+ try {
+ for (const request of codexThreadGoalRequests(session.threadId, change, replacesGoal)) {
+ await session.connection.request(request.method, request.params, { timeoutMs })
+ cleared ||= request.method === 'thread/goal/clear'
+ }
+ return { ok: true }
+ } catch (error) {
+ if (isCodexAppServerRequestError(error)) {
+ const rejected = cleared
+ ? `${error.message} (the previous goal was already cleared)`
+ : error.message
+ return { ok: false, rejected }
+ }
+ throw error
+ }| // A lost response is answered from the journal, which the provider keeps | ||
| // current; otherwise the change runs again, which is safe for every kind. | ||
| recoverUnknownFromDurableState: true, | ||
| replay: (ctx, outcome) => | ||
| outcome.status === 'succeeded' || | ||
| (outcome.status === 'unknown' && | ||
| journalRecordsThreadGoalChange(ctx.journal.threadGoal(), params.change)) | ||
| ? value | ||
| : null, | ||
| rerunWhenReplayMissing: () => true |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
An unknown set reruns and repeats provider work if the goal is no longer active.
The comment says a rerun "is safe for every kind." A rerun is not safe for set. If the set response is lost, the provider may already have started the goal, because an active goal starts work at once.
Before recovery runs, the user can pause the goal, or the provider can finish it (complete). journalRecordsThreadGoalChange then returns false, so rerunWhenReplayMissing runs performThreadGoalChange again. That rerun computes replacesGoal: true, sends thread/goal/clear, and sets the same objective as a new active goal. The provider runs the same work twice, for example editing files or running commands again.
For set, treat the change as applied when the journal holds a goal with the same objective, whatever its status. Update the test at lines 258-264 to match.
Proposed fix
case 'set':
- return goal !== null && goal.status === 'active' && goal.objective === change.objective
+ // Any status: a lost set may already have run, then paused or completed.
+ return goal !== null && goal.objective === change.objective- // A lost response is answered from the journal, which the provider keeps
- // current; otherwise the change runs again, which is safe for every kind.
+ // A lost response is answered from the journal, which the provider keeps
+ // current; otherwise the change runs again.… and pin goal delivery and serialization - A bare `/goal` submitted while already in goal mode re-enters the mode instead of setting a goal whose objective is the literal text "/goal". - The counter-only revision pin now drives the host's own event sink bound to a real journal, so it goes red when the publish after a lifecycle transition is dropped; the previous fake sink never published. - Pin that a set which threw after journaling its objective puts that objective back exactly once when the ledger reruns the same operation id. - Cover the goal controller hook: absent without host support, the loaded window wins over the host's answer, a second change while one is unsettled answers false without a request, and a refused change frees the next one.
There was a problem hiding this comment.
ℹ️ No new issues in this delta. The commit since the prior review is a one-line behavior fix plus test hardening; the earlier mixed-version omission concern is still open in its inline thread.
Reviewed changes — re-reviewed the delta since the prior pullfrog review (8563f69).
- Bare
/goalis always the entrance: the composer submit hook now tests for a bare/goaltoken before theactivebranch, so typing/goalwhile already in goal mode re-enters the mode (keeping the chip) instead of setting a goal whose objective is the literal text/goal.activerequiresthreadGoal !== undefined, so the new first branch cannot mask the normalsetGoalpath; no-goal hosts still fall through tosendStructured/sendPtyunchanged, and the bare-token branch was neverdisabled-gated before or after. - Goal-delivery pin now drives the real sink: the counter-only revision test binds the host's own
createDeferredStructuredAgentSessionEventSinkto a real journal and captures the page published to a caught-up subscriber, so a dropped publish after a lifecycle transition goes red (the previous fake sink never published). - Objective revival pin: a
setthat throws after journaling its objective is covered — the ledger rerun of the same operation id revives the tombstonedsentAs: 'goal'row exactly once rather than appending a duplicate. - Goal controller hook coverage: new tests pin null-without-host-support, window-over-host-answer precedence, a second in-flight change answering
falsewithout a request, and a refused change freeing the next one. Assertions are exact and able to fail.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Preserve edits made while setting a goal. · use-native-chat-composer-submit.ts:48-95
src/renderer/src/components/native-chat/use-native-chat-composer-submit.ts:48-95
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPreserve edits made while setting a goal.
threadGoal.pendingdoes not disable the editor. If the user edits the draft whilesetObjectiveis pending, an accepted response clears that later draft and caret. The structured-send hook already checks whether the composition changed before clearing.Suggested fix
-import { useCallback, useMemo, useState } from 'react' +import { useCallback, useMemo, useRef, useState } from 'react' ... const threadGoal = structuredTransport?.threadGoal const [entered, setEntered] = useState(false) + const draftRef = useRef(draft) + const caretRef = useRef(caret) + draftRef.current = draft + caretRef.current = caret const active = entered && threadGoal !== undefined ... const setGoal = useCallback(() => { const objective = draft.trim() + const submittedDraft = draft + const submittedCaret = caret if (!threadGoal || !structuredTransport || objective === '') { return } ... void threadGoal.setObjective(objective).then((accepted) => { if (accepted) { structuredTransport.onError(null) - setHistory((previous) => pushHistory(previous, draft)) + setHistory((previous) => pushHistory(previous, submittedDraft)) + if ( + draftRef.current !== submittedDraft || + caretRef.current !== submittedCaret + ) { + return + } setDraft('') setCaret(0) setEntered(false)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 2c71e174-ea28-42a5-8c48-392e6f11ac06
📒 Files selected for processing (5)
src/main/codex/codex-structured-journal-goal-revision.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.test.tssrc/renderer/src/components/native-chat/use-native-chat-composer-submit.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-composer-submit.tssrc/renderer/src/components/native-chat/use-structured-agent-session-thread-goal.test.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
…al-mode drafts honest - The goal bar offers Resume on a blocked or usage-limited goal, which the provider resumes exactly as it resumes a paused one; a goal whose token budget is spent still offers only Clear. The rule lives beside the other goal facts in shared code so every reader answers it the same way. - A `/goal <text>` typed inside goal mode sets the objective `<text>`, as it does outside goal mode, instead of a goal whose objective is the literal command. - Setting a goal is a host round trip; a draft edited while it was in flight is no longer wiped when the goal lands, matching every other host command. - Pin that a lost status-change response is read as applied only when the recorded goal is in that status, that a cleared row in the loaded window outranks the host's earlier answer, and that the PTY lane is untouched.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Reviewed changes — re-reviewed the delta since the prior pullfrog review (e3c5cbe).
- Stalled and usage-limited goals are resumable.
agentSessionThreadGoalStatusChangecentralizes the status-to-control mapping; the banner now offers Resume forblockedandusageLimited(both mapped to{ kind: 'status', status: 'active' }) while abudgetLimitedorcompletegoal keeps no status control. The provider request path already handles a status-onlythread/goal/set. - A goal-mode draft edited mid-flight survives.
useNativeChatComposerSubmitrecords the submitted draft in a ref and only clears the draft, caret and goal-mode flag when that draft is still current whensetObjectiveresolves, matching the sibling structured-send hook. - A typed
/goal …inside goal mode names the objective.structuredAgentSessionGoalObjectivestrips the command prefix so the host sets the named objective; a bare/goalis still caught earlier as the mode entrance. - Test hardening. Banner resume/clear matrix, the objective parse, the preserved in-flight draft, the PTY-lane passthrough, the clear-in-window-over-host-answer precedence, and the status replay predicate.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| > | ||
| <Pause className="size-3.5" /> | ||
| </GoalAction> | ||
| ) : statusChange === 'active' ? ( |
There was a problem hiding this comment.
usageLimited and budgetLimited both render the label Goal limited (native-chat-thread-goal-presentation.ts:15-17), but this branch now offers Resume for usageLimited only. A user looking at a Goal limited bar cannot tell why one is resumable and the other is not, even though the saved journal rows already distinguish usage limit from token budget spent (codex-goal-journal-rows.ts:24-25). Consider giving budgetLimited its own label and i18n key.
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: 4458f82d-f3d4-41ff-84a3-e4752889f915
📒 Files selected for processing (10)
src/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.test.tssrc/renderer/src/components/native-chat/NativeChatThreadGoalBanner.test.tsxsrc/renderer/src/components/native-chat/NativeChatThreadGoalBanner.tsxsrc/renderer/src/components/native-chat/use-native-chat-composer-submit.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-composer-submit.tssrc/renderer/src/components/native-chat/use-structured-agent-session-thread-goal.test.tsxsrc/shared/agent-session-thread-goal.test.tssrc/shared/agent-session-thread-goal.tssrc/shared/structured-agent-session-composer.test.tssrc/shared/structured-agent-session-composer.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| const command = commandParts(text) | ||
| return command?.name === 'goal' ? command.argument : text.trim() |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,180p' src/shared/structured-agent-session-composer.ts
sed -n '60,145p' src/renderer/src/components/native-chat/use-native-chat-composer-submit.ts
sed -n '35,100p' src/renderer/src/components/native-chat/use-native-chat-structured-composer-send.tsRepository: stablyai/orca
Length of output: 11976
🏁 Script executed:
rg -n -C 5 "dispatchNativeChatStructuredComposerText|structuredAgentSessionGoalObjective|setThreadGoalObjective|setObjective|threadGoal" srcRepository: stablyai/orca
Length of output: 42720
🏁 Script executed:
cat -n src/renderer/src/components/native-chat/native-chat-structured-composer-dispatch.ts
sed -n '35,95p' src/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.ts
rg -n -C 4 "objective" src/main/native-chat/agent-session-wire src/shared/agent-session-wire.ts src/renderer/src/components/native-chat | head -n 180Repository: stablyai/orca
Length of output: 22688
Parse multiline /goal objectives before submission.
For /goal ship\nand verify, commandParts returns null because its argument pattern does not match an interior newline.
In goal mode, structuredAgentSessionGoalObjective passes the trimmed draft, including /goal, to threadGoal.setObjective. In normal dispatch, the draft is not recognized as a host command and is sent as ordinary message text. These are different failures.
Accept multiline arguments in commandParts. Add coverage for both goal-mode submission and normal /goal dispatch.
Suggested fix
- const match = /^\/([^\s]+)(?:\s+(.*))?$/.exec(text.trimEnd())
+ const match = /^\/([^\s]+)(?:\s+([\s\S]*))?$/.exec(text.trimEnd())|
Electron QA on head
“Show full goal” was present as an icon button. I did not click expand/collapse. Light theme: B1 light is the completed transcript after the first goal finished. E1 light is the restored paused bar. |
…n a live revision lands below it A live revision of a row keeps that row's original sequence. When the row is older than the client's loaded window, the shared reducer merged it in and it became the load-older anchor, so paging `before` it skipped every row between. A goal's counter-only revisions during a long goal turn reach any client that attached after the goal row left its window, so a reopened chat lost rows on scroll-back. The reducer now admits live rows only at or above the window's oldest row while older rows remain on the host; the journal keeps the revision and the page reader serves it once the window reaches the row. With nothing older on the host the window is the whole journal, so a row below the head is admitted as before. Also drain accepted provider events before a goal set reads the journal to decide whether it replaces a recorded goal.
There was a problem hiding this comment.
ℹ️ No new issues in this delta. The one commit since the prior pullfrog review is a focused, well-tested fix. The two earlier findings — the mixed-version goal-row omission and the shared
Goal limitedlabel — are untouched by it and remain open in their threads.
Reviewed changes — re-reviewed the delta since the prior pullfrog review (4ec725b).
- Load-older anchor kept on the loaded window.
liveItemsWithinWindowinstructured-agent-session-reducer.tsnow admits a live batch's rows only at or above the window's oldest sequence whilehasOlderis set. A revision of an older row keeps its original sequence, so admitting it had moved the load-older anchor below the window andbeforepaging skipped every row between. The journal keeps the revision and the page reader serves it once the window reaches the row; with nothing older on the host the window is the whole journal, so a revived row below the head is still admitted. - A goal set drains accepted provider events first.
performThreadGoalChangeawaitsctx.flushStreamedEvents()before readingctx.journal.threadGoal()to decidereplacesGoal, so a goal the host accepted but has not journaled yet still counts as a replacement instead of a fresh set. - Tests. New retention cases pin the preserved anchor, the page-reader revision, an in-window revision and the
hasOlder === falserevival; a deferred-sink case pins thereplacesGoal: truedecision. All fail against the pre-commit code.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review status: ready to merge at
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: d4850194-ec12-4265-9403-59eca104e677
📒 Files selected for processing (4)
src/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.tssrc/shared/structured-agent-session-item-retention.test.tssrc/shared/structured-agent-session-reducer.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| requestedCursor: { epoch: 'epoch-a', sequence: 200 }, | ||
| page: page( | ||
| [{ ...item(50), revision: 2 }, ...Array.from({ length: 149 }, (_, i) => item(i + 51))], | ||
| false |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep pagination open while rows 1–49 remain.
The test says the host has rows 1–199 before the loaded window. This page supplies only rows 50–199, but hasOlder: false makes the reducer stop paging. Set hasOlder to true and update the assertion, or include rows 1–49 in this page.
Proposed test correction
- false
+ true
...
- expect(older.hasOlder).toBe(false)
+ expect(older.hasOlder).toBe(true)| if (!head || !state.hasOlder) { | ||
| return incoming | ||
| } | ||
| return incoming.filter((item) => item.sequence >= head.sequence) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
set -eu
printf '%s\n' '--- reducer outline ---'
ast-grep outline src/shared/structured-agent-session-reducer.ts
printf '%s\n' '--- reducer target ---'
sed -n '90,230p' src/shared/structured-agent-session-reducer.ts
printf '%s\n' '--- helper and reducer references ---'
rg -n -C 3 'liveItemsWithinWindow|older-page|hasOlder|sequence' src --glob '*.{ts,tsx}' | head -n 240Repository: stablyai/orca
Length of output: 44914
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 28639
🏁 Script executed:
set -eu
sed -n '100,220p' src/shared/structured-agent-session-reducer.ts
printf '%s\n' '--- references ---'
rg -n -C 4 'liveItemsWithinWindow|older-page|hasOlder' . --glob '!node_modules' --glob '!dist' --glob '!build' | head -n 300Repository: stablyai/orca
Length of output: 32133
🏁 Script executed:
set -eu
printf '%s\n' '--- history reader references ---'
rg -n -C 5 'readAgentSessionHistory|direction.*before|requestedCursor|older-page' src tests/e2e mobile --glob '*.{ts,tsx}' | head -n 320
printf '%s\n' '--- delayed owner test ---'
sed -n '110,210p' tests/e2e/structured-agent-session-read-owner.unit.test.tsRepository: stablyai/orca
Length of output: 41692
🏁 Script executed:
set -eu
printf '%s\n' '--- history page implementation ---'
ast-grep outline src/main/native-chat/agent-session-wire/agent-session-history-page.ts
sed -n '1,260p' src/main/native-chat/agent-session-wire/agent-session-history-page.ts
printf '%s\n' '--- delayed test continuation ---'
sed -n '195,285p' tests/e2e/structured-agent-session-read-owner.unit.test.ts
printf '%s\n' '--- read-owner implementation references ---'
rg -n -C 5 'getStructuredAgentSessionReadOwner|direction.*before|older-page|delayedOlder|requestedCursor' src tests/e2e --glob '*.{ts,tsx}' | head -n 360Repository: stablyai/orca
Length of output: 41324
Reconcile live revisions with in-flight older-page reads.
When readAgentSessionHistory snapshots an older page before a live revision arrives, it can return the older revision. liveItemsWithinWindow then drops the live revision because its original sequence is below head.sequence. The older-page branch can accept the stale page because its head check does not advance, leaving the reducer without that live update. Retain skipped revisions until page merge, or invalidate and retry the affected older-page request.
|
Layout check on The goal bar sits in the same band above the composer as the background-task strip. This frame is an active goal ("Pursuing goal …") directly under an expanded shell row ( |



















ELI5
When you give Codex a goal in a structured chat, Orca now shows that goal in a small bar above the message box, with buttons to pause, resume or clear it. It stays there when you close and reopen the chat, which it didn't before. You can also type
/goalto switch the message box into "goal mode", so what you send becomes the goal instead of a normal message.What Changed
Before: Codex goal changes showed up as grey "Codex · Goal set: …" lines in the chat. When you reopened a Codex session from history, the goal wasn't shown anywhere, so you couldn't tell a goal was active.
/goal <text>was sent to Codex as ordinary message text, and it was up to the model to create the goal.After (structured Codex chat, desktop):
/goal, or typing/goalon its own and pressing Enter, switches the composer into goal mode. A Goal chip appears (hover shows ✕; its label is "Exit goal mode", so it is never confused with the bar's "Clear goal") and the placeholder becomes "Describe your goal, define measurable outcomes for best results". Sending sets the goal through Codex's goal API (thread/goal/set). Codex then starts working on it by itself; no chat message is sent./goal <text>still sets that text as the goal directly, inside goal mode or out of it. If you keep typing while a goal is being set, that text stays in the box once the goal lands.Mechanism:
agentSession.threadGoal. It uses the same admission, deduplication and history path as the other chat session actions.thread/goal/seton a thread that already has a goal rewrites that goal's objective and keeps its id, timer and token count. So when the chat already records a goal (any status, including complete), Orca sendsthread/goal/clearfirst and thenthread/goal/set, and the new goal starts from zero.sentAs: 'goal', before Codex is asked to set the goal. That puts it ahead of the work Codex starts, and keeps the label after a reload. If Codex refuses the goal, or the request fails, the message is removed.Why
The goal describes the chat as a whole, and Codex is the one that keeps track of it. Showing Codex's latest goal report as persistent state fixes the reopen bug at its cause. The alternative was to rebuild goal history from Codex's session files. That keeps a second copy of the goal that can disagree with Codex; it can still say "paused" after the goal was cleared, which we saw during testing.
Where this intentionally differs from reading the goal live from Codex:
/goalfalls back to being sent as text.Linked Issue
Fixes STA-8159 (https://linear.app/stably/issue/STA-8159/codex-chat-ui-omits-persisted-thread-goal-updated-when-reopening-a)
Visual Proof
Before: reopening a goal session showed no goal anywhere; the Linear ticket has the transcript evidence.
After, from a real Electron dev build (fresh profile) with the real Codex CLI:
Goal mode, hovering the chip to clear it:

Goal set: "Sent as goal" label and the "Pursuing goal" bar:

Paused:

After quitting and relaunching the app (dark and light themes):


The exact bug case: a Codex session with a paused goal, opened from Agent Session History into a new chat on a fresh profile:

Testing
I manually tested these changes locally (macOS, Electron dev build, real Codex CLI):
Codex's own records confirmed each goal change.
Automated tests added/updated:
/goalentering goal mode;/goal <text>inside goal mode naming<text>, and a draft edited while the goal was in flight staying put;pnpm tc:nodeandpnpm tc:webpass. Vitest (config/vitest.config.ts) on native-chat, codex, agent-session-wire, rpc methods and shared: 1456 files / 15517 tests pass. The changed-code quality gate and oxlint pass.Not tested visually: expanding a goal too long for one line, and mobile.
AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)