refactor(trace): deduplicate workspace helpers, eliminate double scan, add error logging#164
Open
jugrajsingh wants to merge 3 commits intoyoanbernabeu:mainfrom
Open
Conversation
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.
Covers LoadWorkspaceSymbolStores with missing config, unknown workspace, unknown project, multi-project loading, and single project filtering. Also tests CloseSymbolStores.
Remove trailing whitespace and normalize alignment detected by gofmt and whitespace hooks.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #164 +/- ##
===========================================
+ Coverage 27.16% 44.51% +17.35%
===========================================
Files 32 67 +35
Lines 3711 12769 +9058
===========================================
+ Hits 1008 5684 +4676
- Misses 2620 6526 +3906
- Partials 83 559 +476 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Description
Addresses the three non-blocking review suggestions from PR #121:
Extract shared workspace symbol store helpers —
loadWorkspaceSymbolStoresandcloseSymbolStoreswere duplicated incli/trace.goandmcp/server.go. Extracted intotrace/workspace.goas exported functionsLoadWorkspaceSymbolStores/CloseSymbolStores, used by both consumers.Eliminate double filesystem scan —
runInitialScanincli/watch.gocalledscanner.ScanMetadata()twice: once insideIndexAllWithBatchProgressand once more for symbol extraction. AddedScannedFilesfield toIndexStatsso callers can reuse the file list from the first scan.Add error logging for silent discards — ~21 instances of
_, _ :=on symbol store lookups and config loads acrosscli/trace.goandmcp/server.gonow log warnings vialog.Printfinstead of silently discarding errors.Related Issue
Follow-up to #121
Type of Change
How Has This Been Tested?
Unit tests:
trace/workspace_test.gocovering: missing config, unknown workspace, unknown project, multi-project loading, project filtering, and CloseSymbolStoresmake pre-commit)Manual testing:
grepai watch --workspace <name>— 10 projects, 1043 files, 4695 chunks, 4987 symbols indexed successfullygrepai trace callers <symbol> --workspace <name>— verified callers found across workspace for multiple symbolsTest Configuration:
Checklist
golangci-lint runand fixed any issuesAdditional Notes
mcp/server.goversion ofloadWorkspaceSymbolStoreswas a*Servermethod but never used any receiver fields, making extraction straightforward