Repository navigation
Git plugin A: move git reads into the bundled Git plugin - #6165
Merged
Merged
Conversation
This was referenced Oct 23, 2026
ymichael
force-pushed
the
bb/git-plugin-2-infra-thr_6e9knccemi
branch
from
October 23, 2026 14:47
42c1f92 to
b589346
Compare
ymichael
force-pushed
the
bb/git-plugin-3-read-side-thr_6e9knccemi
branch
from
October 23, 2026 14:47
5d04376 to
845ed81
Compare
ymichael
changed the base branch from
bb/git-plugin-2-infra-thr_6e9knccemi
to
main
October 23, 2026 20:13
ymichael
force-pushed
the
bb/git-plugin-3-read-side-thr_6e9knccemi
branch
8 times, most recently
from
October 26, 2026 19:53
61deb7c to
ce81c80
Compare
- 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
force-pushed
the
bb/git-plugin-3-read-side-thr_6e9knccemi
branch
from
October 26, 2026 20:13
ce81c80 to
ab07b2c
Compare
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]>
This was referenced Oct 28, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Core owns every git read: the daemon's
workspace.status/workspace.diff*/ branch commands, the server's/environments/:id/status,/diff*and/diff/branchesroutes with their read cache, diff tiering and result adapters, and the CLI'sbb environmentdiff 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 andbb thread show --git-diffkeep 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, idbb--git, bundled and enabled by default, no app entry yet)host.ts,host/*): status, diff, files with initial patches, patches and branch options.packages/host-workspace/src/workspace.tsmoves (git mv) tohost/workspace-reads.ts. Its byte-budget and commit caches and their tests move with it, as does the server's diff tiering.runGitWithNullRecordLimit, the raw, numstat and name-status parsers,readMergeBaseRef) lives inhost/git.ts. The record-limited listing is a record parser over the shared runner's streamingonStdout, which stops git once the limit is reached.experimental_runVcsProcess. The read methods areexperimental_retryable.WorkspaceReadsis kept per path, capped at 64, so the repo probes core repeated on every read run once per workspace.deferred; the server loops until every requested path is answered.server.ts,server/*):statusandpatches, plusworkspaceStatus,diff,files,fileSide,branches.viewed,markViewed,clearViewed,setMergeBaseandrefresh.statusandfilesshare in-flight reads and keep results for 3 s (createAsyncTtlMemofrom@bb/async-cache). Generation tokens are unique per process and change on every environment change. Unwatching an environment drops its caches.environment:changedwhile 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.fileSidereads throughbb.sdk.files.read({ ref }), core'shost.read_file, so its limits andENOENT/invalid_path/file_too_largeoutcomes are core's.bb git status|branches|diff|files|file|patch|viewed. Output, error codes and stderr (including theError:prefix) match what the oldbb environmentcommands printed.plugins/git/contract.ts; the RPC contract inplugins/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, andplugins/git/contract-copies.test.tschecks each copy'sz.toJSONSchemaagainst 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 withexperimental_spawnPortableOutputProcess, or with the provider-bridge entry'sexperimental_spawnPortableProcess(andexperimental_killPortableProcess) for the six reads that feed git stdin (log --stdin,patch-id,hash-object --stdin(-paths)). It admits each run throughexperimental_runVcsProcesswith 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 holdsWorkspaceErrorand its failure mapping,parsePorcelainV2StatusZ, andcreateGitQueries, the repository, branch and default-branch queries. Environment providers'bb-environment-provider-host/gitis now a wrapper that runs it at background priority.branch-options.ts: branch listing, used by the daemon'shost.list_branch_optionsand the plugin'sbranches.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
HOST_DAEMON_PROTOCOL_VERSIONgoes 254 → 255 (only 255 is compatible, as on main: the server now sends a gitreftohost.read_file). Workspace resolution collapses torequireResolvedWorkspaceForCommand.git-plugin-reads.ts) and callsrefreshafterwards. With the plugin off it fails with 409git_plugin_unavailable, and the message names the plugin's state.files.readaccepts a gitref(withrootPath).bb git diffandbb git fileprint whatbb environment diffanddiff-fileprinted.hooks/queries/git-plugin-reads.ts.statusread, so the plugin shares its cache across them.apps/appas onmain, and@bb/shared-uiis 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/domainand@bb/server-contractintoplugins/git/contract.ts(test builders intobb-plugin-bb--git/testing).bb thread show --git-diffreads through the plugin. The oldbb environment status|branches|diff|diff-files|diff-file|diff-patch|diff-viewedcommands still run and print thebb gitcommand that replaced them.bb plugin buildprints server build warnings.bb gitcommands.Retired SDK environment reads
environments.status,diff,diffFiles,diffPatch,diffFileanddiffBranchesleave the public typings and docs.packages/sdk/src/areas/retired-environment-reads.ts) keep their old shapes, limits and error codes overplugins.callRpc.bb-plugin-buildwarns 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_watchRpcand the 32 MiBPLUGIN_CLI_OUTPUT_MAX_BYTES, both indocs/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'sPLUGIN_OVERVIEW.md, README andgitskill.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.
plugins/git/host(workspace reads moved from@bb/host-workspace, plugin-only git code)plugins/gitroot (contract, RPC contract, host and server entries)plugins/git/server(reads, generations, invalidation, Viewed, CLI)bb-environment-provider-host(shared runner, branch listing, git-types)apps/app(read path, live reconcile)@bb/plugin-build(retired-read build warnings)@bb/sdk(retired-read adapters)plugins/mcp,turbo.json,plugin-sdk)@bb/host-workspace(workspace reads moved out)apps/cliapps/server(routes, read cache, tiering)apps/host-daemon@bb/server-contract@bb/host-daemon-contract@bb/domain@bb/test-helpersgetDiffstays, 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,filesandpatchesreads in the same generation share onegit statusrun 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 nomerge-base,rev-parseorsymbolic-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-addplus onediff --raw --numstat. Status, files and patches share the result.One combined diff for the file list.
diff --raw --numstat -M -zagainst 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 diffrefreshes and rewrites.git/indexeven 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 setsGIT_OPTIONAL_LOCKS=0, and status passes--no-optional-locks.Tests pin this down.
plugins/git/host/git-process-budget.test.tsuses a PATH shim that logs every git process and asserts the exact commands per change:It also checks that
.git/indexis 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.mdand 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..git/index.git/index)diff-indexdiff.*config)The reused copy costs the same time as main, writes nothing in steady state, and leaves
.git/indexalone. It re-copies about 1 MB only when the real index changes, that is, on the user's owngit addor checkout. Plumbingdiff-indexwrites 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:--rawreports stat-dirty files as modified, and plumbing ignoresdiff.*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.idleorerror) 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 invalidatesstatusandfilesonly when the result differs from what it last served.refreshes status when a turn ends even if the watcher missed the editinplugins/git/server.test.ts.The dropouts happened in one early PR-state run (reps 1–2, between 23:40 and 23:55):
work-status-changedevents in some edit scenarios. Its logs had no watcher errors for that window.@parcel/watchersubscription on the same repository ran alongside the reruns. It saw the same 15 change batches per run, with no errors.How you verified
plugins/git/host/index-copy.test.ts.host.test.ts. The deferred loop, generations and rewatch, and turn-end only while watched:server.test.ts.Error:stderr:server/cli.test.ts.contract-copies.test.ts.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.retired-sdk-members.test.ts. MCP read mode:policy.test.ts. Commit errors by plugin state:git-plugin-reads.test.ts.bb-environment-provider-host(workspace-git),@bb/host-workspace(git) andplugins/git/host(git,git-admission, workspace reads).node .github/workflows/check-plugin-sdk-version.mjs.🤖 Generated with Claude Code