-
Notifications
You must be signed in to change notification settings - Fork 12
Show graph stats summary after watch generates initial files #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,7 +25,10 @@ | |||||||||||
| FSWatch bool | ||||||||||||
| PollInterval time.Duration | ||||||||||||
| LogFunc func(string, ...interface{}) | ||||||||||||
| OnReady func() | ||||||||||||
| // OnReady is called once after the initial generate completes. | ||||||||||||
| OnReady func(GraphStats) | ||||||||||||
| // OnUpdate is called after each incremental update completes. | ||||||||||||
| OnUpdate func(GraphStats) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Daemon watches for file changes and keeps sidecars fresh. | ||||||||||||
|
|
@@ -35,9 +38,10 @@ | |||||||||||
| cache *Cache | ||||||||||||
| logf func(string, ...interface{}) | ||||||||||||
|
|
||||||||||||
| mu sync.Mutex | ||||||||||||
| ir *api.SidecarIR | ||||||||||||
| notifyCh chan string | ||||||||||||
| mu sync.Mutex | ||||||||||||
| ir *api.SidecarIR | ||||||||||||
| notifyCh chan string | ||||||||||||
| loadedCache bool // true if startup data came from local cache | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // NewDaemon creates a daemon with the given config and API client. | ||||||||||||
|
|
@@ -70,6 +74,11 @@ | |||||||||||
| if err := d.loadOrGenerate(ctx); err != nil { | ||||||||||||
| return fmt.Errorf("startup: %w", err) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| d.mu.Lock() | ||||||||||||
| stats := computeStats(d.ir, d.cache) | ||||||||||||
| stats.FromCache = d.loadedCache | ||||||||||||
| d.mu.Unlock() | ||||||||||||
| d.writeStatus(fmt.Sprintf("ready — %s — %d nodes", | ||||||||||||
| time.Now().Format(time.RFC3339), len(d.ir.Graph.Nodes))) | ||||||||||||
|
|
||||||||||||
|
|
@@ -90,7 +99,7 @@ | |||||||||||
| d.logf("[step:3] Ready — listening on UDP :%d (debounce %s)", d.cfg.NotifyPort, d.cfg.Debounce) | ||||||||||||
| } | ||||||||||||
| if d.cfg.OnReady != nil { | ||||||||||||
| d.cfg.OnReady() | ||||||||||||
| d.cfg.OnReady(stats) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| var ( | ||||||||||||
|
|
@@ -147,6 +156,7 @@ | |||||||||||
| d.ir = &ir | ||||||||||||
| d.cache = NewCache() | ||||||||||||
| d.cache.Build(&ir) | ||||||||||||
| d.loadedCache = true | ||||||||||||
| d.mu.Unlock() | ||||||||||||
|
|
||||||||||||
| files := d.cache.SourceFiles() | ||||||||||||
|
|
@@ -164,6 +174,7 @@ | |||||||||||
| return d.fullGenerate(ctx) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| // fullGenerate does a complete fetch + render. | ||||||||||||
| func (d *Daemon) fullGenerate(ctx context.Context) error { | ||||||||||||
| d.logf("Fetching full graph from Supermodel API...") | ||||||||||||
|
|
@@ -241,16 +252,20 @@ | |||||||||||
|
|
||||||||||||
| d.logf("Updated %d sidecars", written) | ||||||||||||
|
|
||||||||||||
| var nodeCount int | ||||||||||||
| var updateStats GraphStats | ||||||||||||
| func() { | ||||||||||||
| d.mu.Lock() | ||||||||||||
| defer d.mu.Unlock() | ||||||||||||
| d.saveCache() | ||||||||||||
| nodeCount = len(d.ir.Graph.Nodes) | ||||||||||||
| updateStats = computeStats(d.ir, d.cache) | ||||||||||||
| }() | ||||||||||||
|
|
||||||||||||
| d.writeStatus(fmt.Sprintf("ready — %s — %d nodes", | ||||||||||||
| time.Now().Format(time.RFC3339), nodeCount)) | ||||||||||||
| time.Now().Format(time.RFC3339), updateStats.SourceFiles)) | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Status text/value mismatch: writes “nodes” but stores file count. At Line 264, the 💡 Proposed fix- d.writeStatus(fmt.Sprintf("ready — %s — %d nodes",
- time.Now().Format(time.RFC3339), updateStats.SourceFiles))
+ d.writeStatus(fmt.Sprintf("ready — %s — %d files",
+ time.Now().Format(time.RFC3339), updateStats.SourceFiles))📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
|
|
||||||||||||
| if d.cfg.OnUpdate != nil { | ||||||||||||
| d.cfg.OnUpdate(updateStats) | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // saveCache writes the current merged SidecarIR to the cache file. Must be called with d.mu held. | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,6 +45,31 @@ type Cache struct { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FileDomain map[string]string // filePath → domain name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // GraphStats summarises what was mapped after a generate or incremental update. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type GraphStats struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SourceFiles int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Relationships int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FromCache bool // true when data was loaded from a local cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The linked objective calls for cycle/dead-function visibility, but the new stats shape only includes files/functions/relationships. That leaves the feature partially delivered for the requested summary. 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // computeStats derives a GraphStats from a SidecarIR and its built Cache. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func computeStats(ir *api.SidecarIR, c *Cache) GraphStats { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s := GraphStats{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Relationships: len(ir.Graph.Relationships), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for _, n := range ir.Graph.Nodes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case n.HasLabel("File"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.SourceFiles++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case n.HasLabel("Function"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.Functions++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _ = c // reserved for future per-file breakdown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+57
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
At Line 63-66, counting raw 💡 Proposed fix func computeStats(ir *api.SidecarIR, c *Cache) GraphStats {
s := GraphStats{
Relationships: len(ir.Graph.Relationships),
}
- for _, n := range ir.Graph.Nodes {
+ if c != nil {
+ s.SourceFiles = len(c.SourceFiles())
+ }
+ for _, n := range ir.Graph.Nodes {
switch {
- case n.HasLabel("File"):
- s.SourceFiles++
case n.HasLabel("Function"):
s.Functions++
}
}
- _ = c // reserved for future per-file breakdown
return s
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // NewCache creates an empty Cache. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func NewCache() *Cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return &Cache{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint is failing on formatting in this file.
Pipeline shows
goimportsfailure at Line 177; please rungoimports(orgofmt+ import fix) on this file before merge.🧰 Tools
🪛 GitHub Actions: Lint
[error] 177-177: golangci-lint (goimports): File is not properly formatted (goimports check failed).
🪛 GitHub Check: golangci-lint
[failure] 177-177:
File is not properly formatted (goimports)
🤖 Prompt for AI Agents