Skip to content

Inbox: pull requests and stacks (code review, phase 2) - #2590

Merged
backnotprop merged 16 commits into
mainfrom
feat/inbox-pull-requests
Nov 4, 2026
Merged

backnotprop merged 16 commits into
mainfrom
feat/inbox-pull-requests

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Phase 2 of code review in the Inbox: pull requests and stacks (approval "inbox-code-review-direction", items 4 and 5; concept B take 1). Phase 1 was #2582.

What it does

  • Pull requests row under Board, shown only while Settings → Capabilities → Code review is on (the same switch, nothing new).
  • The list, using the Inbox's own rows and bands, grouped by whose move it is: On you (a teammate asked for your review, or your agent's PR waits on you), Ready to land, and a folded N waiting on others. A stack is one row with a chain of the Board's PR marks in landing order ("3 open, 1 merged · start at Skill description exceeds new 250-character limit in Claude Code 2.1.86 #412").
  • The stack view: layers from main up, Lands next on the lowest open layer, the agent's last words, its thread, Board card and Guided Review when linked, Review layer by layer + Whole stack, and Reply at the foot (into the agent's thread). No merge button.
  • Layer review: phase 1's review frame (GuideReader All files, comments, Viewed, DecisionControl) on one layer's own diff, or on the compare from the stack's base up to that layer. Next layer moves up the stack. With an agent thread, Approve / Send feedback is a reply to the agent. A teammate's PR shows its diff with no verdict, plus Open on GitHub. Nothing is posted to the forge.
  • Detection (read-only, only while the page is open and the switch is on): one GraphQL query for each host that gh or glab is signed in to (always --hostname). It covers review-requested and authored PRs, open plus merged in the last 14 days. It is limited to repositories that are an Inbox project's origin. Results are cached; failures and rate limits back off the same way the hover cards do. Stacks: a PR whose base is another open PR's head (same repository, not a fork). Linking: Board card PR links, PR URLs in agent messages, and the branch checked out in an agent thread's folder.
  • Off: no row; #pulls lands on the Inbox; GET /api/inbox/pulls* return 409 code_review_off before any gh, glab or git runs. Agents get no text from this feature in either state.
  • Phone at 390 px with 44 px targets. No new keyboard shortcuts. Bun-only, like the rest of the Inbox.

Tests

  • packages/core/inbox-pulls.test.ts: stack detection (chains, merged layer underneath, forks and other repos, loops, siblings) and whose move it is / grouping.
  • packages/server/inbox-pulls.test.ts: off makes no gh, glab or git calls (default off, and turned off after a read); signed-in hosts only, with --hostname; project repos only; links by URL and by branch; a layer's diff vs. the whole stack's compare; an unlisted key runs nothing; cache, refresh, rate-limit hold; GitHub and GitLab parsing. Uses a scripted refRunner; the real CLIs never run.
  • packages/inbox/pulls/pullReview.test.tsx (DOM): a layer opens its own diff; Whole stack asks for scope=stack; going back doesn't read again; Next layer opens the next key; Approve replies to the agent's last message; a teammate's PR shows no verdict; list grouping and folding.
  • tests/e2e/inbox-pull-requests.spec.ts: the real binary with sh fakes for gh and glab first on PATH, serving real git diffs of scratch repos with invented names.

The draft agent text (verdict words) is in the report; nothing new reaches an agent's tools or --help.

…e 2)

The Pull requests row under Board while Code review is on: the person's
PRs and the ones they are asked to review, from gh and glab on this
computer, grouped by whose move it is (On you, Ready to land, a folded
N waiting on others). A stack is one row with its chain of PR marks; the
stack view shows the layers from main up with Lands next, the agent, its
thread and card, Review layer by layer and Whole stack (phase 1's review
mode on one layer, or the compare from the stack's base), and Reply into
the agent's thread. No merge button; nothing is posted to the forge.

Off: no row, and GET /api/inbox/pulls* refuse before any gh, glab or git
runs.
…aths, no repeated file card

- The list head's title and count always fit; the project filter gives way
  (unset, its folder mark, "All projects" kept as its name).
- The stack view's chips say what they open (Thread, Board) beside their marks.
- The review rail's file list no longer widens past the rail, so paths are cut
  at their start as phase 1 intends (fixes phase 1's rail too).
- A PR layer's review hides the reader's "Every changed file" card that
  repeated the rail; the diffs take the width (data attributes on the guide
  viewer's section card, styled only in the PR review).
- A/B: a verdict only on the person's own PR, into that layer's own thread first
  (the stack's, among their own layers, as a fallback); a teammate's layer reads
  without a verdict even in a stack with theirs.
- C: a fork layer's whole stack uses owner:branch on GitHub; GitLab refuses it
  with a note (409 pull_diff_fork).
- D: a PR URL links only from a project on the PR's own repository.
- E: branch links only for PRs from the repository itself, never a resting branch.
- Searches scoped with repo: qualifiers and sorted newest first; a merged
  long-lived or shared branch is never a stack's bottom; Whole stack runs from
  the lowest open layer's base; every clone of an origin links; a fresh review
  per layer and scope, comments kept per push; Reply keys through the registry;
  diffs streamed under the 8 MB cap; guest vs owner tests.
Owner direction on #2590.
- A PR with no agent shows "No agent yet": Hand to an agent (one of the
  project's live sessions; the hand-off starts a new thread to it) and Launch
  an agent (compose's New thread with the same words, through compose's own
  launch; shown only while the Inbox can launch). The choice is kept in
  inbox/pull-links.json (POST /api/inbox/pulls/owner); verdicts and Reply go
  to that thread.
- Automatic linking is only the PR's URL in an agent's own thread in a project
  of the PR's repository. No branch matching, no Board-card linking.
- The Board is optional: a card that links a PR is a quiet chip while the
  Board is on; otherwise no Board UI. Pull requests works with the Board off.
- A teammate's PR can be handed over for discussion; it still takes no verdict.
- The hand-off words (pullHandoffMessage) are DRAFT agent text.
…r pull requests

- Hand to an agent / Launch an agent: Guided review (default) or Custom curation,
  carried as /review-curate with phase 1's approved instructions; the PR shows
  "guided review on the way", then Start review when the agent's review arrives
- P2-F: titles one line, cut, in a code span; unsafe branches, links and logins left out
- P3-G: Launch's compose offers only the PR's project, refuses another at Send; drafts keep the PRs
- P3-H: Hand to another agent once a PR has an owner
- P3-I: check first (validate_only), then send, then keep the owner; re-read the list on a restart
- P3-J: the 20-layer limit is checked before anything is sent
- Trim the narrative copy in Pull requests; tests for the owner over the tailnet and per-layer notes
… authors' line behind one constant

- The owner route keeps a hand-off whose PRs are all teammates' as theirs (from the
  Inbox's own pull list); such a thread reads pull_theirs, and its review has no
  Approve / Request changes and its card does not wait on a verdict
- PULL_HANDOFF_AUTHORS_LINE (null, out) puts the held safety line in every hand-off
  variant in one change once approved
… + New agent

- No menu and no grey box: "Ask for" [Guided review | Custom curation] and "Hand to"
  [live agents as pills] [+ New agent] above Review; "No agent yet" in the meta line
- Owned: one status line ("· guided review on the way", or the last words), with a quiet
  "Hand to another agent" that opens the lines again as "Hand again for", leaving out the
  session the hand-off went to (handed_to) and the agent that answered; Escape folds them
- Phone: labels over their lines, pills wrap, 44 px targets
The owner's answer C on #2590: when the person finishes a pull request's
review in the Inbox (the layer review, or Start review for a thread handed
one PR), the ending offers two places: Post to the PR on GitHub/GitLab, or
Send to the agent (today's verdict reply). The choice shows only when both
can happen; a PR with no agent, or a teammate's PR, posts only, and a
teammate's agent path stays verdict-free.

Posting reuses the review app's PR mode whole: its platform decision arm,
ReviewSubmissionDialog, buildReviewSubmission, submitPlatformReviewTargets
and the server providers (submitPRReview), through a #platform-post seam
checked by tsconfig.guide.json. The new POST /api/inbox/pulls/review is the
Inbox's only gh/glab write: owner only (local or isOwnerRequest over the
tailnet), same origin, behind the Code review switch, pinned to the head
commit the list read (headRefOid / diffHeadSha). No new agent text, no new
shortcuts. Look DRAFT for the owner's approval.
After a post the decision reads done ("Approved on GitHub") and is
disabled until the PR's head moves or a new comment is written. The
server refuses an identical second post (same PR, head, action and body
while the Inbox runs) with 409 already_posted, running nothing.
- The duplicate-post fingerprint now holds the line and file-level
  comments: a second review at the same head with the same main comment
  ("See inline comments.") but other comments posts.
- A layer's patch answers the head commit it was read at (read from the
  forge before and after the patch; null when a push landed between), and
  the layer review posts at that commit, not the list's older head. The
  route accepts the list's head or the last patch head read for the PR.
- + New agent with Custom curation is recorded as custom: the guided line
  must be a line of its own (pullLaunchAsk), not a substring.
- Start review on pull_moved reads the PR again from the forge, says so
  in place, and posts at the new head. After a post, Comment... offers a
  follow-up with a main comment only; posted comments never go twice.
- A test for the pull_closed gate.
PostEnding filtered posted comments only at the head they went at, and
Start review keeps its comments after a post: after pull_moved and a read
at the new head, an old comment was posted again in the body. The posted
ids now hold for the PR key, whatever the head. Tests: the ReviewPane
case (fails without the fix), and the server refusing a post at either
head when the reads around a patch differ.
The posted-comment filter matched on id only, so a correction to a posted
comment (same id) was never sent. Posted comments are now recorded by id
with their text and lines (postedSignature); an edited one is offered and
sent. DOM test: post, edit, the follow-up sends the edited text (fails on
id-only matching).
…en the diff in every state

The purple button reads just Review and always starts the agent hand-off
with the chosen ask and the picked agent pill; it never opens the diff.
Pills now pick (the last agent handed to is picked first) instead of
handing over on click; with no live agent, Review launches a new one.
Open the diff sits beside it in every state (before, on the way, beside
Start review, posted) and goes straight into the review mode, layer by
layer for a stack; each ladder row opens its diff with an Open diff hint.
Row hover applies only under a real pointer.
…ility

- Re-read compose's live sessions on window focus and after a
  session_not_live answer; drop the dead pick, so Review falls back to
  another live agent or launches a new one.
- Key the stack view by stack, so a PR's pick, ask and words never carry
  to another; one idempotency key per agent, a new pick gets a new key.
- The agent pills are a native radio group; Review is described by the
  picked agent; rows read "Open diff ..."; focus moves to the status
  line after a hand-off.
- Stale comments in PullsPage.tsx and model.ts.
@backnotprop
backnotprop marked this pull request as ready for review November 4, 2026 12:16
@backnotprop backnotprop added the ci:full Run the heavy CI tier on this PR (added by the merge script) label Nov 4, 2026
# Conflicts:
#	docs/agent-guides/environment.md
#	packages/inbox/App.tsx
#	packages/inbox/components/Sidebar.tsx
#	packages/inbox/inbox.css
#	packages/inbox/package.json
#	packages/inbox/tsconfig.json
#	tests/dom-test-list.txt
… its one dynamic import

PlatformPost.tsx (the review app's Post to GitHub/GitLab dialog) reaches the
Inbox window only through PostEnding.tsx's lazy(() => import('#platform-post')),
as ShapeBoard.tsx does through #shape-board. Allow it beside the other lazy
readers, and pin that dynamic import and that nothing imports it statically.
@backnotprop
backnotprop merged commit 730fa68 into main Nov 4, 2026
68 checks passed
Flamintus pushed a commit to Flamintus/plannotator that referenced this pull request Nov 5, 2026
…op#2590)

The 27 findings of the worst-case stress test, with the owner's choices:
a long title is cut in the review header, each agent on a stack gets
verdicts only for its own layers, a capped read says "Showing 100 of 133",
a long chain draws the first 2, +N, the last 2, a forked stack reads
"Also on #N", an ended agent stays named and offers a new hand-off.

A host that times out or is rate limited says so instead of "Nothing
open"; stacks join through merged middle layers and pick the PR into a
long-lived branch when two share a head; non-ASCII branches compare
(percent-encoded); conflicts put a PR on the person; the sidebar count
reads at start and on focus. Regression tests in core, server, the
model and the DOM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Run the heavy CI tier on this PR (added by the merge script)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants