feat(startup): opt-in auto-resume of all indexed projects#72
Conversation
SOCRATICODE_AUTO_RESUME=all resumes the file watcher and incremental catch-up for every indexed project with a stored path on server startup. SOCRATICODE_AUTO_RESUME_PROJECTS accepts an explicit comma-separated list and takes precedence. Default (both unset) keeps the original cwd-only behavior. Multi-project resume is strictly sequential so N projects never run concurrent embedding catch-ups, and every skipped project (missing directory, no stored path, not indexed) is logged at warn level.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds environment-variable-driven multi-project auto-resume for file watchers (explicit list via SOCRATICODE_AUTO_RESUME_PROJECTS or all indexed via SOCRATICODE_AUTO_RESUME=all), refactors per-project resume into awaited sequential flows with recovery and incremental catch-up, and adds unit tests and README docs. ChangesMulti-project auto-resume implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/services/startup.ts`:
- Around line 271-283: The current flow calls startWatching(resolvedPath) before
the try/catch and if it throws the subsequent updateProjectIndex(resolvedPath)
is skipped; modify the code so failures to start the watcher don't prevent the
incremental update: wrap the startWatching call in a safe try/catch (or move it
inside the existing try) that catches and logs errors from startWatching (using
logger) but does not rethrow, and ensure updateProjectIndex(resolvedPath) still
runs inside the try block so the incremental re-embed proceeds even if
isWatching/startWatching fails.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 842f5b05-20b6-422a-912b-97a8b18637e9
📒 Files selected for processing (3)
README.mdsrc/services/startup.tstests/unit/startup.test.ts
…rows startWatching can throw outside its internal guard (lock-file writes, gitignore reads). Wrap it so a watcher failure degrades to a warning instead of skipping the project's catch-up update, which would leave the index stale.
Summary
On server startup, auto-resume (file watcher plus incremental catch-up update) can now cover every indexed project instead of only the one at
process.cwd(). Two opt-in environment variables control it; with both unset, behavior is unchanged. This closes the gap where per-session MCP clients (Claude Code and similar) lose the watchers of every project not opened in the current session, leaving their indexes stale until a manualcodebase_watch start.Changes
autoResumeIndexedProjects(src/services/startup.ts) now supports three modes:SOCRATICODE_AUTO_RESUME_PROJECTS=path1,path2: resume an explicit comma-separated list (comma matches the existingSOCRATICODE_LINKED_PROJECTSconvention). Takes precedence overSOCRATICODE_AUTO_RESUME.SOCRATICODE_AUTO_RESUME=all: resume every indexed project whose Qdrant metadata has a stored path.SOCRATICODE_AUTO_RESUMEvalue (which falls back to the default mode with a warning).resumeProjecthelper; all existing log messages, guard ordering, and the default-mode flow are preserved verbatim. Qdrant collections are fetched once per startup instead of per project.Existing safety machinery is reused, not duplicated: cross-process watch locks prevent concurrent sessions from double-watching a repo, a failed watcher subscribe on a stale path logs and releases its lock, and repeatedly erroring watchers self-stop.
Type of change
Testing
npm run test:unit): 840/840, including 12 new testsnpm run test:integration) — if applicablenpx tsc --noEmit)The 12 new tests in tests/unit/startup.test.ts encode the contract, not just coverage: strict sequencing is proven by holding project A's catch-up promise open and asserting project B is untouched until it resolves; precedence of the explicit list over
=allis asserted via metadata never being consulted; each skip path (missing directory, unindexed explicit entry at warn level, no stored path, vanished stored path, empty list, unrecognized mode value) asserts its specific warn log; failure isolation is proven by making one project's status lookup throw and asserting the next still resumes. The 25 pre-existing startup tests pass unchanged, pinning the default mode exactly.Checklist
Related issues
Fixes #70
Summary by CodeRabbit
New Features
Documentation
Tests