BetaLenzon is in beta — the Free tier is 100% free while we're in beta (bring your own Anthropic key, public repos).See plans →
Lenzon

microsoft/vscode PR #320564 — Optimize temp-index git staging — PR #320564

microsoft/vscode · pull request #320564 ·

Loading…

Transcript

PlainEnglish

Let's walk through pull request three twenty thousand five sixty four — a performance improvement to V S Code's agent host git staging. This one tackles slowness and timeouts in repos with nested repos or large checkouts.

PlainEnglish

We have two primary goals here. First, we're scoping temp-index staging to only the paths that changed, instead of walking the entire working tree. Second, we're making sure changesets refresh automatically whenever git state gets attached to a session. We've also got a few supporting objectives — keeping error contracts consistent, adding a Computing status for background refreshes, and ensuring Branch Changes always has a base branch to diff against.

PlainEnglish

The prior implementation was staging the entire working tree every time with git add dash A colon slash. That was painfully slow in repos with nested repos, large checkouts, or G V F S. On top of that, when git state got attached to a session, the changeset calculations wouldn't refresh — so Branch Changes could end up without a base branch to diff against. This PR flips both of those.

Architecture

Here's the surface area. Most of the logic lives in agentHostGitService — that's where we added the new parseChangedPaths function and refactored the staging strategy. agentHostChangesetService picks up the status transitions and git state fallback. The coordinator and agentService wire up the git state change hook. Tests cover all the new paths — unit tests for parseChangedPaths, integration tests for scoped staging, and tests for the status lifecycle.

Architecture

Let's look at the core change in runWithTempIndex. The old code staged everything with git add dash A colon slash — that's the whole working tree. Now we call stageChangedPaths, which takes the list of paths git status reported as changed and stages just those via pathspec from file. If staging fails, we return undefined, preserving the existing error contract.

Architecture

The new parseChangedPaths function parses the full git status output and extracts every changed path — modified, added, deleted, and untracked. For renames and copies, we grab both the destination and the source path so the scoped staging includes both sides. That keeps the temp index accurate for diffs.

Architecture

When a changeset refresh gets triggered, we now call markStaticChangesetComputing first. That sets the status to Computing and records what the previous status was. The UI sees the Computing indicator while the diff is calculating in the background. If git is temporarily unavailable, we restore the previous status instead of leaving the changeset stuck on Computing.

Architecture

Here's the new git state attachment flow. When agentService updates the session's git state, it now calls onSessionGitStateChanged on the coordinator. The coordinator triggers a refresh of both the Branch and Uncommitted changesets. Inside the changeset service, tryComputeGitDiffs checks for a persisted diff base first, and if it's missing, it falls back to the runtime git state that just got attached. That ensures Branch Changes always has a base branch to diff against.

Architecture

One more detail — error handling. The new stageChangedPaths method returns false if either the pathspec file write fails or the git add command returns undefined. The caller checks that boolean and returns undefined itself, keeping the existing contract where git operation failures return undefined instead of throwing. That preserves compatibility with all the existing error paths.

PlainEnglish

After this lands, temp-index git diff operations will only stage the paths git status reports as changed — no more full working-tree walks. That eliminates the slowness and timeouts in repos with nested repos or large checkouts. Changesets will mark as Computing during background refresh, then restore their previous status if git is temporarily unavailable. And Branch Changes will always have a base branch, either from persistence or from the runtime git state that gets attached.

PlainEnglish

That's pull request three twenty thousand five sixty four. A focused performance fix that scopes git staging to only the changed paths, adds a git state hook to refresh changesets automatically, and tightens up the error handling contracts. The scoped staging logic lives in agentHostGitService, the git state hook is in the changeset coordinator, and the status restoration prevents changesets from getting stuck on Computing when git is temporarily unavailable. Nice and clean.

How this was made

Lenzon read microsoft/vscode at pull request #320564 and generated this walkthrough automatically. The narration above is the transcript of what it says.

Explain a pull request from your own repo

Point Lenzon at a repo or a pull request and get a narrated walkthrough like this one.

Try it