Skip to content

Refresh project branches in one daemon round trip - #8120

Merged
ymichael merged 2 commits into
mainfrom
bb/branch-picker-one-daemon-call-per-keystroke-thr_4muh68dm9r
Nov 24, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/branch-picker-one-daemon-call-per-keystroke-thr_4muh68dm9r

Conversation

@ymichael

@ymichael ymichael commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Refreshing branches (GET /projects/:id/branches, used by the picker's Refresh, bb project branches and sdk.projects.branches) chained its two host RPCs: the server sent host.inspect_git_source with a blocking remote fetch, waited for the reply, and only then sent host.list_branch_options so the list would include fetched branches. On a remote host that is two serial round trips. This is finding #5 of the server→daemon RPC audit.

What changed

  • Wire change, HOST_DAEMON_PROTOCOL_VERSION 281 → 282. host.list_branch_options takes remoteRefresh: "background" | "blocking", the same values as host.inspect_git_source. The server only ever sent "none", which is gone. A 281 daemon rejects "blocking", so the bump is required.
  • Server (apps/server/src/routes/projects.ts): both branch routes send the two RPCs together with the same remoteRefresh. /branches is now one round trip.
  • Daemon (bb-environment-provider-host listBranchOptions): "blocking" awaits refreshRemoteBranches before reading refs. That function keeps one in-flight fetch per repo, so the two blocking RPCs share a single git fetch and both read after it. The git plugin's local "none" call is unchanged.
  • No response-shape, CLI or SDK change. Picker reads (open and keystrokes) keep main's parallel pair.

Removing git status from every keystroke, which an earlier revision did with a server-side inspection cache, is left out. It needs either that cache, whose search responses carry state up to 30 s stale, or a change to the response shape.

How you verified

Live A/B on the host-RPC latency rig. A second daemon reached through a proxy adding 100 ms each way (~200 ms RTT). The proxy decodes WebSocket frames to log every host-rpc.request, and the remote daemon logs every git spawn. The project is a clone of this repo (9,101 files, 1,730 remote branches); 10 rounds each of open, four keystrokes and /branches.

/branches, remote (n=10) main this PR
median 531 ms 270 ms
second RPC starts after the first 286 ms (serial) 0 ms (together)
git fetch per refresh ≤1 ≤1 (shared, never 2)
  • Responses are byte-identical to main for open, search, search with selectedBranch, and /branches with and without a query. Also identical for a repo mid-merge with conflicts plus a dirty tree, and for a non-git folder.
  • Background fetches: 6 in both runs.
  • Open and keystroke requests send the same two parallel RPCs as main.

Tests:

  • host-branches-dispatch.test.ts: a blocking host.list_branch_options sent while a background fetch is held open waits for it and lists the fetched branch. It fails if "blocking" behaves like "background".
  • public-project-workspace-routing.test.ts: /branches has both blocking RPCs in flight before either replies.
  • Contract and provider-host suites pass. turbo run typecheck lint passes for @bb/server, @bb/host-daemon, @bb/host-daemon-contract, bb-environment-provider-host and bb-plugin-bb--git.

🤖 Generated with Claude Code

AGENT GENERATED

…r keystroke

Every branch-options request sent host.inspect_git_source (git status, ref
reads, background fetch) next to host.list_branch_options, so each debounced
keystroke cost two host RPCs and a git status, and /branches chained them
into two serial round trips.

host.list_branch_options now takes remoteRefresh (background | blocking) and
includeSource, and returns the source inspection alongside the page when
asked. The server asks for it on picker open, on /branches, and on a search
with no inspection from the last 30 s for that host path; other searches
reuse the remembered inspection. Protocol 282.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop includeSource, the source result field and the server's 30 s
inspection memory. /branches now sends host.inspect_git_source and
host.list_branch_options together, both with remoteRefresh "blocking";
the daemon de-duplicates the in-flight fetch per repo, so both read
after the same fetch. Picker reads keep main's parallel pair.

host.list_branch_options takes remoteRefresh "background" | "blocking"
(the unused "none" is gone), so the protocol stays at 282.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael ymichael changed the title Read branch-picker branches in one daemon call, with no git status per keystroke Refresh project branches in one daemon round trip Nov 24, 2026
@ymichael
ymichael merged commit 63a7e5d into main Nov 24, 2026
52 checks passed
@ymichael
ymichael deleted the bb/branch-picker-one-daemon-call-per-keystroke-thr_4muh68dm9r branch November 24, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant