Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(codex): surface active goals in thread status #8615

Closedmerged-clem(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/8615/headopened View on GitHub

Codex can report an active goal, but that information was not reflected in durable thread status or the thread list. This makes a goal-backed background task look indistinguishable from an idle thread.

This adds Codex goal lifecycle ingestion, derives the appropriate background liveness state, and renders that state in the web sidebar and mobile thread list. It also covers lifecycle transitions and the relevant status projections.

Testing:

  • pnpm exec vp test run apps/server/src/provider/Layers/CodexAdapter.test.ts apps/server/src/orchestration/ThreadBackgroundLiveness.test.ts apps/web/src/components/Sidebar.logic.test.ts apps/mobile/src/features/threads/threadListV2.test.ts
  • 206 tests passed

Model: GPT-5.6-Terra Harness: Codex


Note

Medium Risk Changes Codex provider event mapping, in-memory liveness derivation, and cross-platform thread status UI; incorrect goal or priority logic could mislabel threads but does not touch auth or persisted data.

Overview Codex durable thread goals now flow from provider notifications into thread status so settled threads with an active goal no longer look idle.

The stack adds canonical thread.goal.updated / thread.goal.cleared events (contracts + Codex adapter), hydrates goal state on session reconnect via thread/goal/get, and feeds ThreadBackgroundLiveness with a new goal tier (below working/monitoring, above null). Runtime ingestion maps goal lifecycle into that registry.

Web and mobile thread lists, sidebar pills, and the chat background-liveness banner show "Goal active" (and existing monitoring labels where added on mobile v2) using the extended backgroundLiveness field on thread shells. Status resolvers keep errors and live sessions ahead of stale background state.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6e895f878c92717c65845aadebed65cec1cb3ed8. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add goal and monitoring background liveness to thread status across server, web, and mobile

  • Server maps Codex thread/goal/updated and thread/goal/cleared provider notifications into canonical runtime events in CodexAdapter.ts, and records them via ThreadBackgroundLivenessService.recordGoalLiveness in ProviderRuntimeIngestion.ts
  • ThreadBackgroundLiveness now tracks a per-thread goals set; precedence is agents > monitors > goals, so a goal only surfaces when no agent or monitor is live
  • CodexSessionRuntime.ts queries thread/goal/get on session ready to hydrate existing goal state without waiting for a provider notification
  • Contracts in providerRuntime.ts add thread.goal.updated / thread.goal.cleared event schemas, and orchestration.ts extends backgroundLiveness with 'goal'
  • Web sidebar, chat banner, and mobile thread list now render a non-pulsing 'Goal active' status pill when backgroundLiveness is 'goal'
  • Behavioral Change: resolveThreadListV2Status, resolveThreadStatus, and resolveSidebarThreadStatus may now return 'goal' or 'monitoring' where they previously returned 'ready' for quiescent threads; session errors and active input/approval checks still take precedence
📊 Macroscope summarized 6e895f8. 12 files reviewed, 3 issues evaluated, 0 issues filtered, 3 comments posted

🗂️ Filtered Issues

    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: ee86716d-660d-4d4c-b022-2edd97f3dc4b

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Comment `@coderabbitai help` to get the list of available commands.
    2. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented

      Codex Review Summary

      This comment shows the latest Codex review activity on this pull request.

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-08-29T04:20:10.020431Z6e895f8PR opened
      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review" or "@codex security review".

      Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    3. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/6e895f878c92717c65845aadebed65cec1cb3ed8/apps/server/src/orchestration/ThreadBackgroundLiveness.ts#L164

      clearThreadLiveness removes active provider goals, so a session/closed event makes a durable goal appear idle until a later reconnect hydrates it. Clear only the agent and monitor sets here, preserving goals until its goal-cleared event.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/orchestration/ThreadBackgroundLiveness.ts around line 164:
      
      `clearThreadLiveness` removes active provider goals, so a `session/closed` event makes a durable goal appear idle until a later reconnect hydrates it. Clear only the agent and monitor sets here, preserving `goals` until its goal-cleared event.
      @@ -2256,3 +2257,9 @@
      22562257 } satisfies ProviderSession;
      22572258 yield* Ref.set(sessionRef, session);
      22582259 yield* emitSessionEvent("session/ready", "Codex App Server session ready.");
      2260+ // Goals are durable Codex thread state, unlike a live turn. Hydrate the
      2261+ // shell after reconnect so a settled thread does not lose its truthful
      2262+ // Goal active indication until the next goal notification arrives.
      2263+ const goalResponse = yield* client
      2264+ .request("thread/goal/get", { threadId: providerThreadId })
      2265+ .pipe(Effect.option);
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High Layers/CodexSessionRuntime.ts:2265

      start can hang indefinitely after a successful thread/start or thread/resume because thread/goal/get awaits an unbounded response; an app server that accepts but never answers this optional hydration RPC prevents every affected session from opening. Bound this request (and keep hydration best-effort) with a timeout before converting failures to Option.none.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/Layers/CodexSessionRuntime.ts around line 2265:
      
      `start` can hang indefinitely after a successful `thread/start` or `thread/resume` because `thread/goal/get` awaits an unbounded response; an app server that accepts but never answers this optional hydration RPC prevents every affected session from opening. Bound this request (and keep hydration best-effort) with a timeout before converting failures to `Option.none`.
      @@ -2256,3 +2257,7 @@
      22562257 } satisfies ProviderSession;
      22572258 yield* Ref.set(sessionRef, session);
      22582259 yield* emitSessionEvent("session/ready", "Codex App Server session ready.");
      2260+ // Goals are durable Codex thread state, unlike a live turn. Hydrate the
      2261+ // shell after reconnect so a settled thread does not lose its truthful
      2262+ // Goal active indication until the next goal notification arrives.
      2263+ const goalResponse = yield* client
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Layers/CodexSessionRuntime.ts:2263

      A stale thread/goal/get response can re-emit thread/goal/updated after a newer thread/goal/cleared or goal update, causing the UI to show an active goal that no longer exists. Because the snapshot is emitted unconditionally after the request resolves, serialize hydration with live notifications or discard the snapshot when a newer goal event has been handled.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/Layers/CodexSessionRuntime.ts around line 2263:
      
      A stale `thread/goal/get` response can re-emit `thread/goal/updated` after a newer `thread/goal/cleared` or goal update, causing the UI to show an active goal that no longer exists. Because the snapshot is emitted unconditionally after the request resolves, serialize hydration with live notifications or discard the snapshot when a newer goal event has been handled.
    5. UI consistency review of the web changes for the new goal background-liveness state. One concrete interaction regression in the composer banner, plus a formatting note in Sidebar.tsx. The sidebar status/pill additions themselves match the existing Working/Monitoring treatment.

      Posted via Macroscope — UI Consistency
      @@ -4727,5 +4728,7 @@
      47274728 ? liveCount > 0
      47284729 ? `${liveCount} ${liveCount === 1 ? "agent" : "agents"} working`
      47294730 : "Background work"
      4730- : "Monitoring",
      4731+ : goal
      4732+ ? "Goal active"
      4733+ : "Monitoring",
      47314734 actions: (

      The banner now renders for backgroundLiveness === "goal", but its Stop action still calls interruptThreadTurn, which cannot end a durable Codex goal: nothing in the app calls thread/goal/clear, and server-side recordGoalLiveness only clears on a thread.goal.updated/thread.goal.cleared notification (or session.exited). So pressing Stop on a goal-only thread either leaves the button permanently disabled at "Stopping..." — the reset effect only fires when activeBackgroundLiveness turns null — or toasts "Failed to stop background work." Suppressing the action for the goal state is the smaller correct behavior until a goal-clearing path exists.

      -      actions: (
      +      // A durable goal is not a live turn: interrupting cannot clear it, so
      +      // Stop would hang on "Stopping..." forever.
      +      actions: goal ? undefined : (
               <Button
      Posted via Macroscope — UI Consistency
      @@ -877,3 +881,4 @@
      877881 icon: null,
      878882 className: "text-sky-600 dark:text-sky-400",
      879883 }
      884+ : status === "goal"
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Inserting this branch shifts the chain one level deeper, but the following branches (: status === "approval" onward) keep their old indentation, so the file is no longer formatter-clean and pnpm fmt:check will fail. Running pnpm fmt re-indents the remainder of the ternary chain.

      Posted via Macroscope — UI Consistency
    6. Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).

      Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6e895f878c92717c65845aadebed65cec1cb3ed8. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -1923,3 +1923,18 @@
      19231923 }
      19241924 }
      19251925
      1926+ if (event.type === "thread.goal.updated") {
      1927+ threadBackgroundLiveness.recordGoalLiveness({
      1928+ threadId: thread.id,
      1929+ goalId: "provider-goal",
      1930+ status: event.payload.status,
      1931+ });
      1932+ }
      1933+
      1934+ if (event.type === "thread.goal.cleared") {
      1935+ threadBackgroundLiveness.recordGoalLiveness({
      1936+ threadId: thread.id,
      1937+ goalId: "provider-goal",
      1938+ status: "complete",
      1939+ });
      1940+ }

      Goal liveness never reaches clients

      High Severity

      thread.goal.updated and thread.goal.cleared only call recordGoalLiveness and never dispatch an orchestration command. Shell upserts only happen after events like thread.activity.append or thread.session.set, so connected sidebars and thread lists keep the previous status. Reconnect hydration is worse: session/ready upserts first without the goal, then the synthetic thread/goal/updated writes memory only.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6e895f878c92717c65845aadebed65cec1cb3ed8. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -4727,4 +4728,6 @@
      47274728 ? liveCount > 0
      47284729 ? `${liveCount} ${liveCount === 1 ? "agent" : "agents"} working`
      47294730 : "Background work"
      4730- : "Monitoring",
      4731+ : goal
      4732+ ? "Goal active"
      4733+ : "Monitoring",

      Stop cannot clear an active goal

      Medium Severity

      The composer banner now treats goal like other background liveness and offers Stop via interruptThreadTurn. That interrupt only kills live tasks and the turn; nothing maps it to a Codex goal clear. If the request is accepted and backgroundLiveness stays goal, Stopping... remains until some other event clears liveness.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6e895f878c92717c65845aadebed65cec1cb3ed8. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -111,0 +129,21 @@
      129+ label: "Monitoring",
      130+ pillClassName: "bg-adaptive-sky-500-a12-a16",
      131+ textClassName: "text-adaptive-sky-700-300",
      132+ iconColor: "#0a84ff",
      133+ iconBackground: "rgba(10,132,255,0.22)",
      134+ pulse: false,
      135+ };
      136+ }
      137+
      138+ if (thread.backgroundLiveness === "goal") {
      139+ return {
      140+ kind: "goal",
      141+ label: "Goal active",
      142+ pillClassName: "bg-adaptive-sky-500-a12-a16",
      143+ textClassName: "text-adaptive-sky-700-300",
      144+ iconColor: "#0a84ff",
      145+ iconBackground: "rgba(10,132,255,0.22)",
      146+ pulse: false,
      147+ };
      148+ }
      149+

      Goal status hides mobile plan prompt

      Medium Severity

      resolveThreadStatus now checks backgroundLiveness before the actionable plan prompt, so a plan-ready thread with an active goal renders Goal active instead of Plan Ready. The web pill keeps plan-ready above lingering liveness because the plan still needs a user decision.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6e895f878c92717c65845aadebed65cec1cb3ed8. Configure [here](https://www.cursor.com/dashboard/bugbot).
    7. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 6e895f878c

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -1923,3 +1923,9 @@
      19231923 }
      19241924 }
      19251925
      1926+ if (event.type === "thread.goal.updated") {
      1927+ threadBackgroundLiveness.recordGoalLiveness({
      1928+ threadId: thread.id,
      1929+ goalId: "provider-goal",
      1930+ status: event.payload.status,
      1931+ });

      P1 Badge Publish goal liveness transitions to shell subscribers

      When a goal notification arrives without another orchestration event—for example, an active goal changes status while its turn is already settled—this only mutates the in-memory registry. Shell WebSocket subscriptions are driven by orchestrationEngine.streamDomainEvents, so no refetch is triggered and connected web/mobile clients retain the old status until an unrelated thread event occurs. Emit a shell-visible domain event or otherwise invalidate subscribers after both goal updates and clears.

      AGENTS.md reference: AGENTS.md:L19-L21

      Useful? React with 👍 / 👎.

      @@ -4713,3 +4713,4 @@
      47134713 return null;
      47144714 }
      47154715 const working = activeBackgroundLiveness === "working";
      4716+ const goal = activeBackgroundLiveness === "goal";

      P1 Badge Clear the durable goal instead of interrupting an absent turn

      When this branch renders Goal active, the turn is settled by construction (activeBackgroundLiveness is hidden while isWorking), but the inherited Stop action calls thread.turn.interrupt. Codex's interruptTurn returns successfully when there is no active turn and never calls thread/goal/clear, so the goal remains active while the button stays disabled as “Stopping...” indefinitely. Wire this state to goal clearing (or omit the Stop action) rather than treating it as ordinary background turn work.

      AGENTS.md reference: AGENTS.md:L73-L73

      Useful? React with 👍 / 👎.

    8. Closing until the fork implementation has completed end-to-end verification.

    9. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR adds a cross-layer Codex goal capability, including new lifecycle events, reconnect-time RPC hydration, server liveness state, and web/mobile UI behavior. The unresolved comments identify risks around startup hangs, stale or unpropagated status, and a Stop action that cannot clear goals, so the runtime and interaction paths need human review.

      Not approved because:

      • 3 blocking correctness issues found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.