VS Code Source Control panel doesn't refresh after git operations
Description
When Claude Code (running as a VS Code extension) performs git operations (git add, git commit, etc.), the VS Code Source Control panel does not update to reflect the new state. Files that were just committed continue to show as modified until the user manually clicks the refresh button or reloads the window.
Root Cause
VS Code's built-in git extension uses three mechanisms to detect changes:
- File system watcher on
.git/index,.git/refs/, etc. - Terminal shell integration — detects git commands run in VS Code's integrated terminal via
onDidExecuteTerminalCommand - Polling via
git.autoRefresh(~5 seconds)
Claude Code runs git commands via child_process, not through VS Code's integrated terminal, so mechanism #2 never fires. On WSL2 specifically, git's atomic write pattern (write to temp file, then rename() over .git/index) unreliably triggers inotify file watchers, making mechanism #1 flaky. The polling fallback (#3) also has delays on WSL2.
The net result is that after any git-mutating operation by Claude Code, the Source Control panel is stale until the user manually refreshes.
Proposed Fix
After completing git-mutating Bash commands (git add, git commit, git reset, git checkout, git switch, git revert, git pull, git push, git fetch, git branch), the VS Code extension should call:
await vscode.commands.executeCommand('git.refresh');
This is exactly what VS Code's own terminal shell integration does internally when it detects git commands in the integrated terminal (see vscode/extensions/git/src/terminalShellExecutionManager.ts).
Environment
- Claude Code VS Code extension
- WSL2 (kernel 6.6.87.2-microsoft-standard-WSL2) — most affected due to inotify issues, but the terminal integration bypass affects all platforms
- VS Code with default git extension settings (
git.autoRefresh: true)
Related VS Code Issues
- microsoft/vscode-remote-release#2310 — Explorer and source control not updating git status in WSL 2
- microsoft/vscode#116673 — Source Control does not refresh status automatically when working on WSL
- microsoft/vscode#223068 — Git refresh model based on terminal command execution
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗