From 1cdb39786ddcc1315aaa39098a8b431e3e10bb1b Mon Sep 17 00:00:00 2001 From: jonathanpopham Date: Tue, 7 Apr 2026 19:34:51 -0400 Subject: [PATCH] fix: eliminate double API call in analyze when file mode is on When file mode is enabled (default), `supermodel analyze` was making two separate API calls to the same endpoint: first via analyze.Run() (caching to ~/.supermodel/cache/), then via files.Generate() (caching to .supermodel/graph.json). Both uploaded the same zip to /v1/graphs/supermodel. Fix: when file mode is on, skip analyze.Run() and let files.Generate() handle the entire pipeline (upload + cache + sidecars) in a single API call. When --no-files is set, use the original analyze.Run() path. The --force flag is passed through to files.Generate() so it bypasses the sidecar cache when requested. --- cmd/analyze.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/analyze.go b/cmd/analyze.go index 21b9f66..8770673 100644 --- a/cmd/analyze.go +++ b/cmd/analyze.go @@ -36,13 +36,13 @@ Use --no-files to skip writing graph files.`, if len(args) > 0 { dir = args[0] } - if err := analyze.Run(cmd.Context(), cfg, dir, opts); err != nil { - return err - } if cfg.FilesEnabled() && !noFiles { - return files.Generate(cmd.Context(), cfg, dir, files.GenerateOptions{}) + // File mode: Generate handles the full pipeline (API call + + // cache + sidecars) in a single upload. Running analyze.Run + // first would duplicate the API call. + return files.Generate(cmd.Context(), cfg, dir, files.GenerateOptions{Force: opts.Force}) } - return nil + return analyze.Run(cmd.Context(), cfg, dir, opts) }, }