Skip to content

feat: multi-worktree watch and daemon support#115

Merged
yoanbernabeu merged 9 commits intoyoanbernabeu:mainfrom
tinker495:feat/multi-worktree-watch
Feb 8, 2026
Merged

feat: multi-worktree watch and daemon support#115
yoanbernabeu merged 9 commits intoyoanbernabeu:mainfrom
tinker495:feat/multi-worktree-watch

Conversation

@tinker495
Copy link
Copy Markdown
Contributor

Summary

Split from #109 (4/4). Adds worktree-aware daemon PID management and multi-worktree parallel watching. Includes PR 3 commits (feat/worktree-detection) - merge PR 3 first.

  • Worktree-specific PID/ready/log files in daemon package
  • discoverWorktreesForWatch() for automatic linked worktree detection with auto-init
  • watchProject() extracted for single-project watch loop
  • Multi-worktree parallel watching via errgroup
  • Platform-specific liveness detection (pipe on Unix, poll on Windows)
  • Bug fix: Lock file handle leak in WriteWorktreePIDFile (defer close after lock)
  • Bug fix: Deduplicate no-worktree path to use watchProject() instead of inline copy
  • Bug fix: Remove duplicate doc comment on watchProject

Test plan

  • go build ./... passes (linux, windows, darwin)
  • go vet ./... clean
  • go test ./daemon/... ./cli/... all pass with -race
  • Updated existing watch tests for new signatures

Merge order: PR 3 (#114) → this PR

Part of #109 split. See also: PR 1 (#112), PR 2 (#113), PR 3 (#114, dependency)

🤖 Generated with Claude Code

tinker495 and others added 2 commits February 7, 2026 11:08
Add git.Detect() for worktree awareness and zero-config auto-init
when running grepai in a linked worktree:

- New git/ package with Detect(path) returning worktree info
  (GitRoot, GitCommonDir, IsWorktree, MainWorktree, WorktreeID)
- FindProjectRoot() auto-initializes .grepai/ in linked worktrees
  by copying config + index from main worktree as seed data
- grepai init --inherit flag for non-interactive worktree config
  inheritance
- WorktreeID = hex(sha256(GitCommonDir))[:12] as stable identifier
- Config auto-init validates config.yaml presence in main worktree

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add worktree-aware daemon PID management and multi-worktree parallel
watching with errgroup:

- Worktree-specific PID/ready/log files in daemon package
- discoverWorktreesForWatch() for automatic linked worktree detection
- watchProject() extracted for single-project watch loop
- Multi-worktree parallel watching via errgroup
- Platform-specific liveness detection (pipe on Unix, poll on Windows)
- Fix: lock file handle leak in WriteWorktreePIDFile
- Fix: deduplicate watchProject logic for no-worktree path
- Fix: remove duplicate doc comment on watchProject

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 7, 2026

Codecov Report

❌ Patch coverage is 31.28079% with 279 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.67%. Comparing base (a322537) to head (afa2aac).
⚠️ Report is 62 commits behind head on main.

Files with missing lines Patch % Lines
cli/watch.go 18.21% 228 Missing and 1 partial ⚠️
daemon/daemon.go 57.69% 34 Missing and 10 partials ⚠️
daemon/daemon_unix.go 80.00% 3 Missing and 1 partial ⚠️
daemon/workspace.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #115      +/-   ##
==========================================
+ Coverage   27.16%   35.67%   +8.51%     
==========================================
  Files          32       42      +10     
  Lines        3711     6755    +3044     
==========================================
+ Hits         1008     2410    +1402     
- Misses       2620     4136    +1516     
- Partials       83      209     +126     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yoanbernabeu
Copy link
Copy Markdown
Owner

Review & Testing Summary ✅

Full local testing completed — everything looks great.

Tests performed

1. Backward compatibility (PR binary on main-indexed project)

  • search on existing index: identical results and scores ✅
  • watch --status / watch --stop / watch --background: all work correctly ✅
  • init --yes on a new project: behavior unchanged ✅
  • Existing .grepai/ directory (config.yaml, index.gob, symbols.gob) read without issues ✅

2. New worktree features

  • Auto-init via search: running grepai search in a linked worktree with no .grepai/ auto-creates it by copying config + index + symbols from main worktree. Search works immediately. ✅
  • init --inherit: correctly detects worktree, displays info (main worktree path, worktree ID, backend), inherits config, warns about GOB per-worktree isolation. ✅
  • Multi-worktree watch: from main worktree, discovers 2 linked worktrees, watches all 3 projects in parallel via errgroup. ✅
  • Incremental indexing: file added in a worktree during watch is detected, indexed (1 chunk), and symbols extracted. Subsequent search returns it as top result. ✅

3. Unit tests

  • make test (go test -v -race ./...): all pass, 0 failures ✅

Action needed

There's a merge conflict with main — please rebase/merge to resolve it, then we can merge.

gh pr checkout 115 && git fetch origin main && git merge origin/main

@tinker495
Copy link
Copy Markdown
Contributor Author

Follow-up: merged latest upstream main as well (commit afa2aac) and resolved the only merge conflict in config/config_worktree_test.go.\n\nRe-validation:\n- go test ./... (all passing locally)\n\nCurrent PR merge state is no longer DIRTY (now UNSTABLE while checks update).

@yoanbernabeu
Copy link
Copy Markdown
Owner

Great work! 🎉

Conflict resolved, all CI checks green, code reviewed — merging.

@yoanbernabeu yoanbernabeu merged commit 43d69ca into yoanbernabeu:main Feb 8, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants