carlos / platform Public

Console UX round and 150 ms page budget: design draft

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev ed1d6a3d6871f865eabda6310dd9e84d2931fd6f parent 241a626
1 file changed, +336 −0
  • docs/superpowers/specs/2026-10-25-console-ux-perf-design.md +336 −0

CI passed — run details

diff --git a/docs/superpowers/specs/2026-10-25-console-ux-perf-design.md b/docs/superpowers/specs/2026-10-25-console-ux-perf-design.md
new file mode 100644
index 000000000..1ab13021c
--- /dev/null
+++ b/docs/superpowers/specs/2026-10-25-console-ux-perf-design.md
@@ -0,0 +1,336 @@
+# Console round: app navigation and a 150 ms page budget
+
+Status: design, awaiting Paul's approval. Branch `console-ux-perf`.
+
+## Why
+
+Two complaints from Paul (2026-10-25):
+
+1. **Things are filed in the wrong place.** Analytics lives under "Logs"
+ but isn't logs. A UX walk of all 30 console screens found more of the
+ same: "Release history" is really the release control room; the
+ Running tab is still headed "Instances"; Placement, a setting, sits
+ under a live status table; operator pages have no navigation.
+2. **Pages are slow.** Measured time to first byte on flagship:
+
+ | Page | TTFB |
+ |---|---|
+ | `/a/{s}/apps/patrix` (Overview, larger app) | 1.32 s |
+ | `/a/{s}/apps/adopt-probe/instances` | 726 ms |
+ | `/a/{s}/apps/adopt-probe` (Overview) | 688 ms |
+ | `/a/{s}/apps/adopt-probe/settings` | 558 ms |
+
+ Rastrillo and Tito Go hold every GET to 150 ms to first byte, enforced
+ in CI and reported in production. Paul wants the console held to the
+ same rule.
+
+Success: every console screen answers within 150 ms, CI fails a change
+that makes one slower, and a person looking for Analytics, a rollback or
+an app's placement finds it where they'd expect.
+
+## Part 1: navigation and layout
+
+Paul approved these four mockups (2026-10-25, visual companion
+`console-nav.html`; the screenshots are reproduced in the appendix).
+
+### 1.1 App tab bar
+
+Today: Overview · Running · Deployments · Logs · Activity · Settings,
+with Logs/Errors/Analytics as sub-tabs of Logs and Deployments/Release
+history as sub-tabs of Deployments.
+
+New: **Overview · Running · Releases · Logs · Errors · Analytics ·
+Activity · Settings.** One level; no sub-tab bars on any app page.
+
+- `lognav` and the Deployments sub-tab bar go.
+- This restores what the errors-and-analytics spec
+ (`2026-09-07-errors-and-analytics-design.md` §49-50) asked for;
+ df6621e4 demoted them with no recorded reason.
+- The tab bar must still fit at 390 px wide (wrap is acceptable; it
+ already wraps). The existing known follow-up, the header overflowing
+ at 390 px, is in scope because the longer tab bar makes it worse.
+
+### 1.2 Running tab: heading and toolbar
+
+Today (Paul's screenshot): heading says "Instances"; Restart sits alone
+on a row above the filters; the Filter button is full size next to small
+inputs; the checkbox label floats.
+
+New:
+
+- The heading reads **Running**, matching the tab. Every leftover
+ "Instances" that names this tab changes too: the instance detail
+ page's back link (app_instance.html:5), the account-review banner
+ (account_review.html:7), the BYO guide (fleet_byo.html:76).
+ "Instances" as a column or count noun ("Instances: 3 / 4") stays.
+- Restart moves to the right end of the heading row and reads
+ **Restart app** (it acts on the whole app; per-instance restart on the
+ detail page is unchanged). It becomes a secondary-style small button,
+ not the filled primary.
+- The filter row is one line of equal-height controls: search, channel
+ select, "Group by channel" checkbox, and a small **Filter** button.
+ Wraps on narrow screens.
+- The health links ("All · Asleep 2") gain a count on All.
+
+The fix is a shared toolbar style (below, 1.6), not one-off CSS.
+
+### 1.3 Releases: one page in place of Deployments + Release history
+
+`/a/{s}/apps/{app}/releases` becomes the single page. Top to bottom:
+
+1. **What's next** (only when there's a candidate): the existing
+ candidate text and the **Make vN live** button, as a callout. Use the
+ data and copy the page has today; the mockup's "no errors in 2 days"
+ line was illustrative and must not be invented.
+2. **Live now**: today's Deployments table, one row per channel:
+ channel, should run, running, instances (linking to Running filtered
+ by channel), and **Roll back** on the row. This is the only Roll back
+ on the page; the duplicate "Rolling back" section and the Roll back
+ inside "Test versions and rolling back" go, or become prose pointing
+ at the row.
+3. **Versions**: today's "All versions" table, newest 20, with a link
+ to older ones.
+4. Folded sections (`<details>`), in this order: **Channels and the
+ promotion ladder**, **Canaries**, **Tags**. Their contents are
+ unchanged.
+
+`/deployments` redirects (303) to `/releases`. Links elsewhere that say
+"Managed on Release history" (app_overview.html:62, app_settings.html:494)
+say Releases.
+
+### 1.4 App settings sidebar
+
+Today: General · Domains · Release pipeline · Environments · Storage ·
+Email · Feature flags · Advanced · Delete. General also holds the error
+level and the analytics switch; Advanced holds one switch.
+
+New: **General · Domains · Placement · Release pipeline · Environments ·
+Storage · Email · Feature flags · Errors and analytics · Delete.**
+
+- **Placement** ("Where this app runs / Move") moves here from the
+ Running tab, at `/settings/placement`. The Move form's POST and its
+ behaviour are unchanged.
+- **Errors and analytics** holds the error level and the analytics
+ switch, moved out of General. The Errors and Analytics tabs' "set on
+ the Settings tab" hints link straight to this section.
+- **Advanced** folds into General (it holds only the control-plane
+ switch). `/settings/advanced` redirects to `/settings/general`.
+- `/a/{s}/apps/{app}/pipeline` keeps working, but redirects to
+ `/settings/pipeline` rather than rendering a second copy.
+- Each section is built on its own (see 2.4); opening General no longer
+ pays for Domains or Environments.
+
+### 1.5 Operator pages get a nav
+
+`/fleet`, `/fleet/store`, `/fleet/metrics`, `/fleet/economics`,
+`/fleet/economics/accounts`, `/fleet/architecture` share one tab bar:
+**Status · Storage requests · Metrics · Economics · Architecture**
+(labels go through copy review). Today metrics and economics are linked
+from nowhere. *(My call, from finding 5; Paul saw it in the findings but
+not as a mockup.)*
+
+### 1.6 Consistency fixes
+
+*(My calls, from findings 6-7; small, mechanical, same look as the
+approved mockups.)*
+
+- **One toolbar pattern** for list filters: Running, Logs, Errors,
+ Analytics and economics accounts use the same `.toolbar` class:
+ `display:flex; align-items:center; gap; flex-wrap`, controls at one
+ height, small buttons. Logs keeps its stacked labels only if the
+ copy review wants them; the "All levels" label that repeats its own
+ first option goes.
+- **One danger style**: destructive buttons ("Delete account", "Delete
+ permanently" in Trash, store "Decline", Roll back, app delete) use
+ `btn-sm btn-danger`. Red links stay only where the action sits inside
+ a sentence.
+- **One page header**: every page opens with `.pagehead` (eyebrow, h1,
+ optional lede), including Apps, Trash, operator pages and New account.
+- **Account settings forms** use the `.settings-row` pattern app settings
+ use, instead of the sign-in form class.
+- **Help text pointers**: newaccount.html's "from the account's page"
+ says Team; Errors' "set on the Settings tab" links the section.
+- Trash's per-app Delete moves into each row.
+
+Out of scope: a redesign of Overview, Logs or the account Settings page
+layout; dark-mode work beyond keeping new CSS on the existing variables.
+
+## Part 2: the 150 ms budget
+
+### 2.1 The rule
+
+Same rule as Rastrillo's `perf`:
+
+- A **GET or HEAD to a console screen** must send its first byte within
+ **150 ms**.
+- POST, PUT, DELETE have no budget.
+- A stream or download is judged on when it started answering.
+- No cold-start budget: the console is a long-running unit, not a
+ sleeping app. *(My call.)*
+
+### 2.2 Measuring: `Server-Timing` and a production log
+
+New package `internal/perf` modelled on Rastrillo's
+(`rastrillo/perf`, docs/site/reference/perf.md), copied as a design,
+not imported: the platform takes no rastrillo dependency. *(My call.)*
+
+- Middleware wraps the console mux. Every response carries
+ `Server-Timing` with `app` (TTFB) plus named spans.
+- Spans: `db` (console SQLite), `s3` (object store), `box` (HTTP to a
+ box or an app host), `render` (template). Spans of one name add up.
+ Wrap at the seams (the store, the console DB, the instances fetcher),
+ not in each handler.
+- Requests are grouped by the matched route pattern
+ (`GET /a/{sqid}/apps/{app}`), never by path.
+- An over-budget GET logs a warning, at most once a minute per route and
+ 120 a minute overall.
+- A `Recorder` keeps the last 2,048 requests. `/fleet/metrics` gains a
+ **Console speed** table: per route, requests, over-budget count, p50,
+ p95, slowest first. This is how Paul checks the rollout worked.
+- `Skip`: `/healthz` and static assets.
+
+### 2.3 Enforcing: a CI test
+
+A test in `internal/console` walks **every GET route registered through
+`registerRoute`** (43 today) and requests each one through the handler
+production builds: the same constructor `cmd/console` uses, per
+[[production-wired-witnesses]]. Each route gets ten requests; the first
+two are discarded; the median must be within 150 ms and no single one
+over 450 ms. It fails only when `CI` is set; locally it prints.
+
+Real S3 isn't available in CI and an in-memory store is instant, so a
+timing test alone would pass the very pages that are slow today. Two
+additions make it honest:
+
+1. **Latency injection.** The test's store, box client and app-host
+ client add a fixed delay per call: 25 ms per S3 request, 40 ms per
+ HTTP call to a box or app host (about what flagship sees in-region).
+ A page that makes six sequential S3 reads fails.
+2. **A request budget per screen.** The test counts remote calls per
+ request with warm caches and fails a screen that makes more than its
+ recorded allowance. The default allowance is **zero remote calls on
+ a warm-cache GET**. A screen that genuinely needs one records it in
+ `internal/console/testdata/perf-budgets.txt` with a reason, the same
+ way Rastrillo's `budgets.txt` records `skip`. This also guards the
+ S3 bill ([[s3-requests-cost-money]]).
+
+Each route with a path parameter needs a real fixture (an account, an
+app with a few instances and channels, a fleet). A route with no fixture
+fails, so new screens can't dodge the test. Deferred-part endpoints
+(2.4) are listed and exempt from the 150 ms rule with the reason
+"deferred part"; they're still timed and reported.
+
+The test runs as part of the normal console package tests (no new CI
+job), and must itself stay cheap: well under 10 s
+([[test-suite-speed-291]]).
+
+### 2.4 Making the pages fast
+
+Paul's rule (2026-10-25): the page arrives within 150 ms. Live parts
+either show the last reading (possibly slightly old) and refresh in the
+background, or fill in a moment later.
+
+**A. Read-through view cache with background refresh.** An in-memory
+cache in the console process for the remote reads behind app pages, keyed
+by account and app:
+
+- On a GET, serve what the cache holds and render immediately. If the
+ entry is older than its freshness window, start one background refresh
+ (single-flight per key) and still render the cached value.
+- On a miss (first view since the console started), the page renders
+ without that part and a placeholder that a small script fills from a
+ deferred-part endpoint (B). It never blocks the page.
+- **Read your own writes.** Every console-mediated write that changes
+ what a cached entry holds (promote, roll back, channel and canary edits,
+ settings saves, placement moves, restarts, domain changes) invalidates
+ that app's entries **and re-reads them inside the POST, before it
+ redirects**. POSTs have no budget, so the cost lands on the action
+ that caused it, and the GET after the redirect is a warm cache hit.
+ The rule: a user never sees their own change missing.
+- Refresh happens **only when someone views the app**. No timers, no
+ per-app or per-box polling ([[s3-requests-cost-money]]). Net S3
+ requests must go down, not up.
+- Windows: about 30 s for live data (instance health, observed
+ versions), about 5 min for data only console writes change (manifests,
+ channels, pipeline, account manifest), with write invalidation keeping
+ them correct. Builder tunes these.
+- When cached data is shown, a part that's older than its window says so
+ in small text ("as of 2 minutes ago"). Copy goes through review.
+
+**B. Deferred parts.** For data that's live and slow (the instances
+report from the app host; box readings on Settings → Domains), the page
+renders the frame and a `fetch()` loads the part, following the existing
+Logs-tab pattern (`/logs/data`, app_logs.html:153). Parts return HTML
+fragments rendered by the same templates. No new JS framework; the page
+must still be usable, minus that part, with JavaScript off.
+
+**C. Stop doing work nobody needs.** From the trace (file:line as of
+241a6266):
+
+| Where | Today | Change |
+|---|---|---|
+| every app tab, `ensureAccountManifest` (server.go ~2668) | GetObject on every view | remember success in process |
+| every GET, `SetLastAccount` (~2608) | SQLite write every view | write only when it changed |
+| every app tab | `AccountsFor` ×3, `registry.List` ×2, each opening a new connection | once per request; reuse the registry connection |
+| `assembleChannels` (view.go ~687) | List + one Get per channel, sequential | cache (A) |
+| `dnsTargets` edge fold (server.go ~948) | refreshes inline once a minute; other requests wait on its mutex | refresh in the background; requests read the last fold |
+| Overview, `Versions` (view.go ~915) | lists every artifact ever shipped, then up to 20 manifest reads, no timeout | cache (A), invalidated on publish/promote; bounded context |
+| `applyPipelineView` + `pendingPipeline` | GetPipeline twice | once |
+| Running, `instances.Report` (instances.go ~93) | HTTP to the app host, 30 s cache, blocks up to 1.5 s on a miss | deferred part (B) on miss; cached readings otherwise |
+| Settings, `populateAppSettings` (~3259) | builds every section | build only the one shown |
+| Settings, `appDeployEmpty` (appsettings.go ~695) | lists every key under the app, then the legacy prefix | one `ListPage(..., 1)` per prefix |
+| Settings, `settingsGates` | List + one Get per instance record, up to 500 | cache (A) |
+| Settings, `aliasReadings` / `LoadBoxes` | one Get per box, uncached | cache (A), or deferred part (B) on Domains |
+| Settings, `envCards` + `storeEnvCards` | each environment read twice | once |
+| console DB | `SetMaxOpenConns(1)`, so request queries queue behind background passes | builder investigates; WAL + a separate read pool is the likely fix |
+
+Independent reads that remain on a request path run concurrently, but
+concurrency is a fallback. Removing the reads is the goal.
+
+### 2.5 Order of work
+
+Measuring first, so every later change is judged by numbers:
+
+1. `internal/perf`, `Server-Timing`, the Console speed table. Ship and
+ roll on its own; read real flagship numbers before and after.
+2. The CI test with latency injection and request counts, with every
+ currently slow screen recorded in `perf-budgets.txt` as a temporary
+ known failure (`over: <reason>`), so CI stays green while the fixes
+ land. The file must be empty of `over` lines by the end of the round.
+3. The fixes (2.4 C, then A and B).
+4. The navigation and layout changes (Part 1). Independent of 1-3; can
+ go in parallel.
+
+### 2.6 Checking it worked
+
+On flagship after the roll, the four pages above, measured the same way
+Paul measured them, are under 150 ms on a second view, and the Console
+speed table shows every screen's p95 under 150 ms after a day of use.
+The first view of an app after a console restart is allowed to show
+placeholders; it must still arrive within 150 ms.
+
+## Constraints
+
+- **Copy review.** Every new or changed user-facing string (tab labels,
+ section names, "Restart app", "as of…", placeholders, operator nav)
+ goes through the copy-review gate before it's written, per house
+ rules (no em dashes; human text only).
+- **No tenant names** in code, tests or fixtures (patrix and
+ adopt-probe appear in this doc only as Paul's measurements).
+- Console security gate order (session, CSRF, owner) is unchanged;
+ deferred-part endpoints go through the same gates as their page.
+- Cross-compile (darwin, windows) and gofmt stay green.
+- Existing URLs keep working (redirects, not 404s).
+
+## Left to the builder
+
+- Cache structure, key shapes, exact freshness windows.
+- Fragment endpoint naming and the small loader script.
+- The fixture set for the CI walk.
+- Whether the console DB change in 2.4 C is needed once the rest lands.
+
+## Appendix: Paul's measurements and screenshot
+
+The Running tab today: the heading reads "Instances"; Restart sits on
+its own row; the Filter button is taller than the search box and
+channel select; the checkbox label sits off the controls' centre line.