fix: correct context bomb zeros for lines and language counts#13
fix: correct context bomb zeros for lines and language counts#13claude[bot] merged 1 commit intomainfrom
Conversation
- Remove Stats.TotalLines (not available in API response) - Remove '· N lines' from the context bomb template - Change Stats.Languages from map[string]int to []string since the API only returns language names, not per-language counts - Change irSummary from a typed struct to map[string]any so that summary fields are read dynamically, avoiding silent zero-fills if API field names change - Update languageList template func to accept []string and render plain names (e.g. 'go, json') instead of 'go (0), json (0)' Fixes #7 Co-authored-by: Grey Newell <greynewell@users.noreply.github.com>
WalkthroughThe Summary field in SupermodelIR transforms from a structured type into a dynamic map[string]any, and irSummary type is removed. Stats.Languages changes from a count map to a simple string list. Template rendering logic updates to handle these structural shifts and removes the unavailable TotalLines field. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/api/client.go (1)
70-79: Clean helper, with a small testing consideration.The comment on line 71 nails it—JSON numbers always unmarshal as
float64intomap[string]any, so this is correct for production.One heads-up: if you ever write unit tests where you manually construct a
Summarymap like this:ir := SupermodelIR{Summary: map[string]any{"filesProcessed": 42}} // int, not float64...it would silently return
0because42is anint, notfloat64. You'd need to write:ir := SupermodelIR{Summary: map[string]any{"filesProcessed": float64(42)}}Not a bug per se—just a potential gotcha for future test authors.
🔧 Optional: Handle both int and float64 for test friendliness
summaryInt := func(key string) int { if v, ok := ir.Summary[key]; ok { if n, ok := v.(float64); ok { return int(n) } + if n, ok := v.(int); ok { + return n + } } return 0 }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/api/client.go` around lines 70 - 79, The helper summaryInt currently only handles float64 and will return 0 if the Summary map contains an int (common in tests); update summaryInt to accept additional numeric types (int, int32, int64, uint, json.Number) and convert them to int before returning so both real JSON-unmarshaled data and manually-constructed test maps (e.g., SupermodelIR.Summary) behave the same; locate the summaryInt closure in internal/api/client.go and add type switches/handling for these numeric variants and safe bounds/conversion to int.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@internal/api/client.go`:
- Around line 70-79: The helper summaryInt currently only handles float64 and
will return 0 if the Summary map contains an int (common in tests); update
summaryInt to accept additional numeric types (int, int32, int64, uint,
json.Number) and convert them to int before returning so both real
JSON-unmarshaled data and manually-constructed test maps (e.g.,
SupermodelIR.Summary) behave the same; locate the summaryInt closure in
internal/api/client.go and add type switches/handling for these numeric variants
and safe bounds/conversion to int.
Remove
Stats.TotalLines(not in API response), changeStats.Languagesfrommap[string]intto[]string, and changeirSummaryfrom a typed struct tomap[string]anyto avoid silent zero-fills if API field names change.Closes #7
Generated with Claude Code
Summary by CodeRabbit