Skip to content

feat(dash): five-page dashboard, bottom line first (#473) - #477

Merged
amiddavid merged 5 commits into
mainfrom
feat/dashboard-five-pages
Oct 12, 2026
Merged

amiddavid merged 5 commits into
mainfrom
feat/dashboard-five-pages

Conversation

@OsherElhadad

@OsherElhadad OsherElhadad commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Redesigns the dashboard home as five pages: Home, Savings, Cache, Tools & context, Sessions. The previous 17-view dashboard stays at /dashboard/index.html (linked from the footer) for settings, requests and admin.

Stacked on #445: the pages read the same endpoints, and a cold 30-day read of /api/tools can still take about a minute on a 3.6 GB database, so the pages draw the fast parts first and retry the slow one. This branch also merges current main into #445's branch. The 5 golden files that merge moved (keep-alive defaults from #444, the billed-elsewhere change) are regenerated in their own commit, test(dash): regenerate golden files after merging main, so they can be reviewed apart from the feature. Merge #445 first and this reduces to the dashboard files.

What changed

  • Every page: bottom line (one number, one sentence), one recommendation with its copy-command or link (the rest behind "More"), one chart, details behind a click.
  • Realised savings (solid green card, hatched bars) and forecasts or upper bounds (dashed amber card) are separate and never added. Badges: Saved, Estimated, Measured.
  • Header states scope, period and data age. Tooltips on jargon. Light, dark, phone width. Contrast checked at 4.5:1 or better in both themes.
  • /api/sessions?sort=cost returns the costliest sessions first.
  • Old bookmarks: a classic hash such as /dashboard/#/savings/usage opens the classic dashboard; #home, #savings, #cache, #tools, #sessions open the new pages. /dashboard/index.html is unchanged.
  • Tests: dash/v2.test.mjs (models, ranking, bookmarks, filler-word check), run from TestV2Models; TestServedUIVersionsEveryAssetItReferences updated for the second document.

Before and after (synthetic fixture data, 1280 px)

Page Before After
Home
Savings
Cache
Tools & context
Sessions

Dark and phone shots of every page: https://raw.githubusercontent.com/rossoctl/context-guru/dashboard-v2-assets/after/ (<page>-<light|dark>-<desktop|phone>.png).

Checks

No horizontal scroll at 390 px on any page, light or dark. Numbers above the fold: Home 5, Cache 5, Tools 4 (priced fixture shows fewer), Savings 6, Sessions 5. The full go test ./dash passed once (302 s) on an earlier build; on the final build under heavy host load seven unrelated tests hit SQLITE_BUSY, and they pass when run alone with the dashboard tests. A full run on a quiet host is still pending.

Osher-Elhadad added 2 commits October 11, 2026 04:11
Measured on a 3.6 GB snapshot of a production database (187k requests,
1.76M request_components, 2.3M tool_declarations), one client, fresh process,
all-time window. Before: Overview 12 s, /api/components 20 s, the Inventory
reads 14-21 s, the KV-cache replays 46-52 s, /api/prompt 21 s, the keep-alive
reads 4-6 s, and /api/series answered its default bucket with 12.9 MB. After,
cold: every endpoint 0.4-4.7 s except Overview at 6.1 s; repeated reads of
any endpoint 10-20 ms. Every number is unchanged (see the tests below).

Root causes, each fixed where it lived:

* Correlated subqueries and per-account re-runs. The replay-ceiling count and
  the ping-inflation sum ran one index walk per saving/ping row (11 s + 4 s);
  both are window functions now, over only the sessions that need them. The
  keep-alive behaviour panel re-ran its LAG CTE once per account for a median;
  it reads every account's gaps once. The keep-alive ledger, calculator and
  recommendation ran 4-6 independent full passes back to back; they run
  together.
* Five passes over requests for five GROUP BYs, and four sorted OFFSET reads for
  two p95s and two medians: one grouped read and one value read each, re-grouped
  and ranked in Go with the same rank rule.
* The components tab joined request_components (1.7M rows) to requests three
  times for the rows and the two read-time valuations, plus json_each over 945k
  gate/event strings (allocation-bound: 7 us a row, 2.7x on eight cores). One
  join at the finest grain feeds the rows and both valuations; the counters are
  summed in Go from the raw JSON when it is a flat integer object (anything else
  falls back to json_each); the join is read in eight id slices side by side.
* The Inventory reads probed tool_declarations once per in-scope session
  (~1,000 rows each, 11 s) or sorted all 2.3M rows. A broad scope now makes one
  concurrent pass over the table and reduces it in Go; a narrow scope keeps the
  probe. The report and the observation windows share the pass.
* Every KV-cache read rebuilt the same window-function dataset (4.5 s). An
  unbounded read is split in four shards of whole sessions (exact: a session
  never straddles two); a time-bounded one stays a single statement (sharding it
  repeats the index lookups per shard and measured slower). The row count and
  the median prefix skip the window when nothing narrows on a derived column.
* BudgetPolicy.Windows asked the reuse model for 4n points and the model rebuilt
  its whole curve for each (25 of the 29 s of an all-history simulate). It
  builds it once per observation and reads it 4n times; the early exit it
  replaces could not change a read (documented at reuseCurve). The policy
  remembers its last answer, which Simulate asks for twice per request. Suggest
  cells and simulate arms are independent replays and run side by side.
* /api/series answered the route's one-minute default bucket over all history
  as 78,000 buckets; it is widened to a whole multiple that fits 2,000 buckets
  (the UI's hourly request is unchanged: 1,305 buckets).
* The remaining heavy GET routes had no response cache and the UI reads them on
  every tab switch. They go through the existing stale-while-revalidate
  singleflight cache (cachedRoute), with the heavy handler bound so the first
  reader after a restart waits for the real work. /api/prompt caches the
  UNSTRIPPED view and applies the per-address content strip to each reader's own
  copy, so nothing that depends on the address is shared.
* The DSN ran journal_mode before busy_timeout, so a connection opened while the
  WAL was busy failed at once with SQLITE_BUSY; the fan-out reads open bursts of
  connections, so busy_timeout now comes first.

No schema change and no new index: the pass over tool_declarations replaces the
index a faster GROUP BY would have needed, and building one costs ~40 s of
start-up downtime on this corpus.

TestGoldenEndpoints pins 28 endpoint payloads, number for number (relative
1e-9 on floats), to files recorded from the code before this change.
perf_equivalence_test.go pins each rewritten read to the one it replaced.

Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Design review, round 1: dashboard. Reviewed the fold screenshots (desktop and phone, light and dark) against the five-second questions in QUESTIONS.md and the text and number budgets. Reviewer persona: a busy first-time user. Counts below are from the fold screenshots on the demo fixture.

5-second test

Page Result What a first-time user gets wrong
Home NO Q1 yes. Q2 partly: "8.2% off" is clear, but the page then shows eight numbers. Q3 partly: the amber card names no action, the action only appears further down
Savings NO Reads "Keep-alive so far $0 / Ceiling" as "the feature did nothing"; the note about the provider's cache saving $0 contradicts "63% served from cache" on Home
Cache NO Q1 is answered with a percent, not dollars. Q2 ("am I losing money") is only answered by the forecast; the loss itself is shown as a turn count
Tools & context NO Hero says "Unknown", so Q1 and Q2 cannot be answered. The useful fact (most declared tools never used) is demoted to a side label
Sessions PARTLY Q1 and Q2 yes. Q3: item 1 is a session id and a turn count with no reason to open it

Rubric

Item Result
One sentence and one number per page PASS on Home, Savings, Sessions; FAIL on Tools
Ranked recommendations with dollars and an action FAIL on Tools (empty) and Sessions (no action)
No paragraph over 2 lines FAIL: the Sessions hero wraps one word ("it.") to a third line; Savings has loose notes outside any card
At most 5 numbers above the fold FAIL: Home 8, Savings 7, Cache 6, Sessions 7
Jargon has a tooltip FAIL: keep-alive, ceiling, upper bound, forecast, tokens, "rewrite"
Realised vs estimated visually separate PASS (dashed amber vs solid green)
Header: scope, period, freshness PASS
Contrast (tokens) PASS in both themes
Units and rounding FAIL: one page shows the period total as $1,960, another as $1,956

Findings

  1. BLOCKING, Home, above the fold: eight distinct numbers (savings, percent, forecast, range, paid, cache share, period, timer). Cut to five. Drop the "$141 to $185" range from the recommendation row (it repeats the card above) and drop "5-minute" from the card text.
  2. BLOCKING, Home, amber card: "Best next step" shows a dollar figure and explanatory text but no action verb or button; the action is in the list below. Put the Copy button in the card, or make the card the first list item.
  3. BLOCKING, Savings, "Keep-alive so far / $0 / Ceiling": "Ceiling" and "upper bound" are jargon, and a $0 under a feature name reads as failure. Say "Not turned on yet" when it is off, and drop the word Ceiling.
  4. BLOCKING, Savings, loose note under the recommendation: "the provider's own cache saved $0" sits next to Home's "63% served from cache". Same thing, opposite impression. Reword to say that the provider's saving is not counted in our number, or remove it from this page.
  5. BLOCKING, Cache, hero: the number is a percent of input. The user asked "am I losing money". Lead with the dollars lost on cache rewrites (observed), with the 63% as support. Also "408 turns paid to rewrite it" is jargon; say "408 times you waited too long and paid full price again".
  6. BLOCKING, Tools & context, hero: "Unknown" as the headline. If prices are missing, say so as a status, and use the real finding as the hero (share of declared tools never called). Never show a hero that answers nothing.
  7. BLOCKING, Tools & context: the recommendations list is empty and the two charts render blank in the fold. An empty state must say what to do ("Prices are not loaded: run the doctor check") rather than "Every tool server was used".
  8. BLOCKING, Sessions, recommendation 1: "Session sess-53: 28 turns" is not a recommendation and carries no reason. Say why this one is first ("Costs 2x the typical session; most of it was one long pause") and attach a saving or an action.
  9. BLOCKING, Sessions vs Home: $1,956 against $1,960 for the same period and scope. The footnote explains it, but a first-time user sees a mismatch. Use one definition on both, or label Sessions' number as "agent requests only" in the hero itself, not behind a badge.
  10. POLISH, Sessions hero: a one-word widow ("it."). Shorten the sentence to fit two lines.
  11. POLISH, Cache hero: "Observed Observed from your logs" repeats the label. Drop the second.
  12. POLISH, vocabulary: "Estimated" (Home saving), "Forecast", "Ceiling", "Upper bound", "Observed". The plugin calls the same Home figure "Realised, modelled". Pick one vocabulary for both surfaces: Saved (measured on your requests), Could save (forecast).
  13. POLISH, phone, Home: the nav tabs clip ("Tools & conte"). Allow wrap or scroll with a visible edge.
  14. POLISH, "Served from cache" card: "Cache is the provider's feature" is the tooltip text printed inline; fine for the first mention, then remove it to save a line.

Next: the author fixes 1-9; I re-judge on new screenshots.

@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Design review, round 2: dashboard. Re-judged the refreshed fold screenshots (light, desktop). Not PASS yet; 3 BLOCKING items remain, everything else from round 1 is fixed.

5-second test

Page Result Note
Home YES saved, share of bill, and the next step with its button are all readable in the first screen
Savings YES "Not on yet" reads correctly; green vs amber stays separate
Cache YES dollars lost lead; percent is support
Tools & context YES share never called is the hero; missing prices are stated as a status
Sessions YES item 1 now says why it is first

Rubric

Item Result
One sentence, one number PASS
Ranked recommendations with dollars and action FAIL on item 2 (Home, Savings, Tools): shows "500 tokens a turn", not dollars
No paragraph over 2 lines FAIL: Cache hero sentence runs 3 lines plus a label line
At most 5 numbers above the fold FAIL on Home, Savings, Tools (recommendation 2 and the chart axis pull in extra numbers); Cache and Sessions pass or are close
Jargon has a tooltip PASS (tool definitions, cache, tenth of the price)
Realised vs estimated separate PASS
Header PASS
Contrast PASS
Units and rounding PASS ($1,956 vs $1,960 now explained in the hero)

Remaining findings

  1. BLOCKING, Home / Savings / Tools, recommendation 2: "500 tokens a turn" is a raw token count and not dollars. Convert to dollars with the gateway rate; if prices are missing, say "price unknown" and rank it below the dollar items.
  2. BLOCKING, Cache hero: the sentence is three lines. Cut to two ("You paid $X extra when the cache expired. Keep-alive would have avoided most of it.") and move the 408 and 63% into the label line or details.
  3. BLOCKING, number budget above the fold: Home and Savings still show more than five distinct numbers because the second recommendation and the chart axis reach the fold. Either shorten the page head so recommendation 2 falls below the fold, or fold recommendations 2 and later behind "More".
  4. POLISH, Sessions: the line "Start with the costliest session..." sits loose above the list and wraps to a second line with one word; drop it or merge it into the item.
  5. POLISH, Home vs plugin: badges read "Estimated" for the saved figure here and "Realised, modelled" in the plugin. Align when convenient.

Next: author fixes 1-3, then I re-judge.

@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Design review, round 3: PASS.

Re-judged the refreshed fold screenshots (all five pages, light and dark; phone spot-check on Sessions). All five pass the 5-second test. Round-2 blockers are fixed: unpriced items read "price unknown" and rank below dollar items, the Cache hero sentence is two lines, and only recommendation 1 shows on each page with the rest behind "More recommendations". Rubric: all items pass (bottom line, ranked recommendations with action, paragraph length, number budget on Home, Savings, Cache and Sessions, tooltips, realised vs estimated, header, contrast, units).

Remaining POLISH, non-blocking:

  1. Tools & context: the two side cards and the bar values bring the fold to about eight numbers, and "Average prompt 35k tokens" is a raw token count. Drop or move that card behind a click.
  2. Cache hero: the label line ("408 times; 63% of input still came from cache") wraps to two lines; shorten.
  3. Badge vocabulary differs from the plugin ("Estimated" here, "Realised, modelled" there); align in a later pass.

@OsherElhadad

OsherElhadad commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Review of 458eee7 (superseded by the re-review below). Fresh worktree, nice 19.

Verified

  • Full go test ./dash (957 s, host load 30-50): the only failures were SQLITE_BUSY (database is locked) in unrelated accounting/archive tests, while a second heavy read was running. Re-run alone after the load dropped: the V2, served-UI, sessions and all six previously failing tests pass (2.4 s). The same SQLITE_BUSY flake hits TestAPIRoutesServeJSON on origin/main.
  • Cold /api/tools read, a reflink copy of the 3.6 GB snapshot per tree, same harness, run back to back under heavy load: origin/main 503 at the 45 s ceiling on the first call, then 500 after 30 s on the second; this branch 503 at 45 s, then 200 in 16.9 s (557 KB). So no regression, and the second call is faster here (the speed-up comes from perf(dash): cut all-time dashboard endpoint latency 3-25x, same numbers #445's perf commit; this PR changes no /api/tools code). Caveat: both first calls hit the 45 s timeout under this load, so "about a minute cold" is accurate and the pages must keep the retry. Not a clean timing; load was ~30.
  • Server-side change beyond perf(dash): cut all-time dashboard endpoint latency 3-25x, same numbers #445 is small: SessionsOrdered with sort=cost (ORDER BY SUM(cost_usd)); parameterised, no injection. The UI builds DOM with textContent / setAttribute only, no innerHTML; hrefs are fixed strings.
  • Privacy: no hosts, ids or paths in the diff. Attribution clean.

Findings

  1. (non-blocking) The PR regenerates 5 golden files that main's keep-alive defaults had moved. Say which commit moved them, or land that as a separate fix, so a bisect does not blame the dashboard.
  2. (non-blocking) /dashboard/ now serves the new home and the old UI needs the explicit /dashboard/index.html; existing bookmarks and docs/dashboard.md deep links should be checked.
  3. Merge order: this PR contains perf(dash): cut all-time dashboard endpoint latency 3-25x, same numbers #445; merge perf(dash): cut all-time dashboard endpoint latency 3-25x, same numbers #445 first.

Approving on top of #445. Labelled ready-to-merge.

@OsherElhadad OsherElhadad added the ready-to-merge Program PR approved by the reviewer, CI green; needs maintainer approval label Oct 12, 2026
@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Test result on the final build (commit "tools page within the number budget; Saved/Estimated badges"):

  • node --test dash/v2.test.mjs: 12 pass, 0 fail.
  • go test ./dash (full package, host load average about 29): FAILED, 7 tests, every failure database is locked (SQLITE_BUSY) under load (TestAnAbandonedAnalysisStopsReading, TestComponentSavedUSDArrivesWithoutDiscardingRows, TestComponentsCached, TestFilterEveryDimension, TestPreColumnComponentRowsAreValuedNotZeroed, TestPromptTextIsStoredOnlyWithContentConsent, TestStatsLeanIsACacheKeySeparateFromTheFullHandler). Run alone, those seven plus TestV2Models and the served-UI tests pass (35 s). An earlier full run on the previous build passed (ok, 302 s). A full run on a quiet host is still needed before merge.
  • Tools & context fold: four figures visible (94%, 769, 500, one count in the text), down from eight; average prompt and share removed now sit in a closed "Prompt size" section.
  • Badges: "Saved" for the realised figure, "Estimated" for forecasts and ceilings, "Measured" for plain spend and cache-share facts.

Osher-Elhadad added 2 commits October 12, 2026 10:23
…faults, billed-elsewhere); fixture writer for demo databases

Signed-off-by: Osher-Elhadad <[email protected]>
@OsherElhadad
OsherElhadad force-pushed the feat/dashboard-five-pages branch from d061eaf to db0cd5c Compare October 12, 2026 10:24
@OsherElhadad

OsherElhadad commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Re-check after the force-push: Cache page, fold and full page. Still PASS.

Hero, one recommendation, the input chart with legend and the collapsed "Why turns missed the cache" read cleanly, and the page is shorter. My earlier comments on this PR do not describe the removed section.

One POLISH note: the keep-alive card badge now reads "Estimated", the same word as the green saved figure on other pages. The dashed amber card still keeps them visually apart, but "Could save" was clearer; consider restoring it.

@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Answers to the review points.

Golden files (5, commit "test(dash): regenerate golden files after merging main"), by cause:

Links to /dashboard/ found in the repo: the proxy start message, the plugin's start script, install.sh and the docs open the new home, which is intended. The only link that needed the old view was docs/how-to/measure-savings.md (/dashboard/#sessions); it now points at /dashboard/index.html#/traffic/sessions. The classic dashboard stays at /dashboard/index.html, and old classic hashes such as /dashboard/#/savings/usage redirect there. Note the one-level classic hashes that are also page names (#sessions, #savings, #cache, #tools) now open the new pages.

Serial full-suite result follows when the run finishes.

@amiddavid
amiddavid merged commit 9336b46 into main Oct 12, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Oct 12, 2026
@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Re-review of db0cd5c (force-pushed): the campaign slot, its sample data and screenshots are gone (grep of dash/ finds only the existing strategy-campaign code), the golden regeneration is its own commit (b8e30ac), and the old bookmarks redirect to /dashboard/index.html. vet clean; V2 and served-UI tests pass; the full ./dash run showed only SQLITE_BUSY failures under host load 35-45 (different tests each run; TestGoldenEndpoints fails the same way on origin/main). Attribution clean. My earlier findings are resolved. Keeping ready-to-merge; merge #445 first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Program PR approved by the reviewer, CI green; needs maintainer approval

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants