Repository navigation
Git Diff panel: one host snapshot per change, refresh only what changed - #8126
Merged
ymichael merged 1 commit intoNov 25, 2026
Merged
Conversation
…what changed Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/git-diff-panel-one-host-read-per-change-thr_6gn43fgdt3
branch
from
November 25, 2026 00:20
6fbb7c1 to
3bf7ede
Compare
ymichael
deleted the
bb/git-diff-panel-one-host-read-per-change-thr_6gn43fgdt3
branch
November 25, 2026 18:21
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
While an agent works, the Diff panel cost two host round trips a second, whether or not the diff changed. The daemon reports
work-status-changedfor every workspace write without fingerprinting it (apps/host-daemon/src/watch-manager.ts), including identical rewrites and writes to ignored output. The git server marked both thestatusandfilestags stale on every such event and flushed at most once a second (plugins/git/server/invalidation.ts). Each flush made the client refetch both reads, and each refetch was oneplugin.host.call. Every hostfilescall also re-randiffPatchfor up to 10 inline patches and shipped them again, though the server and client already had them at the same revision. This is finding #1 of the server→daemon RPC audit.What changed
The change stays inside the git plugin (server and host ship as one plugin artifact). There is no daemon wire change, so no
HOST_DAEMON_PROTOCOL_VERSIONbump.snapshot(plugins/git/host.ts,contract.ts). It reads status and every watched file list in one call, sharing onegit status.statusUnless,files[].unless) and the result still matches, that part comes back as{ outcome: "unchanged" }. An unchanged file list also skipsdiffPatch.knownPatchesonfilesandsnapshot. The server names the inline patches it holds, by path and blob revision. The host reads only the others and lists the reused paths, and the server fills them back in. The client contract (files.initialPatches) is unchanged.server.ts).status/filesinvalidation for a watched environment now makes onesnapshotcall with the status and the watched file-list queries.snapshotcall per repo folder, carrying that repo's watched file lists (with each extra repo's own target) and its status, plus the environment folder's status when no repo is rooted there. A single-repo environment still makes one call. The merged, repo-grouped result is compared with what was served, so a changed repo list also refreshes the panel.server/invalidation.ts). A probe now waits 50 ms of quiet instead of 250 ms, with a 250 ms max wait instead of 500 ms. The 1 s minimum spacing per environment stays, so there is still at most one host call a second. The long debounce existed to batch client refetches; a no-op probe now costs a 275 B reply and no refetch, so it only delayed real edits.server/invalidation.tspasses the environment id topublish.DIFF_FILES_INLINE_PATCH_MAX_FILESmoved tocontract.ts, the schema that uses it. The README andPLUGIN_OVERVIEW.mddescribe the new refresh.Not changed: no-op writes still cost one background
snapshotper second. It is answeredunchangedin 275 B and causes no client refetch. Filtering earlier would mean host-side change detection. The daemon'swork-status-changedhas to stay unfiltered, because core's environment file previews depend on it for ignored files too.How you verified
Real servers, same input (
af25b0b5a60vs this branch, fresh/tmpdata dirs):package.jsonand a write to a.git/info/excluded directory, which is about 230work-status-changedevents a minute.+Ncount in the panel. Latency cells are means over the listed runs (each run is 11 edits). Host-call counts and bytes were identical across runs to within 1 call. The branch numbers in this table were measured at f0d08f9.status+ 61files)snapshot(~50 answeredunchanged)snapshotstatus+filesrefetchesPer action:
snapshotwith a 275 Bunchangedreply and no client refetch.About 3.4 KB of each host request is core's
contributedEnv, sent on everyplugin.host.call(audit finding #9); it is out of scope here.Latency phases for edits only, mean of 22 edits:
The last row is ~52 ms longer on the branch: after the probe invalidates, the client makes one more client→server→plugin request, which the snapshot-seeded memo answers. That cost is fixed and doesn't grow with host RTT, and the shorter quiet period more than covers it.
Under churn, latency is set by where an edit lands against the 1 s minimum spacing, which both builds share. Run-to-run spread (382–693 ms on main) is larger than the difference between builds.
Tests:
plugins/git/server/invalidation.test.ts: covers the 50 ms quiet period, the 250 ms max wait and the unchanged 1 s spacing.plugins/git/server.test.ts(new "workspace change refreshes" block, each failing on main):snapshotand no invalidation for unchanged bursts, with later reads served from it;unchangedfor parts the server holds;initialPatches.plugins/git/host.test.ts: against a real repo,filesandsnapshotre-read only patches whose revision changed, and a matching fingerprint yieldsunchanged.publishsignature and host output shape.pnpm exec turbo run typecheck test lint:type-aware --filter=bb-plugin-bb--gitpasses locally. Full suites are left to CI.Review follow-up (6fbb7c1): A previously read alternate whitespace view now returned the new file 1.45 s after the edit, before the 3 s cache expiry. A rejected host snapshot now sends both reads through the fallback without an unhandled rejection. Both regression cases failed on the prior revision. All 301 git plugin tests, typecheck and type-aware lint passed. With the 200 ms RTT proxy, the updated branch made 61 host snapshots and 22 client status/files refetches in one minute of churn. All 11 edits reached the panel, averaging 685 ms.
🤖 Generated with Claude Code