From 52fa9d020500c549e5b95a4df49b57c83a86369b Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Tue, 27 Oct 2026 17:08:13 +0000 Subject: [PATCH 1/2] stewards: the page shows project and effort detail views, the sidebar is the list (BB-85) --- plugins/stewards/DESIGN.md | 73 ++- plugins/stewards/README.md | 63 ++- plugins/stewards/app.test.tsx | 207 +++++--- plugins/stewards/app.tsx | 691 ++++++++++++++++++-------- plugins/stewards/sidebar-app.test.tsx | 197 +++++++- 5 files changed, 882 insertions(+), 349 deletions(-) diff --git a/plugins/stewards/DESIGN.md b/plugins/stewards/DESIGN.md index 0983812a..40e864b9 100644 --- a/plugins/stewards/DESIGN.md +++ b/plugins/stewards/DESIGN.md @@ -875,14 +875,19 @@ deployment: # where a merge is confirmed live (BB-53); omi - **Agent tools:** `steward_report` and `steward_update` (which also records and completes lessons, §20). - **CLI:** `bb stewards init | check | list | show | needs | done | detach | pass | digest | lessons | drop-lesson`. -- **UI:** the Stewards page, a nav panel with one tab per stewarded project and - the expanded view of the sidebar (BB-78): **Blocked** (needs-you cards first, - then blocked, held, stuck and waiting-on-others), **In flight** (the rest of - the non-`ops` bindings, running before quiet), **Monitors** (the `ops` - bindings with their last wake) and **Recently ended**, then the latest digest - with its date and the lessons block. Each card is headed by the same two-line - effort row the sidebar shows (§21), with the status report underneath; a - needs-you card carries its prompt and the page's full one-click controls. +- **UI:** the Stewards page, a nav panel (BB-85): `board/` is the + project view — the project name and project-steward link, **Waiting on you** + (the needs-you items with no open binding: project-level questions and items + whose binding ended), one line counting what the sidebar holds, the latest + digest with its date and the collapsed lessons block. `board//` + is one effort's detail view, opened from its sidebar row: the sidebar's + two-line effort row (§21) one size up with a crumb back, **Needs you** with + the page's full controls, **Status** (summary, `Next: … (actor)`, the + blocked / on hold / stuck lines and the meta line), **Threads** (the steward, + the workers and the pull request) and the lessons the effort wrote. An ended + effort shows the key, title, how it ended and the archived thread; an unknown + key says so. The page's own sidebar is the same list + (`experimental_sidebar`), told the project and effort the path names. Settings → Plugins → Stewards keeps each project's configuration and health. ### Changes to linear and github @@ -962,7 +967,7 @@ goes wrong there into Linear tickets for the project steward to adopt. its thread is archived; put back, the same binding and thread resume. `bb stewards detach` ends it until the target is taken out and put back, as a ticket stays detached until its label is. It reports to the project - steward and has no workers. On the Stewards page it sits under **Monitors**, + steward and has no workers. In the sidebar it sits under **Monitors**, a quiet row with its last wake; a `watch` stage only survives in the board RPC for the CLI. In `bb stewards list` it shows when it last looked and how many problems are failing. @@ -1135,13 +1140,13 @@ must do, with a link, one line of what, steps, and a close rule. Under BB-30 the steward-filed asks (`decide`, `configure`, `provide-secret`) are the one `escalations` record with `route: me` and a `resolution`; the plugin-filed gate items (`approve-spec`, `approve-pr`, `merge`) stay as -needs. Both appear on the Stewards page under **Blocked**, attached to the -binding's card by its entity key (or, with no open binding, as a card of their -own at the top), in the digest, and by `bb stewards needs` and -`bb stewards show`. The page's needs-you card keeps its full controls — the -free-text answer box, the rationale box, the fixed-choice buttons and **Other…**, -the secret form and the `approve-spec` note — where the sidebar's inline block -carries only the one-click actions. A `route: me` +needs. Both appear on the effort's detail view under **Needs you**, attached +to its binding by its entity key (or, with no open binding, in the project +view's **Waiting on you**), in the digest, and by `bb stewards needs` and +`bb stewards show`. The detail's needs-you item keeps the page's full controls +— the free-text answer box, the rationale box, the fixed-choice buttons and +**Other…**, the secret form and the `approve-spec` note — where the sidebar's +inline block carries only the one-click actions. A `route: me` escalation is rendered from its `resolution` alone: `choice` (one button per label), `text` (the answer box), `approve-decline`, `secret` (the requester thread and bb's secure form) or `done`. @@ -1475,9 +1480,9 @@ A **lesson** makes the answer a record and, for most of them, lands it. section is gone, and `bb stewards lessons --all` is where their state is read. - **Surfaces.** Every lesson is in one collapsed details block at the bottom - of the Stewards page's project tab, with counts by tier and the rows behind + of the Stewards page's project view, with counts by tier and the rows behind the disclosure (no buttons of its own; the boundary Merge / Drop stays the - need under **Blocked**); `bb stewards list` names the pending ones, + need on the effort's detail); `bb stewards list` names the pending ones, `bb stewards lessons [--all]` lists them all with their counts, and `bb stewards lessons --efficacy` prints the escalation-to-user trend and the uncited guidance units; `bb stewards drop-lesson ` drops one. @@ -1501,9 +1506,9 @@ project dropdown in the live view; the sections top to bottom are **Blocked** (needs-you rows first, then blocked), **In flight** (running before quiet), **Threads** (one-off threads, collapsed), **Monitors** (the `ops`, Dependabot and Sentry bindings, collapsed), **Recently ended** (collapsed), 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. +project steward demoted to one small row at the bottom. Every effort and thread +row carries bb's own thread actions context menu, so archive, pin, rename, +split and delete still work. **Two-line effort rows and the four glyphs (BB-76).** An effort row is two lines. Line one is the glyph, the entity key in bold, and the title, which @@ -1551,6 +1556,20 @@ non-ops efforts, running before quiet, then by recency. Pinned rows stay first w `buildSidebar` returns `blocked`, `efforts`, `threads` and `monitors` separately, and the split is unit tested in `sidebar.test.ts`. +**Rows, highlighting and auto-expand (BB-85).** A stewarded effort row in +Blocked, In flight or Monitors and a Recently ended row are real links to the +effort's detail view (`board//`, §16); a worker or reviewer child +row, a one-off thread and the project steward row still open their thread. An +effort row is highlighted while the board shows that effort's detail, and a +thread row is highlighted while its thread page is the route (`bg-state-active`, +with `aria-current="page"` on the anchor). When navigation lands on a row +inside a collapsed parent, the parent expands so the row is revealed: the +effort's row for a worker or reviewer, the **Threads** section for a one-off +thread, and **Monitors** or **Recently ended** for their rows. The board panel +registers the same list as its own `experimental_sidebar`, told the project and +effort the path names, so the list is there whichever thread list the user +pinned; a project pick in it moves the page. + **Grouping is the steward relationship, then 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 the grouping survives a worker spawned @@ -1571,13 +1590,13 @@ question or need's text and its one-click actions, the same RPC calls the old block made. A fixed-choice question answers through `stewardsAnswerQuestion { choice }`, a `decide` need through `stewardsNeedAction { action: "choose", choice }`; an `approve-pr` row carries -**Open PR** (`navigate.openUrl` on the item's `url`), **Approve** +**Open PR** (`navigate.openUrl` on the item's `url`) and **Approve** (`stewardsNeedAction { action: "approve" }`, no confirmation, the server's -refusal shown in the row) and **Details** (the board at that project); a -`merge` row swaps **Merge** for **Approve** (the lane gate re-checked -server-side). Every other row's page button is **Details**, opening the -Stewards page at that project, where the free-text answer and the secret form -live. The inline block adds no write path the page does not already make. The +refusal shown in the row); a `merge` row swaps **Merge** for **Approve** (the +lane gate re-checked server-side). There is no **Details** button: the row +itself opens the effort's detail view (BB-85), where the free-text answer and +the secret form live. The inline block adds no write path the page does not +already make. The project dropdown carries each project's count in its option label, and that count is the number of yellow effort rows, so the picker and the sections cannot disagree. `stewardsSidebar` carries, per project, diff --git a/plugins/stewards/README.md b/plugins/stewards/README.md index 9f534d5f..197e14f5 100644 --- a/plugins/stewards/README.md +++ b/plugins/stewards/README.md @@ -340,22 +340,25 @@ bb. [DESIGN.md](DESIGN.md) is the design; this is how it is built and run. 02:45 so bb-gate's 03:00 restarts do not cut a turn) gives every open binding a turn, then wakes the project steward for the morning digest. A half-hourly mechanical sweep is the adoption and stuck backstop. -- **The Stewards page** (a nav panel, [app.tsx](app.tsx)) is the expanded - view of the sidebar list, with the same sections in the same order: a tab per - stewarded project showing **Blocked** (needs-you cards first, then blocked, - held, stuck and waiting-on-others), **In flight** (the other open non-`ops` - bindings, running before quiet), **Monitors** (the `ops` bindings with their - last wake) and **Recently ended**, then the latest digest with its date and - one collapsed lessons details block at the bottom (counts by tier, rows - behind the disclosure, no buttons of its own). Every card is headed by the - same two-line effort row the sidebar shows — glyph, key, title / kind, phase, - phrase — derived by the same `sidebar.ts` rules. A needs-you card adds the - prompt, the summary and the page's full controls (the free-text answer, the - fixed choices, the secret form and the `approve-spec` note, which the sidebar - does not have); every other card adds the summary, `Next: - ()` and the meta line. A needs-you item attaches to its binding's - card; a project-level question with no binding keeps a card of its own at the - top of Blocked. +- **The Stewards page** (a nav panel, [app.tsx](app.tsx)) is no longer the + list (BB-85). `board/` is the project view: project name and + project-steward link, **Waiting on you** (the needs-you items with no open + binding — project-level questions and items whose binding ended), one line + counting what the sidebar holds, the latest digest with its date and one + collapsed lessons details block at the bottom (counts by tier, rows behind + the disclosure, no buttons of its own). `board//` is one + effort's detail view, opened from its sidebar row: the same two-line effort + row the sidebar shows — glyph, key, title / kind, phase, phrase — one size up + with a crumb back to the project view; **Needs you** with the page's full + controls (the free-text answer, the fixed choices, the secret form and the + `approve-spec` note, which the sidebar does not have); **Status** (the + summary, `Next: ()`, the blocked / on hold / stuck lines + and the meta line with the stage and deployment); **Threads** (the steward, + the workers and the pull request); and the lessons the effort wrote. An ended + effort shows the key, title, how it ended and the archived thread; an unknown + key says so. The page registers its own sidebar (`experimental_sidebar`), the + same list told the project and effort the path names, so it is there whichever + thread list the user pinned. - **Questions and asks to you** are escalations with `route: me`, kept in the store from the moment the project steward asks (`steward_update { ask }`, or forwarding an escalation) until it records @@ -415,16 +418,26 @@ keeps bb's own glyph. A worker or reviewer child row under an effort, and a one-off thread's children, share those glyphs and carry no role tag. An `ops` binding that needs you or is blocked moves from Monitors into Blocked. -**The needs-you items and the picker count (BB-46).** The project dropdown -shows each project's count in its option label, counting the yellow effort -rows. A needs-you effort shows the question or need's text and its one-click -actions inline under line two: a fixed-choice question answers through +**Rows, highlighting and auto-expand (BB-85).** An effort row in Blocked, In +flight or Monitors and a Recently ended row are real links to the effort's +detail view; a worker or reviewer child row, a one-off thread and the project +steward row still open their thread. The row the board is showing is +highlighted, and a thread row is highlighted while its thread page is the +route. When navigation lands on a row inside a collapsed parent, the parent +expands so the row is revealed: the effort's row for a worker or reviewer, the +**Threads** section for a one-off thread, and **Monitors** or **Recently +ended** for their rows. + +**The needs-you items and the picker count (BB-46, BB-85).** The project +dropdown shows each project's count in its option label, counting the yellow +effort rows. A needs-you effort shows the question or need's text and its +one-click actions inline under line two: a fixed-choice question answers through `stewardsAnswerQuestion`, a `decide` need through `stewardsNeedAction -{ action: "choose" }`, an `approve-pr` row carries **Open PR** / **Approve** / -**Details**, a `merge` row **Open PR** / **Merge** / **Details**, and every -other row opens the Stewards page with **Details**. The actions make the same -RPC calls the board does, the server's refusal is shown in the row, and the -row refetches on success. The items come from `stewardsSidebar` and each +{ action: "choose" }`, an `approve-pr` row carries **Open PR** / **Approve**, +and a `merge` row **Open PR** / **Merge**. There is no **Details** button: the +row itself opens the effort's detail view, where the free-text answer and the +secret form live. The actions make the same RPC calls the board does, the +server's refusal is shown in the row, and the row refetches on success. The items come from `stewardsSidebar` and each carries the binding's entity key as `bindingKey`, so a row owns its item; a project-level question with no binding has no row and stays on the Stewards page. The plugin publishes `needs-you-changed { projectId }` on its realtime diff --git a/plugins/stewards/app.test.tsx b/plugins/stewards/app.test.tsx index 69c25931..9d357332 100644 --- a/plugins/stewards/app.test.tsx +++ b/plugins/stewards/app.test.tsx @@ -544,10 +544,10 @@ const boardSteward = (over: Record = {}) => ({ ...over, }); -const renderBoardWith = async (over: { stewards?: unknown[]; questions?: unknown[]; withUser?: unknown[]; needs?: unknown[] } = {}): Promise => { +const renderBoardWith = async (over: { subPath?: string; stewards?: unknown[]; questions?: unknown[]; withUser?: unknown[]; needs?: unknown[]; lessons?: unknown[]; lessonCounts?: unknown; digest?: unknown; ended?: unknown[]; stuck?: unknown[] } = {}): Promise => { const captured = await loadApp(); const panel = captured.navPanels[0]!; - return renderSlot(panel, { subPath: "" }, { + return renderSlot(panel, { subPath: over.subPath ?? "" }, { rpc: { stewardsBoard: () => ({ projects: [{ projectId: "p1", name: "Acme" }], @@ -557,15 +557,15 @@ const renderBoardWith = async (over: { stewards?: unknown[]; questions?: unknown paused: false, projectStewardThreadId: "thr_p", stages: [], - digest: null, + digest: over.digest ?? null, questions: over.questions ?? [], withUser: over.withUser ?? [], needs: over.needs ?? [], - lessons: [], - lessonCounts: { candidate: 0, trial: 0, promoted: 0, retired: 0 }, + lessons: over.lessons ?? [], + lessonCounts: over.lessonCounts ?? { candidate: 0, trial: 0, promoted: 0, retired: 0 }, stewards: over.stewards ?? [], - stuck: [], - ended: [], + stuck: over.stuck ?? [], + ended: over.ended ?? [], }, }), stewardsAnswerQuestion: () => ({ ok: true, message: "closed" }), @@ -579,89 +579,98 @@ const lineTwoIn = (slot: RenderedSlot, title: string): string => { const li = slot.getByText(title).closest("li")!; return (li.querySelector("[data-steward-line-two]") ?? li.querySelector("[data-sidebar-line-two]"))?.textContent ?? ""; }; +const headingGlyph = (slot: RenderedSlot): string | null => slot.container.querySelector("[data-steward-glyph]")?.getAttribute("data-steward-glyph") ?? null; +const headingLineTwo = (slot: RenderedSlot): string => slot.container.querySelector("[data-steward-line-two]")?.textContent ?? ""; -describe("the Stewards page's sections and cards (BB-78)", () => { - it("places every open binding in the section the BB-76 rules put it in, with the shared glyph and phrase", async () => { +const aLesson = (over: Record = {}) => ({ id: "lsn_1", bindingId: null, key: null, file: "AGENTS.md", text: "A rule.", scope: "procedure", status: "pending", tier: "trial", hits: 2, corrections: 0, lastCitedAt: null, branch: null, mergeSha: null, note: null, escalationId: null, createdAt: 1_000, ...over }); + +// BB-85: the page is no longer the list. `board/` is the project +// view and `board//` is one effort's detail, opened from the +// sidebar; the card columns are gone. +describe("the Stewards page's project view and detail views (BB-85)", () => { + it("shows the project view: name, steward link, waiting on you, the count line, digest and collapsed lessons, with no card columns", async () => { const slot = await renderBoardWith({ stewards: [ - boardSteward({ key: "ENG-1", title: "Needs you", needsUser: true, phase: "In Review" }), + boardSteward({ key: "ENG-1", title: "Fix login", needsUser: true }), boardSteward({ key: "ENG-2", title: "Held up", blockedOn: "bb-gate#88" }), - boardSteward({ key: "ENG-3", title: "Working", workers: [{ threadId: "thr_w", title: "w" }] }), - boardSteward({ key: "ENG-4", title: "Waiting", summary: "All done", nextAction: "wait for CI", actor: "steward" }), - boardSteward({ key: "acme/web", title: "Ops watch", kind: "ops", wokeAt: Date.now() - 60_000 }), + boardSteward({ key: "acme/web", title: "Ops watch", kind: "ops" }), ], + questions: [question({ id: "qst_project", key: null, question: "Which release?" })], + digest: { text: "All quiet.", at: 1_000 }, + lessons: [aLesson()], + lessonCounts: { candidate: 0, trial: 1, promoted: 0, retired: 0 }, + ended: [{ key: "ENG-0", url: null, title: "Old work", kind: "ticket", endReason: "done", endedAt: 1_000, threadId: "thr_old" }], }); - await waitFor(() => expect(slot.getByText("Needs you")).toBeTruthy()); - // The sections are in order, and the old stage grouping is gone. - const headings = [...slot.container.querySelectorAll("h2")].map((h) => h.textContent ?? ""); - expect(headings[0]).toContain("Blocked"); - expect(headings[1]).toContain("In flight"); - expect(headings[2]).toContain("Monitors"); - expect(headings[3]).toContain("Recently ended"); - expect(slot.queryByRole("heading", { name: /Waiting on you/u })).toBeNull(); - expect(slot.queryByRole("heading", { name: /Stuck or held/u })).toBeNull(); - // Blocked holds the yellow and the red; In flight the running and the quiet; Monitors the ops. - const blockedSection = slot.getByRole("heading", { name: /^Blocked/u }).closest("section")!; - expect(blockedSection.textContent).toContain("Needs you"); - expect(blockedSection.textContent).toContain("Held up"); - const inflightSection = slot.getByRole("heading", { name: /^In flight/u }).closest("section")!; - expect(inflightSection.textContent).toContain("Working"); - expect(inflightSection.textContent).toContain("Waiting"); - const monitorsSection = slot.getByRole("heading", { name: /^Monitors/u }).closest("section")!; - expect(monitorsSection.textContent).toContain("Ops watch"); - expect(monitorsSection.textContent).toContain("Last wake"); - // The shared row: the same glyph and phrase the sidebar derives. - expect(glyphIn(slot, "Needs you")).toBe("you"); - expect(lineTwoIn(slot, "Needs you")).toBe("ticket · In Review · needs you"); - expect(glyphIn(slot, "Held up")).toBe("blocked"); - expect(lineTwoIn(slot, "Held up")).toBe("ticket · blocked on bb-gate#88"); - expect(glyphIn(slot, "Working")).toBe("running"); - expect(lineTwoIn(slot, "Working")).toBe("ticket · 1 worker running"); - expect(glyphIn(slot, "Waiting")).toBe("quiet"); - expect(lineTwoIn(slot, "Waiting")).toBe("ticket · wait for CI"); + await waitFor(() => expect(slot.getByText("Which release?")).toBeTruthy()); + // The name and the project-steward link. + expect(slot.getByText("Acme")).toBeTruthy(); + expect(slot.getByRole("button", { name: "Open the project steward" })).toBeTruthy(); + // Waiting on you holds only the item with no open binding. + expect(slot.queryByText("Stack or hold?")).toBeNull(); + // The count line. + const count = slot.container.querySelector("[data-board-count-line]")!; + expect(count.textContent).toContain("3 open"); + expect(count.textContent).toContain("2 blocked"); + expect(count.textContent).toContain("1 monitors"); + expect(count.textContent).toContain("1 recently ended"); + // The latest digest and the collapsed lessons block. + expect(slot.getByText("All quiet.")).toBeTruthy(); + expect(slot.getByText("A rule.")).toBeTruthy(); + expect(slot.container.querySelector("details")!.open).toBe(false); + // No card columns any more. + for (const name of [/^Blocked/u, /^In flight/u, /^Monitors/u, /^Recently ended/u]) { + expect(slot.queryByRole("heading", { name })).toBeNull(); + } slot.lifecycle.unmount(); }); - it("shows the summary, next action, actor and meta line under a non-needs-you card", async () => { - const slot = await renderBoardWith({ - stewards: [boardSteward({ summary: "Everything is fine", nextAction: "wait for CI", actor: "steward", statusAt: 1_000, createdAt: 2_000, deployment: "deployed", hold: "a freeze" })], - }); - await waitFor(() => expect(slot.getByText(/Everything is fine/u)).toBeTruthy()); - const card = slot.getByText("Fix login").closest("li")!; - expect(card.textContent).toContain("Next: wait for CI (the steward)"); - expect(card.textContent).toContain("Reported"); - expect(card.textContent).toContain("adopted"); - expect(card.textContent).toContain("deployed"); - expect(card.textContent).toContain("On hold: a freeze"); - expect(slot.getByRole("button", { name: "Open steward" })).toBeTruthy(); + it("replaces the path with the server's project when the path names none", async () => { + const slot = await renderBoardWith({ stewards: [] }); + await waitFor(() => expect(slot.inspection.navigateCalls).toContainEqual({ method: "toPluginPanel", path: "board", options: { subPath: "p1", replace: true } })); slot.lifecycle.unmount(); }); - it("attaches a needs-you item to its binding's card, and keeps a project-level question at the top of Blocked", async () => { + it("shows one effort's detail: the two-line heading, needs you with the page's controls, status, threads and lessons", async () => { const slot = await renderBoardWith({ - stewards: [boardSteward({ key: "ENG-1", title: "Fix login", needsUser: true, summary: "In review" })], - questions: [question({ id: "qst_project", key: null, question: "Which release?" }), question({ id: "qst_eng1", key: "ENG-1", question: "Stack or hold?", choices: ["Stack", "Hold"] })], + subPath: "p1/ENG-1", + stewards: [ + boardSteward({ key: "ENG-1", title: "Fix login", needsUser: true, phase: "In Review", summary: "In review", nextAction: "wait for CI", actor: "steward", statusAt: 1_000, createdAt: 2_000, stage: "build", deployment: "deployed", workers: [{ threadId: "thr_w", title: "Implement retry" }] }), + ], + questions: [question({ id: "qst_eng1", key: "ENG-1", question: "Stack or hold?", choices: ["Stack", "Hold"] })], + needs: [need({ id: "need_spec", kind: "approve-spec", key: "ENG-1", what: "Approve the spec", how: "Read the spec" })], + lessons: [aLesson({ key: "ENG-1" })], }); - await waitFor(() => expect(slot.getByText("Stack or hold?")).toBeTruthy()); - // The project-level question is its own card, before the binding's card. - const items = [...slot.container.querySelectorAll("li")]; - expect(items[0]!.textContent).toContain("Which release?"); - // The binding's question is inside the same card as its row header. - const card = slot.getByText("Fix login").closest("li")!; - expect(card.textContent).toContain("Stack or hold?"); - expect(card.textContent).toContain("In review"); - // Its controls are the page's, and they make the same RPC call. + await waitFor(() => expect(slot.getByText("Fix login")).toBeTruthy()); + // The heading is the sidebar's two-line row one size up, with a crumb back. + expect(headingGlyph(slot)).toBe("you"); + expect(headingLineTwo(slot)).toBe("ticket · In Review · needs you"); + expect(slot.getByRole("button", { name: /Acme/u })).toBeTruthy(); + // Needs you carries the page's full controls. + expect(slot.getByText("Stack or hold?")).toBeTruthy(); + expect(slot.getByText("Approve the spec")).toBeTruthy(); + expect(slot.getByLabelText("Note for: Approve the spec")).toBeTruthy(); fireEvent.click(slot.getByRole("button", { name: "Stack" })); await waitFor(() => expect(slot.inspection.rpcCalls).toContainEqual({ method: "stewardsAnswerQuestion", input: { questionId: "qst_eng1", answer: null, choice: "Stack" } })); + // Status: summary, Next, stage and deployment. + expect(slot.getByText("In review")).toBeTruthy(); + expect(slot.getByText(/Next: wait for CI \(the steward\)/u)).toBeTruthy(); + expect(slot.getByText(/stage build/u)).toBeTruthy(); + expect(slot.getByText(/deployed/u)).toBeTruthy(); + // Threads: the steward, the worker and the pull request. + expect(slot.getByRole("button", { name: "Open the steward" })).toBeTruthy(); + expect(slot.getByRole("button", { name: "Implement retry" })).toBeTruthy(); + // Lessons the effort wrote. + expect(slot.getByText("A rule.")).toBeTruthy(); slot.lifecycle.unmount(); }); - it("keeps the page-only controls on a needs-you card: the secret form and the approve-spec note", async () => { + it("keeps the page-only controls on the detail's needs-you items: the secret form and the approve-spec note", async () => { const slot = await renderBoardWith({ - stewards: [boardSteward({ needsUser: true, summary: "Waiting on you" })], + subPath: "p1/ENG-1", + stewards: [boardSteward({ key: "ENG-1", title: "Fix login", needsUser: true, summary: "Waiting on you" })], needs: [ - need({ id: "need_secret", kind: "provide-secret", what: "Add the token", destination: "the dotenv" }), - need({ id: "need_spec", kind: "approve-spec", what: "Approve the spec", how: "Read the spec first" }), + need({ id: "need_secret", key: "ENG-1", kind: "provide-secret", what: "Add the token", destination: "the dotenv" }), + need({ id: "need_spec", key: "ENG-1", kind: "approve-spec", what: "Approve the spec", how: "Read the spec first" }), ], }); await waitFor(() => expect(slot.getByText("Add the token")).toBeTruthy()); @@ -674,7 +683,47 @@ describe("the Stewards page's sections and cards (BB-78)", () => { slot.lifecycle.unmount(); }); - it("derives the same state and phrase on the page and the sidebar for the same binding", async () => { + it("shows the blocked, hold and stuck lines in the status", async () => { + const slot = await renderBoardWith({ + subPath: "p1/ENG-1", + stewards: [boardSteward({ key: "ENG-1", title: "Fix login", blockedOn: "bb-gate#88", hold: "a freeze", holdBehind: ["ENG-9"], stuck: true, summary: "x", nextAction: "y" })], + stuck: [{ key: "ENG-1", url: null, threadId: "thr_s", why: "waiting on a decision", since: 1 }], + }); + await waitFor(() => expect(slot.getByText("Blocked on bb-gate#88")).toBeTruthy()); + expect(slot.getByText(/On hold: a freeze \(behind ENG-9\)/u)).toBeTruthy(); + expect(slot.getByText(/Stuck: waiting on a decision/u)).toBeTruthy(); + slot.lifecycle.unmount(); + }); + + it("shows what the board knows about an ended effort, and an unknown key says so", async () => { + const ended = await renderBoardWith({ + subPath: "p1/ENG-0", + ended: [{ key: "ENG-0", url: "https://linear.app/x", title: "Old work", kind: "ticket", endReason: "done", endedAt: 1_000, threadId: "thr_old" }], + }); + await waitFor(() => expect(ended.getByText("Old work")).toBeTruthy()); + expect(ended.getByText("done")).toBeTruthy(); + expect(ended.getByRole("button", { name: "Open the archived thread" })).toBeTruthy(); + fireEvent.click(ended.getByRole("button", { name: "Open the archived thread" })); + await waitFor(() => expect(ended.inspection.navigateCalls).toContainEqual({ method: "toThread", threadId: "thr_old" })); + ended.lifecycle.unmount(); + + const unknown = await renderBoardWith({ subPath: "p1/ENG-404" }); + await waitFor(() => expect(unknown.getByText(/No effort/u)).toBeTruthy()); + expect(unknown.getByText("ENG-404")).toBeTruthy(); + unknown.lifecycle.unmount(); + }); + + it("resolves a pull-request key that keeps its own slash", async () => { + const slot = await renderBoardWith({ + subPath: "p1/acme/web#612", + stewards: [boardSteward({ key: "acme/web#612", title: "Read dashboard metrics", kind: "pr", url: "https://github.com/acme/web/pull/612" })], + }); + await waitFor(() => expect(slot.getByText("Read dashboard metrics")).toBeTruthy()); + expect(slot.getByText("#612")).toBeTruthy(); + slot.lifecycle.unmount(); + }); + + it("derives the same state and phrase on the detail heading and the sidebar for the same binding", async () => { const bindings = [ sidebarBinding({ key: "ENG-1", threadId: "thr_1", needsUser: true, phase: "In Review" }), sidebarBinding({ key: "ENG-2", threadId: "thr_2", workers: [{ threadId: "thr_w", title: "w", status: "running" }] }), @@ -704,19 +753,12 @@ describe("the Stewards page's sections and cards (BB-78)", () => { sidebar.lifecycle.unmount(); const board = await renderBoardWith({ - stewards: [ - boardSteward({ key: "ENG-1", title: "Needs you", needsUser: true, phase: "In Review" }), - boardSteward({ key: "ENG-2", title: "Working", workers: [{ threadId: "thr_w", title: "w" }] }), - boardSteward({ key: "ENG-3", title: "Held up", blockedOn: "bb-gate#88" }), - boardSteward({ key: "ENG-4", title: "Waiting", deployment: "deployed" }), - ], + subPath: "p1/ENG-2", + stewards: [boardSteward({ key: "ENG-2", title: "Working", workers: [{ threadId: "thr_w", title: "w" }] })], }); - await waitFor(() => expect(board.getByText("Needs you")).toBeTruthy()); - - for (const title of ["Needs you", "Working", "Held up", "Waiting"]) { - expect(glyphIn(board, title)).toBe(fromSidebar.get(title)!.glyph); - expect(lineTwoIn(board, title)).toBe(fromSidebar.get(title)!.lineTwo); - } + await waitFor(() => expect(board.getByText("Working")).toBeTruthy()); + expect(headingGlyph(board)).toBe(fromSidebar.get("Working")!.glyph); + expect(headingLineTwo(board)).toBe(fromSidebar.get("Working")!.lineTwo); board.lifecycle.unmount(); }); @@ -729,3 +771,4 @@ describe("the Stewards page's sections and cards (BB-78)", () => { slot.lifecycle.unmount(); }); }); + diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx index 9074b2dc..127ca666 100644 --- a/plugins/stewards/app.tsx +++ b/plugins/stewards/app.tsx @@ -1,11 +1,14 @@ -// Two surfaces. The Stewards page (a nav panel, one tab per stewarded -// project) is the expanded view of the sidebar (BB-78): the Blocked, In flight, -// Monitors and Recently ended sections, every card headed by the shared BB-76 -// effort row, and the latest digest and lessons block; the one write is closing -// a question put to you or pressing a needs item's button. Settings → Plugins → -// Stewards: which projects are stewarded and whether their configuration is -// healthy, then every open steward and where it stands. Steering stays with the -// project steward and the CLI. +// Two surfaces. The Stewards page (a nav panel, BB-85) is no longer the list: +// `board/` is the project view (project name and steward link, the +// items waiting on you with no open binding, one count line, the latest digest +// and the lessons block) and `board//` is one effort's detail +// (its two-line row one size up, its needs-you items with the page's full +// controls, its status, threads and lessons). The sidebar (the opt-in +// `experimental_threadList`, or the panel's own `experimental_sidebar`) is the +// list; the one write is closing a question put to you or pressing a needs +// item's button. Settings → Plugins → Stewards: which projects are stewarded +// and whether their configuration is healthy, then every open steward and +// where it stands. Steering stays with the project steward and the CLI. import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react"; import { Markdown, @@ -22,13 +25,14 @@ import { useSdk, useSidebarThreadDraft, useSidebarThreadRowStatus, + type PluginNavPanelProps, type PluginSidebarThread, type PluginThreadActionTarget, type PluginThreadListProps, } from "@get-bb/plugin-sdk/app"; import type { rpcContract } from "./server"; import { NEEDS_YOU_CHANGED } from "./channels.js"; -import { buildSidebar, compareBlocked, compareEfforts, compareInflight, deploymentPhrase, effortPhrase, effortSection, effortState, effortTitle, isBusy, type EffortStatus, type SidebarChild, type SidebarChildRole, type SidebarEffort, type SidebarEffortState, type SidebarSection } from "./sidebar.js"; +import { buildSidebar, compareBlocked, compareEfforts, compareInflight, deploymentPhrase, effortPhrase, effortSection, effortState, effortTitle, isBusy, type EffortStatus, type SidebarChild, type SidebarChildRole, type SidebarEffort, type SidebarEffortState, type SidebarEnded, type SidebarSection, type SidebarTab } from "./sidebar.js"; import { AUTOMATIC_THREAD_LIST_PROVIDER, BUILTIN_THREAD_LIST_ID, THREAD_LIST_PROVIDER_KEY, stewardsThreadListId } from "./sidebar-provider.js"; type Client = ReturnType>; @@ -406,8 +410,36 @@ function Section({ title, count, children }: { title: string; count?: number; ch ); } -function List({ children }: { children: ReactNode }) { - return
    {children}
; +/** `decodeURIComponent` without throwing on a malformed path segment. */ +function safeDecode(value: string): string { + try { + return decodeURIComponent(value); + } catch { + return value; + } +} + +/** + * The panel's `subPath` names the project in its first segment and, in a detail + * view, the effort key in everything after it. A pull-request key like + * `acme/web#612` keeps its own `/`, so the key is the whole remainder, not one + * more segment. + */ +function parseBoardPath(subPath: string): { projectId: string | null; key: string | null } { + const slash = subPath.indexOf("/"); + const first = slash === -1 ? subPath : subPath.slice(0, slash); + const rest = slash === -1 ? "" : subPath.slice(slash + 1); + return { projectId: first === "" ? null : safeDecode(first), key: rest === "" ? null : safeDecode(rest) }; +} + +/** The subPath for a project view, or with a key one effort's detail view. */ +function boardSubPath(projectId: string, key?: string): string { + return key === undefined ? projectId : `${projectId}/${key}`; +} + +/** A real link to one effort's detail view, keeping a pull-request key's own `/` as path. */ +function boardHref(pluginId: string, projectId: string, key: string): string { + return `/plugins/${encodeURIComponent(pluginId)}/${BOARD_PATH}/${encodeURIComponent(projectId)}/${key.split("/").map(encodeURIComponent).join("/")}`; } function None({ children }: { children: ReactNode }) { @@ -417,10 +449,14 @@ function None({ children }: { children: ReactNode }) { function BoardPage({ subPath }: { subPath: string }) { const rpc = useRpc(); const navigate = useBbNavigate(); - const first = subPath.split("/")[0] ?? ""; - const wanted = first === "" ? null : decodeURIComponent(first); + const { projectId: wanted, key } = parseBoardPath(subPath); const { data, error, refetch } = usePolled(useCallback(() => rpc.call("stewardsBoard", { projectId: wanted }), [rpc, wanted])); const boardProjectId = data?.board?.projectId ?? null; + // A path with no project takes the server's choice, replacing rather than + // pushing so the sidebar follows without a back-button trap. + useEffect(() => { + if (wanted === null && boardProjectId !== null) navigate.toPluginPanel(BOARD_PATH, { subPath: boardSubPath(boardProjectId), replace: true }); + }, [wanted, boardProjectId, navigate]); // A steward's question or item shows up here without the half-minute poll. useRealtime( NEEDS_YOU_CHANGED, @@ -453,7 +489,7 @@ function BoardPage({ subPath }: { subPath: string }) { type="button" aria-current={active ? "page" : undefined} className={`-mb-px border-b-2 px-3 py-1.5 ${active ? "border-foreground font-medium" : "border-transparent text-muted-foreground hover:text-foreground"}`} - onClick={() => navigate.toPluginPanel(BOARD_PATH, { subPath: encodeURIComponent(p.projectId) })} + onClick={() => navigate.toPluginPanel(BOARD_PATH, { subPath: boardSubPath(p.projectId) })} > {p.name} @@ -461,7 +497,13 @@ function BoardPage({ subPath }: { subPath: string }) { })} ) : null} - {data.board === null ? That project is not stewarded. : } + {data.board === null ? ( + That project is not stewarded. + ) : key === null ? ( + + ) : ( + + )} {error !== null ?

Refresh failed: {error}

: null} )} @@ -540,17 +582,17 @@ function boardOrder(e: BoardEffort) { }; } -function ProjectBoard({ board: b, refetch }: { board: Board; refetch: () => void }) { +/** The open efforts with their derived state, section, phrase and needs-you items. */ +function boardEfforts(b: Board): { efforts: BoardEffort[]; orphans: NeedsYouItem[] } { const now = Date.now(); // An escalation a need answers is shown as that need's row, not as the raw // escalation: a forwarded approval is answered with Approve/Decline, not by // "approve or decline in its steward's thread". const covered = new Set(b.needs.map((n) => n.escalationId).filter((id): id is string => id !== null)); const withUser = b.withUser.filter((x) => !covered.has(x.id)); - - // Needs-you items attach to their binding's card; an item with no open binding - // (a project-level question, or one whose binding has ended) keeps a card of - // its own at the top of Blocked (BB-78). + // A needs-you item attaches to its binding's detail view; an item with no + // open binding (a project-level question, or one whose binding has ended) + // waits in the project view. const openKeys = new Set(b.stewards.map((s) => s.key)); const itemsByKey = new Map(); const orphans: NeedsYouItem[] = []; @@ -564,16 +606,28 @@ function ProjectBoard({ board: b, refetch }: { board: Board; refetch: () => void if (key === null || !openKeys.has(key)) orphans.push(item); else itemsByKey.set(key, [...(itemsByKey.get(key) ?? []), item]); } - const efforts: BoardEffort[] = b.stewards.map((s) => { const status = boardEffortStatus(s); const state = effortState(status); return { steward: s, state, section: effortSection({ state, kind: s.kind }), phrase: effortPhrase(status, now), items: itemsByKey.get(s.key) ?? [] }; }); - const blocked = efforts.filter((e) => e.section === "blocked").sort((a, b) => compareBlocked(boardOrder(a), boardOrder(b))); - const inflight = efforts.filter((e) => e.section === "inflight").sort((a, b) => compareInflight(boardOrder(a), boardOrder(b))); - const monitors = efforts.filter((e) => e.section === "monitors").sort((a, b) => compareEfforts(boardOrder(a), boardOrder(b))); + return { efforts, orphans }; +} +/** One line counting the efforts the sidebar holds for this project. */ +function boardCountLine(efforts: readonly BoardEffort[], ended: number): string { + const count = (section: SidebarSection) => efforts.filter((e) => e.section === section).length; + return `${efforts.length} open: ${count("blocked")} blocked · ${count("inflight")} in flight · ${count("monitors")} monitors · ${ended} recently ended`; +} + +/** + * The project view at `board/` (BB-85): no list of efforts — the + * sidebar is the list — just the name, the project steward, what waits on you + * with no open binding, one count line, the digest and the collapsed lessons. + */ +function ProjectView({ board: b, refetch }: { board: Board; refetch: () => void }) { + const now = Date.now(); + const { efforts, orphans } = boardEfforts(b); return ( <>
@@ -591,62 +645,21 @@ function ProjectBoard({ board: b, refetch }: { board: Board; refetch: () => void

) : null} -
- {orphans.length === 0 && blocked.length === 0 ? ( - Nothing is blocked or waiting on you. +
+ {orphans.length === 0 ? ( + Nothing is waiting on you. ) : ( - +
    {orphans.map((item) => ( ))} - {blocked.map((e) => ( - - ))} - +
)}
-
- {inflight.length === 0 ? ( - Nothing in flight. - ) : ( - - {inflight.map((e) => ( - - ))} - - )} -
- -
- {monitors.length === 0 ? ( - No ops bindings. - ) : ( - - {monitors.map((e) => ( - - ))} - - )} -
- -
- {b.ended.length === 0 ? ( - Nothing ended in the last two weeks. - ) : ( - - {b.ended.map((x) => ( -
  • - - {x.title} - {x.kind} - {x.endReason !== null ? {x.endReason} : null} - {ago(x.endedAt, now)} -
  • - ))} -
    - )} -
    +

    + {boardCountLine(efforts, b.ended.length)} +

    {b.digest === null ? ( @@ -708,71 +721,174 @@ function LessonsBlock({ lessons, counts, now }: { lessons: Board["lessons"]; cou } /** - * One Stewards page card (BB-78): the BB-76 effort row as its header, then its - * needs-you items (prompt, muted summary, the page's full controls) or its - * status report (summary, next action, meta line). The glyph and phrase come - * from the same `sidebar.ts` rules the sidebar uses. + * The detail view at `board//` (BB-85): the effort's own page. + * Its heading is the sidebar's two-line row one size up, with a crumb back to + * the project view; below it the needs-you items with the page's full controls, + * the status report, the threads and the lessons the effort wrote. */ -function StewardCard({ effort, now, onChanged, projectStewardThreadId }: { effort: BoardEffort; now: number; onChanged: () => void; projectStewardThreadId: string | null }) { +function EffortDetail({ board: b, effortKey, refetch }: { board: Board; effortKey: string; refetch: () => void }) { + const now = Date.now(); + const navigate = useBbNavigate(); + const { efforts } = boardEfforts(b); + const effort = efforts.find((e) => e.steward.key === effortKey); + if (effort === undefined) { + const ended = b.ended.find((x) => x.key === effortKey); + if (ended !== undefined) return ; + return ; + } const s = effort.steward; + const lessons = b.lessons.filter((l) => l.key === effortKey); + const stuck = b.stuck.find((x) => x.key === effortKey) ?? null; return ( -
  • - - {s.priority !== null && s.priority !== "normal" ? {s.priority} : null} - {s.ending !== null ? {s.ending === "detach" ? "detaching" : "wrapping up"} : null} - - } - /> - {effort.items.length > 0 ? ( - effort.items.map((item, i) => ( -
    - - {i === 0 ?

    {s.summary ?? "No status report yet."}

    : null} - -
    - )) - ) : ( - <> - {s.summary === null ? ( -

    No status report yet.

    - ) : ( -

    - {s.summary}{" "} - - Next: {s.nextAction ?? "—"} - {s.actor === null ? "" : ` (${ACTOR_LABEL[s.actor] ?? s.actor})`} - -

    - )} - {s.hold !== null ?

    On hold: {s.hold}

    : null} + <> + +
    + {effort.items.length === 0 ? ( + Nothing is waiting on you for this effort. + ) : ( +
      + {effort.items.map((item) => ( +
    • + + +
    • + ))} +
    + )} +
    +
    +
    + {s.summary === null ?

    No status report yet.

    :

    {s.summary}

    } +

    + Next: {s.nextAction ?? "—"} + {s.actor === null ? "" : ` (${ACTOR_LABEL[s.actor] ?? s.actor})`} +

    + {s.blockedOn !== null ?

    Blocked on {s.blockedOn}

    : null} + {s.hold !== null ?

    On hold: {s.hold}{s.holdBehind.length > 0 ? ` (behind ${s.holdBehind.join(", ")})` : ""}

    : null} + {s.stuck ?

    Stuck{stuck === null ? "" : `: ${stuck.why}`}

    : null}

    {s.kind === "ops" ? `Last wake ${ago(s.wokeAt, now)}` : `Reported ${ago(s.statusAt, now)} · adopted ${ago(s.createdAt, now)}`} + {s.stage !== null ? ` · stage ${s.stage}` : ""} {s.deployment !== null ? ` · ${deploymentPhrase(s.deployment)}` : ""} - {s.threadId !== null ? ( - <> - {" · "} - Open steward - - ) : null} - {s.workers.map((w) => ( - - {" · worker "} - {w.title} - - ))}

    - - )} -
  • +
    + +
    +
    + {s.threadId === null ? null : Open the steward} + {s.workers.map((w) => ( + {w.title} + ))} + {s.url === null ? null : ( + + )} +
    +
    +
    + {lessons.length === 0 ? This effort wrote no lessons. : } +
    + + ); +} + +/** The detail heading: the sidebar's two-line effort row one size up, with a crumb back. */ +function EffortHeading({ board: b, effort }: { board: Board; effort: BoardEffort }) { + const navigate = useBbNavigate(); + const s = effort.steward; + return ( +
    + +
    +
    + + + {s.title === null ? null : {s.title}} + {s.priority !== null && s.priority !== "normal" ? {s.priority} : null} + {s.ending !== null ? {s.ending === "detach" ? "detaching" : "wrapping up"} : null} +
    +

    + {kindLabel(s.kind)} + {s.phase !== null ? ` · ${s.phase}` : ""} + {" · "} + {effort.phrase} +

    +
    +
    + ); +} + +/** An ended effort's detail: what the board still knows about it. */ +function EndedDetail({ board: b, ended, now }: { board: Board; ended: Board["ended"][number]; now: number }) { + const navigate = useBbNavigate(); + return ( +
    + +
    +
    + + {ended.title === null ? null : {ended.title}} + {kindLabel(ended.kind)} + {ended.endReason === null ? null : {ended.endReason}} +
    +

    Ended {ago(ended.endedAt, now)}

    + {ended.threadId === null ?

    Its thread is no longer available.

    :

    Open the archived thread

    } +
    +
    + ); +} + +/** A key the board does not know. */ +function UnknownEffort({ board: b, effortKey }: { board: Board; effortKey: string }) { + const navigate = useBbNavigate(); + return ( +
    + + No effort {effortKey} on this board. It may have ended more than two weeks ago. +
    + ); +} + +/** The lesson rows, shared by the project view's collapsed block and one effort's detail. */ +function LessonsList({ lessons, now }: { lessons: Board["lessons"]; now: number }) { + return ( +
      + {lessons.map((l) => ( +
    • +

      + {l.scope} + {l.tier} + {l.file} + {l.key !== null ? {l.key} : null} + {ago(l.createdAt, now)} +

      +

      {l.text}

      +

      + {l.hits} citation{l.hits === 1 ? "" : "s"} · {l.corrections} correction{l.corrections === 1 ? "" : "s"} · last cited {ago(l.lastCitedAt, now)} + {l.note !== null ? ` · ${l.note}` : ""} +

      +
    • + ))} +
    ); } @@ -1052,11 +1168,15 @@ function QuestionControls({ question: q, onClosed }: { question: BoardQuestion; // ---- The sidebar thread list ------------------------------------------------------------------- // // The opt-in replacement for bb's sidebar list, registered through the -// exclusive `experimental_threadList` slot. One project dropdown, two-line -// effort rows with the four glyphs in the Blocked / In flight / Threads / -// Monitors / Recently ended sections, 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. +// exclusive `experimental_threadList` slot, and the same list as the board +// panel's own sidebar (`experimental_sidebar`, BB-85). One project dropdown, +// two-line effort rows with the four glyphs in the Blocked / In flight / +// Threads / Monitors / Recently ended sections, and a demoted project-steward +// row. An effort row and a Recently ended row open the detail view; worker, +// reviewer, one-off and project-steward rows open their thread; the row the +// board shows is highlighted and navigation expands a collapsed parent. Every +// effort and thread row carries bb's own thread actions context menu, so +// nothing bb's rows can do is lost. /** The live fields bb's thread actions read, from a sidebar row. */ function actionTarget(t: PluginSidebarThread): PluginThreadActionTarget { @@ -1129,6 +1249,8 @@ function SidebarThreadRow({ meta, titleAttr, glyph, + activeThreadId, + openThreads, }: { thread: PluginSidebarThread; role: SidebarChildRole; @@ -1142,11 +1264,21 @@ function SidebarThreadRow({ /** The four-glyph component for a one-off thread or its child, an effort's * worker/reviewer child, or the project steward row; drafts keep bb's glyph. */ glyph?: SidebarEffortState; + /** The route's thread, so the row is highlighted while its page is showing (BB-85). */ + activeThreadId: string | null; + /** The rows that must be open so the active thread is revealed (BB-85). */ + openThreads: ReadonlySet; }) { const navigate = useBbNavigate(); const rowStatus = useSidebarThreadRowStatus(thread.id); const draft = useSidebarThreadDraft(thread.id); const [open, setOpen] = useState(false); + const selected = activeThreadId !== null && thread.id === activeThreadId; + // Navigation to a row inside this one expands it, so the highlighted row is revealed. + const revealed = openThreads.has(thread.id); + useEffect(() => { + if (revealed) setOpen(true); + }, [revealed]); // The array-wide indicator never reports a draft; the row folds in the // client-local one, as bb's own row does. const indicator = draft.hasUnsubmittedDraft && thread.indicator === "none" ? (isBusy(thread.status) ? "working-draft" : "draft") : thread.indicator; @@ -1155,7 +1287,7 @@ function SidebarThreadRow({ return (
  • -
    +
    {count > 0 ? ( ) : null} - {typeof state === "object" ? {state.error} : null}
    @@ -1274,36 +1404,54 @@ function SidebarInlineNeed({ item, onChanged, onOpenBoard }: { item: SidebarNeed /** * One effort's root row, two lines (BB-76): glyph, entity key and title on * line one; kind, phase and status phrase on line two; a needs-you row adds - * its prompt and actions under that, in the same row. + * its prompt and actions under that, in the same row. A stewarded effort row is + * a real link to its detail view (BB-85) and is highlighted while the board + * shows that effort. */ function SidebarEffortRow({ effort, needs, byId, + projectId, + activeKey, + activeThreadId, + openThreads, onNavigate, onChanged, - onOpenBoard, }: { effort: SidebarEffort; needs: readonly SidebarNeedItem[]; byId: ReadonlyMap; + projectId: string; + /** The effort key the board is showing, so its row is highlighted (BB-85). */ + activeKey: string | null; + /** The route's thread, passed to the effort's worker and reviewer rows (BB-85). */ + activeThreadId: string | null; + /** The rows that must be open so the active thread is revealed (BB-85). */ + openThreads: ReadonlySet; onNavigate: () => void; onChanged: () => void; - onOpenBoard: () => void; }) { const root = byId.get(effort.rootThreadId); const navigate = useBbNavigate(); + const pluginId = experimental_usePluginId(); const [open, setOpen] = useState(false); - if (root === undefined) return null; const key = effort.bindingKey; - const displayKey = key === null ? null : shortBindingKey(key); + if (root === undefined || key === null) return null; + const displayKey = shortBindingKey(key); const title = effortTitle(root.displayTitle, key); const count = countThreads(effort.children); const mine = needs.filter((item) => item.bindingKey !== null && item.bindingKey === key); + const selected = activeKey !== null && activeKey === key; + const revealed = openThreads.has(effort.rootThreadId); + useEffect(() => { + if (revealed) setOpen(true); + }, [revealed]); + const href = boardHref(pluginId, projectId, key); return (
  • -
    +
    @@ -1346,7 +1495,7 @@ function SidebarEffortRow({ {mine.length > 0 ? (
    {mine.map((item) => ( - + ))}
    ) : null} @@ -1355,7 +1504,7 @@ function SidebarEffortRow({ {effort.children.map((c) => { const child = byId.get(c.threadId); return child === undefined ? null : ( - + ); })} @@ -1375,8 +1524,12 @@ function SidebarSection({ title, count, children }: { title: string; count: numb ); } -function SidebarCollapsible({ title, count, children }: { title: string; count: number; children: ReactNode }) { +function SidebarCollapsible({ title, count, revealed = false, children }: { title: string; count: number; revealed?: boolean; children: ReactNode }) { const [open, setOpen] = useState(false); + // Navigation to a row inside this section expands it, so the row is revealed. + useEffect(() => { + if (revealed) setOpen(true); + }, [revealed]); return (