From 7e8851125125c3d818afee2920f2e4063d5534bf Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Mon, 26 Oct 2026 14:21:07 +0000 Subject: [PATCH 1/2] stewards: sidebar approve-pr rows get Open, Approve and Details (BB-66) --- plugins/stewards/DESIGN.md | 12 ++++-- plugins/stewards/README.md | 12 ++++-- plugins/stewards/app.test.tsx | 81 +++++++++++++++++++++++++++++++++-- plugins/stewards/app.tsx | 47 ++++++++++++++++---- 4 files changed, 135 insertions(+), 17 deletions(-) diff --git a/plugins/stewards/DESIGN.md b/plugins/stewards/DESIGN.md index e04badf4..21e84478 100644 --- a/plugins/stewards/DESIGN.md +++ b/plugins/stewards/DESIGN.md @@ -1364,9 +1364,15 @@ with the entity key (opening the entity), one line of text, and a question's or `decide` item's fixed `choices` as small buttons. A choice makes exactly the write the page makes (`stewardsAnswerQuestion` with `answer: null` for a question, `stewardsNeedAction { action: "choose" }` for a `decide` item) and -refetches; a row without choices, or a `provide-secret` item, opens the -Stewards page at that project, where the free-text answer and the secret form -live. The block adds no write path of its own. +refetches. An `approve-pr` row carries the page's three actions — **Open the +pull request** (`navigate.openUrl` on the item's `url`), **Approve** +(`stewardsNeedAction { action: "approve" }`, no confirmation, the server's +refusal shown in the row) and **Details** (the board at that project) — and +its text wraps instead of truncating, so the repository, number and title are +readable before the click. Every other row's page button is **Details** too: a +row without choices, or a `provide-secret` item, opens the Stewards page at +that project, where the free-text answer and the secret form live. The block +adds no write path of its own. **One source of truth.** `server.ts`'s `needsYou(projectId, { actionableOnly })` builds the board's `questions`, `withUser` and `needs` lists in one place; diff --git a/plugins/stewards/README.md b/plugins/stewards/README.md index 39adcd2f..60e1873f 100644 --- a/plugins/stewards/README.md +++ b/plugins/stewards/README.md @@ -376,9 +376,15 @@ pill beside it. Above **In flight**, a **Needs you** block lists one row per item: the entity key opens the entity, one line of what, and a question's or `decide` item's fixed `choices` as small buttons. A choice makes the same write the page does (`stewardsAnswerQuestion` for a question, -`stewardsNeedAction { action: "choose" }` for a `decide` item) and refetches; -a row without choices, or a `provide-secret` item, opens the Stewards page at -that project. The block and the board page read one server function +`stewardsNeedAction { action: "choose" }` for a `decide` item) and refetches. +An `approve-pr` row carries the page's three actions: **Open the pull +request** opens the item's `url`, **Approve** makes the page's one-click +approval (`stewardsNeedAction { action: "approve" }`, no confirmation, the +server's refusal shown in the row), and **Details** opens the Stewards page at +that project; its text wraps so the repository, number and title are readable. +Every other row's page button is **Details** too: a row without choices, or a +`provide-secret` item, opens the Stewards page at that project. The block and +the board page read one server function (`needsYou`), so the sidebar and the page can never disagree; a non-actionable need is on the page but not in the sidebar. The count and the items come from `stewardsSidebar`; the plugin publishes diff --git a/plugins/stewards/app.test.tsx b/plugins/stewards/app.test.tsx index 9424020e..fbe5ca40 100644 --- a/plugins/stewards/app.test.tsx +++ b/plugins/stewards/app.test.tsx @@ -392,14 +392,89 @@ describe("the stewards sidebar's needs you block (BB-46)", () => { slot.lifecycle.unmount(); }); - it("opens the board for a row without choices", async () => { + it("opens the board for a row without choices, under a Details label", async () => { const slot = await renderSidebar({ stewardsSidebar: () => sidebarData({ count: 1, items: [needItem({ kind: "configure", choices: [] })] }) }); - await waitFor(() => expect(slot.getByRole("button", { name: "Open" })).toBeTruthy()); - fireEvent.click(slot.getByRole("button", { name: "Open" })); + await waitFor(() => expect(slot.getByRole("button", { name: "Details" })).toBeTruthy()); + expect(slot.queryByRole("button", { name: "Open" })).toBeNull(); + fireEvent.click(slot.getByRole("button", { name: "Details" })); await waitFor(() => expect(slot.inspection.navigateCalls).toContainEqual({ method: "toPluginPanel", path: "board", options: { subPath: "p1" } })); slot.lifecycle.unmount(); }); + it("offers Open the pull request, Approve and Details on an approve-pr row, with wrapped text", async () => { + const slot = await renderSidebar({ + stewardsSidebar: () => sidebarData({ count: 1, items: [needItem({ kind: "approve-pr", url: "https://github.com/bitcomplete/bb-gate/pull/17", what: "Approve bitcomplete/bb-gate#17" })] }), + }); + await waitFor(() => expect(slot.getByRole("button", { name: "Open the pull request" })).toBeTruthy()); + expect(slot.getByRole("button", { name: "Approve" })).toBeTruthy(); + expect(slot.getByRole("button", { name: "Details" })).toBeTruthy(); + const text = slot.getByText("Approve bitcomplete/bb-gate#17"); + expect(text.className).not.toContain("truncate"); + expect(text.className).toContain("break-words"); + slot.lifecycle.unmount(); + }); + + it("opens the pull request's url from the row and makes no RPC", async () => { + const url = "https://github.com/bitcomplete/bb-gate/pull/17"; + const slot = await renderSidebar({ + stewardsSidebar: () => sidebarData({ count: 1, items: [needItem({ kind: "approve-pr", url })] }), + stewardsNeedAction: () => ({ ok: true, message: "done" }), + }); + fireEvent.click(await waitFor(() => slot.getByRole("button", { name: "Open the pull request" }))); + await waitFor(() => expect(slot.inspection.navigateCalls).toContainEqual({ method: "openUrl", url })); + expect(slot.inspection.rpcCalls.some((c) => c.method === "stewardsNeedAction")).toBe(false); + slot.lifecycle.unmount(); + }); + + it("sends the approve action with no note or choice, and refetches on success", async () => { + let calls = 0; + const slot = await renderSidebar({ + stewardsSidebar: () => { + calls += 1; + return sidebarData({ count: 1, items: [needItem({ kind: "approve-pr", url: "https://github.com/bitcomplete/bb-gate/pull/17" })] }); + }, + stewardsNeedAction: () => ({ ok: true, message: "approved" }), + }); + fireEvent.click(await waitFor(() => slot.getByRole("button", { name: "Approve" }))); + await waitFor(() => expect(slot.inspection.rpcCalls).toContainEqual({ method: "stewardsNeedAction", input: { needId: "need_1", action: "approve", note: null, choice: null } })); + await waitFor(() => expect(calls).toBe(2)); + slot.lifecycle.unmount(); + }); + + it("shows the server's refusal in the row and re-enables the buttons", async () => { + const slot = await renderSidebar({ + stewardsSidebar: () => sidebarData({ count: 1, items: [needItem({ kind: "approve-pr", url: "https://github.com/bitcomplete/bb-gate/pull/17" })] }), + stewardsNeedAction: () => ({ ok: false, message: "the owner must approve first" }), + }); + fireEvent.click(await waitFor(() => slot.getByRole("button", { name: "Approve" }))); + await waitFor(() => expect(slot.getByText("the owner must approve first")).toBeTruthy()); + expect((slot.getByRole("button", { name: "Approve" }) as HTMLButtonElement).disabled).toBe(false); + slot.lifecycle.unmount(); + }); + + it("opens the board at the project from Details on an approve-pr row", async () => { + const slot = await renderSidebar({ + stewardsSidebar: () => sidebarData({ count: 1, items: [needItem({ kind: "approve-pr", url: "https://github.com/bitcomplete/bb-gate/pull/17" })] }), + }); + fireEvent.click(await waitFor(() => slot.getByRole("button", { name: "Details" }))); + await waitFor(() => expect(slot.inspection.navigateCalls).toContainEqual({ method: "toPluginPanel", path: "board", options: { subPath: "p1" } })); + slot.lifecycle.unmount(); + }); + + it("labels the page button Details on every other row, with no Open label", async () => { + const items = [ + needItem({ id: "need_merge", kind: "merge", url: "https://github.com/bitcomplete/bb-gate/pull/17" }), + needItem({ id: "need_secret", kind: "provide-secret", choices: [] }), + needItem({ id: "need_config", kind: "configure", choices: [] }), + needItem({ id: "need_decide", kind: "decide", choices: [] }), + questionItem({ id: "qst_1", choices: [] }), + ]; + const slot = await renderSidebar({ stewardsSidebar: () => sidebarData({ count: items.length, items }) }); + await waitFor(() => expect(slot.getAllByRole("button", { name: "Details" })).toHaveLength(5)); + expect(slot.queryByRole("button", { name: "Open" })).toBeNull(); + slot.lifecycle.unmount(); + }); + it("refetches on a realtime event for a shown project and ignores an unknown one", async () => { let calls = 0; const slot = await renderSidebar({ diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx index 28bf90b7..376f8452 100644 --- a/plugins/stewards/app.tsx +++ b/plugins/stewards/app.tsx @@ -1030,17 +1030,18 @@ function ProjectTabs({ tabs, counts, activeId, onPick, onNewThread }: { tabs: Ar */ function SidebarNeedRow({ item, onChanged, onOpenBoard }: { item: SidebarNeedItem; onChanged: () => void; onOpenBoard: () => void }) { const rpc = useRpc(); + const navigate = useBbNavigate(); const [state, setState] = useState<"idle" | "running" | { error: string }>("idle"); // Choices are a decide item's or a question's; every other item opens the page. const choices = item.type === "question" ? item.choices : item.type === "need" && item.kind === "decide" ? item.choices : []; const text = item.type === "need" ? item.what : item.question; const entityUrl = item.type === "need" ? item.entityUrl : item.url; - const choose = (choice: string) => { + const prUrl = item.url; + // An approve-pr row offers the page's one-click approval and the pull + // request beside Details; every other row without choices opens the page. + const isApprovePr = item.type === "need" && item.kind === "approve-pr"; + const run = (call: Promise<{ ok: boolean; message: string }>) => { setState("running"); - const call = - item.type === "question" - ? rpc.call("stewardsAnswerQuestion", { questionId: item.id, answer: null, choice }) - : rpc.call("stewardsNeedAction", { needId: item.id, action: "choose", note: null, choice }); call.then( (r) => { if (!r.ok) return setState({ error: r.message }); @@ -1049,6 +1050,13 @@ function SidebarNeedRow({ item, onChanged, onOpenBoard }: { item: SidebarNeedIte (e: unknown) => setState({ error: message(e) }), ); }; + const choose = (choice: string) => + run( + item.type === "question" + ? rpc.call("stewardsAnswerQuestion", { questionId: item.id, answer: null, choice }) + : rpc.call("stewardsNeedAction", { needId: item.id, action: "choose", note: null, choice }), + ); + const approve = () => run(rpc.call("stewardsNeedAction", { needId: item.id, action: "approve", note: null, choice: null })); return (
  • @@ -1056,9 +1064,32 @@ function SidebarNeedRow({ item, onChanged, onOpenBoard }: { item: SidebarNeedIte {item.type === "withUser" ? {item.kind === "approval" ? "approval request" : `${item.kind} escalation`} : null} {item.type === "need" ? {item.kind} : null}

    -

    {text}

    +

    {text}

    - {choices.length > 0 ? ( + {isApprovePr ? ( + <> + {prUrl !== null ? ( + + ) : null} + + + + ) : choices.length > 0 ? ( choices.map((choice) => ( )} {typeof state === "object" ? {state.error} : null} From d35abcd2200944ff79a112a908be5407d965b6fd Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Mon, 26 Oct 2026 14:24:34 +0000 Subject: [PATCH 2/2] stewards: clarify the sidebar block adds no new write path (BB-66) --- plugins/stewards/DESIGN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/stewards/DESIGN.md b/plugins/stewards/DESIGN.md index 21e84478..c733e466 100644 --- a/plugins/stewards/DESIGN.md +++ b/plugins/stewards/DESIGN.md @@ -1372,7 +1372,7 @@ its text wraps instead of truncating, so the repository, number and title are readable before the click. Every other row's page button is **Details** too: a row without choices, or a `provide-secret` item, opens the Stewards page at that project, where the free-text answer and the secret form live. The block -adds no write path of its own. +adds no write path the page does not already make. **One source of truth.** `server.ts`'s `needsYou(projectId, { actionableOnly })` builds the board's `questions`, `withUser` and `needs` lists in one place;