diff --git a/app/electron/main.ts b/app/electron/main.ts index 99016945..5e7cf0a4 100644 --- a/app/electron/main.ts +++ b/app/electron/main.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, ipcMain, Menu, type MenuItemConstructorOptions } from 'electron' +import { app, BrowserWindow, ipcMain, Menu, nativeTheme, type MenuItemConstructorOptions } from 'electron' import path from 'node:path' import { CliError, resolveCodeburnPath, spawnCli } from './cli' @@ -149,7 +149,7 @@ function createWindow(): BrowserWindow { height: 820, minWidth: 900, minHeight: 600, - backgroundColor: '#0B0D13', + backgroundColor: nativeTheme.shouldUseDarkColors ? '#0e1013' : '#f5f6f8', show: false, webPreferences: { preload: path.join(__dirname, 'preload.js'), diff --git a/app/renderer/sections/Overview.test.tsx b/app/renderer/sections/Overview.test.tsx index 2deb1f98..d80d13d0 100644 --- a/app/renderer/sections/Overview.test.tsx +++ b/app/renderer/sections/Overview.test.tsx @@ -170,16 +170,17 @@ describe('Overview', () => { expect(screen.getByText('from 0 applied fixes')).toBeInTheDocument() }) - it('slices the capsule chart to the selected period window', async () => { + it('always shows at least a 30-day window regardless of the selected period', async () => { const now = new Date() getOverview.mockResolvedValue(makePayload(now)) - // period="week" → last 7 calendar days. The other 23 backfill entries are - // outside the window and must be excluded from the chart. + // The daily chart is a trend, not scoped to the period selector: even for a + // short period like "week" it renders a contiguous >= 30-day window, + // backfilling days with no activity as zero-height bars. const { container } = render() expect(await screen.findByText('parser-service')).toBeInTheDocument() - expect(container.querySelectorAll('.chart .col')).toHaveLength(7) + expect(container.querySelectorAll('.chart .col')).toHaveLength(30) }) it('computes month-to-date, projection, and previous-month pace', async () => { diff --git a/app/renderer/sections/Overview.tsx b/app/renderer/sections/Overview.tsx index f6c38c98..35735657 100644 --- a/app/renderer/sections/Overview.tsx +++ b/app/renderer/sections/Overview.tsx @@ -94,6 +94,23 @@ function streakDays(daily: DailyHistoryEntry[], now: Date): number { return streak } +// The daily chart is a trend, not scoped to the period selector: always show a +// contiguous window of at least 30 calendar days, filling gaps with zero bars. +function buildDailyWindow(daily: DailyHistoryEntry[], now: Date, days: number): DailyHistoryEntry[] { + const byDate = new Map(daily.map(day => [day.date, day])) + const window: DailyHistoryEntry[] = [] + for (let offset = days - 1; offset >= 0; offset--) { + const date = new Date(now.getFullYear(), now.getMonth(), now.getDate() - offset) + const key = localDateKey(date) + window.push(byDate.get(key) ?? { + date: key, cost: 0, calls: 0, savingsUSD: 0, + inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, + topModels: [], + }) + } + return window +} + function CountUp({ value }: { value: number }) { const ref = useRef(null) @@ -271,6 +288,7 @@ export function OverviewContent({ const now = new Date() const stats = deriveStats(data, now) const periodDaily = sliceDailyToPeriod(data.history.daily, period, now) + const chartDaily = buildDailyWindow(data.history.daily, now, Math.max(30, periodDaily.length)) const recent14 = data.history.daily.slice(-14) const dailyAverage = mean(periodDaily.map(day => day.cost)) const averageDelta = dailyAverage > 0 ? ((stats.todayCost - dailyAverage) / dailyAverage) * 100 : 0 @@ -317,7 +335,7 @@ export function OverviewContent({

Daily spend

{topModel ? `Biggest driver: ${topModel.name}` : 'No model driver yet'}
-
{periodDaily.length ? : No spend in this range yet.}
+
{data.history.daily.length ? : No spend yet.}
diff --git a/app/renderer/styles/plain.css b/app/renderer/styles/plain.css index d67ad05d..07c17a47 100644 --- a/app/renderer/styles/plain.css +++ b/app/renderer/styles/plain.css @@ -93,8 +93,14 @@ --fill: #f1f2f4; --hover: #f2f3f5; } -body { background: var(--bg); color: var(--ink); } -.win { background: var(--canvas); box-shadow: 0 1px 2px rgba(20,22,28,.08); } +html, body, #root { height: 100%; margin: 0; } +body { overflow: hidden; background: var(--bg); color: var(--ink); } +.win { height: 100%; min-height: 0; border-radius: 0; background: var(--canvas); box-shadow: none; } +.ct { min-height: 0; } +.body { overflow-y: auto; min-height: 0; } +/* Use the real OS window controls, not the wireframe's fake traffic-light dots. */ +.lights { display: none; } +.sb { padding-top: 12px; } .app b { background: none; color: var(--accent); filter: none; } .ni.on { background: var(--hover); color: var(--t1); box-shadow: none; } .ni.on::before { background: var(--accent); }