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

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/13792-a-new-person-s-app-page-shows-what-they → main 4 commits fork 3 threads · 3 unresolved

  • Merged. scout/13792-a-new-person-s-app-page-shows-what-they was merged into main as 2149f22.

Review

Sign in to review this change.
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 {
5151 app?: boolean;
5252 }
5353
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 */
5557 export function liveMount(config: LiveConfig): Html {
5658 return html`<div
5759 id="live"
@@ -404,6 +406,12 @@ export const liveClientJs = /* js */ `
404406 var theirs = holder.querySelector('#' + id);
405407 if (!mine || !theirs) return;
406408 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 }
407415 mine.replaceWith(theirs);
408416 // A transition, not a resize: the card keeps its own height, and
409417 // prefers-reduced-motion already collapses every animation's
src/web/studio/app.ts +4 −1
@@ -47,6 +47,7 @@ import {
4747 badge,
4848 btn,
4949 card,
50 disclosure,
5051 envPhrase,
5152 icon,
5253 listCard,
@@ -530,7 +531,9 @@ export async function studioApp(
530531 <div id="app-previews"></div>
531532 ${nowRegion(repo, now)}
532533 ${appMilestones(ctx, repo, picture.milestones)}
533 ${more}
534 ${disclosure("Operator detail", html`<div class="stack">${more}</div>`, {
535 id: "app-details",
536 })}
534537 </div>
535538 ${liveMount({ repo: base, app: true })}`
536539 : html`${repoHeader(ctx, repo, "app", {
src/web/studio/now.ts +4 −2
@@ -26,7 +26,7 @@ import { loadRepo, repoBase } from "../chrome.ts";
2626 import { html, type Html } from "../html.ts";
2727 import { flatten, noteLine } from "./note.ts";
2828 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";
3030 import { changeHref, tellHref } from "./nouns.ts";
3131 import { LOG_TAIL_CAP, logBox } from "./log.ts";
3232 import { appPanels } from "./previews.ts";
@@ -222,7 +222,9 @@ export async function nowCard(
222222 }),
223223 );
224224 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 );
226228 }
227229
228230 // 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";
3434 import {
3535 badge,
3636 btn,
37 disclosure,
3738 dormantNote,
3839 envActions,
3940 envFacts,
@@ -280,6 +281,13 @@ function productionTail(
280281 * paint and for the fragment a deploy event refreshes in place
281282 * (`appStateFragment`) — the two never draw two copies of the same markup.
282283 */
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
283291 export function appPanels(
284292 ctx: Ctx,
285293 repo: Repo,
@@ -341,17 +349,21 @@ export function appPanels(
341349 : html`${repo.description ? "· " : ""}<span class="mono">${url.replace(/^https?:\/\//, "")}</span>`}
342350 ${when(copy, (c) => html`${repo.description || url !== undefined ? "· " : ""}${testCopyLink(c)}`)}
343351 </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) },
352366 )}
353 ${buildCacheLine(ctx, repo, record, base)}
354 ${tail.box ?? null}
355367 </div>
356368 <span class="spacer"></span>
357369 ${lookNow(ctx, repo, record)}
test/fresh-app.test.ts +57 −3
@@ -16,6 +16,7 @@ import { createUser } from "../src/core/users.ts";
1616 import { serve, type Servers } from "../src/http/server.ts";
1717 import { proveAll } from "./helpers/verified.ts";
1818 import { quietLogs } from "./helpers/globals.ts";
19 import { deployFailing } from "../src/web/studio/previews.ts";
1920 import { ageApp } from "./helpers/history.ts";
2021
2122 quietLogs();
@@ -111,12 +112,65 @@ test("a guest and a non-owner see the progress, with no owner facts and no termi
111112 }
112113 });
113114
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 {
outdated

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.

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 () => {
115166 ageApp(app.db, repoId);
116167 const page = await read();
168 const { outside, maxDepth } = sections(page);
117169 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);
120174 expect(page).not.toContain("<h2>This week</h2>");
121175 expect(page).not.toContain("<h2>Crew</h2>");
122176 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", () => {
12561256 expect(page).not.toContain("log-tail-row");
12571257 // The block-level log box is a sibling <li> padded by §5's .card-body,
12581258 // 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 );
12601262 expect(page).not.toMatch(
12611263 /<span\s+class="row-title"[^>]*>(?:(?!<\/span>)[\s\S])*id="app-run-tail"/,
12621264 );

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs