Commit bb404f8
authored
feat: stacked PR review — PR switching, scope toggling, multi-PR posting (#620)
* feat(shared): add isSameProject, PR stack types, and PR list provider
Extends PRRef/PRMetadata with defaultBranch, PRStackInfo, PRStackTree,
PRStackNode, PRDiffScope, and PRListItem types. Adds isSameProject()
for owner/repo validation on PR switching. Adds fetchPRStack() and
fetchPRList() dispatch functions (GitHub-only for now, GitLab stubs).
Includes 9 new tests for isSameProject covering GitHub, GitLab, and
cross-platform scenarios.
For provenance purposes, this commit was AI assisted.
* feat(shared): add GitHub PR stack tree walking and PR list fetching
Implements fetchGhPRStack() which walks up/down the PR stack via
GraphQL, resolving numbers and titles for each node in the chain.
Collapses queryPRsByHead/queryPRsByBase into a single queryPRsByRef
helper. Adds fetchGhPRList() using gh pr list. Fixes GHE support
by removing hostnameArgs from fetchGhPRList (--repo already handles
GHE). Filters jq "null" string from defaultBranch detection.
For provenance purposes, this commit was AI assisted.
* feat(shared): fetch defaultBranch for GitLab MRs
Queries the project's default_branch via glab API so getPRStackInfo
can detect stacked MRs on GitLab. Best-effort — caught errors fall
back to undefined.
For provenance purposes, this commit was AI assisted.
* feat(shared): add PR stack detection and full-stack diff module
New pr-stack module with:
- getPRStackInfo(): detects stacked PRs from baseBranch vs defaultBranch
- getPRDiffScopeOptions(): generates layer/full-stack scope options
- runPRFullStackDiff(): computes diff from default branch to HEAD
- resolvePRFullStackBaseRef(): resolves origin/main or local main
- checkoutPRHead(): fetches and checks out a PR head in a worktree
- buildMinimalStackTree(): builds UI tree from stack info
Includes 13 tests covering ref resolution, branch fallbacks, and
GitLab ref formats.
For provenance purposes, this commit was AI assisted.
* feat(shared): add worktree pool for per-PR agent isolation
Creates a session-scoped pool of git worktrees — each PR visited
during a stacked review gets its own isolated checkout. Agents run
in their PR's worktree undisturbed by PR switches. Handles
deduplication of concurrent ensure() calls for the same PR.
Includes 11 tests covering caching, cross-repo restrictions, GitLab
ref formats, and cleanup.
For provenance purposes, this commit was AI assisted.
* feat(shared): add diffScope/prUrl to agent jobs, branch diff type
Adds prUrl and diffScope optional fields to AgentJobInfo so agent
findings carry the PR and scope context they were launched under.
Exports new pr-stack and worktree-pool modules from package.json.
Adds 'branch' to DefaultDiffType union for branch diff as default.
For provenance purposes, this commit was AI assisted.
* feat(ui): add PR annotation fields, Popover, and SearchableSelect
Extends CodeAnnotation with prUrl, prNumber, prTitle, prRepo, and
diffScope fields for stacked PR attribution. Adds shared Popover
wrapper around radix-ui. Adds SearchableSelect for filterable
dropdown lists (used by PR selector).
For provenance purposes, this commit was AI assisted.
* feat(ui): add branch diff as default option, new Git settings tab
Adds 'Branch' as a fourth default diff type option in both the
first-run dialog and settings panel. Moves the default diff type
setting from the Display tab to a new Git tab in review mode.
Updates config store validators to accept 'branch'.
For provenance purposes, this commit was AI assisted.
* feat(server): add prUrl/diffScope plumbing to agent jobs and prompts
Threads prUrl and diffScope through the agent job lifecycle so
findings carry the PR and scope they were generated under. Adds
full-stack prompt branch to codex-review and tour-review — when
in full-stack mode, the diff is inlined in the prompt instead of
telling the agent to run git diff. Re-exports isSameProject and
new PR provider functions from server/pr.ts.
For provenance purposes, this commit was AI assisted.
* feat(server): add stacked PR support to Bun review server
Adds PR switching, layer/full-stack scope toggling, PR list caching,
worktree pool integration, and multi-PR platform posting to the Bun
review server. Key additions:
- /api/pr-diff-scope: switch between layer and full-stack diffs
- /api/pr-list: cached PR list for the current repo
- /api/pr-switch: in-place navigation between PRs in a stack
- /api/pr-action: targetPrUrl support for multi-PR posting
- /api/file-content: full-stack branch for hunk expansion
- prSwitchCache/prStackTreeCache for session-scoped caching
- diffScope tagging on agent job completion
- Scope guard: returns 400 on full-stack diff failure instead of
overwriting the working diff with empty content
For provenance purposes, this commit was AI assisted.
* feat(ai): pass cwd to Claude agent SDK for worktree support
Forwards the working directory to the Claude agent provider so
agents run in the correct worktree when reviewing stacked PRs.
For provenance purposes, this commit was AI assisted.
* feat(pi): add stacked PR support to Pi server (Bun parity)
Mirrors all stacked PR features from the Bun server:
- PR switching, scope toggling, PR list, multi-PR posting
- prSwitchCache/prStackTreeCache with initial PR seeding
- diffScope/prUrl plumbing in agent jobs
- Worktree pool creation and lifecycle
- Full-stack file-content resolution matching Bun's guard structure
- targetPrUrl support on /api/pr-action
Hoists worktreePool declaration to outer scope in plannotator-browser
to fix TS18004 scoping error. Updates vendor.sh for new shared modules.
For provenance purposes, this commit was AI assisted.
* feat(hook): create worktree pool for PR review sessions
Creates a worktree pool when opening a PR review with --local,
seeding it with the initial PR's checkout. Integrates pool cleanup
into server shutdown. Passes the pool to startReviewServer for
agent isolation during PR switching.
For provenance purposes, this commit was AI assisted.
* feat(review-editor): add hooks for PR stack, context, and annotations
- useAnnotationFactory: stamps prUrl/prNumber/prTitle/prRepo/diffScope
onto annotations, only when viewing a stacked PR
- usePRStack: handles scope selection and PR switching with loading state
- usePRContext: adds URL-change detection to prevent stale-fetch race
when switching PRs (discards in-flight responses for previous PR)
For provenance purposes, this commit was AI assisted.
* feat(review-editor): add stacked PR UI components
- PRSelector: searchable dropdown for switching between PRs in a repo
- PRSwitchOverlay: loading animation during PR switch
- StackedPRLabel: stack tree popover with scope selector and PR navigation
- ReviewSubmissionDialog: multi-PR submission dialog with per-target
status, orphaned findings section with copy-as-markdown, and
partial failure retry
For provenance purposes, this commit was AI assisted.
* feat(review-editor): multi-PR export with heading hierarchy
Updates exportReviewFeedback for multi-PR sessions:
- Groups annotations by prUrl, then by file within each PR
- Uses proper heading hierarchy (## for files, ### for annotations
in multi-PR mode)
- Detects single-PR mismatch (annotations from a different PR than
the current view) and uses annotation-level PR context
- Adds diffScope labels per PR group when present
Includes 5 new tests: multi-PR headings, single-PR mismatch,
diffScope labels, and non-stacked annotation handling.
For provenance purposes, this commit was AI assisted.
* feat(review-editor): integrate stacked PR into sidebar, diff panel, and agents
- ReviewSidebar: groups annotations by PR in multi-PR sessions,
shows PR headers with annotation counts
- ReviewDiffPanel: filters annotations by prUrl and diffScope so
only matching annotations appear in the diff gutter
- ReviewStateContext: adds prDiffScope to shared review state
- ReviewAgentJobDetailPanel: shows diffScope in job detail
- PRSummaryTab: shows stack info in PR summary
- index.css: PR switch shimmer and overlay animations
For provenance purposes, this commit was AI assisted.
* feat(review-editor): wire stacked PR into main review app
Integrates all stacked PR features into the review editor:
- PR stack state management (prStackInfo, prStackTree, prDiffScope)
- applyPRResponse: shared handler for PR switch and scope toggle,
preserves active file index on scope changes
- Multi-PR platform posting via Promise.allSettled with parallel
requests, partial failure retry, and per-target status tracking
- ReviewSubmissionDialog replaces inline dialog JSX
- useAnnotationFactory stamps PR context onto annotations
- keepalive on /api/feedback to survive tab closure
- Proper try/catch/finally on handlePlatformAction
For provenance purposes, this commit was AI assisted.
* docs: add stacked PR review documentation
Updates AGENTS.md, code-review command docs, and AI code review
guide with stacked PR review capabilities.
For provenance purposes, this commit was AI assisted.
* fix(server): stamp prNumber/prTitle/prRepo on agent findings
Agent annotations only had prUrl and diffScope, missing prNumber,
prTitle, and prRepo. When agent findings were the only annotations
for a PR target in the submission dialog, the target rendered as
#0 with no title. Now resolves full PR context from prSwitchCache
at job completion and stamps all five fields. Both Bun and Pi.
For provenance purposes, this commit was AI assisted.
* feat(ui): rename diff options — "Committed" replaces "Branch" / "Current PR Diff"
Consolidates two confusing committed-diff options into one:
- Settings/first-run: "Committed" — "Everything you've committed on this branch"
- Mid-session switcher: "Committed changes" (replaces both "vs main" and "Current PR Diff")
Uses merge-base under the hood (matches GitHub PR behavior). Removes
the two-dot branch diff from the UI — it stays in the runtime DiffType
union for backwards compat. Old "branch" values in config/cookies are
silently upgraded to merge-base.
Git settings tab now uses radio cards with descriptions instead of
a cramped segmented control. First-run dialog descriptions rewritten
in plain language — no git commands.
For provenance purposes, this commit was AI assisted.
* fix(review-editor): rename client-side "PR Diff" labels to "Committed changes"
DiffTypePicker.tsx had a hardcoded "PR Diff" override for merge-base
when the base picker is present. exportFeedback.ts also used "PR Diff"
in export labels. Both now say "Committed changes" to match the
server-side label and settings UI.
For provenance purposes, this commit was AI assisted.
* fix(server): discover stack UI for root PRs targeting the default branch
Root PRs (baseBranch === defaultBranch) were excluded from stack
detection because getPRStackInfo returned null. Now the server
always fetches the stack tree in PR mode. If the tree reveals
descendant PRs, prStackInfo is retroactively set with source
"tree-discovered", enabling the stack UI, scope selector, and
PR navigation from the root of a stack.
Both Bun and Pi servers updated. Adds "tree-discovered" to the
PRStackInfo source union.
For provenance purposes, this commit was AI assisted.
* fix(review-editor): derive diff scope from annotations, not UI state
The export function now reads diffScope from annotations instead of
the prReviewScope parameter. Fixes two issues:
1. Agent job "Copy All" showed the wrong scope when the user switched
between layer/full-stack after launching the agent
2. Mixed-scope annotations produced a confusing "layer, full-stack"
comma-joined label instead of grouping by scope
Extracts renderScopedGroups helper for scope-aware grouping — used
by both single-PR and multi-PR export paths. When annotations share
one scope, it appears in the header. When mixed, annotations are
grouped under ## Layer / ## Full-stack headings.
Includes 4 new tests: uniform scope derivation, mixed scope grouping,
single scope header, and prReviewScope override prevention.
For provenance purposes, this commit was AI assisted.
* fix(server): add tree-discovered stack fallback to pr-switch handler
The initial-load path upgrades prStackInfo for root PRs when the
stack tree reveals descendants, but the pr-switch handler was missing
this logic. The server now sends correct prStackInfo after switching
to a root-of-stack PR. Both Bun and Pi.
Also removes stale prReviewScope dependency from agent job panel's
copyAllText useMemo.
For provenance purposes, this commit was AI assisted.
* fix: extract resolveStackInfo helper, fix stack UI on non-stacked PRs
Extracts the tree-discovered stack fallback into resolveStackInfo()
in pr-stack.ts — eliminates 4 copies of the same logic across Bun
startup, Bun pr-switch, Pi startup, and Pi pr-switch.
Fixes StackedPRLabel showing on every PR: the check now counts
non-default-branch nodes (> 1) instead of all nodes (> 1). Without
this, every PR showed a "Stack (1 PR)" popover because the tree
always has at least [defaultBranch, currentPR].
For provenance purposes, this commit was AI assisted.
* fix(review-editor): don't re-open already-succeeded PR tabs on retry
On partial failure retry, openUrls was pre-seeded with URLs from
previously succeeded targets, causing those PR pages to re-open
in the browser alongside newly succeeded ones. Now starts empty —
only URLs from the current attempt are opened.
For provenance purposes, this commit was AI assisted.
* refactor(review-editor): extract PR session state into usePRSession hook
Consolidates 5 independent useState calls (prMetadata, prStackInfo,
prStackTree, prDiffScope, prDiffScopeOptions) into a single
usePRSession hook with atomic updatePRSession callback.
Replaces two identical 5-line setter blocks (initial load and
applyPRResponse) with single updatePRSession calls. All ~60 consumer
sites unchanged — same variable names via destructuring.
For provenance purposes, this commit was AI assisted.1 parent 9a32022 commit bb404f8
52 files changed
Lines changed: 3641 additions & 449 deletions
File tree
- apps
- hook/server
- marketing/src/content/docs
- commands
- guides
- pi-extension
- server
- packages
- ai/providers
- review-editor
- components
- dock
- panels
- hooks
- utils
- server
- tour
- ui
- components
- config
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
253 | 256 | | |
254 | 257 | | |
255 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
293 | 294 | | |
294 | 295 | | |
295 | 296 | | |
| 297 | + | |
296 | 298 | | |
297 | 299 | | |
298 | 300 | | |
| |||
337 | 339 | | |
338 | 340 | | |
339 | 341 | | |
| 342 | + | |
340 | 343 | | |
341 | 344 | | |
342 | 345 | | |
| |||
345 | 348 | | |
346 | 349 | | |
347 | 350 | | |
348 | | - | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
349 | 354 | | |
350 | 355 | | |
351 | 356 | | |
| |||
393 | 398 | | |
394 | 399 | | |
395 | 400 | | |
396 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
397 | 405 | | |
398 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
399 | 413 | | |
400 | 414 | | |
401 | 415 | | |
| |||
443 | 457 | | |
444 | 458 | | |
445 | 459 | | |
446 | | - | |
| 460 | + | |
447 | 461 | | |
448 | | - | |
| 462 | + | |
449 | 463 | | |
450 | 464 | | |
451 | 465 | | |
452 | 466 | | |
453 | 467 | | |
454 | 468 | | |
455 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
456 | 476 | | |
457 | 477 | | |
458 | 478 | | |
459 | 479 | | |
460 | | - | |
461 | | - | |
| 480 | + | |
462 | 481 | | |
| 482 | + | |
463 | 483 | | |
464 | 484 | | |
465 | 485 | | |
| |||
485 | 505 | | |
486 | 506 | | |
487 | 507 | | |
| 508 | + | |
488 | 509 | | |
489 | 510 | | |
490 | 511 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 | | |
64 | 74 | | |
65 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| 187 | + | |
186 | 188 | | |
187 | 189 | | |
188 | 190 | | |
| |||
218 | 220 | | |
219 | 221 | | |
220 | 222 | | |
| 223 | + | |
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
226 | 229 | | |
227 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
228 | 233 | | |
229 | 234 | | |
230 | 235 | | |
| |||
266 | 271 | | |
267 | 272 | | |
268 | 273 | | |
269 | | - | |
270 | 274 | | |
271 | 275 | | |
272 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
273 | 282 | | |
274 | | - | |
| 283 | + | |
275 | 284 | | |
276 | | - | |
| 285 | + | |
| 286 | + | |
277 | 287 | | |
278 | 288 | | |
279 | 289 | | |
| |||
312 | 322 | | |
313 | 323 | | |
314 | 324 | | |
315 | | - | |
316 | 325 | | |
317 | | - | |
| 326 | + | |
318 | 327 | | |
319 | 328 | | |
320 | 329 | | |
321 | | - | |
| 330 | + | |
322 | 331 | | |
323 | 332 | | |
324 | 333 | | |
325 | 334 | | |
326 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
327 | 340 | | |
328 | 341 | | |
329 | 342 | | |
330 | 343 | | |
331 | 344 | | |
332 | | - | |
| 345 | + | |
333 | 346 | | |
| 347 | + | |
334 | 348 | | |
335 | 349 | | |
336 | 350 | | |
| |||
359 | 373 | | |
360 | 374 | | |
361 | 375 | | |
| 376 | + | |
362 | 377 | | |
363 | 378 | | |
364 | 379 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
| |||
120 | 124 | | |
121 | 125 | | |
122 | 126 | | |
123 | | - | |
| 127 | + | |
124 | 128 | | |
125 | 129 | | |
126 | 130 | | |
| |||
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
| 146 | + | |
| 147 | + | |
142 | 148 | | |
143 | 149 | | |
144 | 150 | | |
| |||
422 | 428 | | |
423 | 429 | | |
424 | 430 | | |
| 431 | + | |
| 432 | + | |
425 | 433 | | |
426 | 434 | | |
427 | 435 | | |
| |||
445 | 453 | | |
446 | 454 | | |
447 | 455 | | |
| 456 | + | |
| 457 | + | |
448 | 458 | | |
449 | 459 | | |
450 | 460 | | |
| |||
464 | 474 | | |
465 | 475 | | |
466 | 476 | | |
| 477 | + | |
| 478 | + | |
467 | 479 | | |
468 | 480 | | |
469 | 481 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| |||
104 | 109 | | |
105 | 110 | | |
106 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
0 commit comments