From 0e24544d757c737eaf98e8fbaf971dec74c36e3d Mon Sep 17 00:00:00 2001 From: DexterStorey Date: Wed, 22 Jul 2026 15:36:08 -0400 Subject: [PATCH 1/4] session reset time on analytics, fixes #9 --- CHANGELOG.md | 3 ++- package.json | 2 +- src/tui/dashboard.ts | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41911f6..c6e09a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ -- [2026-07-22] alpha channel +- [2026-07-22] session reset time on analytics, fixes #9 +- [2026-07-22] [alpha channel](https://github.com/RubricLab/tokenmaxx/commit/5e106a78a47a6265b37dbd3713cbe17635458372) - [2026-07-21] follow claude's profile email rename - [2026-07-21] [failed logins say why](https://github.com/RubricLab/tokenmaxx/commit/e28f1472327450ca8e7640ca7ab5c3b945790a31) - [2026-07-20] [readme](https://github.com/RubricLab/tokenmaxx/commit/e2d9002286227126cb529961d6bad9ca4bc36f6c) diff --git a/package.json b/package.json index 2ffa1fe..c3d402d 100644 --- a/package.json +++ b/package.json @@ -59,5 +59,5 @@ "post-commit": "bun x @rubriclab/package post-commit" }, "type": "module", - "version": "0.0.53" + "version": "0.0.54" } diff --git a/src/tui/dashboard.ts b/src/tui/dashboard.ts index 6a7dcbe..d177036 100644 --- a/src/tui/dashboard.ts +++ b/src/tui/dashboard.ts @@ -424,16 +424,38 @@ function tabBar(ctx: Ctx, tab: Tab) { ) } -function analyticsBar(ctx: Ctx, timeframe: Timeframe, view: AnalyticsView) { +function sessionResets(ctx: Ctx, snapshot: DashboardSnapshot): string | null { + const parts = providerOrder.flatMap(provider => { + const state = snapshot.providers.find(s => s.provider === provider) + if (state?.activeAccountId == null) { + return [] + } + const windows = snapshot.usage.find(u => u.accountId === state.activeAccountId)?.windows ?? [] + const reset = shortReset(windows.find(isFiveHour)?.resetAt ?? null, ctx.now) + return reset === null ? [] : [`${providerCli[provider]} ${reset}`] + }) + return parts.length === 0 ? null : `↻ session · ${parts.join(' · ')}` +} + +function analyticsBar( + ctx: Ctx, + snapshot: DashboardSnapshot, + timeframe: Timeframe, + view: AnalyticsView +) { const ranges = TIMEFRAMES.flatMap((option, index) => [ ...(index === 0 ? [] : [Text({ content: ' ', fg: rgb(ctx.theme.faint) })]), pill(ctx, option.label, option.key === timeframe.key) ]) + const resets = sessionResets(ctx, snapshot) return Box( { flexDirection: 'row', width: '100%' }, Text({ content: 'range ', fg: rgb(ctx.theme.dim) }), ...ranges, Box({ flexGrow: 1 }), + ...(resets === null || ctx.tier === 'compact' + ? [] + : [Text({ content: resets, fg: rgb(ctx.theme.dim) }), Box({ flexGrow: 1 })]), Text({ attributes: view === 'chart' ? 1 : 0, content: 'chart', @@ -661,7 +683,18 @@ function analyticsBody( }, ...body ) - return column(ctx, [analyticsBar(ctx, timeframe, state.analyticsView), card], 150) + const resets = sessionResets(ctx, analytics.snapshot) + return column( + ctx, + [ + analyticsBar(ctx, analytics.snapshot, timeframe, state.analyticsView), + card, + ...(resets === null || ctx.tier !== 'compact' + ? [] + : [centered(Text({ content: resets, fg: rgb(ctx.theme.dim) }))]) + ], + 150 + ) } function dwellLabel(milliseconds: number): string { From d39703d09048f8d029caa1b7097c1ea1cc2c0fb0 Mon Sep 17 00:00:00 2001 From: DexterStorey Date: Wed, 22 Jul 2026 17:45:42 -0400 Subject: [PATCH 2/4] the chart leaves room for the lines under it --- src/tui/dashboard.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tui/dashboard.ts b/src/tui/dashboard.ts index bf3f07d..5a25338 100644 --- a/src/tui/dashboard.ts +++ b/src/tui/dashboard.ts @@ -551,7 +551,7 @@ function centered(...children: ReturnType[]) { } function throughputChart(ctx: Ctx, tokens: TokenTimeframe, timeframe: Timeframe, width: number) { - const height = Math.max(4, Math.min(10, ctx.rows - 15)) + const height = Math.max(4, Math.min(10, ctx.rows - 18)) const body: ReturnType[] = [] const axisTop = `${compactNumber(tokens.peakPerHour)}/h` const gutter = Math.max(6, axisTop.length) @@ -697,9 +697,11 @@ function chartView(ctx: Ctx, tokens: TokenTimeframe, timeframe: Timeframe, width ) } body.push(centered(...headline)) - body.push( - centered(Text({ content: 'press m for the full pricing breakdown', fg: rgb(ctx.theme.faint) })) - ) + if (ctx.rows >= 28) { + body.push( + centered(Text({ content: 'press m for the full pricing breakdown', fg: rgb(ctx.theme.faint) })) + ) + } return body } From ac52e30659547bdca75c0acd9ba849402d9f4e7e Mon Sep 17 00:00:00 2001 From: DexterStorey Date: Wed, 22 Jul 2026 17:47:46 -0400 Subject: [PATCH 3/4] session line names the active account --- src/tui/dashboard.ts | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/tui/dashboard.ts b/src/tui/dashboard.ts index 5a25338..73b554d 100644 --- a/src/tui/dashboard.ts +++ b/src/tui/dashboard.ts @@ -494,32 +494,28 @@ function sessionResets(ctx: Ctx, snapshot: DashboardSnapshot): string | null { if (state?.activeAccountId == null) { return [] } + const account = snapshot.accounts.find(a => a.id === state.activeAccountId) const windows = snapshot.usage.find(u => u.accountId === state.activeAccountId)?.windows ?? [] const reset = shortReset(windows.find(isFiveHour)?.resetAt ?? null, ctx.now) - return reset === null ? [] : [`${providerCli[provider]} ${reset}`] + if (account === undefined || reset === null) { + return [] + } + const label = account.label.length <= 22 ? account.label : `${account.label.slice(0, 21)}…` + return [`${providerCli[provider]} · ${label} · ↻ ${reset}`] }) - return parts.length === 0 ? null : `↻ session · ${parts.join(' · ')}` + return parts.length === 0 ? null : parts.join(' ') } -function analyticsBar( - ctx: Ctx, - snapshot: DashboardSnapshot, - timeframe: Timeframe, - view: AnalyticsView -) { +function analyticsBar(ctx: Ctx, timeframe: Timeframe, view: AnalyticsView) { const ranges = TIMEFRAMES.flatMap((option, index) => [ ...(index === 0 ? [] : [Text({ content: ' ', fg: rgb(ctx.theme.faint) })]), pill(ctx, option.label, option.key === timeframe.key) ]) - const resets = sessionResets(ctx, snapshot) return Box( { flexDirection: 'row', width: '100%' }, Text({ content: 'range ', fg: rgb(ctx.theme.dim) }), ...ranges, Box({ flexGrow: 1 }), - ...(resets === null || ctx.tier === 'compact' - ? [] - : [Text({ content: resets, fg: rgb(ctx.theme.dim) }), Box({ flexGrow: 1 })]), Text({ attributes: view === 'chart' ? 1 : 0, content: 'chart', @@ -753,11 +749,9 @@ function analyticsBody( return column( ctx, [ - analyticsBar(ctx, analytics.snapshot, timeframe, state.analyticsView), + analyticsBar(ctx, timeframe, state.analyticsView), card, - ...(resets === null || ctx.tier !== 'compact' - ? [] - : [centered(Text({ content: resets, fg: rgb(ctx.theme.dim) }))]) + ...(resets === null ? [] : [centered(Text({ content: resets, fg: rgb(ctx.theme.dim) }))]) ], 150 ) From fadf45318330f55295bc5f79af50d553d5fc923b Mon Sep 17 00:00:00 2001 From: DexterStorey Date: Wed, 22 Jul 2026 17:48:48 -0400 Subject: [PATCH 4/4] settings without the caption --- src/tui/dashboard.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tui/dashboard.ts b/src/tui/dashboard.ts index 73b554d..9f4adc1 100644 --- a/src/tui/dashboard.ts +++ b/src/tui/dashboard.ts @@ -901,8 +901,7 @@ function settingsBody(ctx: Ctx, snapshot: DashboardSnapshot, rows: SettingRow[], ctx, [ settingsPanel(ctx, snapshot, rows, 'openai', selected), - settingsPanel(ctx, snapshot, rows, 'anthropic', selected), - Box({ flexDirection: 'row' }, Text({ content: 'changes apply live', fg: rgb(ctx.theme.faint) })) + settingsPanel(ctx, snapshot, rows, 'anthropic', selected) ], 78 )