feat(workspace): add trace, symbol indexing, and watcher fixes for workspace mode#121
Conversation
Cover path prefixing behavior for SaveChunks, DeleteByFile, GetDocument, SaveDocument, DeleteDocument with both absolute and relative paths. Also verify projectFileEvent carries embedded FileEvent and Project context.
Add 26 tests covering workspace multi-project functionality: - trace/store_test.go: 11 GOBSymbolStore tests (save, delete, lookup, callers, callees, call graph, persist/reload, stats, replace-on-save) - cli/trace_test.go: 5 workspace trace CLI tests (error handling, closeSymbolStores, --project validation, cross-store aggregation) - mcp/server_test.go: 10 MCP workspace tests (resolveWorkspace, workspace params on trace tools, index status schema, handleTraceCallersFromStores/CalleesFromStores aggregation)
Persist now calls MkdirAll before creating the GOB file, ensuring workspace projects without a .grepai/ directory can write symbols.
Document --workspace/--project flags on trace commands, update MCP tool parameter tables, and replace stale warning about trace tools not working in workspace mode.
Replace hardcoded Unix paths with filepath.Join and t.TempDir() so tests pass on Windows where filepath.Rel cannot resolve Unix-style absolute paths.
Use filepath.ToSlash after filepath.Rel to ensure vector store paths always use forward slashes regardless of OS. Extracts toRelSlash helper to eliminate duplicated path resolution logic.
Use filepath.ToSlash after filepath.Rel to ensure vector store paths always use forward slashes regardless of OS. Extracts toRelSlash helper to eliminate duplicated path resolution logic.
…fixes' into feature/workspace-trace-watcher-fixes
|
Hey @jugrajsingh 👋 Great work on this PR! The code looks solid overall — nice refactoring of However, this PR currently has merge conflicts with Thanks! |
# Conflicts: # CHANGELOG.md # cli/watch.go # trace/store_test.go
- Remove orphaned ready-file block from watchProject (upstream uses onReady callback) - Update handleWorkspaceFileEvent call signature in initialscan test - Rewrite watch_test.go to match upstream function signatures - Rename workspace fixture in tests to "test"
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #121 +/- ##
===========================================
+ Coverage 27.16% 44.77% +17.61%
===========================================
Files 32 50 +18
Lines 3711 9348 +5637
===========================================
+ Hits 1008 4186 +3178
- Misses 2620 4794 +2174
- Partials 83 368 +285 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Use filepath.ToSlash in test expectations to match the production code's forward-slash normalization, fixing Windows CI failures. Also rename workspace fixture in tests to generic "test".
Add tests for outputJSON, displayCallersResult, displayCalleesResult, displayGraphResult, truncate, isTracedLanguage, stopWorkspaceWatchDaemon, loadWorkspaceSymbolStores (with filter and error cases), and runTraceCallees/Graph validation.
|
Hey @yoanbernabeu, conflicts are resolved and all CI checks are passing (tests green on all platforms including Windows). Is there anything else blocking the merge or are we good to go? |
|
Hey @jugrajsingh 👋 Thanks for the rebase! Unfortunately, new merges on I've done a thorough code review and here's my feedback: ✅ What looks great
🔧 Suggestions for improvement (non-blocking)
🚫 Blocking
Once the conflicts are resolved, we're good to merge! 🚀 |
…ce-watcher-fixes # Conflicts: # cli/watch.go # mcp/server.go # trace/store.go
|
Hey @yoanbernabeu, thanks for the detailed review! Merge conflicts are resolved again — rebased on latest Regarding your suggestions:
Happy to address these in a follow-up to keep this PR focused. Ready to merge whenever you are! |
Extract shared LoadWorkspaceSymbolStores and CloseSymbolStores into trace/workspace.go, eliminating ~50 lines of duplication between cli/trace.go and mcp/server.go. Add ScannedFiles field to IndexStats so runInitialScan reuses the file list from IndexAllWithBatchProgress instead of calling scanner.ScanMetadata() a second time. Replace ~21 silent error discards (_, _ :=) on symbol store and config operations with log.Printf warnings in both cli/trace.go and mcp/server.go.
Summary
handleWorkspaceFileEventcompared relative event paths against absolute project paths. Replaced path matching with per-project event tagging viaprojectFileEventstruct.grepai watch --workspacenow extracts symbols and builds per-project call graphs (stored in.grepai/symbols.gobper project, regardless of vector backend).grepai trace callers/callees/graphsupports--workspaceand--projectflags for single-project or cross-project call graph analysis.grepai_index_statussupportworkspaceandprojectparameters, with auto-injection when--workspaceis set onmcp-serve.SymbolStoreinterface: Generic interface intrace/trace.gofor symbol store implementations.GOBSymbolStore.Persist: Create parent directories automatically so workspace projects without.grepai/don't fail.projectPrefixStorefor cross-platform compatibility.Test plan
make pre-commitpasses (fmt, vet, lint, test)gitleaks detect— no leaksgrepai watch --workspace test— all projects indexed with symbolsgrepai trace callers— single-project and cross-project aggregationgrepai trace callees— single-project with cross-file resolutiongrepai trace graph --depth 3— 60+ nodes, 100+ edgesgrepai search --workspace test— vector search unaffected