mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-12-03 03:29:51 +00:00
fix(app): Overview daily chart min 30-day window, internal scroll, native chrome
- Daily-spend chart always shows a contiguous >=30 calendar-day trend (backfilling gaps with zero bars) instead of collapsing to the period selector (e.g. a single bar on Today). - Real app shell: viewport-height window with an internally scrolling .body (was clipped/unscrollable). - Drop the wireframe's fake traffic-light dots; rely on the real OS window controls. Window background follows the system theme. - Update Overview test to assert the 30-day chart window.
This commit is contained in:
parent
95cf876999
commit
51e47112ca
4 changed files with 34 additions and 9 deletions
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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(<Overview period="week" provider="all" />)
|
||||
|
||||
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 () => {
|
||||
|
|
|
|||
|
|
@ -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<HTMLDivElement>(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({
|
|||
|
||||
<div className="ov-card ov-panel">
|
||||
<div className="ov-panel-head"><h3>Daily spend</h3><span className="r">{topModel ? `Biggest driver: ${topModel.name}` : 'No model driver yet'}</span></div>
|
||||
<div className="ov-panel-body">{periodDaily.length ? <DailyChart daily={periodDaily} /> : <EmptyNote>No spend in this range yet.</EmptyNote>}</div>
|
||||
<div className="ov-panel-body">{data.history.daily.length ? <DailyChart daily={chartDaily} /> : <EmptyNote>No spend yet.</EmptyNote>}</div>
|
||||
</div>
|
||||
|
||||
<div className="ov-card ov-panel">
|
||||
|
|
|
|||
|
|
@ -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); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue