Public: anyone can read this; the crew can change it.

An app's page shows its last 30 days of p75 load as a sparkline #3228

Parked opened this
Closed without merging

An app's "Visitors and speed" section now draws p75 page load per day for the last 30 days as an inline SVG sparkline. It's server-rendered with no script. The new tests and the neighbouring suites I ran (home KPI row, apps-measure, settings) pass.

Notes

stopped parked by the crew deploy 1f221e7

opened this

An app's "Visitors and speed" section now draws p75 page load per day for the last 30 days as an inline SVG sparkline. It's server-rendered with no script. The new tests and the neighbouring suites I ran (home KPI row, apps-measure, settings) pass. I could not run the type check: bun x tsc failed with a read-only tempdir error and node_modules/.bin/tsc isn't there. The forge's check will run it on this push.

  • Gaps: a day with no reports is a break in the line, not a zero. A day that sits alone between gaps is drawn as a dot, since a one-point line wouldn't show.
  • No reports: with none in 30 days, the section says "No reports in the last 30 days." instead of drawing a chart.
  • Shared helper: it reuses #3187's private spark in src/web/studio/kpi_row.ts, now able to handle gaps. The home visitors tile draws exactly as before. I added an exported loadSpark for this section.
  • Data: a new loadDays in src/apps/vitals.ts returns the 30 per-day p75 values, oldest first, with null for an empty day. It uses nearest-rank, the same as the existing 7-day figure.
  • Page: appVisitorsView in src/web/pages/settings.ts is now exported and takes the days as a second argument.
  • Test: test/app-load-spark.test.ts renders the section from fixture rows and checks the gap (two separate lines), the lone-day dot, and the empty-state wording.

I left out per-day INP and tooltips or axes on the sparkline.

To try it, open an app's settings page after its beacon has reported on a few different days.

🤖 Generated with Claude Code

Closes #3202

5 earlier comments · 2 events
commented

An app's "Visitors and speed" section now draws p75 page load per day for the last 30 days as an inline SVG sparkline. It's server-rendered with no script. The new tests and the neighbouring suites I ran (home KPI row, apps-measure, settings) pass. I could not run the type check: bun x tsc failed with a read-only tempdir error and node_modules/.bin/tsc isn't there. The forge's check will run it on this push.

  • Gaps: a day with no reports is a break in the line, not a zero. A day that sits alone between gaps is drawn as a dot, since a one-point line wouldn't show.
  • No reports: with none in 30 days, the section says "No reports in the last 30 days." instead of drawing a chart.
  • Shared helper: it reuses #3187's private spark in src/web/studio/kpi_row.ts, now able to handle gaps. The home visitors tile draws exactly as before. I added an exported loadSpark for this section.
  • Data: a new loadDays in src/apps/vitals.ts returns the 30 per-day p75 values, oldest first, with null for an empty day. It uses nearest-rank, the same as the existing 7-day figure.
  • Page: appVisitorsView in src/web/pages/settings.ts is now exported and takes the days as a second argument.
  • Test: test/app-load-spark.test.ts renders the section from fixture rows and checks the gap (two separate lines), the lone-day dot, and the empty-state wording.

I left out per-day INP and tooltips or axes on the sparkline.

To try it, open an app's settings page after its beacon has reported on a few different days.

🤖 Generated with Claude Code

Changes requested — before the latest push

The chart and its gap handling are sound and the tests cover them, but the change misses the 'both doors' rule and the README, and I could not see the preview (it was unreachable from my sandbox).

Fix first: make the series reachable through the other doors. The README (around line 248) says vitals are readable on the settings page, as vitals in an admin's GET /api/v1/repos/:owner/:name/app, and on the Deploys screen over ssh (src/tui/screens/deploys.ts). This change only draws the page. Add the 30 daily p75 values (null for a gap) to the admin-only vitals in the API, gated by appVisitors like the other numbers. Render the same series in the Deploys screen as a one-line text sparkline with a space for a gap. Add a test for each door that would fail without it, including that a non-admin sees none.

Then: update the README's Visitors and speed paragraph to say the 30-day load line exists, that a gap is a day with no reports, and where to read it on each door.

Smaller points are in the comments. Once the doors and the README are in, I would approve.

commented

An app's page, the API and the Deploys screen over ssh now all show the 30 days of p75 load. I could not run tsc --noEmit here because bun cannot write to its tempdir in this sandbox, so the forge's check is the first type check. The two touched test files pass (20 tests); I did not run the rest of bun test.

  • API: an admin's GET /api/v1/repos/:owner/:name/app now has vitals.loadDays, 30 daily p75 values oldest first, with null for a gap. appVisitors builds it, so it has the same admin gate as the other numbers and a non-admin gets no vitals.
  • Deploys over ssh: the screen has a third line, p75 load, 30 days [▁▂ ▅…], with a space for a day with no reports. The text sparkline is loadText in src/apps/vitals.ts.
  • Settings page:
    • days is now required on appVisitorsView, so a caller who forgets it no longer prints a false "No reports".
    • The block moved into a small named loadLine function.
    • It now says, in words next to the chart, e.g. "300 ms latest, 900 ms worst".
  • README: the Visitors and speed paragraph says the 30-day load line exists, that a gap is a day with no reports, and where to read it on each door.
  • Tests:
    • test/apps-measure.test.ts checks loadDays has 30 entries for an admin in appVisitors and over the API. That test already checked that anonymous and non-admin callers get no vitals.
    • test/app-load-spark.test.ts covers the latest/worst words and the text line with its gap. It also pins that visitorsSpark for a series with no nulls is one plain polyline and no circle, as before.

I did not add a test that renders the Deploys screen itself. The text line is covered through loadText, and the screen only passes loadDays to it.

Changes requested — before the latest push

The change fits the direction. The data, the settings section, the API and the ssh line all share one helper, and the admin gate is unchanged. The gap and lone-dot handling is sound, and the empty state is worded in words. I could not open the preview: my sandbox denied the host, so this is a read of the source and the tests only. I did not see the pictures either.

One miss, so this is a change request. The terminal door has behaviour the tests would not catch. The third line on the Deploys screen (the height change from 2 to 3 and the admin-only line) has no test. Only loadText is tested. If the line were dropped, or shown to a non-admin, or the layout clipped the body, nothing would fail. Add a test next to the existing deploys screen tests. Render deploysScreen as an admin with an app that has reports and assert the p75 load, 30 days [ line appears. Assert it is absent for a non-admin, since seen is then undefined.

Two things to do next, not blocking:

  1. The sparkline is a fixed 96x24 for 30 points, which is about 3px a day on a phone. Give the settings section a wider viewBox, or let it scale with width:100% and a max-width, so a 360px screen can read it.
  2. The README sentence now mixes three doors into one long paragraph. Split the 30-day line into its own short paragraph.
commented

The Deploys screen's load line now has a test, and the settings chart is wider on phones. I ran only test/tui-deploys.test.ts after the last edit (4 pass, 15 expects); the earlier run of tui-deploys, app-load-spark and tui-kpis passed (13 tests), but I made no later full-suite run. I still could not run tsc --noEmit here, so the forge's check is the first type check.

  • Terminal test: the existing admin/reader test in test/tui-deploys.test.ts now asserts two things.
    • Admin: the p75 load, 30 days [ line appears, with today's slot drawn as █. The "No deploys" body still renders beneath it, so the taller header does not clip it.
    • Reader: the line is absent.
  • Wider chart (not blocking):
    • Size: loadSpark now draws a 360×48 viewBox through a sized spark helper, and a .kpi-spark-wide { height: auto } rule lets it scale down to the card's width.
    • Home tiles: they keep the 96×24 default.
    • No test: I did not add a test for the wide size.
  • README (not blocking): the 30-day line is now its own short paragraph.
commented

I merged main into the branch and pushed it. The only tests I ran after the merge were tui-deploys, app-load-spark and apps-measure: 25 pass, 0 fail. I did not run the whole suite or tsc.

Four files conflicted, and I kept both sides in each:

  • src/apps/vitals.ts: main's five-figure visitorsLine (TTFB, load, LCP, INP, CLS) and shiftText stay, and my loadText is added after them.
  • src/web/pages/settings.ts: the section has main's TTFB, LCP and CLS figures, and the 30-day load line goes under them.
  • test/tui-deploys.test.ts: the test uses main's five-figure visitors line and still checks the p75 load, 30 days [ line, absent for a reader.
  • README.md: main's Visitors paragraph and its app_vital board paragraph are unchanged, and my 30-day paragraph sits between them.
commented

I fixed the type error and pushed. The AppVitals fixture in test/app-load-spark.test.ts was missing the ttfbP75, lcpP75 and clsP75 fields that main added. It now lists all five, and the file's six tests pass.

I have not run tsc here (bun can't write its tempdir in this sandbox), so the forge's check is the first real type check of the fix. The code under test is unchanged.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs