Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

Usage cost-trend bars render at zero pixels: items-end collapses each column to its label, so the percentage heights resolve against nothing

Open schmetti-dev opened this issue 3 months ago • 1 comments

The Usage tab's cost-trend chart renders bars whose percentage heights are correct and whose pixel heights are all zero, so a tab with weeks of cost data shows an empty box under the "Cost trend" header. The axis labels render, which makes it read as "the chart works, there is no data" rather than as a bug.

LIFEOS/PULSE/Observability/src/app/usage/page.tsx:

<div className="flex items-end gap-1 h-48">
  {trend.map((p) => (
    <div key={p.label} className="flex-1 flex flex-col items-center justify-end group min-w-0" title={...}>
      <div
        className="w-full rounded-t transition-colors"
        style={{ height: `${Math.max(2, (p.costUsd / maxCost) * 100)}%`, background: "var(--accent-blue)" }}
      />
      <div className="text-[9px] text-ink-3 mt-1 truncate w-full text-center">{p.label.slice(5)}</div>
    </div>
  ))}
</div>

items-end on the row is align-items: flex-end, so each column is sized to its content instead of stretching. The content is the 9px label, so the column resolves to ~17px inside a 192px (h-48) row, and the bar's height: N% resolves against almost nothing.

Measured

19 days of data, read from the live DOM with getBoundingClientRect():

Day style.height rendered px
08-12 22.3011% 0
08-20 64.7542% 0
08-22 100% 0

Every bar 0px; the enclosing column measured 17.25px against a 180px row.

Fix

Give each column the row's height and put the bar in a flex track above the label, so the percentage has a definite basis:

<div className="flex-1 h-full flex flex-col items-center justify-end group min-w-0">
  <div className="w-full flex-1 min-h-0 flex flex-col justify-end">
    <div className="w-full rounded-t transition-colors" style={{ height: ..., background: ... }} />
  </div>
  <div className="text-[9px] ...">{p.label.slice(5)}</div>
</div>

After that change, same data: 19 bars, none at zero, tallest 162.8px, pixel heights proportional to the percentages.

Note for anyone verifying

Observability/out is a tracked static export and is what Pulse serves (dashboardDir in pulse.ts), so a source-only change ships with no visible effect until bun run build is committed alongside it.

Verified on 7.40.4.

schmetti-dev avatar Aug 27 '26 20:08 schmetti-dev

Withdrawing this — the fix exists and belongs in a PR rather than a report. Sorry for the noise.

schmetti-dev avatar Aug 27 '26 20:08 schmetti-dev