From f6eeb8778fcb8a47665b246ea31c2acfe40a27d3 Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Sat, 24 Oct 2026 22:59:22 +0000 Subject: [PATCH 1/2] stewards: always show the project dropdown and add a New thread button (BB-49) --- plugins/stewards/DESIGN.md | 10 +-- plugins/stewards/README.md | 9 ++- plugins/stewards/app.test.tsx | 7 ++- plugins/stewards/app.tsx | 89 +++++++++++++-------------- plugins/stewards/sidebar-app.test.tsx | 60 +++++++++++++----- 5 files changed, 100 insertions(+), 75 deletions(-) diff --git a/plugins/stewards/DESIGN.md b/plugins/stewards/DESIGN.md index 623068a0..dd81d3d7 100644 --- a/plugins/stewards/DESIGN.md +++ b/plugins/stewards/DESIGN.md @@ -1271,8 +1271,8 @@ A **lesson** makes the answer a record and, for most of them, lands it. ## 21. The sidebar thread list An opt-in replacement for bb's own sidebar list, registered through the -exclusive `experimental_threadList` slot (`plugins/stewards/app.tsx`). One tab -per project in the live view; in-flight efforts grouped by the steward +exclusive `experimental_threadList` slot (`plugins/stewards/app.tsx`). One +project dropdown in the live view; in-flight efforts grouped by the steward relationship; a collapsed Watches row for `ops`, Dependabot and Sentry bindings; a collapsed Recently ended row; and the project steward demoted to one small row at the bottom. Every row carries bb's own thread actions @@ -1303,9 +1303,9 @@ component joins them to `experimental_useSidebarThreads` and polls **The Needs you block and the count badge (BB-46).** The sidebar is where the user already looks, so what waits on them is shown there, not only on the -Stewards page. Each tab carries a count pill when its project has anything -waiting; the compact picker shows the summed count and per-project counts in -its options. Above In flight, a **Needs you** block lists one row per item +Stewards page. The project dropdown carries each project's count in its option +label and the summed count in a pill beside it. Above In flight, a **Needs you** +block lists one row per item 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 diff --git a/plugins/stewards/README.md b/plugins/stewards/README.md index 25130bd1..0478171e 100644 --- a/plugins/stewards/README.md +++ b/plugins/stewards/README.md @@ -318,7 +318,7 @@ bb. [DESIGN.md](DESIGN.md) is the design; this is how it is built and run. ## The sidebar thread list and its toggle BB-44 registers a replacement for bb's own sidebar thread list through the -exclusive `experimental_threadList` slot: one tab per stewarded project, +exclusive `experimental_threadList` slot: one project dropdown, in-flight efforts grouped by the steward relationship, and collapsed Watches and Recently ended rows. BB-45 makes it switchable from where you are. @@ -346,10 +346,9 @@ is left alone. The write is best-effort: a failure is logged and the sidebar keeps working. (`bb.onInstall` is not usable here; it does not run for plugins baked into the `bb-server` image.) -**The Needs you block and the tab badge (BB-46).** Each tab shows a small -count pill when the project has anything waiting on you, and the compact -viewport's picker shows the summed count beside it and per-project counts in -its options. Above **In flight**, a **Needs you** block lists one row per +**The Needs you block and the picker badge (BB-46).** The project dropdown +shows each project's count in its option label and the summed count in a small +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, diff --git a/plugins/stewards/app.test.tsx b/plugins/stewards/app.test.tsx index 926a8729..20e0ff82 100644 --- a/plugins/stewards/app.test.tsx +++ b/plugins/stewards/app.test.tsx @@ -340,17 +340,18 @@ describe("the stewards sidebar's needs you block (BB-46)", () => { } as never); }; - it("shows a count badge on a tab only when the count is non-zero", async () => { + it("shows the summed count badge beside the picker only when non-zero", async () => { const slot = await renderSidebar({ stewardsSidebar: () => sidebarData({ count: 2, items: [questionItem()] }, { count: 0, items: [] }) }); + await waitFor(() => expect(slot.getByLabelText("Project")).toBeTruthy()); await waitFor(() => expect(slot.getByLabelText("2 waiting on you")).toBeTruthy()); expect(slot.queryByLabelText("0 waiting on you")).toBeNull(); slot.lifecycle.unmount(); }); - it("sums the count on the compact picker and shows per-project counts in its options", async () => { + it.each([false, true])("sums the count beside the picker and shows per-project counts in its options (compact=%s)", async (isCompactViewport) => { const slot = await renderSidebar( { stewardsSidebar: () => sidebarData({ count: 2, items: [questionItem(), needItem()] }, { count: 1, items: [needItem({ id: "need_2" })] }) }, - { isCompactViewport: true }, + { isCompactViewport }, ); await waitFor(() => expect(slot.getByLabelText("3 waiting on you")).toBeTruthy()); expect(slot.getByRole("option", { name: "Acme (2)" })).toBeTruthy(); diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx index ff7c19e8..7e0e71f8 100644 --- a/plugins/stewards/app.tsx +++ b/plugins/stewards/app.tsx @@ -820,14 +820,11 @@ function InFlightRow({ steward: s, now }: { steward: Board["stewards"][number]; // ---- The sidebar thread list ------------------------------------------------------------------- // // The opt-in replacement for bb's sidebar list, registered through the -// exclusive `experimental_threadList` slot. One tab per project, in-flight +// exclusive `experimental_threadList` slot. One project dropdown, in-flight // efforts grouped by the steward relationship, collapsed Watches and Recently // ended rows, and a demoted project-steward row. Every row carries bb's own // thread actions context menu, so nothing bb's rows can do is lost. -/** Past this many projects the tabs become a picker, as on a compact viewport. */ -const SIDEBAR_TAB_LIMIT = 5; - /** The live fields bb's thread actions read, from a sidebar row. */ function actionTarget(t: PluginSidebarThread): PluginThreadActionTarget { return { @@ -990,48 +987,41 @@ function SidebarCollapsible({ title, count, children }: { title: string; count: ); } -function ProjectTabs({ tabs, counts, activeId, compact, onPick }: { tabs: Array<{ projectId: string; name: string }>; counts: ReadonlyMap; activeId: string | null; compact: boolean; onPick: (projectId: string) => void }) { +/** + * The project dropdown, always a native ` onPick(e.target.value)} - > - {tabs.map((t) => { - const count = counts.get(t.projectId) ?? 0; - return ( - - ); - })} - - {total > 0 ? : null} - - ); - } return ( -
- {tabs.map((t) => { - const count = counts.get(t.projectId) ?? 0; - return ( - - ); - })} +
+ + {total > 0 ? : null} +
); } @@ -1113,8 +1103,9 @@ function SidebarNeedsSection({ projectId, needs, onChanged }: { projectId: strin ); } -function StewardsSidebar({ activeProjectId, isCompactViewport, onNavigate }: PluginThreadListProps) { +function StewardsSidebar({ activeProjectId, onNavigate }: PluginThreadListProps) { const rpc = useRpc(); + const navigate = useBbNavigate(); const { status, threads, projects } = experimental_useSidebarThreads(); const { data, error, refetch } = usePolled(useCallback(() => rpc.call("stewardsSidebar", null), [rpc])); const tabs = useMemo(() => buildSidebar({ projects, threads, data: data?.projects ?? [] }), [projects, threads, data]); @@ -1141,9 +1132,15 @@ function StewardsSidebar({ activeProjectId, isCompactViewport, onNavigate }: Plu const active = tabs.find((t) => t.projectId === wanted) ?? tabs[0] ?? null; const activeNeeds = active === null ? undefined : needsByProject.get(active.projectId); const now = Date.now(); + // The picker only changes local state; the plus button is what retargets the + // composer to it, then closes the drawer. + const openNewThread = () => { + if (active !== null) navigate.toCompose({ projectId: active.projectId }); + onNavigate(); + }; return (
- + {status === "loading" && data === null ? (

Loading…

) : active === null ? ( diff --git a/plugins/stewards/sidebar-app.test.tsx b/plugins/stewards/sidebar-app.test.tsx index e88315d0..8fff23f8 100644 --- a/plugins/stewards/sidebar-app.test.tsx +++ b/plugins/stewards/sidebar-app.test.tsx @@ -102,8 +102,8 @@ describe("the stewards sidebar list (BB-44)", () => { sidebarThreads: { projects, threads: [thread({ id: "thr_steward", displayTitle: "Fix login" })] }, rpc: { stewardsSidebar: () => sidebarData({ bindings: [binding({ hold: "billing freeze" })] }) } as never, }); - await waitFor(() => expect(slot.getByRole("tab", { name: "Acme" })).toBeTruthy()); - expect(slot.getByRole("tab", { name: "Personal" })).toBeTruthy(); + await waitFor(() => expect(slot.getByRole("option", { name: "Acme" })).toBeTruthy()); + expect(slot.getByRole("option", { name: "Personal" })).toBeTruthy(); await waitFor(() => expect(slot.getByText("Fix login")).toBeTruthy()); // The title does not name the key, so the key shows; the stage does not. expect(slot.getByText("ENG-1")).toBeTruthy(); @@ -249,32 +249,60 @@ describe("the stewards sidebar list (BB-44)", () => { slot.lifecycle.unmount(); }); - it("renders a project picker on a compact viewport", async () => { + it("renders the project picker at every viewport width", async () => { + for (const isCompactViewport of [false, true]) { + const slot = await renderSidebar( + { + sidebarThreads: { projects, threads: [] }, + rpc: { stewardsSidebar: () => sidebarData() } as never, + }, + { isCompactViewport }, + ); + await waitFor(() => expect(slot.getByLabelText("Project")).toBeTruthy()); + expect(slot.queryByRole("tab")).toBeNull(); + expect(slot.getByRole("option", { name: "Acme" })).toBeTruthy(); + slot.lifecycle.unmount(); + } + }); + + it("follows activeProjectId in the picker and switches on pick without navigating", async () => { const slot = await renderSidebar( { - sidebarThreads: { projects, threads: [] }, + sidebarThreads: { projects, threads: [thread({ id: "thr_personal", projectId: "personal", displayTitle: "My notes" })] }, rpc: { stewardsSidebar: () => sidebarData() } as never, }, - { isCompactViewport: true }, + { activeProjectId: "personal" }, ); - await waitFor(() => expect(slot.getByLabelText("Project")).toBeTruthy()); - expect(slot.queryByRole("tab")).toBeNull(); + const select = await waitFor(() => slot.getByLabelText("Project") as HTMLSelectElement); + expect(select.value).toBe("personal"); + fireEvent.click(slot.getByRole("button", { name: /Threads/u })); + await waitFor(() => expect(slot.getByText("My notes")).toBeTruthy()); + fireEvent.change(select, { target: { value: "p1" } }); + await waitFor(() => expect(select.value).toBe("p1")); + expect(slot.inspection.navigateCalls).not.toContainEqual(expect.objectContaining({ method: "toProject" })); slot.lifecycle.unmount(); }); - it("follows activeProjectId for the active tab and switches on pick", async () => { - const slot = await renderSidebar( + it("opens the composer on the picked project, then closes the drawer", async () => { + let slot!: RenderedSlot; + let composeSeenAtNavigate = false; + const onNavigate = vi.fn(() => { + composeSeenAtNavigate = slot.inspection.navigateCalls.some((c) => c.method === "toCompose"); + }); + slot = await renderSidebar( { - sidebarThreads: { projects, threads: [thread({ id: "thr_personal", projectId: "personal", displayTitle: "My notes" })] }, + sidebarThreads: { projects, threads: [] }, rpc: { stewardsSidebar: () => sidebarData() } as never, }, - { activeProjectId: "personal" }, + { onNavigate }, ); - await waitFor(() => expect(slot.getByRole("tab", { name: "Personal" }).getAttribute("aria-selected")).toBe("true")); - fireEvent.click(slot.getByRole("button", { name: /Threads/u })); - await waitFor(() => expect(slot.getByText("My notes")).toBeTruthy()); - fireEvent.click(slot.getByRole("tab", { name: "Acme" })); - await waitFor(() => expect(slot.getByRole("tab", { name: "Acme" }).getAttribute("aria-selected")).toBe("true")); + const select = await waitFor(() => slot.getByLabelText("Project") as HTMLSelectElement); + fireEvent.change(select, { target: { value: "personal" } }); + await waitFor(() => expect(select.value).toBe("personal")); + fireEvent.click(slot.getByRole("button", { name: "New thread" })); + await waitFor(() => expect(slot.inspection.navigateCalls).toContainEqual({ method: "toCompose", options: { projectId: "personal" } })); + expect(onNavigate).toHaveBeenCalledTimes(1); + expect(composeSeenAtNavigate).toBe(true); slot.lifecycle.unmount(); }); From 61eb2b653951067c1e294c5fdfb84ebf111015e5 Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Sat, 24 Oct 2026 23:02:54 +0000 Subject: [PATCH 2/2] stewards: hide the New thread button when no projects are stewarded (BB-49) --- plugins/stewards/app.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx index 7e0e71f8..7a51841d 100644 --- a/plugins/stewards/app.tsx +++ b/plugins/stewards/app.tsx @@ -1013,15 +1013,17 @@ function ProjectTabs({ tabs, counts, activeId, onPick, onNewThread }: { tabs: Ar })} {total > 0 ? : null} - + {tabs.length > 0 ? ( + + ) : null}
); }