Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,29 +245,51 @@ func runWithoutCache(cfg *config.Config, proj *project.Info, wm *project.Working
return nil
}

// fetchGraphWithCircularDeps calls GetGraph and GetCircularDependencies, storing
// cycle count in Stats so it is cached alongside the graph.
// fetchGraphWithCircularDeps calls GetGraph and GetCircularDependencies concurrently,
// storing cycle count in Stats so it is cached alongside the graph.
func fetchGraphWithCircularDeps(
ctx context.Context,
client *api.Client,
projectName string,
repoZip []byte,
logFn func(string, ...interface{}),
) (*api.ProjectGraph, error) {
graph, err := client.GetGraph(ctx, projectName, repoZip)
if err != nil {
return nil, err
type graphResult struct {
graph *api.ProjectGraph
err error
}
type circResult struct {
circDeps *api.CircularDependencyResponse
err error
}

circDeps, err := client.GetCircularDependencies(ctx, projectName, repoZip)
if err != nil {
logFn("[warn] circular dependency check failed: %v", err)
} else if circDeps != nil {
graph.Stats.CircularDependencyCycles = len(circDeps.Cycles)
logFn("[debug] circular dependency cycles found: %d", graph.Stats.CircularDependencyCycles)
graphCh := make(chan graphResult, 1)
circCh := make(chan circResult, 1)

go func() {
g, err := client.GetGraph(ctx, projectName, repoZip)
graphCh <- graphResult{g, err}
}()

go func() {
c, err := client.GetCircularDependencies(ctx, projectName, repoZip)
circCh <- circResult{c, err}
}()

gr := <-graphCh
if gr.err != nil {
return nil, gr.err
}

cr := <-circCh
if cr.err != nil {
logFn("[warn] circular dependency check failed: %v", cr.err)
} else if cr.circDeps != nil {
gr.graph.Stats.CircularDependencyCycles = len(cr.circDeps.Cycles)
logFn("[debug] circular dependency cycles found: %d", gr.graph.Stats.CircularDependencyCycles)
}

return graph, nil
return gr.graph, nil
}

// silentExit returns nil (success) so we never block Claude Code sessions.
Expand Down