Skip to content

Move the Diff tab, Info git rows and composer segment into the Git plugin - #6157

Merged
ymichael merged 1 commit into
mainfrom
bb/git-plugin-read-side-thr_6e9knccemi
Oct 27, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/git-plugin-read-side-thr_6e9knccemi

Conversation

@ymichael

@ymichael ymichael commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Since #6165, the Git plugin owns every git read, but core still drew the Diff tab, the Info tab's branch, merge base, git status, Commits and Uncommitted files rows, and the composer's changed-files segment. Plugins couldn't replace them, and turning the plugin off left them showing errors. This PR moves that UI into the Git plugin, through the same public slots any plugin uses, on top of the four prep PRs: the panel controller (#6356), experimental_useCanOpenFileExternally (#6357), automatic Add to chat on diff and code views (#6353) and experimental_ref on workspace file targets (#6348).

What changed

Moved into the Git plugin (plugins/git/app.tsx, plugins/git/ui/)

  • Diff tab: a thread fixed experimental_tab with { kind: "file", path } and { kind: "commit", sha } targets.
    • It shows its own loading state, failure and Retry from its bb--git status read, and hides for a workspace that isn't a git repository.
    • Filters are kept per environment, so they survive switching tabs.
    • Open in editor is decided per file card with experimental_useCanOpenFileExternally. The workspace path for copying absolute paths comes from the plugin's own environment read.
  • Mod+D: the plugin's toggle-diff command calls ctx.experimental_panel.toggleTab. A user's saved diff.toggle binding migrates to it, as before.
  • Info:
    • Branch, Merge base and Git status rows, plus the Commits and Uncommitted files sections.
    • A missing workspace folder shows "Workspace not found" from the plugin's status read.
    • Changed files with status D preview read-only at HEAD or the merge base through experimental_ref.
  • Composer: the changed-files segment with its merge-base picker.
  • Merge-base picker: takes its branch from the plugin's own status read, not from an environment record.
  • Removed from core:
    • The Diff tab and its panel code, the Info git rows and sections, and the changed-files segment.
    • The status, files, patches, branches and Viewed query hooks.
    • diff.toggle, and the core Diff case in the panel controller contract table.
    • Core still reads status through the plugin for the Commit button and the composer branch chip.

Components

  • Moved to @bb/shared-ui, because both core and the plugin render them:
    • The diff card body and header, diff parsing and patch text, renderers, and BranchPicker with its picker helpers.
    • Git status display, the workspace change summary and changes list, and the diff stats tally.
    • The file path link, Open in editor button, copy button, image preview and diff loading skeleton.
    • InfoListRow with its row actions, and InfoRowTime. Core's Related threads and thread storage sections use these too.
  • Kept inside the plugin, because only it uses them: the Diff panel, toolbar, filters, the Info subheading and the commit rail.

Plugin SDK 0.6.90 (all in docs/api_to_audit.md and the Plugin Guide)

  • environment on thread tabs and Info rows.
    • Thread tabs (fixed and action, including useVisible and action run) and Info rows receive environment: { id } | null. It comes straight from the thread and is null only when the thread has no environment.
    • Components read the environment's state themselves.
    • Core no longer filters Info rows' environment through its "can use git UI" check.
    • New type: ExperimentalThreadTabProps.
  • experimental_useTabVisible(): boolean:
    • True while the panel tab it renders in is selected and the side panel is open. False when the panel is closed or suppressed, when another tab is selected, and outside a tab.
    • Core keeps a closed panel's tab mounted, as before. ThreadSecondaryPanel provides the value for every surface.
    • The Diff tab pauses its file list, patch, Viewed and branch-list reads while it is false, as core's Diff did with isDiffPanelLive.
    • The test harness answers it with tabVisible, default true.
  • refetchKeys(keys) on keyed reads: reads only those keys again and keeps every other row. The Diff tab retries one failed patch with it, and Retry re-reads one environment's status.

Dropped from the previous version of this PR

  • environmentState, threadArchived and isOpen on tab props, and keeping visited fixed tabs mounted.
  • useVisible returning "pending" for context segments.
  • experimental_shortcutCommandId (on main the shortcut appeared only in the Diff tab's screen-reader label) and experimental_inactiveInInputs.
  • experimental_InfoRowTime, experimental_InfoSubheading, InfoList rail and InfoListRow actions as SDK members.
  • DiffProps.experimental_addSelectionToChat, now automatic since Offer Add to chat on plugin diff and source views inside threads #6353.
  • experimental_deleted, replaced by experimental_ref.
  • ctx.experimental_toggleTab, replaced by the panel controller.

Differences from main (accepted)

  • Mod+D also toggles the Diff tab while typing.
  • The composer context row appears when git status arrives, instead of being held back until then.
  • Turning the Git plugin off hides the Diff tab, the Info git rows and the composer segment. With the plugin off, Commit returns 409 git_plugin_unavailable.

How you verified

  • Turbo checks:
    • pnpm exec turbo run typecheck lint --filter='...[origin/main]' passes.
    • Tests pass for @bb/app (6286), the Git plugin, @bb/shared-ui, @get-bb/plugin-sdk, @bb/query-tags, @bb/client-core, the Plugin Guide, the GitHub, Side chat, Tasks, Workflows, Docs and Automations plugins, and the server's authoring-docs and keybinding tests.
  • New tests (each fails without its change):
    • ThreadSecondaryPanel.tabVisible.test.tsx: true while selected and open; false once closed, still mounted.
    • The panel controller contract table: "reports the shown tab visible only while the side panel is open", run against the thread view, plugin page and New thread surfaces.
    • DiffTab.test.tsx: visibility from status; the status failure with Retry; no file list while the tab isn't showing; Open in editor only for a valid per-file target.
    • DiffFilesPanel.test.tsx: no patch or Viewed reads while the tab is hidden.
    • PluginThreadFixedTabs.test.tsx: the tab and its useVisible receive the thread's environment.
    • plugins/git/app.test.tsx: Mod+D calls toggleTab on the Diff tab.
  • Squash tests on Windows: in plugins/git/host/workspace-status-cache.test.ts, the squash-detection tests now read again until the check completes, as bb does on the next refresh. The plugin package now also runs the Diff and Info UI tests, and that extra load on Windows runners pushed single reads past the 1 s squash budget (three runs, three different tests). The tests of the timeout itself are unchanged.
  • Real app QA: this branch and main built side by side on the same data and repository (a rename, edits, a deletion, a binary file, an image, a mode change).
Check Branch Main
Diff tab opens and closes with Mod+D and lists the same files Pass Pass
Open in editor on every Diff card (7) Pass Pass
Mod+D while typing in the composer Toggles (accepted) Does nothing
Composer context row "Uncommitted · 7 files, +3 −74" and merge-base picker Pass Pass
Info: branch, merge base, git status, Uncommitted files Pass Pass
Merge-base picker opens with the branch list Pass Pass
Add to chat on selected diff lines inserts the quoted diff Pass Pass
A deleted file opens a read-only preview at HEAD Pass Pass
A thread whose workspace folder is gone shows "Workspace not found" Pass n/a
No file list, patch or Viewed reads after an edit while the Diff tab is closed; reads resume on reopen Pass Pass

AGENT GENERATED

@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch from c026b79 to 4402b0c Compare October 23, 2026 12:35
@ymichael ymichael changed the title Move git status, changed files and the Diff tab into a bundled Git plugin Git plugin 4/4: move the Diff tab, Info git rows and composer segment into the Git plugin Oct 23, 2026
@ymichael
ymichael changed the base branch from bb/git-plugin-pr2-thread-slots-thr_i4jcnrjiv8 to bb/git-plugin-3-read-side-thr_6e9knccemi October 23, 2026 12:35
@ymichael
ymichael force-pushed the bb/git-plugin-3-read-side-thr_6e9knccemi branch from 5d04376 to 845ed81 Compare October 23, 2026 14:47
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch from 4402b0c to cab3e07 Compare October 23, 2026 14:47
@ymichael
ymichael force-pushed the bb/git-plugin-3-read-side-thr_6e9knccemi branch from 845ed81 to 12a05ce Compare October 23, 2026 20:13
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch from cab3e07 to 44aca0f Compare October 23, 2026 20:14
@ymichael ymichael changed the title Git plugin 4/4: move the Diff tab, Info git rows and composer segment into the Git plugin Git plugin B: move the Diff tab, Info git rows and composer segment into the Git plugin Oct 23, 2026
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch from 44aca0f to ca67a65 Compare October 23, 2026 23:02
@ymichael
ymichael force-pushed the bb/git-plugin-3-read-side-thr_6e9knccemi branch 2 times, most recently from 573d067 to b173756 Compare October 23, 2026 23:33
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch from ca67a65 to b400b27 Compare October 23, 2026 23:33
@ymichael
ymichael force-pushed the bb/git-plugin-3-read-side-thr_6e9knccemi branch from b173756 to 4db66ea Compare October 26, 2026 17:16
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch 2 times, most recently from 3347b33 to a335a24 Compare October 26, 2026 17:26
@ymichael
ymichael force-pushed the bb/git-plugin-3-read-side-thr_6e9knccemi branch 2 times, most recently from 2b499df to f0b0da1 Compare October 26, 2026 17:36
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch from a335a24 to c46d11f Compare October 26, 2026 17:36
@ymichael
ymichael force-pushed the bb/git-plugin-3-read-side-thr_6e9knccemi branch from f0b0da1 to 61deb7c Compare October 26, 2026 17:59
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch 6 times, most recently from 7faf7d7 to 0cd3288 Compare October 26, 2026 19:53
@ymichael
ymichael force-pushed the bb/git-plugin-3-read-side-thr_6e9knccemi branch from 61deb7c to ce81c80 Compare October 26, 2026 19:53
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch from 0cd3288 to f18bab2 Compare October 26, 2026 20:13
@ymichael
ymichael force-pushed the bb/git-plugin-3-read-side-thr_6e9knccemi branch from ce81c80 to ab07b2c Compare October 26, 2026 20:13
ymichael added a commit that referenced this pull request Oct 26, 2026
## Human comments

## What was wrong

Core owns every git read: the daemon's `workspace.status` /
`workspace.diff*` / branch commands, the server's
`/environments/:id/status`, `/diff*` and `/diff/branches` routes with
their read cache, diff tiering and result adapters, and the CLI's `bb
environment` diff commands. Plugins can't replace or build on any of it.
This PR moves the read side into a bundled Git plugin. Core's Diff tab,
Info git rows, composer segment, Commit dialog and `bb thread show
--git-diff` keep their UI and read through the plugin's RPCs; #6157
moves that UI into the plugin.

Based on `main`, which now has #6183 (SDK realtime reconnect) and #6184
(`experimental_retryable`) that this PR uses.

## What changed

**Git plugin (`plugins/git`, id `bb--git`, bundled and enabled by
default, no app entry yet)**

- **Host** (`host.ts`, `host/*`): status, diff, files with initial
patches, patches and branch options.
- `packages/host-workspace/src/workspace.ts` moves (`git mv`) to
`host/workspace-reads.ts`. Its byte-budget and commit caches and their
tests move with it, as does the server's diff tiering.
- Git code only the plugin calls (`runGitWithNullRecordLimit`, the raw,
numstat and name-status parsers, `readMergeBaseRef`) lives in
`host/git.ts`. The record-limited listing is a record parser over the
shared runner's streaming `onStdout`, which stops git once the limit is
reached.
- Reads run in the plugin host worker, with its own VCS process pool.
Diff, file, patch and branch reads run at interactive priority: the
handler sets it in a plugin-local store, and the plugin's git calls pass
it explicitly to `experimental_runVcsProcess`. The read methods are
`experimental_retryable`.
- One `WorkspaceReads` is kept per path, capped at 64, so the repo
probes core repeated on every read run once per workspace.
- A reference-counted index copy keeps the real index's times and never
writes a split index. It lives in the worker's temp directory and is
removed when the last reader releases it.
- A racy-untracked guard re-reads only when the work generation changed
within the mtime granularity window.
- Patch batches are capped at 6 MiB and return the rest as `deferred`;
the server loops until every requested path is answered.
- **Server** (`server.ts`, `server/*`):
- Reads: keyed `status` and `patches`, plus `workspaceStatus`, `diff`,
`files`, `fileSide`, `branches`.
- Mutations: `viewed`, `markViewed`, `clearViewed`, `setMergeBase` and
`refresh`.
- `status` and `files` share in-flight reads and keep results for 3 s
(`createAsyncTtlMemo` from `@bb/async-cache`). Generation tokens are
unique per process and change on every environment change. Unwatching an
environment drops its caches.
- Invalidation comes from `environment:changed` while a client watches,
coalesced per environment. The turn-end status heal subscribes only
while something is watched, checks the watch first, caches thread →
environment, and unsubscribes on dispose.
- `fileSide` reads through `bb.sdk.files.read({ ref })`, core's
`host.read_file`, so its limits and `ENOENT` / `invalid_path` /
`file_too_large` outcomes are core's.
- CLI: `bb git status|branches|diff|files|file|patch|viewed`. Output,
error codes and stderr (including the `Error: ` prefix) match what the
old `bb environment` commands printed.
- **Types**: the plugin's own shapes (workspace status, diff response,
file stats, the host contract) live in `plugins/git/contract.ts`; the
RPC contract in `plugins/git/rpc-contract.ts`. Core keeps its schemas
where they are on main (`@bb/domain`, `@bb/host-daemon-contract`,
`@bb/server-contract`). The few the plugin host needs at runtime (diff
target, branch options, checkout ref, resolution failure, branch list
limits) have plugin-side copies, and
`plugins/git/contract-copies.test.ts` checks each copy's
`z.toJSONSchema` against core's.

**Shared between the daemon and the plugin
(`bb-environment-provider-host`)**

Only code both still call:
- `workspace-git.ts`: the one git runner, on the public host process
APIs. It spawns with `experimental_spawnPortableOutputProcess`, or with
the provider-bridge entry's `experimental_spawnPortableProcess` (and
`experimental_killPortableProcess`) for the six reads that feed git
stdin (`log --stdin`, `patch-id`, `hash-object --stdin(-paths)`). It
admits each run through `experimental_runVcsProcess` with an explicit
priority, and keeps the byte caps, truncated stdout, timeouts with a 1 s
force kill, the Windows startup-crash retry and process-group kill. It
also holds `WorkspaceError` and its failure mapping,
`parsePorcelainV2StatusZ`, and `createGitQueries`, the repository,
branch and default-branch queries. Environment providers'
`bb-environment-provider-host/git` is now a wrapper that runs it at
background priority.
- `branch-options.ts`: branch listing, used by the daemon's
`host.list_branch_options` and the plugin's `branches`.
- `git-types.ts`: zod-only schemas for the above, safe in the plugin
host and app bundles.

Core-only git code stays in `@bb/host-workspace/src/git.ts`, as on main.
Code that lost its last caller is deleted.

**Core on the plugin's reads**

- **Daemon**: the git read commands are gone and
`HOST_DAEMON_PROTOCOL_VERSION` goes 254 → 255 (only 255 is compatible,
as on main: the server now sends a git `ref` to `host.read_file`).
Workspace resolution collapses to `requireResolvedWorkspaceForCommand`.
- **Server**:
- The status, diff and branch read routes are gone, along with the
workspace read cache, diff tiering and RPC result adapters.
- Commit reads its status and diff through the plugin
(`git-plugin-reads.ts`) and calls `refresh` afterwards. With the plugin
off it fails with 409 `git_plugin_unavailable`, and the message names
the plugin's state.
  - `files.read` accepts a git `ref` (with `rootPath`).
- The plugin CLI output cap is 32 MiB, so `bb git diff` and `bb git
file` print what `bb environment diff` and `diff-file` printed.
- **App**:
- The environment query hooks keep their keys, placeholders and cache
owners. Their fetchers call the plugin through
`hooks/queries/git-plugin-reads.ts`.
- Each hook watches the environment's plugin `status` read, so the
plugin shares its cache across them.
- The live plugin-frontend reconcile that runs on every WebSocket
connect marks frontends as pending only when a frontend actually loads,
changes or leaves. Before, every reconnect flipped "settled" true →
false → true about 250 ms after boot. With the bundled Git plugin's
frontend on that path, the flip swapped the secondary panel surface and
remounted every Diff card (code → skeleton → code). A card probe on this
PR over 10 reloads: 10 of 10 doubled before, 0 of 10 after.
- Core UI is unchanged: every component stays in `apps/app` as on
`main`, and `@bb/shared-ui` is untouched. The only app changes are the
read path above and the type imports that follow the workspace and diff
types this PR moves out of `@bb/domain` and `@bb/server-contract` into
`plugins/git/contract.ts` (test builders into
`bb-plugin-bb--git/testing`).
- **CLI**: `bb thread show --git-diff` reads through the plugin. The old
`bb environment
status|branches|diff|diff-files|diff-file|diff-patch|diff-viewed`
commands still run and print the `bb git` command that replaced them.
`bb plugin build` prints server build warnings.
- **MCP**: read mode allows the bundled plugin's read-only `bb git`
commands.

**Retired SDK environment reads**

- `environments.status`, `diff`, `diffFiles`, `diffPatch`, `diffFile`
and `diffBranches` leave the public typings and docs.
- Runtime adapters
(`packages/sdk/src/areas/retired-environment-reads.ts`) keep their old
shapes, limits and error codes over `plugins.callRpc`.
- `bb-plugin-build` warns on calls to them. It detects optional,
aliased, bracket and destructured calls, and never fails the build.

**Plugin SDK 0.6.83 → 0.6.84**: the fake host's `experimental_watchRpc`
and the 32 MiB `PLUGIN_CLI_OUTPUT_MAX_BYTES`, both in
`docs/api_to_audit.md`. No new process primitives: the git runner uses
the existing public host APIs.

**Docs**: the bb-cli skill and command index, the backend SDK and CLI
guides, the new `references/git-reads.md`, the vcs-process-admission and
manual-runbook docs, the verify-bb feature map, and the plugin's
`PLUGIN_OVERVIEW.md`, README and `git` skill.

**With the Git plugin disabled** in this PR, core's Diff tab, Info git
rows and composer segment show their read errors, and Commit returns
409. #6157 hides them instead.

**Production lines** (excluding tests, stories, fixtures and docs):
+8,540 / −7,483, net +1,057. #6157 then moves the UI (net −676), so the
stack is net +381.

| Area | Added | Removed | Net |
|---|---:|---:|---:|
| `plugins/git/host` (workspace reads moved from `@bb/host-workspace`,
plugin-only git code) | 3,154 | 0 | +3,154 |
| `plugins/git` root (contract, RPC contract, host and server entries) |
1,297 | 0 | +1,297 |
| `plugins/git/server` (reads, generations, invalidation, Viewed, CLI) |
1,272 | 0 | +1,272 |
| `bb-environment-provider-host` (shared runner, branch listing,
git-types) | 1,256 | 560 | +696 |
| `apps/app` (read path, live reconcile) | 247 | 119 | +128 |
| `@bb/plugin-build` (retired-read build warnings) | 87 | 4 | +83 |
| `@bb/sdk` (retired-read adapters) | 273 | 193 | +80 |
| other (`plugins/mcp`, `turbo.json`, `plugin-sdk`) | 50 | 26 | +24 |
| `@bb/host-workspace` (workspace reads moved out) | 228 | 3,975 |
−3,747 |
| `apps/cli` | 87 | 577 | −490 |
| `apps/server` (routes, read cache, tiering) | 279 | 719 | −440 |
| `apps/host-daemon` | 58 | 436 | −378 |
| `@bb/server-contract` | 229 | 535 | −306 |
| `@bb/host-daemon-contract` | 18 | 179 | −161 |
| `@bb/domain` | 5 | 103 | −98 |
| `@bb/test-helpers` | 0 | 57 | −57 |
- `getDiff` stays, at about 211 lines: rebuilding diffs from files plus
patches would lose binary patches, name-status rename scores and the
total byte budget across files.

## Git reads on the host

#### Git reads on the host: what is shared per change

- **One status snapshot per change.** The plugin server keeps a work
generation per watched environment. Each `environment:changed`, turn
end, refresh or merge-base change starts a new one, and a generation
also expires after 3 s. `status`, `files` and `patches` reads in the
same generation share one `git status` run and its untracked list. Reads
without a watch, and CLI and commit reads, get a unique generation and
share nothing.
- **Ref-derived values cached per refs generation and HEAD.** This
covers the merge base, the base commit and origin/HEAD. Only
`git-refs-changed`, environment status changes, refresh and merge-base
changes bump the refs generation, and it also expires after 30 s. An
edit therefore runs no `merge-base`, `rev-parse` or `symbolic-ref`.
- **Untracked line stats and blob ids cached per file signature** (mode,
size, mtime, ctime, inode). Only new or changed untracked files go
through `add --intent-to-add` plus one `diff --raw --numstat`. Status,
files and patches share the result.
- **One combined diff for the file list.** `diff --raw --numstat -M -z`
against the base replaces the separate raw, numstat and name-status
calls. With Ignore whitespace on, raw and numstat stay two calls,
because git 2.55 drops whitespace-only files from `--raw -w`. Patches
reuse the file list's rename pairs, and a single path skips the numstat.
- **The real index is never written.** Porcelain `git diff` refreshes
and rewrites `.git/index` even with `--no-optional-locks` /
`GIT_OPTIONAL_LOCKS=0`. That write fed the gitdir watcher and is what
drove the idle Diff loop on main. Worktree diffs therefore run against a
copy of the index, reused until the real index changes. The copy is
reference-counted, so a reader never loses it mid-diff, keeps the real
index's times, never writes a split index, and lives in the worker's
temp directory. Every other read sets `GIT_OPTIONAL_LOCKS=0`, and status
passes `--no-optional-locks`.
- **Tests pin this down.** `plugins/git/host/git-process-budget.test.ts`
uses a PATH shim that logs every git process and asserts the exact
commands per change:
  - 8 for an edit that adds an untracked file with Diff open,
  - 5 for a tracked edit with Diff open,
  - 2 for a tracked edit with Diff closed.

It also checks that `.git/index` is byte-identical after reads, even
when the stat data in the index is stale.

#### Index copy vs alternatives (bb clone, 3.4 GB `.git`, 0.99 MB index)

Each change appends to `README.md` and runs the three worktree diffs a
change triggers. Times are per change, as the median of 10 changes.
Bytes are per change, averaged over the 10. "Stat-dirty" means 500
tracked files had their mtime bumped without a content change.

| Strategy | Clean: ms | Clean: bytes written | Stat-dirty: ms |
Stat-dirty: bytes written | Writes `.git/index` | Same output as main |
|---|---:|---:|---:|---:|---|---|
| Real index (main) | 45.0 | 0 | 98.8 | 97 KB (one rewrite of
`.git/index`) | yes | yes |
| Fresh copy per change | 45.7 | 968 KB | 133.1 | 1935 KB | no | yes |
| Copy reused until the index changes (#6165) | 44.7 | 97 KB (one 0.99
MB copy, then 0) | 98.9 | 194 KB (the copy plus one refresh of the copy,
then 0) | no | yes |
| Plumbing `diff-index` | 44.4 | 0 | 160.0 | 0 | no | no (raw lists
stat-dirty files; ignores `diff.*` config) |

The reused copy costs the same time as main, writes nothing in steady
state, and leaves `.git/index` alone. It re-copies about 1 MB only when
the real index changes, that is, on the user's own `git add` or
checkout. Plumbing `diff-index` writes nothing, but it is slower once
entries are stat-dirty, because it re-reads them on every call and never
refreshes. It is also wrong for the file list: `--raw` reports
stat-dirty files as modified, and plumbing ignores `diff.*` config,
which would change patches compared with main.

#### Missed watcher events heal at turn end

On main, git reads rewrote `.git/index`, and the gitdir watcher turned
each rewrite into another status check. That hid gaps in the
workspace-root watcher. During the first PR-state branch runs, reps 1
and 2, the daemon's root watcher reported 1 to 7 of 15 edits in some
scenarios.
- Now, when a thread's turn ends (status becomes `idle` or `error`) and
a client watches its environment, the Git plugin starts a new generation
for that environment, clears its caches and reads status once. With
nothing watched it subscribes to no thread events at all. It invalidates
`status` and `files` only when the result differs from what it last
served.
- A missed edit therefore shows up at the latest when the turn ends,
without polling.
- Test: `refreshes status when a turn ends even if the watcher missed
the edit` in `plugins/git/server.test.ts`.

The dropouts happened in one early PR-state run (reps 1–2, between 23:40
and 23:55):
- The daemon emitted 1, 5, 6 or 7 of 15 `work-status-changed` events in
some edit scenarios. Its logs had no watcher errors for that window.
- In every run after that (PR-state rerun, even state, base, and the
final edit reruns), the daemon reported all 15 edits.
- An independent `@parcel/watcher` subscription on the same repository
ran alongside the reruns. It saw the same 15 change batches per run,
with no errors.
- The dropouts did not recur, so whether FSEvents or the daemon caused
them is not established.

## How you verified

- New tests, each failing without its fix:
- Index copy times, reference counting, no split index, racy untracked:
`plugins/git/host/index-copy.test.ts`.
- The patch byte budget: `host.test.ts`. The deferred loop, generations
and rewatch, and turn-end only while watched: `server.test.ts`.
- CLI output, error codes and the exact `Error: ` stderr:
`server/cli.test.ts`.
- Core's schemas and the plugin's copies stay identical:
`contract-copies.test.ts`.
- Retired adapter codes and limits: `retired-environment-reads.test.ts`.
- `plugin-frontend-live-reconcile.test.ts`: the reconcile reports
changes on first load, on a hash change and on a removal, and not for an
unchanged list.
- Build warnings: `retired-sdk-members.test.ts`. MCP read mode:
`policy.test.ts`. Commit errors by plugin state:
`git-plugin-reads.test.ts`.
- The moved git tests pass from their new homes:
`bb-environment-provider-host` (`workspace-git`), `@bb/host-workspace`
(`git`) and `plugins/git/host` (`git`, `git-admission`, workspace
reads).
- Git processes and requests, measured at the top of the stack: see
#6157.
- `node .github/workflows/check-plugin-sdk-version.mjs`.
- CI on this head.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Base automatically changed from bb/git-plugin-3-read-side-thr_6e9knccemi to main October 26, 2026 20:35
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch from f18bab2 to 84c884f Compare October 26, 2026 20:45
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch 2 times, most recently from 59ba790 to caafa0a Compare October 27, 2026 05:38
@ymichael ymichael changed the title Git plugin B: move the Diff tab, Info git rows and composer segment into the Git plugin Move the Diff tab, Info git rows and composer segment into the Git plugin Oct 27, 2026
…ugin

The Git plugin now draws the Diff tab, the Info tab's branch, merge base,
git status, Commits and Uncommitted files rows, and the composer's
changed-files segment through the public slots, on top of the panel
controller (#6356), experimental_useCanOpenFileExternally (#6357),
automatic Add to chat (#6353) and experimental_ref (#6348).

- Thread tabs and Info rows receive environment: { id } | null straight
  from the thread, null only without one. The Git plugin reads everything
  else itself: the Diff tab's loading, failure and Retry come from its
  bb--git status read, and a missing workspace folder shows "Workspace not
  found" in Info.
- experimental_useTabVisible() tells any panel tab whether it is selected
  in an open panel; the Diff tab pauses its file list, patch and Viewed
  reads while it is false.
- Mod+D is the Git plugin's toggle-diff command, calling the panel
  controller's toggleTab.
- InfoListRow, its row actions and InfoRowTime move to @bb/shared-ui for
  core and the plugin; the subheading and commit rail live in the plugin.
- Keyed RPC reads gain refetchKeys for a per-row Retry.
- Plugin SDK 0.6.90.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/git-plugin-read-side-thr_6e9knccemi branch from caafa0a to 95ff6db Compare October 27, 2026 06:05
@ymichael
ymichael merged commit 2f61afc into main Oct 27, 2026
52 checks passed
@ymichael
ymichael deleted the bb/git-plugin-read-side-thr_6e9knccemi branch October 27, 2026 16:50
ymichael added a commit that referenced this pull request Oct 27, 2026
## Human comments

## What was wrong

Plugin stylesheets repeated Tailwind `@property` registrations and
inherited theme variables on `:root`, so inserting a sheet restyled the
entire document. Removing a layered plugin stylesheet also made Chrome
re-resolve the host's CSS `@property` rules and restyle the whole page.
Fixing only insertion or only the host registrations left the other
trigger intact.

Unconditionally stripping plugin CSS on the server also created version
skew: a tab loaded before an update retains its old host CSS while
fetching new plugin CSS. The old host lacks about 50 registrations and
330 theme variables supplied by the expanded host sheet.

## What changed

This combines #6148 and #6149, rebased onto `origin/main` at
`2f61afc227` (#6157). Conflict resolution preserved main's runtime-slot
metadata, retired Git API migration-warning coverage, and this PR's CSS
regression coverage; no CSS behavior changes were needed.

- Generate the complete Tailwind registrations, fallback declarations
and theme values into the host stylesheet. Strip only identical
host-provided rules from plugin CSS; preserve different or unknown
declarations. Plugin build artifacts remain complete and compatible with
older servers.
- Before the first app render, move the host's top-level CSS property
registrations into `CSS.registerProperty()` and delete the equivalent
CSS rules. Keep conflicting rules, rejected registrations and unreadable
sheets. Keep the loader's existing attach/release lifecycle and
1.5-second removal grace period.
- Make stripping opt-in from the app: preload, prefetch and stylesheet
URLs carry `host-tailwind=<hash of generated host CSS>`. Both asset
routes serve the complete original CSS for absent or mismatched markers.
A future host CSS change gets a different marker automatically. Bundle
hashes cover both CSS variants, and compressed response caches
distinguish them.
- Document the request behavior and stale-tab reproduction in
`docs/debugging-and-qa.md`. No daemon wire changes or new CLI/SDK
controls; browser, desktop and mobile use the same app loader.

Script registrations take precedence over CSS `@property`; a plugin's
conflicting registration can no longer override a host registration. No
bundled plugin depends on that behavior. Browsers without
`CSS.registerProperty` retain the CSS rules and fallback layer.

## How you verified

### Combined performance results

The existing PR measurements below used the same 70-thread fixture
(about 1,420 elements), Chrome at 1280×800, Performance-domain style
duration and trace element counts, median of seven. The after column
includes **both** changes.

| Operation | Main | Combined |
| --- | --- | --- |
| Page open (sidebar + composer) | 71.5 ms / 3,785 elements | 44.4 ms /
1,579 elements |
| Automations open / close | 88.7 / 83.1 ms | 45.0 / 45.6 ms |
| Storage & retention open / close | 74.0 / 83.4 ms | 41.4 / 42.2 ms |
| Plugin Guide open / close | 214.0 / 81.1 ms | 158.4 / 42.0 ms |
| Remove Automations stylesheet | 26.0 ms / 1,162 elements | 12.6 ms /
78 elements |
| Remove Storage & retention stylesheet | 27.7 ms / 1,162 elements | 9.2
ms / 78 elements |
| Remove Plugin Guide stylesheet | 29.2 ms / 1,162 elements | 14.3 ms /
78 elements |
| Remove Automations stylesheet, 16,000-element page | 63.9 ms / 16,006
elements | 35.6 ms / 0 elements |

The prior insertion-only measurements were Automations 38.2 → 17.3 ms
(1,234 → 86 elements), Plugin Guide 39.4 → 16.4 ms (1,234 → 86), and
GitHub PR Status 35.7 → 3.5 ms (1,346 → 26). WebKit broadly restyles on
sheet changes and showed no material improvement. Prior combined
verification covered open/close/reopen, popover and dialog animations,
spinners, the Automations toast, and compact drawer transitions in
Chrome and WebKit.

### Stale tab across a server update

Reproduced in real headless Chrome 155 at 1280×800 using main
`efe987702b87ca4bfe9df905b4b63ede478e12c7`, then switching the same
isolated server to the combined branch and opening Automations and
Plugin Guide through their navigation buttons.

**Test condition:** normal `AppUpdateHost` revision detection
automatically reloads the tab. To exercise the requested client that has
not received that update status yet, a local proxy held
`/api/v1/system/app-update` at main's actual response and retained
main's immutable app assets. All plugin metadata, JS and CSS came from
the real switched server. No app CSS or plugin styles were injected into
the tab. The stale tabs' `performance.timeOrigin` and
`index-BR1pQoni.css` host URL stayed unchanged across the server switch.

| View / observation | Unconditionally stripped server | Opt-in server,
old tab | Opt-in server, fresh tab |
| --- | --- | --- | --- |
| Automations content | Matches fresh load | Matches fresh load, zero
changed content pixels | Reference |
| Plugin Guide heading's italic “bb” | **600**, missing
`--font-weight-bold`; fresh load is **700** | **700**, variable present
| **700** |
| Guide stylesheet | Stripped despite old host | Complete, 56
`@property` rules and theme layer | Stripped, 0 `@property` rules and no
`:root` |

Before the fix, the Guide heading differed by 440 screenshot pixels.
After the fix its heading matches, and the Guide's computed styles and
element geometry match across the old and fresh tabs; tiny rasterization
differences remain in scaled fixture strokes. Screenshots and
observations are retained in the task evidence directory
(`/tmp/bb-6148-evidence/`).

Old-tab timestamps: before case `1792785386806`, after case
`1792785387394.9`; both retained main's CSS. The fresh app adds
`host-tailwind=90105b453d213b90e1c3f988b900bdc9fbb0a5f2677466f83df3227db69320f9`;
the old app sends no marker.

### Regression coverage and checks

- Extended the existing real asset-route test. An unmarked request
failed on the unpatched branch because the response omitted the original
registrations/theme. It now passes. Both hash and plugin-ID routes cover
matching, absent and mismatched markers, interleaved gzip requests, and
immutable caching.
- Existing frontend lifecycle tests now verify the capability URL
through preload, prefetch, attach, replacement and grace-period
handling. Property-registry coverage from #6149 is included.
- `pnpm exec turbo run lint typecheck --filter=@bb/app
--filter=@bb/server --filter=@bb/plugin-build`: passed.
- Focused Turbo app tests: **46 passed**. Focused Turbo server asset
tests: **13 passed**.
- Production `pnpm start:worktree` build: passed, including app, server,
host daemon, SDK and bundled plugins.
- `pnpm exec turbo run test --filter=@bb/plugin-build`: **235 passed, 1
skipped**.
- [Full GitHub
CI](https://github.com/get-bb/bb/actions/runs/40545551643) passed on
rebased head `f501ca183c4c7fd0e6960c13169e2f817f5a47ba`: **47 successful
checks, 4 conditional skips, zero failures or pending checks**. Skips:
iOS, Android, Node Compatibility smoke, and Windows dependency warming.
All executed checks passed on their first attempt. Local affected
lint/typechecks, 46 app tests, 13 server asset tests, and 235
plugin-build tests also passed (1 plugin-build test skipped).

> AGENT GENERATED

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Oct 28, 2026
)

## Human comments

## What was wrong

On phone-sized coarse-pointer screens, the Info panel's Branch, Merge
base and Git status rows drew 12px icons, while Parent, Project,
Environment and Directory drew 16px. Their labels started 4px further
left. This began with #6157, which moved those rows into the Git plugin
via the SDK `experimental_DetailRow`.

The SDK component is core's own `DetailRow`, so the class list stayed
the same: `size-3 … max-md:pointer-coarse:size-4`. What changed is that
the row now renders inside the Git plugin's root. Plugin sheets compile
into the shared `utilities` cascade layer and load after the app sheet.
The Git plugin uses `size-3` itself, so its sheet emits
`:where([data-bb-plugin="bb--git"], …) .size-3`. That rule has the same
specificity as core's `max-md:pointer-coarse:size-4` and comes later, so
it wins.

Nothing drops the variant. In the live page, the matched rules on the
Branch icon are core `.size-3`, core `@media (width < 48rem) and
(pointer: coarse) .max-md\:pointer-coarse\:size-4`, and the Git plugin's
scoped `.size-3`, last and winning. This is the same ordering problem as
#3691, which made `hidden md:flex` disjoint after the layer change in
#3635 was reverted.

## What changed

- `apps/app/src/components/ui/detail-card.tsx`: `DETAIL_ROW_ICON_CLASS`
is now a single size utility, `size-(--bb-detail-row-icon-size)`, with
no base/variant pair. A plugin sheet re-emitting `size-3` or `size-4` no
longer matches the icon. `cn`/tailwind-merge still drops `Icon`'s
default `size-6` for custom and asset icons.
- `apps/app/src/components/ui/theme.css`: defines
`--bb-detail-row-icon-size` as `calc(var(--spacing) * 3)` on `:root`.
The existing `(max-width: 767px) and (pointer: coarse)` `:root` block
raises it to `* 4`, the same token-override pattern the file already
uses for `--text-*` so responsive values don't fight in the cascade.
- Rebased onto #6367, which added `min-h-0 min-w-0` to
`DETAIL_ROW_ICON_CLASS`. Those are kept, so the class is now
`size-(--bb-detail-row-icon-size) min-h-0 min-w-0 shrink-0
text-subtle-foreground`.
- Every SDK DetailRow from any plugin, and core's own rows using
`DETAIL_ROW_ICON_CLASS`, now resolve the icon size from the token.

No wire, SDK surface, CLI or doc changes. Plugin artifacts do not need
rebuilding.

## How you verified

New test in `apps/app/src/lib/plugin-sdk-app-impl.test.tsx`. It renders
`pluginSdkAppImplementation.experimental_DetailRow` and fails if any
rendered element pairs an unconditional utility with a variant utility
that overrides it (checked with tailwind-merge). Any such pair breaks
once a plugin sheet re-emits the base utility. With main's
`detail-card.tsx` it fails, reporting `size-3 +
max-md:pointer-coarse:size-4`. With this change it passes.

`pnpm exec turbo run typecheck lint --filter=@bb/app` passes. `pnpm exec
turbo run test --filter=@bb/app -- src/lib/plugin-sdk-app-impl.test.tsx
src/components/ui/theme.test.ts src/components/secondary-panel` passes:
54 files, 571 tests.

I checked the live layout on a source dev app (`pnpm dev`), using a
project on a local git repo and a worktree thread with the Info panel
open.

Chromium, 390×844, touch plus `pointer: coarse` emulation (icon box,
label left in CSS px):

| Row | main | this branch |
| --- | --- | --- |
| Parent / Project / Directory (core) | 16×16, 38 | 16×16, 38 |
| Branch (git plugin) | **12×12, 34** | 16×16, 38 |
| Merge base (git plugin) | **12×12, 34** | 16×16, 38 |
| Git status (git plugin) | **12×12, 34** | 16×16, 38 |

iOS 18.4 Simulator Safari (iPhone 16 Pro, 402px wide), measured from
simulator screenshots. On main, Branch, Merge base and Git status labels
start at x≈35.3 with ~9–10px glyphs, while core rows start at 39.3. On
this branch all six of those rows start at 39.3 with matching ~13–14px
glyphs.

On desktop (Chromium 1280×800, fine pointer), every row stays 12×12 with
labels at x=835, and the Info panel region is pixel-identical between
main and this branch.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Michael Yong <review@local>
Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Nov 3, 2026
## Human comments

## What was wrong

Moving the composer (#6122) and git (#6165, #6157, #6388, #6410) into
plugins left dead code and duplicate implementations in core and in
neighbouring plugins. An audit of those moves (thread thr_7hk642w2es)
found code that could be deleted with no protocol bump, no plugin SDK
change and no change in behaviour. This PR implements the audit's steps
1 (pure deletions) and 2 (consolidations). Every item was re-checked
against the current code before it was deleted; the items that turned
out to change behaviour are left out and listed below.

## What changed

Two commits. Together they remove 643 lines net. No
`HOST_DAEMON_PROTOCOL_VERSION` change, no plugin SDK change, and no CLI
or config change.

**Step 1: deletions (+42 / −423, net −381)**
- `useUpdateEnvironment` (built but never mutated) and its always-false
`isPending` read in `ThreadDetailView`.
- `isGitDiffFixedPanelTab`, `EMPTY_ORDERED_MENTION_SUGGESTIONS`, the
`useCommandSuggestions().triggers` field that only echoed its input, and
the `maxHeight` prop on `ComposerBox`, which no caller passes (the max
height comes from `ComposerMaxHeightContext`).
- client-core's uncached `composerDraftFromPromptDraft`. `ComposerBox`
now uses the cached apps/app copy. The history object is rebuilt on
every render and drafts are compared by value, so the result is the
same.
- 9 unused `@tiptap/*` dependencies of `@bb/app`. `@tiptap/core` and
`@tiptap/pm` become devDependencies because only
`PromptBoxInternal.test.tsx` uses them.
- host-workspace's porcelain v1 quoted-path parser. Its only caller is
the conflict check, which reads just the two status letters.
- host-workspace's copy of the checkout admission lock (it now reuses
the one in `locks.ts`) and its copy of `throwIfProvisionAborted`. Also a
`withGitRefMutationLock` re-export nothing imports, and `export` on
helpers only used inside their own file.
- Stale docs: `vcs-process-admission.md` now cites protocol 255.
`api_to_audit.md` now says `ComposerBox` owns `submit`. The `app.css`
comment and the `bundle-budget.json` note no longer describe the
pre-plugin composer.

**Step 2: consolidations (+299 / −561, net −262)**
- Checkout-ref, uncommitted-changes and in-progress-operation inspection
had two implementations: host-workspace (used by the daemon's
`host.inspect_git_source`) and
`plugins/environment-project-checkout/host/git.ts`. Both now use one
implementation in `createGitQueries`
(`bb-environment-provider-host/workspace-git`), and the plugin's file is
deleted. Because it goes through each side's runner, the daemon keeps
its default git priority and the plugin keeps `background`. Every caller
already confirms a work tree before calling, so the result is identical;
the daemon just runs two fewer `git rev-parse` checks per inspection.
- `plugins/git/host/workspace-reads.ts` (−85):
- The HEAD-to-empty-tree fallback is now generic over the result type,
so the record-limited tracked diff reuses it instead of keeping its own
copy.
- One `rangeGitRunner`, one lstat/ENOENT helper and `sumNumstatLines`
replace the inline copies.
  - Local copies of contract types and unused exports are gone.
- Ladle's `makeWorkspaceStatus` is now built on
`bb-plugin-bb--git/testing`, keeping the same defaults.

**Planned items left out**
- **Server-contract "unused" schemas:** not dead. They are the source of
`EnvironmentDiffViewedResponse` and `EnvironmentActionApiError`, which
the SDK and `public-api.ts` use.
- **The `ComposerPluginActions` wrapper:** it discards any props a
plugin passes at runtime. Passing `ComposerActionsSlot` directly would
start honouring them.
- **One-off migrations for the git-era ids (`diff.toggle`, Info section
ids):** these would change behaviour.
- The UI-preference transform also runs on writes (`PUT /ui-preferences`
and `bb settings`).
- The keybinding `PUT` stores any command id and returns the overrides
read back through the read-time migration.
- A one-off database migration would stop converting legacy ids written
later, for example by a cached older client.
- **A fake segment instead of the real Git segment in core banner
tests:** those tests are the only coverage of the plugin's
`ChangedFilesSegmentView` (deferred list mount, merge-base action, file
buttons). A fake would drop that coverage unless the tests move into the
plugin, which is relocation rather than deletion.
- **Lifting the small boundary copies (`commit-errors.ts`,
overflow-mode, label-class and debounce constants) into shared-ui:**
each new shared-ui entry needs a 5-line `exports` block, and the copies
are 1–3-line constants or helpers with a different shape, so this would
add lines.
- **The shared-ui workspace-status fixture:** shared-ui can't depend on
the plugin's test builders, and #6935 deletes this fixture by moving its
modules into plugins/git.

## How you verified

- `pnpm exec turbo run typecheck lint` for `@bb/app`, `@bb/client-core`,
`@bb/host-workspace`, `bb-environment-provider-host`, `@bb/host-daemon`,
`bb-plugin-bb--git`, `bb-plugin-bb--composer`,
`bb-plugin-environment-git-worktree` and
`bb-plugin-environment-project-checkout`: all pass.
- `pnpm exec turbo run test` with the same filters: every package passes
after the rebase. Two `@bb/app` tests failed under a local load average
of about 50 and are not caused by this PR:
  - `PluginSettings.test.tsx` passes when run on its own.
- `lazy-plugin-renderers.cold-load.test.tsx` fails the same way on the
base commit.
- `pnpm exec turbo run build --filter=@bb/app` plus
`check-bundle-budget.mjs`: budget OK.
- `pnpm exec turbo run prepare:bundled` for the git, git-worktree and
project-checkout plugins: the host bundles build with the shared
helpers.
- The existing `getCheckoutRef` and `getWorkspaceGitOperation` tests
(bare repo, detached, unborn, merge and rebase conflicts) now run
against the shared implementation and pass.

> AGENT GENERATED

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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