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

Talk workspace W1: workspace bar (repo ▸ branch, status) and a hot-reloading dev cell per workspace #17135

opened this

Merged 2d 0h ago, live in production

scout/forge:scout/17119-talk-workspace-w1-workspace-bar-repo-bra → main 0 commits fork 6 threads · 6 unresolved

  • Merged. scout/17119-talk-workspace-w1-workspace-bar-repo-bra was merged into main as 725400b.

Review

Sign in to review this change.
10 files changed +153 −10
docs/design/areas/talk.md +2 −1
@@ -108,7 +108,8 @@ Prior art: Claude and ChatGPT (one centred column, the person's words in a quiet
108108
109109 - `.talk-pane-bar`: the pane's bar: Preview, Code and Diff as a `.seg`, the address, Reload and Open on its own.
110110 - `.talk-addr`: the address of what runs, a muted pill: which environment (Production, Pull #N) and its host; hidden under 30rem.
111 - `.talk-addr-pick`: the address bar as a switcher, a `<form method="get">` in the same muted pill: a repository `<select>`, a version `<select>` (Live, each open pull's preview), a path `<input>`; with the script a pick swaps the pane in place, without it the form's `.talk-addr-go` button (hidden under `:root.js`) sends it.
111 - `.talk-addr-pick`: the address bar as a switcher, a `<form method="get">` in the same muted pill: a repository `<select>`, a branch `<select>` after a `▸` (the default branch for Live, each open pull's head branch), a path `<input>`; with the script a pick swaps the pane in place, without it the form's `.talk-addr-go` button (hidden under `:root.js`) sends it.
outdated

Remove "after #17119," from the middle of the sentence. It is a build note, not a description of the component (principle 1).

112 - `.talk-dev-status`: the workspace's status in a muted pill after the address: Starting, Live, Reloading, or a bold Error (its file and line in the `title`, with what to do next; the terminal prints them in the line); `data-dev-status` carries the state (`paneStatus`, `src/actions/dev_workspace.ts`).
112113 - `.talk-pane-info`: one muted line under the bar: for a pull's preview who made it, its number and title, checks and review, and a link to the pull; for Live the default branch and what last landed (`paneInfo`, the terminal prints the same).
113114 - `.talk-pane-fell`: one line when a picked pull's preview is gone: "#N landed: Live has it now."
114115 - `.talk-diff-change`: in Diff, one pull this conversation's work led to: a `<details>` whose summary links the pull and says landed, open or closed, the newest open.
docs/features/talk-workspace.md added +12
@@ -0,0 +1,12 @@
1 ---
2 topic: Tell the crew
3 row: Talk's workspace bar: repo ▸ branch and its status
4 ---
5
6 # Talk's workspace bar: repo ▸ branch and its status
7
8 The bar over Talk's preview (`src/web/pages/talk_preview.ts`) names the environment as **repository ▸ branch** and says its status in one word (#17119, W1 of #16940). The branch picker offers the default branch (Live) and the head branch of each open pull whose preview runs; the old version picker is gone, and the path stays in the address field. The status is `devStatus` in `src/actions/dev_workspace.ts`: **Starting** while nothing answers, **Live** when an address does, **Reloading** while a build or the crew's run is under way, and **Error in file:line** when the newest run failed with a failure that names a place (only relative paths are taken).
9
10 In the terminal, the `p` view of the Talk screen (`src/tui/screens/talk_chats.ts`) prints the same `Status:` line; `w` picks the branch's version as before.
11
12 Not yet: a hot-reloading dev cell per workspace, which will drive the status from the dev server itself (W2, #17140). Where the page shows only **Error**, the file and line sit in its title; the terminal's `p` view prints them: "Error in src/app.ts:12; ask the crew to fix it". Both read `paneStatus`.
scripts/doorless-allow.json −1
@@ -76,7 +76,6 @@
7676 "src/web/pages/security.ts",
7777 "src/web/pages/signup-passkey.ts",
7878 "src/web/pages/start_claim.ts",
79 "src/web/pages/talk_preview.ts",
8079 "src/web/pages/tree_cache.ts",
8180 "src/web/pages/usage-tabs.ts",
8281 "src/web/pages/visitors.ts",
src/actions/dev_workspace.ts added +61
@@ -0,0 +1,61 @@
1 /**
2 * The state of a Talk workspace as its bar says it (#17119, W1 of #16940): `repo ▸ branch` and one
3 * status word: starting, live, reloading, or the error with its file and line. Plain data in, plain
4 * data out, so the page's bar and the terminal's `p` view say the same. The dev cell that hot
5 * reloads a branch is W2's; for now the status is read from what the forge already knows: the
6 * address that answers and the crew's newest run.
7 */
8
9 export type DevState = "starting" | "live" | "reloading" | "error";
10
11 export interface DevStatus {
12 readonly state: DevState;
13 /** The word the bar shows: "Starting", "Live", "Reloading", or "Error in src/a.ts:12". */
14 readonly word: string;
15 readonly file?: string;
16 readonly line?: number;
17 }
18
19 /** What the status is read from. */
20 export interface DevFacts {
21 /** An address answers (the preview or production is up). */
22 readonly up: boolean;
23 /** A build or a crew run is under way. */
24 readonly working: boolean;
25 /** The newest run failed, with the words it ended on. */
26 readonly failed?: string;
27 }
28
29 // A relative path with an extension, then `:line`, as bun, tsc and stack traces print it.
30 const SITE = /(?:^|[\s("'])((?:\.{0,2}\/)?[\[email protected]]+(?:\/[\[email protected]]+)*\.[A-Za-z]{1,5}):(\d{1,6})(?::\d{1,6})?/;
31
32 /**
33 * The first file and line a failure's words name, if any; never a path that climbs out (`..`) or
34 * starts at the root.
35 */
36 export function errorSite(text: string): { readonly file: string; readonly line: number } | undefined {
37 const m = SITE.exec(text.slice(0, 4000));
38 if (m === null) return undefined;
39 const file = m[1]!.replace(/^\.\//, "");
40 if (file.startsWith("/") || file.split("/").includes("..")) return undefined;
41 return { file, line: Number(m[2]) };
42 }
43
44 export function devStatus(facts: DevFacts): DevStatus {
45 if (facts.failed !== undefined) {
46 const site = errorSite(facts.failed);
47 return site === undefined ? { state: "error", word: "Error" } : { state: "error", word: `Error in ${site.file}:${String(site.line)}`, ...site };
48 }
49 if (!facts.up) return { state: "starting", word: "Starting" };
50 return facts.working ? { state: "reloading", word: "Reloading" } : { state: "live", word: "Live" };
51 }
52
53 /**
54 * The facts the bar reads, built once for both doors: whether an address answers, the crew's newest
55 * run (queued or running is work under way; failed is the error, with the words it ended on), and
56 * whether an ask is being answered.
57 */
58 export function paneStatus(input: { readonly url: string | undefined; readonly crew: { readonly state: string; readonly line: { readonly says: string } } | undefined; readonly busy?: boolean }): DevStatus {
59 const going = input.crew !== undefined && (input.crew.state === "queued" || input.crew.state === "running");
60 return devStatus({ up: input.url !== undefined, working: going || input.busy === true, ...(input.crew?.state === "failed" ? { failed: input.crew.line.says } : {}) });
61 }
src/actions/talk_workspace.ts +7 −7
@@ -163,29 +163,29 @@ export function paneOffer(app: App, user: User, current: string | undefined): Pa
163163 const o = originOf(runtime.urlFor(record, env));
164164 if (o !== undefined) origins.add(o);
165165 }
166 return { name: `${repo.ownerName}/${repo.name}`, repo, versions: [{ key: "live", label: "Live" }, ...previews.map((p) => ({ key: `pull-${String(p.number)}`, label: `#${String(p.number)} ${p.title}` }))] };
166 return { name: `${repo.ownerName}/${repo.name}`, repo, versions: [{ key: "live", label: "Live", branch: repo.defaultBranch }, ...previews.map((p) => ({ key: `pull-${String(p.number)}`, label: `#${String(p.number)} ${p.title}`, branch: p.branch }))] };
167167 });
168168 return { repos, origins: [...origins] };
169169 }
170170
171171 /** What the address bar offers: each repository with its versions, and the origins they run at. */
172172 export interface PaneOffer {
173 readonly repos: readonly { readonly name: string; readonly repo: Repo; readonly versions: readonly { readonly key: string; readonly label: string }[] }[];
173 readonly repos: readonly { readonly name: string; readonly repo: Repo; readonly versions: readonly { readonly key: string; readonly label: string; readonly branch: string }[] }[];
174174 readonly origins: readonly string[];
175175 }
176176
177177 /** The open pulls of these repositories by repository, newest first, in one read; a sealed one only for its author. */
178 function openPullTitles(db: App["db"], repoIds: readonly string[], viewerId: string): Map<string, { number: number; title: string }[]> {
179 const out = new Map<string, { number: number; title: string }[]>();
178 function openPullTitles(db: App["db"], repoIds: readonly string[], viewerId: string): Map<string, { number: number; title: string; branch: string }[]> {
179 const out = new Map<string, { number: number; title: string; branch: string }[]>();
180180 if (repoIds.length === 0) return out;
181181 const rows = db
182 .query<{ repo_id: string; number: number; title: string }, string[]>(
183 `SELECT i.repo_id, i.number, i.title FROM issue i JOIN pull p ON p.issue_id = i.id
182 .query<{ repo_id: string; number: number; title: string; head_branch: string }, string[]>(
183 `SELECT i.repo_id, i.number, i.title, p.head_branch FROM issue i JOIN pull p ON p.issue_id = i.id
184184 WHERE i.kind = 'pull' AND i.state = 'open' AND (i.sealed = 0 OR i.author_id = ?1)
185185 AND i.repo_id IN (${repoIds.map((_, n) => `?${n + 2}`).join(",")}) ORDER BY i.number DESC`,
186186 )
187187 .all(viewerId, ...repoIds);
188 for (const r of rows) out.set(r.repo_id, [...(out.get(r.repo_id) ?? []), { number: r.number, title: r.title }]);
188 for (const r of rows) out.set(r.repo_id, [...(out.get(r.repo_id) ?? []), { number: r.number, title: r.title, branch: r.head_branch }]);
189189 return out;
190190 }
191191
src/tui/screens/talk_chats.ts +2
@@ -34,6 +34,7 @@ import { filesOf, receiptIssues, repoOf, steerOf, stepOf } from "../../core/talk
3434 import { cardsPlaced, holdsCard, plainVoice } from "../../core/talk_voice.ts";
3535 import { setTalkDisplay, talkDisplay } from "../../core/settings.ts";
3636 import { talkDisplayScreen } from "./talk_display.ts";
37 import { paneStatus } from "../../actions/dev_workspace.ts";
3738 import { conversationPulls, liveReceipts, paneCrew, paneFell, paneInfo, type LiveReceipt } from "../../core/talk_work.ts";
3839 import { tapRunLogs } from "../../runs/log.ts";
3940 import { mayReadRunLog, mayReadRuns, requeueRepoRun } from "../../actions/runs.ts";
@@ -268,6 +269,7 @@ function chatScreen(f: Session, ctx: Ctx, chat: Conversation, hit?: string): Scr
268269 return [
269270 `${name} · ${ws.shows === undefined ? "Production" : `Pull #${String(ws.shows)}`}${pointedAt(picked, steer).path === undefined ? "" : ` · ${pointedAt(picked, steer).path ?? ""}`}`,
270271 paneInfo(f.app.db, ws.repo, ws.shows),
272 `Status: ${((st) => (st.state === "error" ? `${st.word}; ask the crew to fix it` : st.word))(paneStatus({ url, crew: paneCrew(f.app.db, f.app.config.dataDir, ws.repo.id, f.user, { runs: mayReadRuns(f.app, f.user, ws.repo), logs: false }) }))}`,
outdated

The terminal says only Starting or Live: working: false is fixed and failed is never passed. The page shows Reloading and Error in file:line for the same workspace. Feed the same facts (crew run state and busy) here so both doors agree.

271273 ...(fell === undefined ? [] : [fell]),
272274 // Who else is here and what was done lately, in the page's words (`togetherOf`).
273275 ...((t) => [...(t.here === undefined ? [] : [`Here: ${t.here.words}`]), ...(t.lately.length === 0 ? [] : [`Lately: ${t.lately.map((l) => `${l.words} · ${agoWords(l.at, Date.now())}`).join(" · ")}`]), ...(t.elsewhere === undefined ? [] : [`Elsewhere: ${t.elsewhere}`]), ...t.held, ...(t.landed === undefined ? [] : [`${t.landed.words} (L shows Live)`])])(togetherOf(f.app.db, ws.repo, f.user)),
src/web/pages/talk_preview.ts +10 −1
@@ -11,6 +11,7 @@
1111 * streaming beside it carries on.
1212 */
1313
14 import { paneStatus } from "../../actions/dev_workspace.ts";
1415 import { offersOwnToken } from "../../actions/own_token.ts";
1516 import { getRun } from "../../core/runs.ts";
1617 import { ownTokenBox } from "../own_token.ts";
@@ -118,10 +119,15 @@ export async function talkPane(ctx: Ctx, user: User, name: string | undefined, w
118119 : html`<form class="talk-addr talk-addr-pick small" method="get" data-pane-at>
119120 <input type="hidden" name="pane" value="${view}">
120121 <select name="repo" aria-label="Repository">${offered.map((r) => html`<option value="${r.name}"${r.name === name ? raw(" selected") : null}>${r.name}</option>`)}</select>
121 <select name="show" aria-label="Version">${here.versions.map((v) => html`<option value="${v.key}"${v.key === shownKey ? raw(" selected") : null}>${v.label}</option>`)}</select>
122 <span class="muted" aria-hidden="true">▸</span>
123 <select name="show" aria-label="Branch">${here.versions.map((v) => html`<option value="${v.key}"${v.key === shownKey ? raw(" selected") : null}>${v.branch}</option>`)}</select>
122124 <input name="path" value="${path ?? "/"}" aria-label="Path" spellcheck="false" autocomplete="off">
123125 <button class="btn talk-addr-go" type="submit">Go</button>
124126 </form>`;
127 // The workspace's status, in one word: starting, live, reloading, or the error with its file and
128 // line.
129 const status = paneStatus({ url, crew, busy: ask.busy === true });
outdated

This status logic is only reachable from the page, so the terminal duplicates a weaker copy. Move the facts-building into one function in dev_workspace.ts, or next to it, and call it from both. Also add tests for the failed-run and busy paths in talkPane.

130 const statusPill = html`<span class="talk-dev-status small" data-dev-status="${status.state}" role="status" title="${status.word}${status.state === "error" ? "; ask the crew to fix it" : ""}">${status.state === "error" ? "Error" : status.word}</span>`;

Non-blocking (principle 1, plain words): the pill reads "Error" and the file, line and next step are only in title. That is invisible on a phone and unreliable with a screen reader. Render "Error in src/app.ts:12" as visible text, or add a muted line, and keep title as an extra.

125131 const fell = paneFell(ctx.app.db, ws.repo.id, ws.fell);
126132 const fellLine = fell === undefined ? null : html`<p class="talk-pane-fell small" role="status">${fell}</p>`;
127133 return {
@@ -132,6 +138,7 @@ export async function talkPane(ctx: Ctx, user: User, name: string | undefined, w
132138 <div class="talk-pane-bar">
133139 <nav class="seg" aria-label="Preview, code or diff">${tab("preview", "Preview")}${tab("code", "Code")}${tab("diff", "Diff")}</nav>
134140 ${bar}
141 ${statusPill}
135142 ${url === undefined || view !== "preview" ? null : iconBtn("sync", "Reload the preview", { variant: "ghost", type: "button", extra: "js-only talk-reload" })}
136143 ${url === undefined ? null : btn(icon("external"), { href: url, label: `Open ${name} on its own`, title: "Open on its own", variant: "ghost", external: true, extra: "btn-icon" })}
137144 </div>
@@ -236,6 +243,8 @@ export const paneCss = /* css */ `
236243 .talk-addr-pick select { flex: 0 1 auto; min-width: 5rem; max-width: 14rem; text-overflow: ellipsis; }
237244 .talk-addr-pick input { flex: 1; min-width: 4rem; font-family: var(--mono); }
238245 .talk-addr-pick :is(select, input):focus-visible { background: var(--card); }
246 .talk-dev-status { flex: 0 1 auto; min-width: 0; padding: 6px 12px; border-radius: 999px; background: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
outdated

Phone 360px: a nowrap, non-shrinking pill carrying a file path will overflow the bar. Let it shrink with min-width:0, overflow hidden and text-overflow ellipsis, and put the full text in title. Check that the background token is a surface, not the text colour, and match .talk-addr.

247 .talk-dev-status[data-dev-status="error"] { font-weight: 600; }
outdated

Principle 5: a red --danger is a second accent on a page that has --accent. Keep the error to --fg, bold, and the word Error.

239248 @media (forced-colors: active) { .talk-addr-pick :is(select, input):focus-visible { outline: 2px solid CanvasText; } }
240249 :root.js .talk-addr-go { display: none; }
241250 .talk-pane-info, .talk-pane-fell { margin: 0 0 8px; overflow-wrap: anywhere; }
test/dev-workspace.test.ts added +19
@@ -0,0 +1,19 @@
1 import { describe, expect, test } from "bun:test";
2 import { devStatus, errorSite } from "../src/actions/dev_workspace.ts";
3
4 describe("workspace status (#17119)", () => {
5 test("nothing answering is starting; an address is live; a build under way is reloading", () => {
6 expect(devStatus({ up: false, working: false }).state).toBe("starting");
7 expect(devStatus({ up: true, working: false })).toEqual({ state: "live", word: "Live" });
8 expect(devStatus({ up: true, working: true }).word).toBe("Reloading");
9 });
10 test("a failure names its file and line, and wins over the rest", () => {
11 const s = devStatus({ up: true, working: true, failed: "error: Unexpected token\n at ./src/app.ts:12:5" });
12 expect(s).toEqual({ state: "error", word: "Error in src/app.ts:12", file: "src/app.ts", line: 12 });
13 });
14 test("a failure with no place is a bare error; paths that climb out are not taken", () => {
15 expect(devStatus({ up: true, working: false, failed: "it broke" }).word).toBe("Error");
16 expect(errorSite("at ../../etc/passwd.txt:3")).toBeUndefined();
17 expect(errorSite("at /etc/hosts.conf:3")).toBeUndefined();
18 });
19 });
test/talk-steps.test.ts +28
@@ -109,6 +109,7 @@ describe("a repository the person can read", () => {
109109 expect(pane.live).toBe(true);
110110 // The bar says which environment and where, and offers to reload it and to open it on its own.
111111 expect(pane.html.text).toContain('<span class="talk-addr small" title="https://lab--7--site.example.test/"><span class="muted">Pull #7</span> lab--7--site.example.test</span>');
112 expect(pane.html.text).toContain('data-dev-status="live"');
112113 expect(pane.html.text).toContain("talk-reload");
113114 expect(pane.html.text).toContain('href="https://lab--7--site.example.test/"');
114115 expect(frameSources({ frameSrc: pane.frame })).toContain("https://lab--7--site.example.test");
@@ -119,6 +120,32 @@ describe("a repository the person can read", () => {
119120 const pane = await talkPane(ctx, user, "erin/site", works, "preview", apps(undefined, { production: "https://site.example.test/" }));
120121 expect(pane.html.text).toContain('src="https://site.example.test/"');
121122 expect(pane.html.text).toContain("Production");
123 expect(pane.html.text).toContain('data-dev-status="live"');
124 });
125
126 test("the branch select shows the head branch, and a failed crew run is an Error with its file and line (#17119)", async () => {
127 const repo = await createRepo(app, user, { name: "bar", visibility: "public" });
128 if (!repo.ok) throw new Error(repo.error);
129 const row = getRepo(app.db, "erin", "bar");
130 if (row === undefined) throw new Error("repo");
131 const offer = { origins: [], repos: [{ name: "erin/bar", repo: row, versions: [{ key: "live", label: "Live", branch: "main" }, { key: "pull-4", label: "#4 Dim", branch: "crew/dim" }] }] };
132 const wctx = { app, url: new URL("http://x.test/talk") } as Ctx;
133 const urls = { production: "https://bar.example.test/" };
134 const pane = await talkPane(wctx, user, "erin/bar", works, "preview", apps(undefined, urls), { offer });
135 expect(pane.html.text).toContain('<option value="live" selected>main</option>');
136 expect(pane.html.text).toContain('<option value="pull-4">crew/dim</option>');
137 const run = createRun(app.db, { repoId: row.id, kind: "agent", reason: "work", branch: "crew/dim" });
138 app.db.run("UPDATE run SET state = 'failed', summary = ?2 WHERE id = ?1", [run.id, "error: Unexpected token at src/app.ts:12:5"]);
139 const failed = await talkPane(wctx, user, "erin/bar", works, "preview", apps(undefined, urls), { offer });
140 expect(failed.html.text).toContain('data-dev-status="error"');
141 expect(failed.html.text).toContain("Error in src/app.ts:12; ask the crew to fix it");
142 expect(failed.html.text).toContain(">Error</span>");
143 app.db.run("UPDATE run SET state = 'running' WHERE id = ?1", [run.id]);
144 const busy = await talkPane(wctx, user, "erin/bar", works, "preview", apps(undefined, urls), { offer });
145 expect(busy.html.text).toContain('data-dev-status="reloading"');
146 app.db.run("UPDATE run SET state = 'ok' WHERE id = ?1", [run.id]);
147 const asking = await talkPane(wctx, user, "erin/bar", works, "preview", apps(undefined, urls), { offer, busy: true });
148 expect(asking.html.text).toContain('data-dev-status="reloading"');
122149 });
123150
124151 test("nothing running draws no frame and no frame-src, and says so in words", async () => {
@@ -127,6 +154,7 @@ describe("a repository the person can read", () => {
127154 expect(pane.html.text).not.toContain("<iframe");
128155 expect(pane.frame).toBeUndefined();
129156 expect(pane.html.text).toContain("Nothing is running yet: the app appears here once it is built.");
157 expect(pane.html.text).toContain('data-dev-status="starting"');
130158 });
131159
132160 test("Code is the repository's files at the conversation's branch, its changed files first; Diff is the change itself, inline", async () => {
test/tui-talk-chats.test.ts +12
@@ -264,6 +264,18 @@ describe("the terminal's conversations screen", () => {
264264 expect(await drive(alice, [...open, "\r", "p"])).toContain("Not a repository you can see.");
265265 });
266266
267 test("p says Error in file:line when the crew's newest run failed, as the page's bar does (#17119)", async () => {
268 const made = createConversation(app.db, alice.id);
269 if (!made.ok) throw new Error(made.error);
270 const repo = await createRepo(app, alice, { name: "broken", visibility: "public" });
271 if (!repo.ok) throw new Error(repo.error);
272 const run = createRun(app.db, { repoId: repo.value.id, kind: "agent", reason: "work", branch: "crew/x" });
273 app.db.run("UPDATE run SET state = 'failed', summary = ?2 WHERE id = ?1", [run.id, "error: Unexpected token at src/app.ts:12:5"]);
274 appendTurn(app.db, alice.id, made.value.id, { role: "tool", text: 'mcp__forge__write_file {"repo":"alice/broken","path":"src/y.ts","content":"a"}' });
275 const text = await drive(alice, [...open, "\r", "p"]);
276 expect(text).toContain("Status: Error in src/app.ts:12; ask the crew to fix it");
277 });
278
267279 test("an ask waits at the foot of the conversation, never in the thread, and a opens Confirms to answer it", async () => {
268280 const made = createConversation(app.db, alice.id);
269281 if (!made.ok) throw new Error(made.error);

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs