Public: anyone can read this; the crew can change it.
A new person's app page shows what they can act on; the operator's detail is one click away #13804
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13792-a-new-person-s-app-page-shows-what-they → main 4 commits fork 3 threads · 3 unresolved
7 files
changed +112
−18
docs/features/app-page-details.md added +13
| @@ -0,0 +1,13 @@ | ||
| 1 | # The app's page: detail on demand | |
| 2 | ||
| 3 | A first ask opens a page of one column: the state, the box to tell the crew, and Now. The operator's | |
| 4 | detail sits behind named disclosures, so the controls differ for a screen reader: | |
| 5 | ||
| 6 | - **Deploy and log** (under the name): the commit, terminal, build cache and log tail. It opens by | |
| 7 | itself when production errored or its last deploy failed. | |
| 8 | - **Run log**: the crew's log tail inside a running Now row. | |
| 9 | - **Operator detail** (first-ask page only): variants, drop, environment settings, archive. | |
| 10 | ||
| 11 | An app that has run keeps its rail, previews, crew and forks in view as before; only Deploy and log | |
| 12 | and Run log fold. A disclosure someone has opened stays open when a deploy event refreshes the head. | |
| 13 | The terminal has no page layout, so it is unchanged. |
src/web/live.ts +9 −1
| @@ -51,7 +51,9 @@ export interface LiveConfig { | ||
| 51 | 51 | app?: boolean; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | /** The config element, the polite status line, the quiet "N above" marker and the connection word. */ | |
| 54 | /** | |
| 55 | * The config element, the polite status line, the quiet "N above" marker and the connection word. | |
| 56 | */ | |
| 55 | 57 | export function liveMount(config: LiveConfig): Html { |
| 56 | 58 | return html`<div |
| 57 | 59 | id="live" |
| @@ -404,6 +406,12 @@ export const liveClientJs = /* js */ ` | ||
| 404 | 406 | var theirs = holder.querySelector('#' + id); |
| 405 | 407 | if (!mine || !theirs) return; |
| 406 | 408 | var changed = mine.innerHTML !== theirs.innerHTML; |
| 409 | // A disclosure someone is reading stays open across the swap. | |
| 410 | var was = mine.querySelectorAll('details'); | |
| 411 | var now = theirs.querySelectorAll('details'); | |
| 412 | for (var d = 0; d < was.length && d < now.length; d++) { | |
| 413 | if (was[d].open) now[d].open = true; | |
| 414 | } | |
| 407 | 415 | mine.replaceWith(theirs); |
| 408 | 416 | // A transition, not a resize: the card keeps its own height, and |
| 409 | 417 | // prefers-reduced-motion already collapses every animation's |
src/web/studio/app.ts +4 −1
| @@ -47,6 +47,7 @@ import { | ||
| 47 | 47 | badge, |
| 48 | 48 | btn, |
| 49 | 49 | card, |
| 50 | disclosure, | |
| 50 | 51 | envPhrase, |
| 51 | 52 | icon, |
| 52 | 53 | listCard, |
| @@ -530,7 +531,9 @@ export async function studioApp( | ||
| 530 | 531 | <div id="app-previews"></div> |
| 531 | 532 | ${nowRegion(repo, now)} |
| 532 | 533 | ${appMilestones(ctx, repo, picture.milestones)} |
| 533 | ${more} | |
| 534 | ${disclosure("Operator detail", html`<div class="stack">${more}</div>`, { | |
| 535 | id: "app-details", | |
| 536 | })} | |
| 534 | 537 | </div> |
| 535 | 538 | ${liveMount({ repo: base, app: true })}` |
| 536 | 539 | : html`${repoHeader(ctx, repo, "app", { |
src/web/studio/now.ts +4 −2
| @@ -26,7 +26,7 @@ import { loadRepo, repoBase } from "../chrome.ts"; | ||
| 26 | 26 | import { html, type Html } from "../html.ts"; |
| 27 | 27 | import { flatten, noteLine } from "./note.ts"; |
| 28 | 28 | import { fragment, missingFragment } from "../layout.ts"; |
| 29 | import { avatar, badge, btn, icon, listCard, row, time } from "../ui.ts"; | |
| 29 | import { avatar, badge, btn, disclosure, icon, listCard, row, time } from "../ui.ts"; | |
| 30 | 30 | import { changeHref, tellHref } from "./nouns.ts"; |
| 31 | 31 | import { LOG_TAIL_CAP, logBox } from "./log.ts"; |
| 32 | 32 | import { appPanels } from "./previews.ts"; |
| @@ -222,7 +222,9 @@ export async function nowCard( | ||
| 222 | 222 | }), |
| 223 | 223 | ); |
| 224 | 224 | if (activeTail !== undefined && r.id === activeRun?.id) |
| 225 | runRows.push(html`<li class="card-body">${activeTail}</li>`); | |
| 225 | runRows.push( | |
| 226 | html`<li class="card-body">${disclosure("Run log", activeTail, { small: true })}</li>`, | |
| 227 | ); | |
| 226 | 228 | } |
| 227 | 229 | |
| 228 | 230 | // An environment the sleep sweep is sparing because it is mid-work: |
src/web/studio/previews.ts +22 −10
| @@ -34,6 +34,7 @@ import { hasHistory } from "./fresh.ts"; | ||
| 34 | 34 | import { |
| 35 | 35 | badge, |
| 36 | 36 | btn, |
| 37 | disclosure, | |
| 37 | 38 | dormantNote, |
| 38 | 39 | envActions, |
| 39 | 40 | envFacts, |
| @@ -280,6 +281,13 @@ function productionTail( | ||
| 280 | 281 | * paint and for the fragment a deploy event refreshes in place |
| 281 | 282 | * (`appStateFragment`) — the two never draw two copies of the same markup. |
| 282 | 283 | */ |
| 284 | /** | |
| 285 | * Production errored, or its last deploy failed: the log that says why is open, not behind a click. | |
| 286 | */ | |
| 287 | export function deployFailing(env: EnvStatus | undefined): boolean { | |
| 288 | return env?.error !== undefined || env?.failedDeploy !== undefined; | |
| 289 | } | |
| 290 | ||
| 283 | 291 | export function appPanels( |
| 284 | 292 | ctx: Ctx, |
| 285 | 293 | repo: Repo, |
| @@ -341,17 +349,21 @@ export function appPanels( | ||
| 341 | 349 | : html`${repo.description ? "· " : ""}<span class="mono">${url.replace(/^https?:\/\//, "")}</span>`} |
| 342 | 350 | ${when(copy, (c) => html`${repo.description || url !== undefined ? "· " : ""}${testCopyLink(c)}`)} |
| 343 | 351 | </p>`)} |
| 344 | ${onboarding === undefined | |
| 345 | ? when(production, (env) => envFacts(base, env)) | |
| 346 | : onboardingRow(onboarding)} | |
| 347 | ${when(writer && !fresh, () => | |
| 348 | terminalLine( | |
| 349 | terminalFor(ctx.app, record, "production", production), | |
| 350 | ctx.app.config.sshHostKey, | |
| 351 | ), | |
| 352 | ${disclosure( | |
| 353 | "Deploy and log", | |
| 354 | html`${onboarding === undefined | |
| 355 | ? when(production, (env) => envFacts(base, env)) | |
| 356 | : onboardingRow(onboarding)} | |
| 357 | ${when(writer && !fresh, () => | |
| 358 | terminalLine( | |
| 359 | terminalFor(ctx.app, record, "production", production), | |
| 360 | ctx.app.config.sshHostKey, | |
| 361 | ), | |
| 362 | )} | |
| 363 | ${buildCacheLine(ctx, repo, record, base)} | |
| 364 | ${tail.box ?? null}`, | |
| 365 | { small: true, open: deployFailing(production) }, | |
| 352 | 366 | )} |
| 353 | ${buildCacheLine(ctx, repo, record, base)} | |
| 354 | ${tail.box ?? null} | |
| 355 | 367 | </div> |
| 356 | 368 | <span class="spacer"></span> |
| 357 | 369 | ${lookNow(ctx, repo, record)} |
test/fresh-app.test.ts +57 −3
| @@ -16,6 +16,7 @@ import { createUser } from "../src/core/users.ts"; | ||
| 16 | 16 | import { serve, type Servers } from "../src/http/server.ts"; |
| 17 | 17 | import { proveAll } from "./helpers/verified.ts"; |
| 18 | 18 | import { quietLogs } from "./helpers/globals.ts"; |
| 19 | import { deployFailing } from "../src/web/studio/previews.ts"; | |
| 19 | 20 | import { ageApp } from "./helpers/history.ts"; |
| 20 | 21 | |
| 21 | 22 | quietLogs(); |
| @@ -111,12 +112,65 @@ test("a guest and a non-owner see the progress, with no owner facts and no termi | ||
| 111 | 112 | } |
| 112 | 113 | }); |
| 113 | 114 | |
| 114 | test("an older app keeps its rail and previews, and still has no empty cards", async () => { | |
| 115 | /** The top-level `<details>` blocks of a page, balanced, and the page without them. */ | |
| 116 | function sections(page: string): { blocks: string[]; outside: string; maxDepth: number } { | |
| 117 | const blocks: string[] = []; | |
| 118 | let outside = ""; | |
| 119 | let depth = 0, maxDepth = 0, start = 0, at = 0; | |
| 120 | for (const m of page.matchAll(/<details\b|<\/details>/g)) { | |
| 121 | if (m[0] === "</details>") { | |
| 122 | depth--; | |
| 123 | if (depth === 0) { | |
| 124 | at = m.index + m[0].length; | |
| 125 | blocks.push(page.slice(start, at)); | |
| 126 | } | |
| 127 | } else { | |
| 128 | if (depth === 0) { outside += page.slice(at, m.index); start = m.index; } | |
| 129 | depth++; | |
| 130 | maxDepth = Math.max(maxDepth, depth); | |
| 131 | } | |
| 132 | } | |
| 133 | return { blocks, outside: outside + page.slice(at), maxDepth }; | |
| 134 | } | |
| 135 | const summaries = (page: string): string[] => | |
| 136 | [...page.matchAll(/<summary[^>]*>([^<]*)<\/summary>/g)].map((m) => m[1]!.trim()); | |
| 137 | ||
| 138 | test("the first-ask page folds the operator's detail into named disclosures", async () => { | |
| 139 | const page = await read(); | |
| 140 | const { blocks, outside, maxDepth } = sections(page); | |
| 141 | expect(maxDepth).toBe(1); | |
| 142 | expect(page).toContain('id="app-details"'); | |
| 143 | expect(page).not.toContain("<aside"); | |
| 144 | const gones = ["The terminal is off", "Build cache", "doors", "knocked", "Slots", "Governor", "decider", "Gap"]; | |
| 145 | for (const gone of gones) | |
| 146 | expect(outside).not.toContain(gone); | |
| 147 | const names = summaries(page); | |
| 148 | expect(names).toContain("Operator detail"); | |
| 149 | expect(names).toContain("Deploy and log"); | |
| 150 | expect(new Set(names).size).toBe(names.length); | |
| 151 | expect(names).not.toContain("Details"); | |
| 152 | const operator = blocks.find((b) => b.includes('id="app-details"'))!; | |
| 153 | expect(operator).toContain("Environment settings"); | |
| 154 | expect(outside).not.toContain("Environment settings"); | |
| 155 | }); | |
| 156 | ||
| 157 | test("a deploy that failed opens its log, and a healthy one leaves it closed", () => { | |
| 158 | expect(deployFailing(undefined)).toBe(false); | |
| 159 | expect(deployFailing({ env: "production", state: "running" } as never)).toBe(false); | |
| 160 | expect(deployFailing({ env: "production", state: "running", error: "boom" } as never)).toBe(true); | |
| 161 | const failed = { env: "production", state: "running", failedDeploy: { runId: "r" } }; | |
| 162 | expect(deployFailing(failed as never)).toBe(true); | |
| 163 | }); | |
| 164 | ||
| 165 | test("an older app keeps its rail and previews in view, with no page-level disclosure", async () => { | |
| 115 | 166 | ageApp(app.db, repoId); |
| 116 | 167 | const page = await read(); |
| 168 | const { outside, maxDepth } = sections(page); | |
| 117 | 169 | expect(page).toContain("<aside"); |
| 118 | expect(page).toContain("<h2>Previews</h2>"); | |
| 119 | expect(page).toContain("Environment settings"); | |
| 170 | expect(page).not.toContain('id="app-details"'); | |
| 171 | expect(outside).toContain("<h2>Previews</h2>"); | |
| 172 | expect(outside).toContain("Environment settings"); | |
| 173 | expect(maxDepth).toBeLessThanOrEqual(1); | |
| 120 | 174 | expect(page).not.toContain("<h2>This week</h2>"); |
| 121 | 175 | expect(page).not.toContain("<h2>Crew</h2>"); |
| 122 | 176 | expect(page).not.toContain("The map</a>"); |
test/studio-runs.test.ts +3 −1
| @@ -1256,7 +1256,9 @@ describe("the app's page tails the crew's log while it works", () => { | ||
| 1256 | 1256 | expect(page).not.toContain("log-tail-row"); |
| 1257 | 1257 | // The block-level log box is a sibling <li> padded by §5's .card-body, |
| 1258 | 1258 | // never inside a row's ellipsizing, nowrap .row-title, so its lines wrap. |
| 1259 | expect(page).toMatch(/<li class="card-body">\s*<[^>]*id="app-run-tail"/); | |
| 1259 | expect(page).toMatch( | |
| 1260 | /<li class="card-body">\s*<details[^>]*>\s*<summary[^>]*>Run log<\/summary>\s*<[^>]*id="app-run-tail"/, | |
| 1261 | ); | |
| 1260 | 1262 | expect(page).not.toMatch( |
| 1261 | 1263 | /<span\s+class="row-title"[^>]*>(?:(?!<\/span>)[\s\S])*id="app-run-tail"/, |
| 1262 | 1264 | ); |
new above
offline
This non-greedy strip breaks with nested details and can leak hidden text into
outside, so the test can pass or fail for the wrong reason. Assert the section structure instead.