You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Three files have outgrown their responsibilities. All three splits are pure code motion — no logic changes.
pkg/tui/chart.go (1333 lines, five responsibilities):
ZoomLevel + time↔column geometry (lines ~19-220)
Skyline-morph rasterization/drawing (~239-348)
Nice-number math + value formatting — formatTokenCount/formatUnitValue/formatBarValue/groupThousands/compactSig3/... (~394-468, 812-1011) — three number-formatting families living 400 lines apart is how their precision rules drifted into needing 📊 tui: higher-precision number formatting on 24h bars (fill the bar width) #324
pkg/cache/cache.go (997 lines, four responsibilities): DB lifecycle (55-248, 651-663), usage-samples write/read (250-471, 964-997), message/cursor ingest (473-649), bucket aggregation (665-944). The package already set the precedent with recost.go / projects.go / lock.go — cache.go just never got the same treatment; new methods get appended wherever (e.g. EarliestMessageTime at 946 sits between zoomLabel and the warn-once machinery).
cmd/ccpulse/main.go (554 lines): status/index/doctor/recost each get their own file, but the config and version commands (with three inline anonymous subcommands + ensureConfigFile, main.go:117-195), the quota poller, backfill, and cache-rebuild helpers all live in main.go.
🛠️ Suggested shape
pkg/tui: split into format.go (number formatting), geometry.go (ZoomLevel, columnToTime/timeToColumn/bucketCountInRange/computeSpringSlice), labels.go (overlay*/splice/buildXLabelsRow/crossfadeLabelRow), skyline.go (rasterize/draw, pairs with zoomspring.go); chart.go keeps buildChart/buildLineChart
pkg/cache: split into usage_samples.go, buckets.go, ingest.go; lifecycle stays in cache.go
cmd/ccpulse: split out config.go and version.go command files; move runTUI + helpers to tui.go; main.go keeps main(), newRootCmd, globals
⚠️ Notes
Same-package file moves: zero semantic change, git log -L/blame friendliness is the only real cost.
Can land as three independent small PRs (one per file) or one mechanical PR.
🔍 Problem
Three files have outgrown their responsibilities. All three splits are pure code motion — no logic changes.
pkg/tui/chart.go(1333 lines, five responsibilities):formatTokenCount/formatUnitValue/formatBarValue/groupThousands/compactSig3/... (~394-468, 812-1011) — three number-formatting families living 400 lines apart is how their precision rules drifted into needing 📊 tui: higher-precision number formatting on 24h bars (fill the bar width) #324pkg/cache/cache.go(997 lines, four responsibilities): DB lifecycle (55-248, 651-663), usage-samples write/read (250-471, 964-997), message/cursor ingest (473-649), bucket aggregation (665-944). The package already set the precedent withrecost.go/projects.go/lock.go— cache.go just never got the same treatment; new methods get appended wherever (e.g.EarliestMessageTimeat 946 sits betweenzoomLabeland the warn-once machinery).cmd/ccpulse/main.go(554 lines): status/index/doctor/recost each get their own file, but theconfigandversioncommands (with three inline anonymous subcommands +ensureConfigFile,main.go:117-195), the quota poller, backfill, and cache-rebuild helpers all live in main.go.🛠️ Suggested shape
pkg/tui: split intoformat.go(number formatting),geometry.go(ZoomLevel, columnToTime/timeToColumn/bucketCountInRange/computeSpringSlice),labels.go(overlay*/splice/buildXLabelsRow/crossfadeLabelRow),skyline.go(rasterize/draw, pairs with zoomspring.go);chart.gokeeps buildChart/buildLineChartpkg/cache: split intousage_samples.go,buckets.go,ingest.go; lifecycle stays in cache.gocmd/ccpulse: split outconfig.goandversion.gocommand files; moverunTUI+ helpers totui.go; main.go keepsmain(),newRootCmd, globalsgit log -L/blame friendliness is the only real cost.