Repository navigation
Conversation
Stopping a Codex thread left its Goal active. Clearing the Goal later resumed the Codex thread first, and Codex continues an active Goal as soon as the thread loads, so a new turn started on the Goal being cleared. The Codex bridge now pauses an active Goal before interrupting the turn, as Codex's own client does. A paused Goal stays paused until the user resumes it: the bridge handles "/goal resume", "/goal pause", and "/goal clear" itself instead of sending them to Codex. Resume binds the goal turn Codex starts to the user's message, and settles the message with an empty turn if Codex starts none. Other "/goal" text still goes to Codex as a prompt. Clearing now accepts a Goal in any status, and the Goal card shows paused, blocked, and usage-limited Goals so they can be cleared. The Goal status schemas accept Codex's blocked and usageLimited statuses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/clearing-a-codex-goal-on-a-stopped-thread-starts-thr_7csui6fdj4
branch
October 29, 2026 22:29
ymichael
added a commit
that referenced
this pull request
Oct 30, 2026
#6684) ## Human comments ## What was wrong Since #6143, the GitHub PR Status plugin saves a link from each environment to its PR and re-reads that URL on later loads. It only looks up the branch again when the branch name changes. When a PR merged and the thread opened a second PR from the same branch, the environment stayed linked to the merged PR forever. For example, a thread whose branch carried merged #6596 and then open #6613 kept showing #6596. Before #6143 every load ran `gh pr view` on the current branch, which prefers an open PR. ## What changed - `plugins/github-pr-status/store.ts`: adds `isSettled(environmentId)`, which says whether the environment's linked PR is merged or closed. `staleAfterMs` now uses it. - `plugins/github-pr-status/server.ts`: `prepareLoad` looks up the branch (`url: null`) instead of reading the saved URL when the linked PR is settled, just as it already does after a branch change. The branch lookup prefers an open PR and otherwise returns the same settled PR, so this takes one GitHub request per load, not two. There are no wire, CLI or SDK changes. Performance, measured against GitHub on the affected branch: a settled link's reload goes from a URL read (~760 ms, 1 rate-limit point) to a branch read (~990 ms, 3 points). Settled PRs are never polled. They reload only when a viewer sees one over an hour old, when a CLI read finds one more than 10 s old, on push, or after a turn that ran `gh`. App viewers are served the cached row immediately and refreshed in the background. ## How you verified - A new `server.test.ts` case checks that a link to a merged PR switches to the branch's newer open PR, with exactly one host read per load. It fails before this change and passes after. - `pnpm exec turbo run test typecheck lint --filter=bb-plugin-bb--github-pr-status` passes (182 tests). - On the real affected branch, the GitHub branch lookup returns #6613 (open) ahead of #6596 (merged). > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 14, 2026
After setting the Goal active the bridge asks Codex which turn is active (a steer with an impossible expected id; Codex queues it behind the goal set and names the active turn in its refusal). The message is accepted into that Goal turn, or settles at once with an empty turn when Codex starts none. /goal pause and clear settle on Codex's reply without a turn. Restores #6596 coverage. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 14, 2026
After setting the Goal active the bridge asks Codex which turn is active (a steer with an impossible expected id; Codex queues it behind the goal set and names the active turn in its refusal). The message is accepted into that Goal turn, or settles at once with an empty turn when Codex starts none. /goal pause and clear settle on Codex's reply without a turn. Restores #6596 coverage. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 17, 2026
After setting the Goal active the bridge asks Codex which turn is active (a steer with an impossible expected id; Codex queues it behind the goal set and names the active turn in its refusal). The message is accepted into that Goal turn, or settles at once with an empty turn when Codex starts none. /goal pause and clear settle on Codex's reply without a turn. Restores #6596 coverage. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Stopping a Codex thread interrupted its turn but left its Goal active. Clearing the Goal afterwards (the Goal card's ✕ or
bb thread clear-goal) first resumes the Codex thread, and Codex 0.164 continues an active Goal as soon as a thread loads (thread/resume→ idle →continue_if_idle). So a new goal turn started in the same moment as the clear, working on the Goal being cleared, while bb showed the thread as idle with no Stop button. An ordinary message after a stop did the same: Codex answered, then went back to the Goal.Related: Codex's
blockedandusageLimitedGoal statuses failed bb's schemas, so those Goals were invisible, and bb had no way to resume a Goal at all (#6551).What changed
All of the Goal behaviour lives in the Codex plugin; core only stops assuming every Goal is active.
Codex plugin (
plugins/provider-codex)bridge.ts: the bridge tracks each thread's Goal status from the goal events it already forwards. When bb stops a turn whose Goal is active, the bridge sendsthread/goal/set {status: "paused", origin: "user"}beforeturn/interrupt, as Codex's own terminal client does. A paused Goal stays paused until the user resumes it.bridge.ts: the bridge handles/goal resume,/goal pauseand/goal clearitself instead of sending them to Codex. bb already offers/goalin the composer for Codex./compactuses. If Codex starts no turn within 5s (it can quietly skip one), the message finishes with an empty turn./goaltext, such as/goal <objective>, still goes to Codex as a prompt.schemas.ts,extension-kinds.ts: acceptblockedandusageLimited.fake-codex-app-server.mjs: supportsthread/goal/setandthread/goal/get, and starts a goal turn on resume./goalcommands.Core
apps/server/src/routes/threads/actions.ts: the clear-goal route accepts a Goal in any status, not just an active one; a stopped thread's Goal is now paused. The 409 message is now "No Goal to clear".apps/server/src/services/threads/thread-runtime-display.ts: addsgetThreadTimelineGoal, which reads the thread's latest Goal.ThreadGoalCard.tsxandCollapsibleActiveStackCard.tsx:packages/domain/src/thread-timeline-goal.ts: adds the two statuses.bb thread clear-goal: the CLI description and the guide line say "the thread's Goal" instead of "the active Goal".There is no
HOST_DAEMON_PROTOCOL_VERSIONbump and no Plugin SDK change.This differs from #6551's proposal: instead of a new REST/SDK/CLI "set Goal" call, you resume with
/goal resume. That's typed in the composer, or sent withbb thread tell <id> "/goal resume".How you verified
Tests
plugins/provider-codex/src/bridge/bridge.goal-controls.test.ts, 7 tests against the fake Codex app-server:turn/interrupt;/goal resumeattaches Codex's goal turn to the message;/goal resumefinishes the message when Codex starts no turn;/goal clearclears without a Codex turn;/goal resumeis rejected for an active Goal;/goaltext reaches Codex unchanged./goaltests fail with the handling switched off.Commands, on the rebased branch
pnpm exec turbo run typecheck lint --filter='...[origin/main]': 153/153 passed.turbo run testforbb-plugin-provider-codex(550),@bb/cli(865, 1 skipped),@bb/templates(46) and@bb/domain(294): all pass.public-thread-banner-actions.test.ts(13) and appcomponents/promptbox/banner(130): all pass.Manual, real app. Two
pnpm start:worktreeservers, this branch and its base (main without the change), with Codex 0.164 and gpt-6-luna. The same steps were run on both through the UI (headless browser) and the sourcebbCLI. File counts come from a goal that writes one numbered file per shell command./goal clear/goal resumebb thread clear-goalwith no Goal409 No active Goal to clear409 No Goal to clearRegression checks on the branch server also passed:
bb thread compact;/goal <objective>reaching Codex as identical text on both builds, checked in Codex's session file.Known limits
/goalcommand shows as a failed message and marks the threaderroruntil the next message, like any failed message./goal pausesent while Codex is running is a steer, so it reaches the model as text.Fixes #6551
🤖 Generated with Claude Code