Repository navigation
Description
Summary
When an agent opens a pull request itself, by running gh pr create or glab mr create through its shell tool, BiBCode doesn't notice. The thread's branch/PR status only picks up the new PR on the next passive summary cycle (30-second deadline) or the next lookup after the open-PR cache expires. Terminal commands and BiBCode's own Create PR already trigger an immediate refresh, but provider tool commands don't.
Trigger the existing local-change refresh as soon as a provider command_execution item settles with a PR/MR create command, so the PR shows up right after the agent prints its URL.
Current behavior (verified at a0ea849ef92b)
The refresh already exists
observe_local_changes(apps/server/src/production/git_vcs.rs:171-199) handles a reported local change for a worktree. It callsinvalidate_open_pull_request_lookups(cwd)and spawnssummary.notify_local_change, skipping the "30-second deadline". Its doc comment names this case: "a command such asgh pr createcan change the hosting service's answer".- Open-PR lookups are cached for
OPEN_PULL_REQUEST_LOOKUP_TTL= 10 s (apps/server/src/source_control/open_pull_request_lookups.rs:43, capacity 64 at:45).
Who triggers it today
- Integrated terminal process exit:
apps/server/src/production/runtime.rs:527-534(set_process_exit_callback→status_broadcaster.notify_local_change). - Uploads:
runtime.rs:210-222. - BiBCode's own PR create: it invalidates lookups at
apps/server/src/source_control/pull_request.rs:700-711, and.with_created_request_observer(...)is wired atruntime.rs:520(builder atgit_vcs.rs:464). rg notify_local_changefinds callers only ingit/summary.rs,git/broadcaster.rs:863,runtime.rs:219/533andgit_vcs.rs:192/198. No provider-runtime caller.
Provider commands are not observed
- Provider events are projected in
project_provider_event(apps/server/src/production/provider_runtime.rs:11054). It handlesitem.completed, e.g. compaction at:11171-11179, andturn.completed(:11180+), but has no VCS/PR hook. command_executionis a tool lifecycle item type (packages/contracts/src/providerRuntime.ts:123-124).- Where the command text is:
- Codex:
commandin params (apps/server/src/provider/codex/runtime.rs:2953; see thecommand_item_event_payloadtest, around:4623); - Claude Bash:
input.command(apps/server/src/provider/claude/runtime.rs, test around:7087); - Cursor, OpenCode and Grok payload shapes not verified.
- Codex:
- AI Terminal threads (provider CLI inside a PTY) only notify when the terminal process exits, not after each command.
I haven't measured the actual delay before the PR appears after an agent-run gh pr create. It depends on the summary cycle and the 10 s lookup TTL.
Proposed change
-
Detector (pure function, unit-tested). For a settled
item.completedwithitemType: "command_execution", decide whether the command creates a PR/MR:gh pr createorglab mr createat command position. Handle:- shell wrappers (
bash -lc,zsh -lc '…'),&&/;/|chains, quotes and heredocs; - false positives:
echo "gh pr create"andgrep 'gh pr create'must not match.
Only the boolean result leaves the detector; command text is never logged.
- shell wrappers (
-
Observer. Add a narrow observer dependency to the provider runtime, like
with_created_request_observer. When the detector matches, the runtime callsstatus_broadcaster.notify_local_change(<thread cwd/worktree>). That reusesobserve_local_changes: invalidate lookups plus a fresh summary cycle. Optionally, also fire on any settled command whose output contains a PR/MR URL for the thread's remote. -
Debounce. At most one refresh per thread per settled item. A batch of commands in one turn produces one refresh.
T3 Code reference (their claims, not measured by us)
- pingdotgg/t3code#24813, merged 2026-10-25 06:45 ART. A
PullRequestSyncReactorlinks a thread to a PR from settledcommand_executionoutput. - Guards they describe:
- Codex
zsh -lcunwrapping; - heredocs and quotes;
- command position only;
- skipping when the output has more URLs than create commands.
- Codex
- They report 11 new tests and a replay of real threads that found 15 missed links and 0 wrong ones.
- Known gaps they list:
forloops andgh apicalls. - T3 stores the thread↔PR link. BiBCode derives the PR from the branch (see Open questions).
Acceptance criteria
- Rust unit tests for the detector (a new
apps/server/src/source_control/pr_create_command.rsor similar, with colocated tests):- matches plain,
bash -lc/zsh -lc-wrapped, chained and heredoc-body (--body-file -) forms ofgh pr createandglab mr create; - rejects
echo/grep/comment mentions andgh pr view/list; - rejects non-command-position matches.
- matches plain,
- Rust tests in
apps/server/src/production/provider_runtime.rs(same module as the existingproject_provider_eventtests):- a settled Codex
command_executionwithgh pr createcalls the observer once for the thread's cwd; - a Claude Bash item with the same command does the same;
- an in-progress or failed-to-start item, or an unrelated command, doesn't call it.
- a settled Codex
-
apps/server/src/production/git_vcs.rs:a_reported_local_change_runs_a_fresh_lookup(:7297) still passes. A new case shows that a provider-reported change for a watched worktree runs a fresh open-PR lookup, without waiting for the TTL. - Desktop e2e:
vp run test:ui:desktop, includingapps/desktop/e2e/specs/chat-activity-panel.e2e.tsandproject-session-terminal.e2e.ts(no regressions in command rows or terminal-exit refresh). - Manual: in a Codex thread and a Claude thread on a GitHub repo, ask the agent to push a branch and run
gh pr create. The thread's PR status updates within a few seconds of the command finishing. Record the observed delay before and after the change. - Gates:
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings, relevantcargo test -p bibcode-server(provider_runtime, git_vcs, source_control),vp check(zero warnings),vp run typecheck, Release Smoke. - UI.md and
vercel-react-best-practicesreviews are recorded if any UI changes (none expected).docs/testing/runbooks are reviewed and updated or stated "remain accurate". - Profiler coverage line in the delivery report. Command text and output (user and agent text) never reach profiler records or logs; only the match boolean and the cwd key do.
Living docs to update
docs/architecture/overview.md/docs/plans/pull-requests/research/server-provider-layer.md: list provider command completion as a local-change source next to terminal exit and uploads.
Not in scope
- Persisting a thread↔PR link (see Open questions).
- Parsing PR URLs from output to link PRs on other branches or repos.
forloops, scripts andgh apicalls that create PRs (T3's known gaps).- AI Terminal per-command detection inside a PTY.
Related
- The terminal-exit refresh (
runtime.rs:527-534) and BiBCode's own create path (pull_request.rs:700-711) that this reuses.
Open questions
- Should BiBCode store a durable thread↔PR link (as T3 does), so a thread keeps its PR after the branch is renamed, deleted or merged? Today the PR is found by branch lookup. That's a persisted shape and would need a
docs/plans/design doc. - Cursor, OpenCode and Grok
command_executionpayloads: where does the command text live? Not verified. - Should a settled command whose output contains a PR URL (but no recognized create command) also trigger the refresh?
Activity
mubeda commentedon Oct 31, 2026
Triage, 2026-10-31. Not going into PR #213 (#139 MCP batch). It goes in a follow-up PR after that release. Batch 2 (quick fixes).
PR #213 refreshes the Source Control panel only for PRs created through BiBCode's MCP
create_pull_requesttool, which goes through BiBCode's own create path. It does not handle an agent runninggh pr create/glab mr createin its shell.production/provider_runtime.rsstill never callsnotify_local_change, so this issue is fully open.Planned order after the release: (1) #222 copy lint; (2) quick fixes #228, #221, #229, #231, #232; (3) MCP #220; (4) performance #225, then #223, #226, #227; (5) features #230, #224, #211, #212; (6) #210 after a Windows repro.