feat: track API profile per session for per-profile stats (#32)#38
feat: track API profile per session for per-profile stats (#32)#38
Conversation
- Add Profile field to SessionRecord, populated with config.Default at scan time - Add ByProfile map to DailyStat for per-profile cost aggregation - Add ProfileCost struct and TopProfiles to Summary - Add ProfileBreakdown() aggregator function - Update Aggregate() to populate ByProfile data - Add 'profile' view to TUI Stats tab f-key cycle (all→project→model→profile→all) - Add aggregateByProfile() and rendering in stats_view.go
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThe changes introduce profile-level cost tracking throughout the stats system. Profiles are detected from config during session scanning, accumulated in daily stats aggregations, exposed via a ProfileBreakdown function, and rendered in the TUI alongside existing project and model breakdowns. Changes
Sequence DiagramsequenceDiagram
participant Scanner as Session Scanner
participant Config as Config System
participant Aggregator as Stats Aggregator
participant TUI as TUI Display
Scanner->>Config: Load default user profile
Config-->>Scanner: Return profile (or "unknown")
Scanner->>Scanner: ScanSessions with currentProfile
Scanner->>Scanner: parseSessionFile(..., profile)
Scanner->>Scanner: Create SessionRecord with Profile field
Scanner->>Aggregator: Pass SessionRecord with profile
Aggregator->>Aggregator: Accumulate costs to DailyStat.ByProfile
Aggregator->>Aggregator: ProfileBreakdown(dailyStats)
Aggregator-->>Aggregator: Return sorted []ProfileCost
Aggregator->>Aggregator: GenerateSummary with TopProfiles
Aggregator-->>TUI: Summary containing TopProfiles
TUI->>TUI: aggregateByProfile(dailyStats)
TUI->>TUI: Render "By Profile" section
TUI-->>TUI: Display profile costs sorted
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Profilefield toSessionRecord, populated withconfig.Defaultat scan time (falls back to"unknown")ByProfile map[string]float64toDailyStatfor per-profile cost aggregationProfileCoststruct,ProfileBreakdown()function, andTopProfilestoSummaryfkey now cycles all → project → model → profile → allChanges
internal/stats/types.goProfileonSessionRecord,ByProfileonDailyStat,ProfileCoststruct,TopProfilesonSummaryinternal/stats/scanner.goconfig.Defaultat scan time and pass toparseSessionFileinternal/stats/aggregator.goByProfileinAggregate, addProfileBreakdown(), include inGenerateSummaryinternal/tui/stats_view.goprofiletof-key cycle,aggregateByProfile(), "By Profile:" render sectionTest plan
go vet ./...— no errorsgo test ./...— all tests passcodes→ Stats tab → pressfrepeatedly to cycle through all/project/model/profile viewsSummary by CodeRabbit
New Features