Skip to content

Commit 3f7c65c

Browse files
committed
docs(diff-ux): PR checkout model (lazy worktree ladder) and orchestrator integration
Answers the two open questions on the PR flow: Checkout: a PR review never switches the user's working tree. Tier 0 (default) reviews entirely from fetched git objects — reading, marks, comments, and submit need no checkout; Enter opens read-only file-at-PR-head buffers. Tier 1 materializes a linked review worktree on demand (scope-bar button, or offered at depth boundaries like LSP, edit, run-tests) using the orchestrator's worktree machinery; the workspace-trust prompt fires at materialization — when code could first run, not when reading. Review state is keyed to PR identity (repo + number + head-sha versions), never worktree paths, so materialization and force-pushes carry marks forward. Orchestrator: one worktree engine, one dock. A materialized PR review is a workspace with a dock card (progress + checks) and normal lifecycle; the PR picker and scope bar reuse the orchestrator's PR metadata plumbing; an agent session with an attached PR is the same review seen from two bases (merge-base vs session-start) via the scope-bar flip; the reverse door (hand must-fix comments to an agent in the same worktree) stays Part II. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01756Rh35n65zC4xHQcQAqBL
1 parent 5ef120c commit 3f7c65c

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

docs/internal/unified-diff-experience-design.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,52 @@ command log like any other mutation. (Deeper bidirectional sync — replying
449449
to threads, resolving conversations, live thread updates, viewed-state
450450
sync — remains Part II, §4.4; the flow above is complete without it.)
451451

452+
**Underneath: the checkout question.** A PR review must never switch the
453+
user's working tree (the `gh pr checkout` model destroys whatever you were
454+
doing), but pure no-checkout review hits a wall the moment you want depth —
455+
`Enter` on a line, LSP navigation, running the tests. The design is a lazy
456+
ladder:
457+
458+
- **Tier 0 — objects only (instant, the default).** Selecting a PR runs
459+
`git fetch origin pull/N/head:refs/fresh/pr/N` and renders the whole
460+
review from git blobs. Reading, folds, viewed marks, comments,
461+
commit lens, and `C` submit all work; `Enter` opens *read-only
462+
file-at-PR-head* buffers. Zero disk cost, zero disturbance, and no
463+
foreign code is executed — most PR reviews never need more than this.
464+
- **Tier 1 — materialize a review worktree (one click, on demand).** The
465+
scope bar carries `[⌗ Materialize]`, and any depth boundary offers it in
466+
place (first LSP request, first edit attempt, "run tests"): Fresh creates
467+
a linked worktree at the PR head **through the same worktree machinery
468+
the orchestrator uses**, and the review re-targets it. Now `Enter` opens
469+
real editable files, LSP/diagnostics/terminal work, and the buffer lens
470+
shows the PR diff in-buffer. This is the moment the existing
471+
workspace-trust prompt fires — trust is asked when code could first
472+
*run*, not when you merely read the diff.
473+
- **Never — checkout in the user's main worktree.** Not offered.
474+
475+
Review state (marks, folds, drafts) is keyed to the PR's identity — repo +
476+
number + head-sha version history — never to a worktree path, so
477+
materializing, discarding the worktree, or a force-push (new `` version)
478+
carries the review forward intact.
479+
480+
**Orchestrator integration: one worktree engine, one dock.** A
481+
materialized PR review *is* a workspace — same primitive as an agent
482+
session, same dock, same lifecycle (reclaimed on conclude/close if
483+
untouched, archivable otherwise):
484+
485+
- The dock shows a review card — `⇵ PR #482 · 4/9 viewed · ✓ checks`
486+
and clicking it reopens the review exactly where it stood. The PR
487+
picker's rows and the scope bar's checks-chip reuse the orchestrator's
488+
existing PR metadata plumbing (checks, review decision, comment counts).
489+
- **An agent session with an attached PR is the same review seen from two
490+
bases.** The session card's PR badge opens the PR scope; the scope bar
491+
then offers the flip between `merge-base(PR base) ⟶ head` (what the
492+
reviewer sees) and `session start ⟶ head` (what the agent did this run) —
493+
one control, no separate feature.
494+
- The reverse door is Part II: from a PR review with open must-fix
495+
comments, "open an agent session in this worktree" hands the comment set
496+
to an agent working on the same checkout.
497+
452498
History is not a separate surface: **history = the commits lens over a wide
453499
scope** (the `⌂ history` preset). The commit strip fills the rail, the shared
454500
renderer previews the selection (debounced, in-flight `git show` cancelled),

0 commit comments

Comments
 (0)