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

Talk: the crew line speaks only of the conversation's own app, never another repository's runs #17582

opened this

Merged 24h 42m ago, live in production

talk-crew-line → main 0 commits 1 thread · 1 unresolved

  • Merged. talk-crew-line was merged into main as 14aad07.

Review

Sign in to review this change.
5 files changed +56 −20
src/web/crew_now.ts +6
@@ -25,6 +25,12 @@ interface LiveRow {
2525 readonly app: string;
2626 }
2727
28 /**
29 * The live runs on one repository (`owner/name`): Talk's line speaks only of the conversation's own
30 * app.
31 */
32 export const crewOn = <R extends LiveRow>(live: readonly R[], repo: string): R[] => live.filter((r) => r.app === repo);
33
2834 /** Words for the live runs (`liveCrewRows`). */
2935 export function crewLine(live: readonly LiveRow[]): string {
3036 const first = live[0];
src/web/pages/talk.ts +8 −4
@@ -74,7 +74,7 @@ import { codePaneCss } from "../talk_code.ts";
7474 import { linkRefs, refTarget } from "../../text/talk_links.ts";
7575 import { appLook, linkTalk, talkLook, type TalkLook } from "../../text/talk_link_words.ts";
7676 import { liveCrewRows } from "../../actions/crew_now.ts";
77 import { crewLine } from "../crew_now.ts";
77 import { crewLine, crewOn } from "../crew_now.ts";
7878 import { agentHtml, liveHtml, voiceCss, voiceOf, type Voice } from "../talk_parts.ts";
7979 import { badge, btn, icon, iconBtn, menu, meter, row, time } from "../ui.ts";
8080 import { inlineIcons } from "../icons.ts";
@@ -677,8 +677,12 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
677677 const about = editing === undefined ? aboutLine(ctx) : null;
678678 const display = talkDisplay(ctx.app.db, user.id);
679679 const lines = receiptLines(ctx.app.db, ctx.app.config.dataDir, user, turns);
680 // The crew's line says something only while a run is live: idle is silence.
681 const crew = liveCrewRows(ctx, user);
680 // The crew's line says something only while a run is live on this conversation's own app: idle,

Nit: two stacked comment blocks say one thing. Merge them into one.

681 // or another repository's work, is silence.
682 // Only a repository the pane offers this person (one they may read), so the page never names one
683 // they may not.
684 const crewRepo = paneRow?.name;
685 const crew = crewRepo === undefined ? [] : crewOn(liveCrewRows(ctx, user), crewRepo);
682686 // The model picker (`talk_model.ts`), only where a connection offers a model.
683687 const pickerAt = buildMode ? null : modelPicker(ctx, user, conversation.id);
684688 const picker = pickerAt === null ? null : pickerAt();
@@ -699,7 +703,7 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
699703 : foldSteps(display.steps === "open", timeGroups(turns, turns.map((t) => turnHtml(t, waiting, costs.get(t.id), acts.get(t.id), works.get(t.id), sent.get(t.id), expired, undone, refs, voice, look, lines))))}
700704 ${!paged && running ? queuedTalk(ctx.app, user, conversation.id).map(queuedHtml) : null}
701705 </ol>
702 <p class="talk-crew small muted" id="talk-crew" data-live="run.*" data-live-src="/live/talk-crew">${crew.length === 0 ? null : crewLine(crew)}</p>
706 <p class="talk-crew small muted" id="talk-crew" data-live="run.*" data-live-src="/live/talk-crew${crewRepo === undefined ? "" : `?repo=${encodeURIComponent(crewRepo)}`}">${crew.length === 0 ? null : crewLine(crew)}</p>
703707 <div id="end"></div>
704708 <div class="talk-keys" data-keys role="region" aria-label="Keyboard shortcuts" hidden><dl>${TALK_KEYS.map((k) => html`<dt>${k.keys}</dt><dd>${k.does}</dd>`)}</dl></div>
705709 <div class="talk-base">
src/web/talk_lines.ts +4 −2
@@ -15,7 +15,7 @@ import { getConversation } from "../core/conversations.ts";
1515 import { notePhase, takeSessionTime } from "../core/route_timing.ts";
1616 import { fragment } from "./layout.ts";
1717 import { liveCrewRows } from "../actions/crew_now.ts";
18 import { crewLine } from "./crew_now.ts";
18 import { crewLine, crewOn } from "./crew_now.ts";
1919 import { FOR_MINUTES, workLineFor, type WorkLine } from "../core/talk_work.ts";
2020 import { PEEK } from "./peek_client.ts";
2121
@@ -43,7 +43,9 @@ function workFragment(ctx: Ctx): Response {
4343 export function liveTalkCrew(ctx: Ctx): Response {
4444 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
4545 const rendering = performance.now();
46 const rows = ctx.auth.user === undefined ? undefined : liveCrewRows(ctx, ctx.auth.user);
46 // Only the conversation's own app's runs (`?repo=`); without one, nothing.
47 const repo = ctx.url.searchParams.get("repo");
48 const rows = ctx.auth.user === undefined ? undefined : repo === null ? [] : crewOn(liveCrewRows(ctx, ctx.auth.user), repo);
4749 const answer = rows === undefined ? fragment(html``, { status: 404 }) : fragment(html`<p class="talk-crew small muted" id="talk-crew">${rows.length === 0 ? null : crewLine(rows)}</p>`, { request: ctx.request });
4850 notePhase(ctx.request, "render", performance.now() - rendering);
4951 return answer;
test/talk-crew-now.test.ts +37 −11
@@ -1,6 +1,8 @@
11 /**
2 * /talk shows the crew's live work in one server-rendered line above the box, and says the crew
3 * is idle when no run is live (#13970).
2 * /talk shows the crew's live work on the conversation's own app in one server-rendered line above
3 * the box, and nothing when no run is live there (#13970). Another repository's crew is not this
4 * conversation's: the owner's walk (2026-12-02) found the forge's own runs named under a
5 * conversation about trevato/hello. The terminal's `talk /crew` still asks after the whole crew.
46 */
57 import { setMember } from "../src/core/roles.ts";
68 import { inviteContributor } from "../src/actions/invites.ts";
@@ -15,6 +17,8 @@ import { createApp as createAppRecord } from "../src/core/apps.ts";
1517 import { createIssue } from "../src/core/issues.ts";
1618 import { createRun } from "../src/core/runs.ts";
1719 import { createSession } from "../src/core/sessions.ts";
20 import { appendTurn, createConversation } from "../src/core/conversations.ts";
21 import { startChatBuild } from "../src/core/chat_build.ts";
1822 import { serve, type Servers } from "../src/http/server.ts";
1923 import { crewLine, CREW_IDLE } from "../src/web/crew_now.ts";
2024 import type { SshSession } from "../src/ssh/server.ts";
@@ -35,7 +39,15 @@ describe("/talk crew line", () => {
3539 let bobCookie: string;
3640 let bobId: string;
3741 const talk = async (c = cookie) => (await fetch(`${servers.url}/talk`, { headers: { cookie: c } })).text();
38 const line = (h: string) => /<p class="talk-crew[^>]*>([^<]*)<\/p>/.exec(h)?.[1];
42 /** A conversation of `who` building on `repo` (its own app), as `c` sees it. */
43 const talkOn = async (who: string, repo: string, c = cookie) => {
44 const made = createConversation(app.db, who);
45 if (!made.ok) throw new Error(made.error);
46 appendTurn(app.db, who, made.value.id, { role: "person", text: "how is it going?" });
47 startChatBuild(app.db, made.value.id, repo, true);
48 return (await fetch(`${servers.url}/talk/${made.value.id}`, { headers: { cookie: c } })).text();
49 };
50 const line = (h: string) => /<p [^>]*?class="talk-crew[^>]*>([^<]*)<\/p>/.exec(h)?.[1];
3951
4052 beforeAll(async () => {
4153 dir = await mkdtemp(join(tmpdir(), "forge-talk-crew-"));
@@ -64,6 +76,7 @@ describe("/talk crew line", () => {
6476
6577 test("idle when nobody works: the page says nothing, so no row is spent on it", async () => {
6678 expect(line(await talk())).toBe("");
79 expect(line(await talkOn(userId, repoId))).toBe("");
6780 });
6881
6982 test("signed out, /talk asks for sign-in and shows no crew line", async () => {
@@ -80,22 +93,29 @@ describe("/talk crew line", () => {
8093 const sealed = createIssue(app.db, { repoId, authorId: userId, title: "the hole", sealed: true });
8194 if (!sealed.ok) throw new Error("issue");
8295 createRun(app.db, { repoId, kind: "agent", issueId: sealed.value.id, reason: "work" });
83 expect(line(await talk(bobCookie))).toBe("");
84 expect(line(await talk())).toStartWith("The crew is working (2):");
96 // Bob reads hello but not its sealed report: nothing. Ada reads both, and hears only hello's.
97 expect(line(await talkOn(bobId, repoId, bobCookie))).toBe("");
98 expect(line(await talkOn(userId, repoId))).toBe("The crew is working: the crew on #1 the hole.");
99 expect(line(await talkOn(userId, secret.value.id))).toBe("The crew is working: the crew on ada/secret.");
85100 });
86101
87102 test("busy names who works on what", async () => {
88103 const issue = createIssue(app.db, { repoId, authorId: userId, title: "round the corners" });
89104 if (!issue.ok) throw new Error("issue");
90105 createRun(app.db, { repoId, kind: "agent", issueId: issue.value.id, reason: "work" });
91 const text = line(await talk());
92 expect(text).toStartWith("The crew is working (3):");
106 const text = line(await talkOn(userId, repoId));
107 expect(text).toStartWith("The crew is working (2):");
108 // A conversation with no app of its own names no crew at all, whatever runs elsewhere.
109 const bare = createConversation(app.db, userId);
110 if (!bare.ok) throw new Error(bare.error);
111 appendTurn(app.db, userId, bare.value.id, { role: "person", text: "hi" });
112 expect(line(await (await fetch(`${servers.url}/talk/${bare.value.id}`, { headers: { cookie } })).text())).toBe("");
93113 // A guest who can merely see the public repository hears nothing of its crew on their Talk
94114 // (#16487); made a member of the forge, they follow its crew like anyone on it.
95 expect(line(await talk(bobCookie))).toBe("");
115 expect(line(await talkOn(bobId, repoId, bobCookie))).toBe("");
96116 setMember(app.db, bobId, true, userId, new Date());
97117 try {
98 expect(line(await talk(bobCookie))).toBe("The crew is working: the crew on #2 round the corners.");
118 expect(line(await talkOn(bobId, repoId, bobCookie))).toBe("The crew is working: the crew on #2 round the corners.");
99119 } finally {
100120 setMember(app.db, bobId, false, userId, new Date());
101121 }
@@ -109,11 +129,17 @@ describe("/talk crew line", () => {
109129 const made = createIssue(app.db, { repoId: other.value.id, authorId: userId, title: "water the beans" });
110130 if (!made.ok) throw new Error("issue");
111131 createRun(app.db, { repoId: other.value.id, kind: "agent", issueId: made.value.id, reason: "work" });
112 expect(line(await talk(bobCookie))).toBe("");
132 expect(line(await talkOn(bobId, other.value.id, bobCookie))).toBe("");
113133 const bob = getUserById(app.db, bobId)!;
114134 const invited = inviteContributor(app, ada, getRepoById(app.db, other.value.id)!, bob.username);
115135 if (!invited.ok) throw new Error(String(invited.error));
116 expect(line(await talk(bobCookie))).toBe("The crew is working: the crew on #1 water the beans.");
136 expect(line(await talkOn(bobId, other.value.id, bobCookie))).toBe("The crew is working: the crew on #1 water the beans.");
137 // garden's crew is garden's: a conversation on hello does not name it.
138 expect(line(await talkOn(userId, repoId))).not.toContain("water the beans");
139 // The live line answers the same way, for the repository it names, and nothing without one.
140 const live = (q: string) => fetch(`${servers.url}/live/talk-crew${q}`, { headers: { cookie } }).then((r) => r.text());
141 expect(line(await live(`?repo=${encodeURIComponent("ada/garden")}`))).toBe("The crew is working: the crew on #1 water the beans.");
142 expect(line(await live(""))).toBe("");
117143 });
118144
119145 test("the terminal prints the same line: `talk /crew`", () => {
test/talk-receipt-live.test.ts +1 −3
@@ -176,9 +176,7 @@ test("the page draws the receipt with its live line and Reply; the line's fragme
176176 expect(page).toContain(
177177 'href="/alice/secret/issues/1#comment-body" data-reply="/alice/secret/issues/1" data-reply-to="alice/secret#1"',
178178 );
179 expect(page).toContain(
180 'id="talk-crew" data-live="run.*" data-live-src="/live/talk-crew"',
181 );
179 expect(page).toMatch(/id="talk-crew" data-live="run\.\*" data-live-src="\/live\/talk-crew(\?repo=[^"]*)?"/);
182180 const id = /id="(w-[0-9a-z]+)"/.exec(page)![1]!;
183181 const href = `/live/talk-work?href=${encodeURIComponent("/alice/secret/issues/1")}&id=${id}`;
184182 const mine = await get(href, alice);

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

Keyboard shortcuts

Docs