Repository navigation
Defer assisted-commit Git metadata probes outside active runs - #23222
Merged
Merged
Conversation
Avoid spawning four sequential Git metadata commands (rev-parse and count-objects) before every ordinary repository mutation when no Copilot assisted commit run or protection is active. When no assisted commit protection is active, ordinary mutations reserve their working-directory path without invoking Git. If an assisted commit run begins while an ordinary mutation is still in flight, assisted admission lazily resolves the active mutation's Git metadata paths to detect shared common directories and alternate object stores before admitting the run or acquiring a lease. Also short-circuit busy checks in withIsCommitting, withPushPullFetch, and withIsGeneratingCommitMessage before entering resource reservation.
Only run getAssistedCommitProtectedPaths in AssistedCommitReaders.loadStatusCore when an assisted commit run or assisted-commit protection is active. Previously every status refresh (app startup, focus, file changes, and post-operation refreshes) spawned four sequential Git processes even when no assisted commit run existed.
…tive Skip getRepositoryType, getAssistedCommitProtectedPaths, and listWorktrees before local and file:// clones when no assisted commit protection or lease is active. The clone source is still tracked as an active read operation so that any assisted commit lease acquired while the clone is in flight lazily discovers shared Git metadata and drains the clone before proceeding. When assisted commit protection is already active, multi-path read admission waits for leases atomically via withRepositoryGitReads to avoid deadlocks.
Skip missing candidate paths before probing Git metadata during lazy active-repository resolution, document the lazy coordination policy, and add unit tests covering: - Zero assisted-commit Git metadata commands during ordinary status, commit, branch, and local clone operations when no run is active - Lazy resolution of in-flight peer linked worktree mutations when an assisted commit run tries to start - Rejection of starting a second assisted commit run on a peer linked worktree while another run is active
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical registry-lifetime races can hide active reads or leases from later operations, and suppressed metadata-discovery failures can let conflicting operations bypass overlap protection.
4 open issues
What changed in this PR
Reduces the input delay reported in #23219 by deferring GitHub Desktop’s assisted-commit Git metadata probes until coordination is needed.
Changes:
- Adds fast paths for ordinary mutations, status loads, and local clones when no assisted-commit protection is active.
- Introduces lazy shared-resource discovery and multi-path read coordination for assisted-commit admission.
- Adds regression tests and documents the deferred-discovery behavior.
| File | Description |
|---|---|
docs/technical/assisted-commit-runs.md |
Documents skipped probes and lazy resource discovery. |
app/test/unit/git/repository-operation-test.ts |
Tests probe-free ordinary operations and peer-worktree admission. |
app/test/unit/git/clone-test.ts |
Tests local cloning without assisted-commit source probes. |
app/src/lib/stores/app-store.ts |
Adds lightweight mutation reservations and early busy checks. |
app/src/lib/git/repository-operation.ts |
Implements lazy overlap discovery and multi-path read admission. |
app/src/lib/git/clone.ts |
Defers source discovery and coordinates reads across shared resources. |
app/src/lib/assisted-commit/readers.ts |
Skips metadata discovery during unprotected status loads. |
app/src/lib/assisted-commit/coordinator.ts |
Adds asynchronous overlap checks and guards concurrent run starts. |
Review effort: Balanced
Review feedback: I1 (adversarial review F1; #23222 (comment)). acquireAssistedCommitGitLease fetched its IRepositoryOperations registry record before awaiting resolveUnresolvedMutationRepositories and findOverlappingActiveRepositories, without pinning the record against forget(). If an in-flight reader on the target repository finished during those awaits, forget() deleted the record from the registry and the lease was installed on a detached object invisible to later lookups, causing lease.run mutations to fail hasAccess() and reject themselves as busy. This PR exacerbated a narrow microtask race on development by introducing multi-subprocess Git discovery awaits before lease installation. Add a reference-counted pin (pins) on IRepositoryOperations checked by forget(), and obtain the live registry entry via pinRepositoryOperations in acquireAssistedCommitGitLease, unpinning in finally after the lease is installed or acquisition fails. Add a regression test verifying that a reader completing during unrelated discovery does not detach the lease. Validation: npx eslint --rulesdir eslint-rules and npm test -- app/test/unit/git/repository-operation-test.ts passed (45/45).
…path read waits Review feedback: I2 (adversarial review F1; #23222 (comment)). withRepositoryGitReads collected IRepositoryOperations entries without pinning them while resolving later paths or waiting for an active lease to release. If an earlier path's last operation completed during that wait, forget() removed the entry from the registry and the new read operation was registered on a detached object invisible to subsequent leases. This race was introduced by this PR's new withRepositoryGitReads helper. Pin every unique repository entry via pinRepositoryOperations for the full duration of multi-path admission and execution, releasing all pins in finally after operations settle. Add a regression test verifying that a later lease on an earlier path still drains the multi-path read after an unrelated prior reader finishes during a lease wait. Validation: npx eslint --rulesdir eslint-rules and npm test -- app/test/unit/git/repository-operation-test.ts passed (46/46).
….git suffix fallback Review feedback: I5 (adversarial review F4; #23222 (comment)). resolveActiveRepositoryResourcePaths previously caught all errors from realpath and getAssistedCommitProtectedPaths and returned an empty list, after which resolveUnresolvedMutationRepositories deleted the unresolved mutation entry. That allowed transient Git execution, alternate-parsing, or filesystem failures to fail open instead of blocking overlapping admission. It also tried a sibling <path>.git fallback for all callers rather than only local clone sources. Both behaviors were introduced by this PR. Only suppress verified ENOENT (from realpath) and DugiteError.NotAGitRepository (from getAssistedCommitProtectedPaths); propagate all other errors so assisted admission fails closed and retains the unresolved mutation entry. Restrict the .git-suffix candidate fallback to local clone source reads tagged with allowGitSuffix. Add regression tests for both fail-closed error propagation and sibling .git non-fallback. Validation: npx eslint --rulesdir eslint-rules and npm test -- app/test/unit/git/repository-operation-test.ts app/test/unit/git/clone-test.ts passed (139/139).
…ree UI state Review feedback: I3 (adversarial review F2). Skipping idle status metadata probes left previously visited external peer linked worktrees without repositoryResourcePaths entries when an assisted commit run started in another worktree. That caused two gaps exacerbated by this PR: 1. Unwrapped mutations invoking withRepositoryGitOperation(path, 'mutation') directly (such as GitStore.performFailableOperation for upstream remote setup or branch pruning, and worktree delete/move) only checked cached paths and could write into shared Git metadata while an assisted run protected it. 2. Synchronous UI guards (isRepositoryAffectedByAssistedCommit) left peer worktree controls enabled until an asynchronous post-switch status refresh and metadata probe completed. Close both gaps with zero idle Git overhead: - In withRepositoryGitOperation, pin the repository record and lazily call isRepositoryOverlappingAssistedCommit when kind === 'mutation' and an assisted commit resource lock is active. - In getAssistedCommitProtectedResources (which only runs during active assisted commit runs/protection), record peer worktree common-dir paths from git worktree list --porcelain -z, and remember realpath aliases in canonicalPathAliases so synchronous UI checks recognize peer worktrees even through symlinked roots (such as /var -> /private/var on macOS). Add a regression test covering synchronous peer UI detection, unwrapped peer worktree mutations, and unwrapped alternate-sharing clone mutations. Validation: npx eslint --rulesdir eslint-rules and npm test -- app/test/unit/git/repository-operation-test.ts passed (49/49).
… discovery Review feedback: I4 (adversarial review F3; #23222 (comment)). AssistedCommitCoordinator.prepare and un-prepared create previously awaited hasOverlappingRepositoryGitMutation and isRepositoryOverlappingAssistedCommit before reading initialState, account, modelSelection, providerDefinition, providerRevision, and freezing the request. If an unrelated repository triggered asynchronous lazy discovery and the user changed model/provider or switched branches during that wait, preparation silently captured the replacement values instead of binding the first click. This regression was introduced by this PR. Capture initialState, account, modelSelection, providerDefinition, providerRevision, and the frozen request synchronously before any asynchronous lazy discovery awaits in both prepare and create, while keeping synchronous fast busy checks ahead of capture and re-checking availability after discovery completes. Add a regression test verifying that changing the assisted model during prepare discovery preserves the first-click model. Validation: npx eslint --rulesdir eslint-rules and npm test -- app/test/unit/git/repository-operation-test.ts app/test/unit/assisted-commit-coordinator-test.ts passed (52/52).
tidy-dev
previously approved these changes
Nov 24, 2026
sergiou87
enabled auto-merge
November 25, 2026 08:38
sergiou87
added a commit
that referenced
this pull request
Nov 25, 2026
niik
approved these changes
Nov 26, 2026
This was referenced Dec 1, 2026
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.


Closes #23219
Description
rev-parse --absolute-git-dir,rev-parse --git-common-dir,rev-parse --git-path objects,count-objects -v) and local-clone worktree probes outside of active Copilot-assisted commit runs:AppStore.withAssistedCommitMutationResources,repository-operation.ts,coordinator.ts): When no assisted-commit lease, protection, or admission check is active (hasActiveAssistedCommitProtection() === false), ordinary mutations only reserve their canonical working-directory path without invoking Git. If an assisted-commit run later starts while an ordinary mutation is still in flight, assisted admission (prepare,create, andacquireAssistedCommitGitLease) lazily resolves the active mutation's Git metadata paths to detect shared common directories and alternate object stores. Also short-circuit in-progress checks inwithIsCommitting,withPushPullFetch, andwithIsGeneratingCommitMessagebefore entering resource reservation.AssistedCommitReaders.loadStatusCore): SkipgetAssistedCommitProtectedPathsunless an assisted-commit run or assisted-commit protection is active.file://clones (git/clone.ts,repository-operation.ts): SkipgetRepositoryType,getAssistedCommitProtectedPaths, andlistWorktreesbefore cloning when no assisted-commit protection is active. The clone source remains tracked as an active read operation and is lazily discovered and drained if an assisted-commit lease is acquired on a shared peer worktree while the clone is in flight; when protection is already active, multi-path read admission useswithRepositoryGitReadsto wait for leases atomically without deadlocking.docs/technical/assisted-commit-runs.mdand added unit tests covering zero assisted-commit Git metadata commands during ordinary status/commit/branch/local-clone operations as well as lazy peer-worktree coordination.Performance Benchmark (No Active Assisted Commit Run)
macOS
Measured on macOS (Darwin 25.6.0, Apple M3 Max, Node
v24.22.1, bundled Git2.56.1) comparingdevelopment(993bb4a319) vs. this branch (4cf2916963), using realAppStore+GitStore+dugiteGit against a local repo with a bare remote (manual commit mode,pushAfterCommit: false, 1 warmup + 10 measured iterations per operation):assistedCommit*Calls_commitIncludedChanges)¹_fetch, user-initiated)_pull, 1 remote commit)_push, 1 local commit)_loadStatus)¹ Unawaited background
_refreshRepositoryAfterCommitalso dropped from 19 → 15 Git calls (4 → 0assistedCommit*calls), median 87.98 ms → 60.70 ms (-31.0%) (total commit + background refresh: 33 → 21 Git calls).Windows
Measured on Windows (Windows 11 Pro Insider Preview
10.0.26340 Build 26340, Apple Silicon ARM64 VM, Nodev24.15.0, bundled Git2.56.1.windows.1) comparingdevelopment(993bb4a319) vs. this branch (0fc4691694), using the same methodology (manual commit mode,pushAfterCommit: false, 1 warmup + 10 measured iterations per operation):assistedCommit*Calls_commitIncludedChanges)¹_fetch, user-initiated)_pull, 1 remote commit)_push, 1 local commit)_loadStatus)¹ Unawaited background
_refreshRepositoryAfterCommitalso dropped from 19 → 15 Git calls (4 → 0assistedCommit*calls), median 576.27 ms → 443.80 ms (-23.0%) (total commit + background refresh: 33 → 21 Git calls, -36.4%).On Windows (higher
git.exespawn + Defender overhead) and larger repositories (slowergit count-objects -v), eliminating 4–12 Git subprocesses before UI busy state is emitted yields proportionally larger latency savings.Validation (at
4cf29169632e20c9fe97c5ec4619650a12c465cb)npm test -- app/test/unit/git/repository-operation-test.ts app/test/unit/git/clone-test.ts— passed (135/135).npm test -- app/test/unit/*assisted* app/test/unit/git/*assisted* app/test/unit/stores/*assisted* app/test/unit/ui/*assisted* app/test/unit/stores/commit-auto-push-test.ts— 596/597 passed on initial run (1 transientENOENTon.git/objects/maintenance.lockinapp/test/unit/git/assisted-commit-execution-test.ts), followed bynpm test -- app/test/unit/git/assisted-commit-execution-test.ts— passed (21/21).npx tsc --noEmit— passed.npm run lint:src— passed.npm run markdownlint— passed.npm run test:e2e:build:unpackaged) driven via Playwright CDP against a local mock OpenAI BYOK server verified all Copilot-assisted commit workflows (mode switching/persistence across repo switches & restart, single commit & unselected preservation, multi-file and intra-file hunk splitting, uncertain-boundaries fallback, repo & global custom instructions, commit options including sign-off/bypass hooks/empty commit, hook failure ignore/decline rollback, error stop, mid-run selected/unselected file edits, cancellation during analysis and mid-commit with rollback, push-after-commit + push failure retry) plus manual commit + push — all passed.Manual Testing
assistedCommitMetadataDirectory/assistedCommitAlternateObjectDirectoriesentries appear in Desktop's logs (Help>Show Logs).Screenshots
N/A — no UI layout or visual changes.
Team-authored review
Evidence: See the Performance Benchmark and Validation sections above (covering
4cf29169632e20c9fe97c5ec4619650a12c465cb). Artifacts/screenshots are not applicable because this change does not alter UI layout.Review path: lightweight review.
Release notes
Notes: [Fixed] Eliminate input delay before committing, fetching, pulling, and pushing