From aa126ac5412b894ca260568af0e22ca30519a9e5 Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Sat, 24 Oct 2026 21:28:09 +0000 Subject: [PATCH 1/2] stewards: title-first sidebar rows and a separate Threads section (BB-48) --- plugins/stewards/DESIGN.md | 14 +++++ plugins/stewards/app.tsx | 46 +++++++++++--- plugins/stewards/sidebar-app.test.tsx | 87 ++++++++++++++++++++++++--- plugins/stewards/sidebar.test.ts | 30 +++++++-- plugins/stewards/sidebar.ts | 7 ++- 5 files changed, 158 insertions(+), 26 deletions(-) diff --git a/plugins/stewards/DESIGN.md b/plugins/stewards/DESIGN.md index a61bb0ee..623068a0 100644 --- a/plugins/stewards/DESIGN.md +++ b/plugins/stewards/DESIGN.md @@ -1278,6 +1278,20 @@ 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 context menu, so archive, pin, rename, split and delete still work. +**Title-first rows (BB-48).** A row is the status glyph, the title, and — for +a stewarded effort — the binding key only when the title does not already name +it, plus the held and blocked badges. The title wins: it takes the available +width and truncates last, while the meta shrinks and truncates first. A key +shown is shortened (a pull request `acme/web#612` as `#612`, a ticket as its +own key) and the full key stays on the row's `title` attribute. The stage +leaves the row — the board still groups by stage, but a row no longer repeats +it — and the chevron no longer carries a child count, so only the chevron +signals children. A child row's worker/reviewer label is a small muted `W`/`R` +tag. One-off threads no longer share In flight: they sit in a collapsed +**Threads** row below it, so In flight counts stewarded efforts only. +`buildSidebar` returns `efforts`, `threads` and `watches` separately, and the +split is unit tested in `sidebar.test.ts`. + **Grouping is the steward relationship, not the thread tree.** A worker belongs to its binding through the plugin's `workers` table and a reviewer through the worker the RPC names, so BB-23's removal of the parent link cannot diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx index 7093f7df..15347916 100644 --- a/plugins/stewards/app.tsx +++ b/plugins/stewards/app.tsx @@ -847,6 +847,12 @@ function countThreads(children: readonly SidebarChild[]): number { return children.reduce((n, c) => n + 1 + countThreads(c.children), 0); } +/** A pull-request key like `acme/web#612` shortens to `#612`; a ticket key stays its key. */ +function shortBindingKey(key: string): string { + const pull = /#(\d+)$/.exec(key); + return pull === null ? key : `#${pull[1]}`; +} + /** One thread row: bb's glyph, title and context menu, expanding into its children. */ function SidebarThreadRow({ thread, @@ -856,6 +862,7 @@ function SidebarThreadRow({ byId, onNavigate, meta, + titleAttr, }: { thread: PluginSidebarThread; role: SidebarChildRole; @@ -864,6 +871,8 @@ function SidebarThreadRow({ byId: ReadonlyMap; onNavigate: () => void; meta?: ReactNode; + /** The full binding key, kept on the row's `title` attribute when the row is an effort. */ + titleAttr?: string; }) { const navigate = useBbNavigate(); const rowStatus = useSidebarThreadRowStatus(thread.id); @@ -876,17 +885,16 @@ function SidebarThreadRow({ return (
  • -
    +
    {count > 0 ? ( ) : ( @@ -903,7 +911,11 @@ function SidebarThreadRow({ > - {role === "worker" || role === "reviewer" ? {role} : null} + {role === "worker" || role === "reviewer" ? ( + + {role === "worker" ? "W" : "R"} + + ) : null} {meta}
    @@ -921,20 +933,25 @@ function SidebarThreadRow({ ); } -/** One effort's root row, with the binding's key, stage and held/blocked badges. */ +/** One effort's root row, title-first: the shortened key only when the title omits it, and the held/blocked badges. */ function SidebarEffortRow({ effort, byId, onNavigate }: { effort: SidebarEffort; byId: ReadonlyMap; onNavigate: () => void }) { const root = byId.get(effort.rootThreadId); if (root === undefined) return null; + const key = effort.bindingKey; + const displayKey = key === null ? null : shortBindingKey(key); + // The title wins: a steward is titled after its binding, so showing the key again is noise. + const keyInTitle = key !== null && displayKey !== null && (root.displayTitle.includes(key) || root.displayTitle.includes(displayKey)); + const showKey = displayKey !== null && !keyInTitle; + const badges = effort.hold !== null || effort.blockedOn !== null; const meta = - effort.bindingKey === null ? null : ( - - {effort.bindingKey} - {effort.stage !== null ? {effort.stage} : null} + !showKey && !badges ? null : ( + + {showKey ? {displayKey} : null} {effort.hold !== null ? held : null} {effort.blockedOn !== null ? blocked : null} ); - return ; + return ; } function SidebarSection({ title, count, children }: { title: string; count: number; children: ReactNode }) { @@ -1138,6 +1155,15 @@ function StewardsSidebar({ activeProjectId, isCompactViewport, onNavigate }: Plu )} + {active.threads.length > 0 ? ( + +
      + {active.threads.map((e) => ( + + ))} +
    +
    + ) : null} {active.watches.length > 0 ? (
      diff --git a/plugins/stewards/sidebar-app.test.tsx b/plugins/stewards/sidebar-app.test.tsx index 64792a58..8ea90dab 100644 --- a/plugins/stewards/sidebar-app.test.tsx +++ b/plugins/stewards/sidebar-app.test.tsx @@ -97,20 +97,90 @@ describe("the stewards sidebar list (BB-44)", () => { expect(captured.threadLists[0]).toMatchObject({ id: "sidebar", title: "Stewards" }); }); - it("shows a tab per live project and the active project's effort with its key, stage and badges", async () => { + it("shows a tab per live project and a title-first row with the shortened key and badges", async () => { const slot = await renderSidebar({ 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.getByText("ENG-1")).toBeTruthy()); - expect(slot.getByText("build")).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(); + expect(slot.queryByText("build")).toBeNull(); expect(slot.getByText("held")).toBeTruthy(); + // The full key stays on the row's title attribute. + expect(slot.container.querySelector('[title="ENG-1"]')).not.toBeNull(); + slot.lifecycle.unmount(); + }); + + it("drops the key when the title already names it, and keeps no stage text", async () => { + const slot = await renderSidebar({ + sidebarThreads: { projects, threads: [thread({ id: "thr_steward", displayTitle: "Review acme/web#612: Read dashboard metrics" })] }, + rpc: { stewardsSidebar: () => sidebarData({ bindings: [binding({ key: "acme/web#612", stage: "review" })] }) } as never, + }); + await waitFor(() => expect(slot.getByText("Review acme/web#612: Read dashboard metrics")).toBeTruthy()); + expect(slot.queryByText("#612", { exact: true })).toBeNull(); + expect(slot.queryByText("review", { exact: true })).toBeNull(); + expect(slot.container.querySelector('[title="acme/web#612"]')).not.toBeNull(); + slot.lifecycle.unmount(); + }); + + it("shortens a pull-request key to #N when the title omits it", async () => { + const slot = await renderSidebar({ + sidebarThreads: { projects, threads: [thread({ id: "thr_steward", displayTitle: "Fix login" })] }, + rpc: { stewardsSidebar: () => sidebarData({ bindings: [binding({ key: "acme/web#612" })] }) } as never, + }); + await waitFor(() => expect(slot.getByText("#612")).toBeTruthy()); + expect(slot.queryByText("acme/web#612", { exact: true })).toBeNull(); + expect(slot.container.querySelector('[title="acme/web#612"]')).not.toBeNull(); + slot.lifecycle.unmount(); + }); + + it("renders held and blocked badges without a stage", async () => { + const slot = await renderSidebar({ + sidebarThreads: { projects, threads: [thread({ id: "thr_steward", displayTitle: "Fix login" })] }, + rpc: { stewardsSidebar: () => sidebarData({ bindings: [binding({ hold: "waiting", blockedOn: "a review" })] }) } as never, + }); + await waitFor(() => expect(slot.getByText("held")).toBeTruthy()); + expect(slot.getByText("blocked")).toBeTruthy(); slot.lifecycle.unmount(); }); - it("shows workers and reviewers only when the effort is expanded", async () => { + it("drops the child count beside the chevron but keeps the expand aria-label", async () => { + const slot = await renderSidebar({ + sidebarThreads: { + projects, + threads: [thread({ id: "thr_steward", displayTitle: "Fix login" }), thread({ id: "thr_worker", displayTitle: "Implement retry" })], + }, + rpc: { stewardsSidebar: () => sidebarData({ bindings: [binding({ workers: [{ threadId: "thr_worker", title: "Implement retry" }] })] }) } as never, + }); + const expand = await waitFor(() => slot.getByRole("button", { name: "Expand Fix login" })); + expect(expand.textContent).toBe(""); + fireEvent.click(expand); + await waitFor(() => expect(slot.getByText("Implement retry")).toBeTruthy()); + expect(slot.getByRole("button", { name: "Collapse Fix login" })).toBeTruthy(); + slot.lifecycle.unmount(); + }); + + it("keeps one-off threads out of In flight, in a collapsed Threads section", async () => { + const slot = await renderSidebar({ + sidebarThreads: { projects, threads: [thread({ id: "thr_steward", displayTitle: "Fix login" }), thread({ id: "thr_oneoff", displayTitle: "My notes" })] }, + rpc: { stewardsSidebar: () => sidebarData({ bindings: [binding()] }) } as never, + }); + await waitFor(() => expect(slot.getByText("Fix login")).toBeTruthy()); + const inFlight = slot.getByRole("heading", { name: /In flight/u }); + expect(inFlight.textContent).toContain("1"); + const threads = slot.getByRole("button", { name: /Threads/u }); + expect(threads.textContent).toContain("1"); + // Collapsed by default: the one-off's title is not rendered until it is opened. + expect(slot.queryByText("My notes")).toBeNull(); + fireEvent.click(threads); + await waitFor(() => expect(slot.getByText("My notes")).toBeTruthy()); + slot.lifecycle.unmount(); + }); + + it("shows workers and reviewers only when the effort is expanded, as muted glyph tags", async () => { const slot = await renderSidebar({ sidebarThreads: { projects, @@ -123,14 +193,14 @@ describe("the stewards sidebar list (BB-44)", () => { }), } as never, }); - await waitFor(() => expect(slot.getByText("ENG-1")).toBeTruthy()); + await waitFor(() => expect(slot.getByText("Fix login")).toBeTruthy()); expect(slot.queryByText("Implement retry")).toBeNull(); fireEvent.click(slot.getByRole("button", { name: /Expand Fix login/u })); await waitFor(() => expect(slot.getByText("Implement retry")).toBeTruthy()); - expect(slot.getByText("worker")).toBeTruthy(); + expect(slot.getByTitle("worker").textContent).toBe("W"); fireEvent.click(slot.getByRole("button", { name: /Expand Implement retry/u })); await waitFor(() => expect(slot.getByText("Review the PR")).toBeTruthy()); - expect(slot.getByText("reviewer")).toBeTruthy(); + expect(slot.getByTitle("reviewer").textContent).toBe("R"); slot.lifecycle.unmount(); }); @@ -192,7 +262,8 @@ describe("the stewards sidebar list (BB-44)", () => { { activeProjectId: "personal" }, ); await waitFor(() => expect(slot.getByRole("tab", { name: "Personal" }).getAttribute("aria-selected")).toBe("true")); - expect(slot.getByText("My notes")).toBeTruthy(); + 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")); slot.lifecycle.unmount(); diff --git a/plugins/stewards/sidebar.test.ts b/plugins/stewards/sidebar.test.ts index 6927201d..b238b049 100644 --- a/plugins/stewards/sidebar.test.ts +++ b/plugins/stewards/sidebar.test.ts @@ -92,9 +92,26 @@ describe("stewards sidebar grouping", () => { threads: [thread({ id: "thr_root" }), thread({ id: "thr_child", parentThreadId: "thr_root" }), thread({ id: "thr_fork", lifecycleOwnerThreadId: "thr_child" })], data: [data({ projectId: "p1" })], }); - expect(tabs[0]!.efforts).toHaveLength(1); - expect(tabs[0]!.efforts[0]).toMatchObject({ rootThreadId: "thr_root", key: "thread:thr_root" }); - expect(tabs[0]!.efforts[0]!.children).toMatchObject([{ threadId: "thr_child", role: "thread", children: [{ threadId: "thr_fork", role: "thread" }] }]); + expect(tabs[0]!.efforts).toHaveLength(0); + expect(tabs[0]!.threads).toHaveLength(1); + expect(tabs[0]!.threads[0]).toMatchObject({ rootThreadId: "thr_root", key: "thread:thr_root" }); + expect(tabs[0]!.threads[0]!.children).toMatchObject([{ threadId: "thr_child", role: "thread", children: [{ threadId: "thr_fork", role: "thread" }] }]); + }); + + it("returns stewarded efforts, one-off threads and ops watches as separate lists", () => { + const tabs = buildSidebar({ + projects: [project({ id: "p1" })], + threads: [thread({ id: "thr_steward" }), thread({ id: "thr_ops" }), thread({ id: "thr_oneoff" })], + data: [ + data({ + projectId: "p1", + bindings: [binding({ key: "ENG-1", threadId: "thr_steward" }), binding({ key: "acme/web", threadId: "thr_ops", kind: "ops", stage: null })], + }), + ], + }); + expect(tabs[0]!.efforts.map((e) => e.key)).toEqual(["ENG-1"]); + expect(tabs[0]!.threads.map((e) => e.key)).toEqual(["thread:thr_oneoff"]); + expect(tabs[0]!.watches.map((e) => e.key)).toEqual(["acme/web"]); }); it("skips a binding whose steward thread is not in the live view", () => { @@ -103,7 +120,8 @@ describe("stewards sidebar grouping", () => { threads: [thread({ id: "thr_other" })], data: [data({ projectId: "p1", bindings: [binding({ key: "ENG-1", threadId: "thr_archived" })] })], }); - expect(tabs[0]!.efforts.map((e) => e.key)).toEqual(["thread:thr_other"]); + expect(tabs[0]!.efforts).toHaveLength(0); + expect(tabs[0]!.threads.map((e) => e.key)).toEqual(["thread:thr_other"]); }); it("gives every live project a tab, stewarded or not, including the personal project", () => { @@ -148,12 +166,12 @@ describe("stewards sidebar ordering", () => { expect(["idle", "finished", "failed"].some(isBusy)).toBe(false); }); - it("orders a tab's efforts and watches with the same comparator", () => { + it("orders a tab's threads and watches with the same comparator", () => { const tabs = buildSidebar({ projects: [project({ id: "p1" })], threads: [thread({ id: "thr_quiet", updatedAt: 5 }), thread({ id: "thr_busy", status: "active", updatedAt: 1 })], data: [data({ projectId: "p1" })], }); - expect(tabs[0]!.efforts.map((e) => e.rootThreadId)).toEqual(["thr_busy", "thr_quiet"]); + expect(tabs[0]!.threads.map((e) => e.rootThreadId)).toEqual(["thr_busy", "thr_quiet"]); }); }); diff --git a/plugins/stewards/sidebar.ts b/plugins/stewards/sidebar.ts index efe6fea8..7fec6e0e 100644 --- a/plugins/stewards/sidebar.ts +++ b/plugins/stewards/sidebar.ts @@ -102,8 +102,10 @@ export interface SidebarTab { projectId: string; name: string; isPersonal: boolean; - /** In-flight efforts, ordered. `ops` bindings are in `watches`, not here. */ + /** In-flight stewarded efforts, ordered. `ops` bindings are in `watches`, one-off threads in `threads`. */ efforts: SidebarEffort[]; + /** One-off threads (no steward binding), ordered. */ + threads: SidebarEffort[]; /** `ops`, Dependabot and Sentry bindings, grouped in a collapsed row. */ watches: SidebarEffort[]; projectStewardThreadId: string | null; @@ -278,7 +280,8 @@ function buildTab(project: SidebarLiveProject, data: SidebarProjectData | undefi projectId: project.id, name: project.name, isPersonal: project.isPersonal, - efforts: efforts.filter((e) => e.kind !== "ops").sort(compareEfforts), + efforts: efforts.filter((e) => e.bindingKey !== null && e.kind !== "ops").sort(compareEfforts), + threads: efforts.filter((e) => e.bindingKey === null).sort(compareEfforts), watches: efforts.filter((e) => e.kind === "ops").sort(compareEfforts), projectStewardThreadId: stewardThreadId, ended: data?.ended ?? [], From f14c1cf79cd3ab98cefcfeaf28e33d4dcee1716d Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Sat, 24 Oct 2026 21:33:49 +0000 Subject: [PATCH 2/2] stewards: anchor the key-in-title check so #612 is not swallowed by #6123 (BB-48) --- plugins/stewards/app.tsx | 9 ++++++++- plugins/stewards/sidebar-app.test.tsx | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx index 15347916..ff7c19e8 100644 --- a/plugins/stewards/app.tsx +++ b/plugins/stewards/app.tsx @@ -853,6 +853,13 @@ function shortBindingKey(key: string): string { return pull === null ? key : `#${pull[1]}`; } +const escapeRegExp = (text: string): string => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + +/** Whether the title names the key as a whole token, so `#612` is not swallowed by `#6123`. */ +function titleNamesKey(title: string, key: string): boolean { + return new RegExp(`${escapeRegExp(key)}(?!\\d)`).test(title); +} + /** One thread row: bb's glyph, title and context menu, expanding into its children. */ function SidebarThreadRow({ thread, @@ -940,7 +947,7 @@ function SidebarEffortRow({ effort, byId, onNavigate }: { effort: SidebarEffort; const key = effort.bindingKey; const displayKey = key === null ? null : shortBindingKey(key); // The title wins: a steward is titled after its binding, so showing the key again is noise. - const keyInTitle = key !== null && displayKey !== null && (root.displayTitle.includes(key) || root.displayTitle.includes(displayKey)); + const keyInTitle = key !== null && displayKey !== null && (titleNamesKey(root.displayTitle, key) || titleNamesKey(root.displayTitle, displayKey)); const showKey = displayKey !== null && !keyInTitle; const badges = effort.hold !== null || effort.blockedOn !== null; const meta = diff --git a/plugins/stewards/sidebar-app.test.tsx b/plugins/stewards/sidebar-app.test.tsx index 8ea90dab..e88315d0 100644 --- a/plugins/stewards/sidebar-app.test.tsx +++ b/plugins/stewards/sidebar-app.test.tsx @@ -137,6 +137,15 @@ describe("the stewards sidebar list (BB-44)", () => { slot.lifecycle.unmount(); }); + it("does not swallow a key into a longer number in the title", async () => { + const slot = await renderSidebar({ + sidebarThreads: { projects, threads: [thread({ id: "thr_steward", displayTitle: "Fix login #6123" })] }, + rpc: { stewardsSidebar: () => sidebarData({ bindings: [binding({ key: "acme/web#612" })] }) } as never, + }); + await waitFor(() => expect(slot.getByText("#612", { exact: true })).toBeTruthy()); + slot.lifecycle.unmount(); + }); + it("renders held and blocked badges without a stage", async () => { const slot = await renderSidebar({ sidebarThreads: { projects, threads: [thread({ id: "thr_steward", displayTitle: "Fix login" })] },