Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ codexometer --codex /path/to/codex

The responsive top rail below the account status selects Quota, Monitor, or
Benchmark by mouse, `Tab`, or `Shift+Tab`. Quota adds a second rail for Bars,
Pie, Consumption Pace, and Fuel Tank; select these with the mouse or cycle them
Consumption Pace, Pie, and Fuel Tank; select these with the mouse or cycle them
with `v`. Codexometer remembers the selected Quota view when you leave
and return. Both rails condense automatically as the terminal narrows.
The footer presents the remaining actions as clickable buttons, including View
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ func benchmarkSegmentButtonAt(localX int, segments []benchmarkControlSegment) fo
}

func (m Model) benchmarkHeaderAt(x, y int) (benchmarkSortColumn, bool) {
if m.meterStyle != styleBenchmark || x < 0 || y < 0 {
if m.meterView != viewBenchmark || x < 0 || y < 0 {
return benchmarkSortNone, false
}
dashboard := m.dashboardLayout()
Expand Down
24 changes: 12 additions & 12 deletions internal/ui/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (f benchmarkStubFetcher) RunBenchmarkSuite(ctx context.Context, tasks []cod

func TestBenchmarkViewRendersResponsiveResultsTable(t *testing.T) {
model := Model{
width: 100, height: 30, meterStyle: styleBenchmark,
width: 100, height: 30, meterView: viewBenchmark,
benchmarkState: benchmarkFinished,
benchmarkResults: []codex.BenchmarkResult{
{TaskName: "MERGE RANGES", Model: "gpt-5.6-sol", DisplayName: "GPT-5.6 Sol", Effort: "high", Correct: true, Duration: 12500 * time.Millisecond, Usage: codex.BenchmarkUsage{TotalTokens: 4321}, UsageKnown: true, CostKnown: true, CostUSD: 0.0412},
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestVeryShortBenchmarkAreaExposesNoHiddenMouseTargets(t *testing.T) {
for _, height := range []int{8, 9, 10} {
model := Model{
snapshot: codex.DemoSnapshot(), width: 40, height: height,
meterStyle: styleBenchmark,
meterView: viewBenchmark,
}
dashboard := model.dashboardLayout()
if dashboard.meterHeight >= 3 {
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestBenchmarkHotkeyRunsSuiteAndCollectsEvents(t *testing.T) {
model := New(fetcher, time.Minute)
model.snapshot = codex.DemoSnapshot()
model.loading = false
model.meterStyle = styleBenchmark
model.meterView = viewBenchmark

updated, command := model.Update(key('b'))
model = updated.(Model)
Expand Down Expand Up @@ -214,7 +214,7 @@ func TestBenchmarkButtonSupportsHoverAndClick(t *testing.T) {
model.snapshot = codex.DemoSnapshot()
model.loading = false
model.width, model.height = 100, 30
model.meterStyle = styleBenchmark
model.meterView = viewBenchmark
x, y := benchmarkControlCoordinates(t, model, footerButtonBenchmarkSelected)
mouse := tea.MouseMsg{X: x, Y: y, Action: tea.MouseActionMotion}
updated, command := model.Update(mouse)
Expand Down Expand Up @@ -250,7 +250,7 @@ func TestBenchmarkTableClipsOlderRows(t *testing.T) {
}

func TestBenchmarkPageKeysAndMouseWheelScrollResults(t *testing.T) {
model := Model{width: 90, height: 28, meterStyle: styleBenchmark, benchmarkState: benchmarkFinished}
model := Model{width: 90, height: 28, meterView: viewBenchmark, benchmarkState: benchmarkFinished}
for index := 0; index < 30; index++ {
model.benchmarkResults = append(model.benchmarkResults, codex.BenchmarkResult{DisplayName: "Model", Effort: "low"})
}
Expand All @@ -273,7 +273,7 @@ func TestBenchmarkPageKeysAndMouseWheelScrollResults(t *testing.T) {

func TestBenchmarkHeadingButtonsSortAndReverse(t *testing.T) {
model := Model{
width: 100, height: 30, meterStyle: styleBenchmark, benchmarkState: benchmarkFinished,
width: 100, height: 30, meterView: viewBenchmark, benchmarkState: benchmarkFinished,
benchmarkResults: []codex.BenchmarkResult{
{DisplayName: "Zulu", Effort: "low", Duration: 2 * time.Second, Usage: codex.BenchmarkUsage{TotalTokens: 200}},
{DisplayName: "Alpha", Effort: "high", Correct: true, Duration: time.Second, Usage: codex.BenchmarkUsage{TotalTokens: 100}},
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestBenchmarkRenderedClickSurfacesMatchHitTestingAcrossSizes(t *testing.T)
t.Run(fmt.Sprintf("%dx%d", size.width, size.height), func(t *testing.T) {
model := Model{
snapshot: codex.DemoSnapshot(), width: size.width, height: size.height,
meterStyle: styleBenchmark, benchmarkCombinations: 3,
meterView: viewBenchmark, benchmarkCombinations: 3,
}
dashboard := model.dashboardLayout()
geometry := layoutBenchmarkArea(dashboard.contentWidth, dashboard.meterHeight)
Expand Down Expand Up @@ -563,7 +563,7 @@ func TestBenchmarkTaskSelectorRunAllGuardAndExactTurnCount(t *testing.T) {
model.snapshot = codex.DemoSnapshot()
model.loading = false
model.width, model.height = 100, 30
model.meterStyle = styleBenchmark
model.meterView = viewBenchmark
model.benchmarkCombinations = 33

updated, _ := model.Update(tea.KeyMsg{Type: tea.KeyRight})
Expand Down Expand Up @@ -617,7 +617,7 @@ func TestBenchmarkSelectorAnchorsButtonsToLongestTaskName(t *testing.T) {
}
}

clickable := Model{snapshot: codex.DemoSnapshot(), width: 100, height: 30, meterStyle: styleBenchmark}
clickable := Model{snapshot: codex.DemoSnapshot(), width: 100, height: 30, meterView: viewBenchmark}
nextX, nextY := benchmarkControlCoordinates(t, clickable, footerButtonBenchmarkNext)
for range clickable.benchmarkTasks() {
clickable.selectBenchmarkTask(1)
Expand All @@ -633,7 +633,7 @@ func TestBenchmarkRunAllLaunchesUnifiedCatalog(t *testing.T) {
model := New(fetcher, time.Minute)
model.snapshot = codex.DemoSnapshot()
model.loading = false
model.meterStyle = styleBenchmark
model.meterView = viewBenchmark
model.benchmarkCombinations = 1

model, _ = model.activateFooterButton(footerButtonBenchmarkAll)
Expand Down Expand Up @@ -681,7 +681,7 @@ func TestBenchmarkRunAllAvailabilityRequiresTasksAndCombinations(t *testing.T) {

func TestBenchmarkPassFailFilterButtonsAndHotkey(t *testing.T) {
model := Model{
width: 100, height: 30, meterStyle: styleBenchmark, benchmarkState: benchmarkFinished,
width: 100, height: 30, meterView: viewBenchmark, benchmarkState: benchmarkFinished,
benchmarkResults: []codex.BenchmarkResult{
{DisplayName: "Passing", TaskName: "LRU CACHE", Correct: true},
{DisplayName: "Failing", TaskName: "SHORTEST PATH", Correct: false},
Expand All @@ -706,7 +706,7 @@ func TestBenchmarkPassFailFilterButtonsAndHotkey(t *testing.T) {

func TestBenchmarkRankWeightButtonsAndHotkeyRecomputeImmediately(t *testing.T) {
model := Model{
width: 100, height: 30, snapshot: codex.DemoSnapshot(), meterStyle: styleBenchmark,
width: 100, height: 30, snapshot: codex.DemoSnapshot(), meterView: viewBenchmark,
benchmarkRankMode: benchmarkRankBalanced,
benchmarkResults: []codex.BenchmarkResult{
{Model: "cheap", DisplayName: "Cheap", Effort: "low", Correct: true, Duration: 30 * time.Second, CostKnown: true, CostUSD: 0.01},
Expand Down
60 changes: 30 additions & 30 deletions internal/ui/meters.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import (
"github.com/merefield/codexometer/internal/codex"
)

func usesMeterGrid(style meterStyleID) bool {
switch style {
case styleBars, stylePie, styleConsumptionPace, styleFuel:
func usesMeterGrid(view meterViewID) bool {
switch view {
case viewBars, viewPie, viewConsumptionPace, viewFuel:
return true
default:
return false
}
}

func renderMeterGrid(width, height int, meters []codex.Meter, style meterStyleID, colors palette) string {
func renderMeterGrid(width, height int, meters []codex.Meter, view meterViewID, colors palette) string {
if len(meters) == 0 {
return ""
}
const columnGap = 1
columns := meterGridColumns(width, height, len(meters), style)
columns := meterGridColumns(width, height, len(meters), view)
rows := (len(meters) + columns - 1) / columns
rowGap := 1
// A framed meter needs at least its title, body, and bottom border. Drop the
Expand All @@ -49,7 +49,7 @@ func renderMeterGrid(width, height int, meters []codex.Meter, style meterStyleID
pieces = append(pieces, strings.Repeat(" ", columnGap))
}
if meterIndex < len(meters) {
pieces = append(pieces, renderMeterArea(columnWidths[column], rowHeight, meters[meterIndex], style, colors))
pieces = append(pieces, renderMeterArea(columnWidths[column], rowHeight, meters[meterIndex], view, colors))
} else {
pieces = append(pieces, strings.Repeat(" ", columnWidths[column]))
}
Expand All @@ -63,13 +63,13 @@ func renderMeterGrid(width, height int, meters []codex.Meter, style meterStyleID
return grid
}

func meterGridColumns(width, height, meterCount int, style meterStyleID) int {
if style == styleBars || style == styleConsumptionPace || style == styleFuel {
func meterGridColumns(width, height, meterCount int, view meterViewID) int {
if view == viewBars || view == viewConsumptionPace || view == viewFuel {
return 1
}
minimumColumns := 1
maximumColumns := meterCount
if isRadialStyle(style) && meterCount > 1 {
if isRadialView(view) && meterCount > 1 {
minimumColumns = 2
// Below this width the circular canvas and title both become ambiguous.
// Retain at least two columns, then add more only when each card remains
Expand All @@ -87,8 +87,8 @@ func meterGridColumns(width, height, meterCount int, style meterStyleID) int {
visualChrome := 6
visualHeight := max(cellHeight-visualChrome, 1)
detail := innerWidth * visualHeight
switch style {
case stylePie:
switch view {
case viewPie:
canvasWidth, canvasHeight := radialCanvasSize(innerWidth, visualHeight, 11)
detail = canvasWidth * canvasHeight
}
Expand All @@ -100,8 +100,8 @@ func meterGridColumns(width, height, meterCount int, style meterStyleID) int {
return bestColumns
}

func isRadialStyle(style meterStyleID) bool {
return style == stylePie
func isRadialView(view meterViewID) bool {
return view == viewPie
}

func distributeSpace(total, parts int) []int {
Expand All @@ -117,29 +117,29 @@ func distributeSpace(total, parts int) []int {
return sizes
}

func renderMeter(width int, meter codex.Meter, style meterStyleID, colors palette) string {
return renderMeterArea(width, 0, meter, style, colors)
func renderMeter(width int, meter codex.Meter, view meterViewID, colors palette) string {
return renderMeterArea(width, 0, meter, view, colors)
}

func renderMeterArea(width, height int, meter codex.Meter, style meterStyleID, colors palette) string {
func renderMeterArea(width, height int, meter codex.Meter, view meterViewID, colors palette) string {
used := min(max(meter.Window.UsedPercent, 0), 100)
free := 100 - used
color := meterColor(used, colors)
innerWidth := max(width-4, 1)

usedText := lipgloss.NewStyle().Bold(true).Foreground(color).Render(fmt.Sprintf("USED %3d%%", used))
freeText := colors.dimmed().Render(fmt.Sprintf("FREE %3d%%", free))
if style == styleFuel {
if view == viewFuel {
usedText = colors.dimmed().Render(fmt.Sprintf("USED %3d%%", used))
freeText = lipgloss.NewStyle().Bold(true).Foreground(colors.primary).Render(fmt.Sprintf("FREE %3d%%", free))
}
gap := max(innerWidth-lipgloss.Width(usedText)-lipgloss.Width(freeText), 1)
stats := usedText + strings.Repeat(" ", gap) + freeText
if style == styleFuel {
if view == viewFuel {
stats = freeText + strings.Repeat(" ", gap) + usedText
}
if lipgloss.Width(stats) > innerWidth {
if style == styleFuel {
if view == viewFuel {
stats = freeText
} else {
stats = usedText
Expand All @@ -166,13 +166,13 @@ func renderMeterArea(width, height int, meter codex.Meter, style meterStyleID, c
visualHeight = max(bodyHeight-chromeHeight, 1)
}
now := time.Now()
visual := renderVisualizationSized(innerWidth, visualHeight, used, style, color, colors)
if style == styleConsumptionPace {
visual := renderVisualizationSized(innerWidth, visualHeight, used, view, color, colors)
if view == viewConsumptionPace {
visual = renderConsumptionPaceMeterSized(innerWidth, visualHeight, meter.Window, now, colors)
}
gaugeWidth := min(max(lipgloss.Width(visual), 1), innerWidth)
resetGauge := renderResetGauge(innerWidth, gaugeWidth, meter.Window, now, reset, color, colors)
if style == styleFuel {
if view == viewFuel {
gaugeWidth = max(innerWidth-6, 1)
resetGauge = renderReverseResetGauge(innerWidth, gaugeWidth, meter.Window, now, reset, color, colors)
}
Expand Down Expand Up @@ -290,19 +290,19 @@ func meterColor(used int, colors palette) lipgloss.Color {
return colors.primary
}

func renderVisualization(width, used int, style meterStyleID, color lipgloss.Color, colors palette) string {
return renderVisualizationSized(width, 0, used, style, color, colors)
func renderVisualization(width, used int, view meterViewID, color lipgloss.Color, colors palette) string {
return renderVisualizationSized(width, 0, used, view, color, colors)
}

func renderVisualizationSized(width, height, used int, style meterStyleID, color lipgloss.Color, colors palette) string {
switch style {
case stylePie:
func renderVisualizationSized(width, height, used int, view meterViewID, color lipgloss.Color, colors palette) string {
switch view {
case viewPie:
return renderPieSized(width, height, used, color, colors)
case styleConsumptionPace:
case viewConsumptionPace:
return renderConsumptionPaceSized(width, height, 0, false, colors)
case styleFuel:
case viewFuel:
return renderFuelTankSized(width, height, used, color, colors)
case styleBars:
case viewBars:
return renderClassicBarSized(width, height, used, color, colors)
default:
return renderClassicBarSized(width, height, used, color, colors)
Expand Down
Loading
Loading