fix(git): stop git process overflow#2223
Merged
Merged
Conversation
…her invalidations Forward AbortSignal through the tRPC read procedures and GitService methods into the underlying queries package, so TanStack Query refetches and unmounts actually kill the spawned `git status --untracked-files=all` child process (streamGitStatus already wires SIGTERM on abort, but never received the signal). Debounce git working-tree invalidations from useFileWatcher at 500ms so a burst of file events (worktree setup, node_modules churn, large merges) collapses into one refetch instead of stacking dozens of concurrent git processes. Generated-By: PostHog Code Task-Id: 8b1baf87-a02c-4bbc-bf41-c6267dac1846
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/renderer/hooks/useFileWatcher.ts:36-43
The timer cleanup effect has an empty dependency array, so it only runs on unmount. If `repoPath` changes while a 500 ms timer is pending, the old-path timer is not cancelled and will fire ~500 ms later calling `invalidateGitWorkingTreeQueries` with the stale path. Because there are no active query observers for that old path, TanStack Query won't refetch, so no git process is spawned — but adding `repoPath` to the deps array gives cleaner semantics and avoids the unnecessary invalidation entirely.
```suggestion
useEffect(() => {
return () => {
if (gitInvalidateTimerRef.current) {
clearTimeout(gitInvalidateTimerRef.current);
gitInvalidateTimerRef.current = null;
}
};
}, [repoPath]);
```
Reviews (1): Last reviewed commit: "fix(git): cancel superseded git status q..." | Re-trigger Greptile |
…vent Move the debounce from the renderer into the file-watcher service. The service already debounces events at 500ms; emit a single WorkingTreeChanged event per flush so the renderer invalidates git queries once per burst instead of once per file event. Generated-By: PostHog Code Task-Id: 8b1baf87-a02c-4bbc-bf41-c6267dac1846
charlesvien
approved these changes
May 19, 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.
lets batch incoming untracked changes instead of spawning a new git process for each one