Skip to content

Git plugin A: move git reads into the bundled Git plugin - #6165

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

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

Conversation

@ymichael

@ymichael ymichael commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

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 Move the Diff tab, Info git rows and composer segment into the Git plugin #6157.
  • node .github/workflows/check-plugin-sdk-version.mjs.
  • CI on this head.

AGENT GENERATED

🤖 Generated with Claude Code

@ymichael
ymichael force-pushed the bb/git-plugin-2-infra-thr_6e9knccemi branch from 42c1f92 to b589346 Compare October 23, 2026 14:47
@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 changed the title Git plugin 3/4: move git reads into the bundled Git plugin Git plugin A: move git reads into the bundled Git plugin Oct 23, 2026
@ymichael
ymichael changed the base branch from bb/git-plugin-2-infra-thr_6e9knccemi to main October 23, 2026 20:13
@ymichael
ymichael force-pushed the bb/git-plugin-3-read-side-thr_6e9knccemi branch 8 times, most recently from 61deb7c to ce81c80 Compare October 26, 2026 19:53
- plugins/git (bb--git, bundled, no app entry yet) owns git status, changed files, diffs, file sides, branches and Viewed through its host, server, RPC contract and bb git CLI; its own shapes live in plugins/git/contract.ts and its plugin-only git code in plugins/git/host.
- Daemon git read commands, server read routes, the read cache and diff tiering are removed; HOST_DAEMON_PROTOCOL_VERSION 255. Core's Diff tab, Info git rows, composer segment, Commit dialog and bb thread show --git-diff read through the plugin.
- bb-environment-provider-host keeps only the git code the daemon and the plugin both call (runner, errors, failure mapping, porcelain status, repo queries, branch listing) and the git-types the plugin host needs; core keeps its own schemas, checked identical by a test.
- One git runner in bb-environment-provider-host/workspace-git serves the daemon, environment providers and the plugin host on the public host process APIs (experimental_spawnPortableOutputProcess, provider-bridge experimental_spawnPortableProcess for stdin, experimental_runVcsProcess with explicit priority); the plugin host sets interactive priority from a plugin-local store.
- Core UI is unchanged: it keeps its own components and reads git through the plugin; plugin-owned workspace and diff types move to plugins/git/contract.ts and core imports them from there.
- The plugin server caches reads with @bb/async-cache.
- Retired SDK environment reads keep working through adapters, with build warnings; old bb environment diff commands point at bb git.
- Plugin SDK 0.6.84.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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
ymichael merged commit d23374d into main Oct 26, 2026
95 of 96 checks passed
@ymichael
ymichael deleted the bb/git-plugin-3-read-side-thr_6e9knccemi branch October 26, 2026 20:35
ymichael added a commit that referenced this pull request Oct 26, 2026
…folders (#6336)

## Human comments

## What was wrong

`bb thread spawn --base-branch main` passed `main` to `git worktree add`
unchanged. When the local `main` was behind `origin/main`, the new
worktree started from the stale local commit. Only names that already
began with `origin/` were fetched first. The default base (no
`--base-branch`) already compared local with origin; named branches
skipped that comparison.

Separately, a child of a live thread in a project whose folder is not a
Git repository always asked the git-worktree provider for a fresh
worktree on the parent's machine. That fails, because there is no
repository to make a worktree of.

This is the part of #6193 that still applies after #6165. #6165 rebuilt
git reads and the shared git runner on main, which replaced the rest of
#6193.

## What changed

- **Named bases use the default-branch rule**
(`plugins/environment-git-worktree/host/base-branch.ts`):
- a bare branch name uses `origin/<name>` when local is equal or behind;
  - it keeps local when local is ahead, diverged or unknown;
  - it uses the remote when only the remote branch exists.
  
Explicit remote names such as `origin/main` and `refs/...` paths are
used exactly. The selected remote base is fetched before creation, as
before.
- **The default base is always returned and stored.** Before, the
resolver returned `null` when the result equaled the local default, and
`createWorktree` re-read the repository default. `defaultBaseBranch` and
`create` now share one resolver.
- `readBranchRelation` (previously the private
`readDefaultBranchRelation` in
`bb-environment-provider-host/workspace-git`) is exported, so the plugin
can compare any local/remote branch pair.
- **Non-git parent reuse**
(`apps/server/src/services/threads/thread-default-policy.ts`): a child
of a live thread in the same project reuses its parent's environment
instead of requesting a worktree. This applies only when:
- the child asked for the project default, or the implicit host default
on the parent's machine;
  - the parent's environment is ready;
- the environment is not a Git repository and its path is not owned by a
provider.
- **Docs:** the `--base-branch` help in `bb thread spawn` and `bb thread
fork`, the threads guide and the worktree plugin README describe both
rules.

No wire changes and no SDK changes.

## How you verified

- `pnpm exec turbo run typecheck lint --filter='...[origin/main]'`:
123/123 pass.
- `pnpm exec turbo run test` for the git-worktree, project-checkout and
Git plugins, `bb-environment-provider-host`, `@bb/cli` and
`@bb/templates`: all pass. The server's `thread-default-policy` and
`worktree-base-branch` tests pass.
- Tests added. Against main's code, the stale-base and reuse tests fail
and the rest pass:
- `host.test.ts`: a stale local `main` or `release` now starts from the
remote commit. `origin/main` is used as the remote. `refs/heads/main`
keeps the local commit. These fail on main for `main` and `release`.
- `host.test.ts`: local commits are kept when local is ahead or
diverged, for `main`, `release`, `refs/heads/main` and the default base.
These guard against the new rule dropping local work.
- `thread-default-policy.test.ts`: implicit project-default and host
children of a non-git parent reuse its environment. Both fail on main.

Fixes #1917

> AGENT GENERATED

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

Co-authored-by: review <review@local>
Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Oct 27, 2026
…ugin (#6157)

## 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
#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

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