Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .bb/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{ "name": "diff-explorer", "source": "./plugins/diff-explorer" },
{ "name": "html-preview", "source": "./plugins/html-preview" },
{ "name": "image-copy", "source": "./plugins/image-copy" },
{ "name": "repo-dashboard", "source": "./plugins/repo-dashboard" }
{ "name": "repo-dashboard", "source": "./plugins/repo-dashboard" },
{ "name": "pr-inbox", "source": "./plugins/pr-inbox" }
]
}
2 changes: 1 addition & 1 deletion .github/workflows/plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
plugin: [devbox-provider, github-watcher, html-preview, image-copy, kubernetes-provider, stewards, team-setup, thread-briefs, workstreams]
plugin: [devbox-provider, github-watcher, html-preview, image-copy, kubernetes-provider, pr-inbox, stewards, team-setup, thread-briefs, workstreams]
defaults:
run:
working-directory: plugins/${{ matrix.plugin }}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Plugins for [bb](https://getbb.app), maintained by Bit Complete.
| [linear](plugins/linear) | Connect Linear once with OAuth; threads then read, search, comment on and move issues through native tools, as you |
| [github-watcher](plugins/github-watcher) | Lets a thread watch a GitHub pull request or issue with the server's `gh` login and be woken when reviews, checks, comments or state change |
| [stewards](plugins/stewards) | Gives a labelled Linear ticket or GitHub pull request, and every teammate's pull request, a long-lived thread that manages it as you by a playbook in `.bb` |
| [My PRs](plugins/pr-inbox) | Human feedback waiting on your authored PRs, with dismiss and Address comments |
| [repo-dashboard](plugins/repo-dashboard) | Shows weekly pull request activity by contributor for Parsley Health, Bit Complete, and Cscc |

Install one:
Expand Down
2 changes: 2 additions & 0 deletions plugins/pr-inbox/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
28 changes: 28 additions & 0 deletions plugins/pr-inbox/PLUGIN_OVERVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Your pull requests waiting on you

My PRs shows the human feedback on your authored PRs that still needs a
response. Every row says why: an approval note, a change request, a comment,
or an open thread where another person spoke last. Bot feedback alone does
not add a PR. Drafts stay visible when a person is waiting.

Dismiss a PR until new commits or human feedback arrive. Restore it from the
dismissed list whenever you want. Refresh manually or let the background poll
keep the page current. Failed reads display an error and retain the previous inbox.

## Address comments

Start a thread for one PR or select up to 20 and address them together. The
thread finds the relevant checkout, fixes code, runs checks, pushes changes,
and replies to comments. It addresses bot comments too. Its instructions forbid
merging. The plugin starts no work automatically and only reads GitHub itself.
Started PRs keep their thread links after the feedback clears.

## Requirements

Use the BB server's authenticated GitHub CLI or configure a secret GitHub token.
Choose a BB project whose default environment has the repository checkouts for
Address threads. Optional provider and model settings override that project's
defaults. Agent work uses the configured provider account.

My PRs runs independently of Workstreams. Review Watch is its companion for
PRs where someone else needs your review.
123 changes: 123 additions & 0 deletions plugins/pr-inbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# My PRs

My PRs shows human feedback waiting on your authored pull requests. It is a
standalone sibling of Review Watch, whose Reviews page shows requests for your
review of other people's PRs. My PRs does not require Workstreams.

## Install and configure

Install the plugin from the collection:

```sh
bb plugin install git:https://github.com/bitcomplete/bb-plugins.git@bb/pr-inbox-from-workstreams --plugin pr-inbox --yes
bb plugin config pr-inbox set project <project-id>
bb plugin reload pr-inbox
bb pr-inbox poll --json
```

Open **My PRs** in the sidebar. The first successful refresh shows your open
PRs. By default, the poller uses the BB server's authenticated `gh`. If that
server has no `gh` login, set the secret `githubToken` in the plugin settings.
The token needs read access to the repositories you want to follow.

The page groups PRs alphabetically by GitHub organization, then by area, using the same compact layout as Reviews. Its
branch icon distinguishes My PRs in the sidebar. Groups come from PR title
scopes, falling back to the repository name.

The header and navigation badge show the number of PRs on Your turn. The
navigation badge clears when nothing needs your response. This requires a BB
server with Plugin SDK 0.6.53 or newer; reinstalling only the desktop app does
not update a remote server.

Choose one PR's **Address**, or select several rows and choose **Address N**.
Checkboxes select individual PRs, with one select-all control at the top.
Organization and area headings are labels and counts. Shift-click selects a range. Press **b** to
address the selection or **Esc** to clear it. Address opens a project picker, then starts one thread on the chosen project's
default checkout and machine. Organization mappings preselect the project; the
configured default is a fallback. Override it for an individual PR or batch.
A batch spanning different mapped projects requires a choice. The thread finds checkouts, fixes code,
runs checks, pushes the changes, and replies to review comments. It includes bot comments
in that work. The prompt forbids merging, approving, closing PRs, and automatic
thread resolution. The plugin itself only reads GitHub.

**Hold…** moves a PR to a faded **On hold** section at the bottom for 1 hour,
until tomorrow at 9 AM in your browser’s timezone, or for 1 week. Held PRs stay
out of Your turn counts and batch selection. Holds survive new feedback and
restarts, expire automatically, and can be ended early with **Resume**.

**Dismiss** hides feedback until a new commit or new human feedback changes
that PR. Open the dismissed list and choose **Restore** to bring it back.
Started PRs keep a link to their thread, including after the feedback clears.
When an attempt finishes, **Clear attempt** lets you start another. If a start
fails without returning a thread, check your threads before clearing it.

## Feedback rules

The policy comes from Workstreams' `your-turn.ts`, `feedback-to-address.ts`,
and `pr-gates.ts`. A PR needs your response when it has any of these:

- A human's approval note that you have not answered.
- A human's change request with no later push, reply, or re-request.
- An unresolved thread where another human spoke last.
- A human's comment with no later reply from you.

Drafts count. Bot feedback alone never puts a PR on Your turn. A push answers
a change request, but comments and approval notes require a reply. A bot's
reply does not answer a human's thread. A later standing approval covers that
reviewer's earlier comments.

My PRs keeps no effort assignments, merge gates, or model
enrichment. Workstreams' existing Your turn view continues to work independently.
Workstreams' local **Confirm handled** records do not transfer to My PRs.

GitHub search, reviews, conversation comments, review requests, review threads,
and comments inside threads all paginate. The search limit is 1,000 open authored
PRs. An incomplete or failed read keeps the last successful inbox and displays
an error. Address reads only the selected PRs and checks their current heads and
feedback before dispatch. Each PR’s initial feedback connections share one
request; further pages load only when needed. If GitHub rate limits a request,
the plugin keeps the inbox and pauses API reads until the reported reset time,
including across plugin reloads.

## Settings

| Setting | Default | Effect |
| --- | --- | --- |
| `project` | Unset | Fallback project for Address threads. The picker can override it. |
| `organizationProjects` | `{}` | JSON mapping of GitHub organization names to BB project IDs; names ignore case. |
| `githubToken` | Unset | Secret GitHub token. Empty uses the server's `gh`. |
| `repoAllowlist` | Empty | Comma-separated `owner/repo` names. Empty includes every repository. |
| `pollMinutes` | 5 | Refresh interval, clamped to 1–60 minutes. |
| `provider` | Unset | Optional provider for Address threads. |
| `model` | Unset | Optional model for Address threads. |

Token and repository changes clear the old snapshot. Changes apply to the next
refresh. The project picker works even when no default project is configured.

## CLI

```sh
bb pr-inbox list --json
bb pr-inbox status --json
bb pr-inbox poll --json
bb pr-inbox dismiss <PR-node-id>
bb pr-inbox restore <PR-node-id>
bb pr-inbox address <PR-node-id> [<PR-node-id>...]
bb pr-inbox clear <PR-node-id>
```

Use the `id` field from `list`. Address accepts up to 20 distinct PRs. Dismiss,
restore, and clear each take one id. Clearing a link retains its thread in BB.

## Develop

```sh
npm ci --legacy-peer-deps
npm run typecheck
npm test
npm run build
```

`--legacy-peer-deps` avoids an npm 10 optional-peer resolver error when installing
the frontend test dependencies. Tests cover the feedback rules, pagination,
persistence, stale dispatch, and the page's manual actions using BB's public SDK.
80 changes: 80 additions & 0 deletions plugins/pr-inbox/address-project-dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { useEffect, useState } from "react";
import { useRpc } from "@get-bb/plugin-sdk/app";
import type { rpcContract } from "./server";
import type { Selection } from "./types.js";
import type { z } from "zod";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "./components/ui/dialog";
import { Button } from "./components/ui/button";

type Targets = z.infer<(typeof rpcContract)["address_targets"]["output"]>;
type Load = { kind: "loading" } | { kind: "error"; message: string } | { kind: "ready"; targets: Targets };

export function AddressProjectDialog({ items, onClose, onStart }: {
items: Selection[];
onClose: () => void;
onStart: (projectId: string) => Promise<void>;
}) {
const rpc = useRpc<typeof rpcContract>();
const [load, setLoad] = useState<Load>({ kind: "loading" });
const [projectId, setProjectId] = useState("");
const [starting, setStarting] = useState(false);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
let active = true;
rpc.call("address_targets", { items: items.map(({ id, activity }) => ({ id, activity })) }).then((targets) => {
if (!active) return;
setLoad({ kind: "ready", targets });
setProjectId(targets.projectId ?? "");
}, (cause) => {
if (active) setLoad({ kind: "error", message: cause instanceof Error ? cause.message : String(cause) });
});
return () => { active = false; };
}, [items, rpc]);

const start = async () => {
if (starting || projectId === "" || load.kind !== "ready") return;
setStarting(true);
setError(null);
try { await onStart(projectId); }
catch (cause) { setError(cause instanceof Error ? cause.message : String(cause)); }
finally { setStarting(false); }
};

return (
<Dialog open onOpenChange={(open) => { if (!open && !starting) onClose(); }}>
<DialogContent hideCloseButton={starting} className="sm:max-w-md">
<DialogHeader>
<DialogTitle>{items.length === 1 ? "Address feedback" : `Address ${items.length} pull requests`}</DialogTitle>
<DialogDescription>Choose the project for this feedback thread.</DialogDescription>
</DialogHeader>
{load.kind === "loading" ? <p role="status" className="text-sm text-muted-foreground">Loading projects…</p> : null}
{load.kind === "error" ? <p role="alert" className="text-sm text-destructive">{load.message}</p> : null}
{load.kind === "ready" ? (
<div className="grid gap-2">
<label htmlFor="address-project" className="text-sm font-medium">Project</label>
<select id="address-project" value={projectId} disabled={starting}
onChange={(event) => setProjectId(event.target.value)}
className="h-9 w-full min-w-0 rounded-md border border-input bg-background px-2 text-sm text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring">
<option value="" disabled>Choose a project</option>
{load.targets.projects.map((project) => <option key={project.id} value={project.id}>{project.name}</option>)}
</select>
<p className="text-xs text-muted-foreground">
{load.targets.projects.length === 0 ? "Add a project checkout in BB to address feedback."
: load.targets.reason === "mixed" ? "These PRs map to different projects. Choose one for this batch."
: load.targets.reason === "organization" ? "Preselected from your organization mappings."
: load.targets.reason === "default" ? "Preselected from your default feedback project."
: "This selection has no available default project."}
</p>
</div>
) : null}
{error === null ? null : <p role="alert" className="text-sm text-destructive">{error}</p>}
<DialogFooter>
<Button variant="outline" disabled={starting} onClick={onClose}>Cancel</Button>
<Button disabled={starting || load.kind !== "ready" || projectId === ""} onClick={start}>
{starting ? "Starting…" : "Address feedback"}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
Loading
Loading