diff --git a/plugins/github-watcher/source-contract.ts b/plugins/github-watcher/source-contract.ts index f1219423..afe9dd00 100644 --- a/plugins/github-watcher/source-contract.ts +++ b/plugins/github-watcher/source-contract.ts @@ -516,6 +516,13 @@ export const sourceContract = { priority: z.enum(["none", "urgent", "high", "medium", "low"]).optional(), parent: z.string().min(1).max(200).optional(), assignee: z.string().min(1).max(200).optional(), + /** + * BB-361: the playbook a local ticket runs under, `ticket` (the default, + * `local-tickets`) or `initiative`. Linear and github have no playbook of + * their own and ignore it; the local source stores it and the snapshot's + * optional `playbook` field carries it back. + */ + playbook: z.string().min(1).max(200).optional(), }), output: z.object({ id: z.string(), key: z.string(), url: z.string().nullable() }), }, diff --git a/plugins/linear/source-contract.ts b/plugins/linear/source-contract.ts index f1219423..afe9dd00 100644 --- a/plugins/linear/source-contract.ts +++ b/plugins/linear/source-contract.ts @@ -516,6 +516,13 @@ export const sourceContract = { priority: z.enum(["none", "urgent", "high", "medium", "low"]).optional(), parent: z.string().min(1).max(200).optional(), assignee: z.string().min(1).max(200).optional(), + /** + * BB-361: the playbook a local ticket runs under, `ticket` (the default, + * `local-tickets`) or `initiative`. Linear and github have no playbook of + * their own and ignore it; the local source stores it and the snapshot's + * optional `playbook` field carries it back. + */ + playbook: z.string().min(1).max(200).optional(), }), output: z.object({ id: z.string(), key: z.string(), url: z.string().nullable() }), }, diff --git a/plugins/stewards/README.md b/plugins/stewards/README.md index fd42e638..3ceb28f5 100644 --- a/plugins/stewards/README.md +++ b/plugins/stewards/README.md @@ -30,6 +30,16 @@ bb. [DESIGN.md](DESIGN.md) is the design; this is how it is built and run. of its first 96 turns on bithub, so stewards were top-level.) Grouping in the sidebar is bb's own: its project organization, or the stewards thread list; the plugin makes no sidebar sections (DESIGN.md §15). +- **Local tickets.** A third source, `local`, keeps a ticket in the stewards + store rather than Linear or GitHub. `ticket_file { unit: "local" }` files + one under the project's prefix (`LOCAL` by default, `localPrefix` to + override); it is adopted by state, not by label: Backlog is parked, Ready or + later non-terminal is adopted, and `bb stewards detach ` sets it back to + Backlog. It has no labels or priority, its children are local tickets, and a + pull request's body cites its key so the merge gate resolves the local spec's + approval. The owner's page comments and description edits form the spec; the + `bb stewards tickets list|show|file|comment|update|close|export` commands are + the by-hand surface. - **Ops stewards.** Each namespace and Sentry project in a login's `roles.json` `ops` entry gets an `ops` steward, reporting to the project steward, for as long as it is listed. The plugin looks at the target with @@ -1080,7 +1090,10 @@ copies drift. Sources serve `sourceSnapshot`, `sourceValidate`, `sourceEnsureLabel` (the label create `check --create-labels` uses, optional so a source without it is unavailable), `sourceAdoptable` and `sourceSetInterest`; stewards serves `stewardsRing`, and `stewardsSession` -for linear's `@bb` mentions. +for linear's `@bb` mentions. The third source, `local`, is served by stewards +itself in-process (`sourceRpc("local", …)` never leaves the process), backed +by the `local_tickets` and `local_comments` tables; a local ticket is adopted +by state and a pull request cites its key. ## Develop diff --git a/plugins/stewards/app.test.tsx b/plugins/stewards/app.test.tsx index e39c505b..9951acea 100644 --- a/plugins/stewards/app.test.tsx +++ b/plugins/stewards/app.test.tsx @@ -1027,7 +1027,7 @@ const boardSteward = (over: Record = {}) => ({ ...over, }); -const renderBoardWith = async (over: { subPath?: string; stewards?: unknown[]; questions?: unknown[]; withUser?: unknown[]; needs?: unknown[]; lessons?: unknown[]; lessonCounts?: unknown; digest?: unknown; ended?: unknown[]; stuck?: unknown[]; sidebarThreads?: { threads?: unknown[]; status?: "error" | "loading" | "ready" }; threadId?: string | null } = {}): 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[]; sidebarThreads?: { threads?: unknown[]; status?: "error" | "loading" | "ready" }; threadId?: string | null; localTicket?: { ticket: Record; comments?: unknown[] } } = {}): Promise => { const captured = await loadApp(); const panel = captured.navPanels[0]!; return renderSlot(panel, { subPath: over.subPath ?? "" }, { @@ -1054,6 +1054,11 @@ const renderBoardWith = async (over: { subPath?: string; stewards?: unknown[]; q }), stewardsAnswerQuestion: () => ({ ok: true, message: "closed" }), stewardsNeedAction: () => ({ ok: true, message: "done", ...(over.threadId === undefined ? {} : { threadId: over.threadId }) }), + // BB-361: the local ticket detail view. Null for a non-local effort. + stewardsLocalTicket: () => ({ ticket: over.localTicket?.ticket ?? null, comments: over.localTicket?.comments ?? [] }), + stewardsLocalEditDescription: () => ({ ok: true, message: "Saved." }), + stewardsLocalComment: () => ({ ok: true, message: "Commented." }), + stewardsLocalSetState: () => ({ ok: true, message: "Done." }), } as never, ...(over.sidebarThreads === undefined ? {} : { sidebarThreads: over.sidebarThreads }), } as never); @@ -1160,6 +1165,33 @@ describe("the Stewards page's project view and detail views (BB-85)", () => { slot.lifecycle.unmount(); }); + it("edits a local ticket's description and state, and comments as the owner (BB-361)", async () => { + const slot = await renderBoardWith({ + subPath: "p1/LOCAL-1", + stewards: [boardSteward({ key: "LOCAL-1", title: "A local effort" })], + localTicket: { + ticket: { key: "LOCAL-1", title: "A local effort", description: "Old text.", state: "Backlog", parent: null, playbook: "local-tickets", createdAt: 1, updatedAt: 1 }, + comments: [{ id: "c1", author: "Dana", owner: true, body: "**Spec:** owner words", createdAt: 2 }], + }, + }); + await waitFor(() => expect(slot.getByText("Local ticket")).toBeTruthy()); + await waitFor(() => expect((slot.getByLabelText("Description of LOCAL-1") as HTMLTextAreaElement).value).toBe("Old text.")); + const description = slot.getByLabelText("Description of LOCAL-1") as HTMLTextAreaElement; + fireEvent.change(description, { target: { value: "New text." } }); + fireEvent.click(slot.getByRole("button", { name: "Save description" })); + await waitFor(() => expect(slot.inspection.rpcCalls).toContainEqual({ method: "stewardsLocalEditDescription", input: { key: "LOCAL-1", description: "New text." } })); + // The state control. + const stateControl = slot.container.querySelector("#local-state-LOCAL-1")!; + fireEvent.change(stateControl, { target: { value: "Ready" } }); + await waitFor(() => expect(slot.inspection.rpcCalls).toContainEqual({ method: "stewardsLocalSetState", input: { key: "LOCAL-1", state: "Ready" } })); + // The owner's comment box, and the owner's earlier comment. + fireEvent.change(slot.getByLabelText("Comment on LOCAL-1"), { target: { value: "**Spec:** more" } }); + fireEvent.click(slot.getByRole("button", { name: "Comment as the owner" })); + await waitFor(() => expect(slot.inspection.rpcCalls).toContainEqual({ method: "stewardsLocalComment", input: { key: "LOCAL-1", body: "**Spec:** more" } })); + expect(slot.getByText(/owner words/u)).toBeTruthy(); + slot.lifecycle.unmount(); + }); + 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({ subPath: "p1/ENG-1", diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx index 26d7ab38..07fbef8f 100644 --- a/plugins/stewards/app.tsx +++ b/plugins/stewards/app.tsx @@ -1588,6 +1588,7 @@ function EffortDetail({ board: b, effortKey, refetch }: { board: Board; effortKe return ( <> +
{effort.items.length === 0 ? ( Nothing is waiting on you for this effort. @@ -1664,6 +1665,93 @@ function EffortDetail({ board: b, effortKey, refetch }: { board: Board; effortKe ); } +/** + * BB-361: a local ticket's own controls on its detail view: the description + * editor (the spec hash covers the description, so the owner revises it before + * approving), the state control, and the owner's comment box -- the one path + * an owner-entered local comment counts as the user's own spec words. + */ +function LocalTicketDetail({ effortKey }: { effortKey: string }) { + const rpc = useRpc(); + const { data, refetch } = usePolled(useCallback(() => rpc.call("stewardsLocalTicket", { key: effortKey }), [rpc, effortKey])); + const [description, setDescription] = useState(null); + const [comment, setComment] = useState(""); + const [busy, setBusy] = useState<"idle" | "saving" | { error: string }>("idle"); + const ticket = data?.ticket ?? null; + useEffect(() => { + setDescription(ticket === null ? null : ticket.description); + }, [ticket?.key, ticket?.updatedAt]); + if (ticket === null) return null; + const run = (p: Promise) => { + setBusy("saving"); + p.then( + () => { + setBusy("idle"); + refetch(); + }, + (e: unknown) => setBusy({ error: message(e) }), + ); + }; + const button = "w-fit rounded-md border border-input px-3 py-1 text-xs hover:bg-state-hover disabled:opacity-50"; + return ( +
+
+

+ {ticket.key} · playbook {ticket.playbook} + {ticket.parent === null ? "" : ` · parent ${ticket.parent}`} +

+ + + +