feat(watch): add config option to disable linked worktree discovery - #270
Open
rusel95 wants to merge 3 commits into
Open
feat(watch): add config option to disable linked worktree discovery#270rusel95 wants to merge 3 commits into
rusel95 wants to merge 3 commits into
Conversation
grepai watch auto-discovers and indexes every linked git worktree with
no way to opt out. In projects where tooling creates many short-lived
worktrees (e.g. AI coding agents), each one triggers a parallel initial
scan and its own watch session, multiplying memory usage and embedding
work for trees that are throwaway copies of the main checkout.
Add watch.discover_worktrees to config.yaml:
watch:
discover_worktrees: false
The option is a pointer-typed bool so existing configs without the key
keep the historical default (enabled). The check lives inside
discoverWorktreesForWatch, so it covers the initial scan, the TUI path,
and the supervisor's periodic reconcile - toggling it takes effect on
the next reconcile without restarting the watcher.
Fixes yoanbernabeu#211
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…worktrees Review findings on the original commit: - a torn/invalid config during the 3s reconcile no longer silently re-enables discovery (which auto-inits worktrees — a side effect that is not free to undo); the error is now logged and the pass skipped - test pins the fail-closed direction - the option is documented in watch-guide, configuration and git-worktrees docs (incl. a 'Disabling Worktree Discovery' section) - struct comment notes the key is only read from the main worktree Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
markpinero
added a commit
to hi-high/grepai
that referenced
this pull request
Jul 29, 2026
Bring in high-value open upstream fixes for Qdrant multi-project workspaces, monorepo watch startup, Ollama resilience, and worktree fan-out control: - yoanbernabeu#248 qdrant project namespace - yoanbernabeu#263 workspace ListDocuments scope - yoanbernabeu#207 qdrant gRPC message size - yoanbernabeu#257 embedder timeout/retries - yoanbernabeu#277 parallel change detection - yoanbernabeu#270 discover_worktrees config - yoanbernabeu#203 gitignore root guard - yoanbernabeu#264 symbol extractor version invalidation Keeps prior mark.1 harden (atomic GOB, corrupt recovery, 90s shutdown, --no-worktrees).
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.
Problem
Fixes #211.
grepai watchin a main worktree unconditionally discovers all linked git worktrees, auto-initializes them (creates.grepai/, edits their.gitignore) and watches them alongside the main project. There is no way to opt out.For workflows that create many short-lived worktrees — AI-agent sessions,
git worktree-based review checkouts — this multiplies indexing work, embedding calls and resident memory by the worktree count. The #211 author tried five separate workarounds (ignore patterns, per-worktree configs, killing sub-watchers…) — none work, because discovery is a separate mechanism from file scanning and ignores all of them.Change
One new key in
.grepai/config.yaml, read in the main worktree:*bool(omitempty), so existing configs — and configs rewritten by the watcher — keep the historical behavior (enabled) unless the user explicitly opts out.WorktreeDiscoveryEnabled()encapsulates the default.discoverWorktreesForWatch, which is the sole entry to discovery, so the initial scan, the TUI path and the supervisor's periodic reconcile all respect it.Tests
discover_worktrees: false→ no discovery, no auto-init side effectsWorktreeDiscoveryEnabled()accessor: nil/true/false table testfalsesurvives config load/saveDocs
configuration.mdandwatch-guide.mdnow list the key;git-worktrees.mdgains a "Disabling Worktree Discovery" section and two troubleshooting rows (discovery not triggering; too many worktrees indexed).🤖 Generated with Claude Code