feat(pr-review): native PR review — diffs, comments, checks, approve & merge in-app#3174
feat(pr-review): native PR review — diffs, comments, checks, approve & merge in-app#3174mariusandra wants to merge 9 commits into
Conversation
Add a native pull request review surface to PostHog Code: - Inbox PR detail now lists all changed files under the summary as collapsible diffs with GitHub-style "Viewed" tracking, plus approve and merge buttons. - The sidebar PR badge opens a new native /code/pr view (description, files changed, approve/merge) instead of the browser. - Viewed state persists per PR and is fingerprinted against the patch, so files touched by new commits drop back to unviewed. - New GitService methods getPrInfoByUrl, approvePr and mergePr (gh CLI), exposed through workspace-server and host-router tRPC. Generated-By: PostHog Code Task-Id: 62132ab5-28e5-428b-922e-0773b75024a5
Show the PR's CI status between the files-changed list and the approve/merge buttons, on both the inbox PR detail and the native /code/pr view: - Checks sorted failed → running → succeeded (cancelled with failed, skipped last), with colored status icons; clicking a check opens it in GitHub. - Collapsible section whose header always shows a per-bucket summary; starts collapsed when all checks are green, expanded otherwise. - Polls every 15s while the view is mounted and the window is visible. - New GitService.getPrChecks backed by `gh pr checks --json`, exposed through workspace-server and host-router tRPC. Generated-By: PostHog Code Task-Id: 62132ab5-28e5-428b-922e-0773b75024a5
Show GitHub comments above the checks section on both the inbox PR detail and the native /code/pr view: - Merges PR conversation comments with inline review comments into one chronological list (avatar, author, relative time, file path chip and Resolved badge for review comments, markdown-rendered body, and an open-in-GitHub link per comment). - Collapsed by default; the header always shows the comment count. - New GitService.getPrComments (issue comments via gh api); inline review comments reuse the existing getPrReviewComments endpoint. - Extracts the shared PrSectionHeader used by both the comments and checks sections. Generated-By: PostHog Code Task-Id: 62132ab5-28e5-428b-922e-0773b75024a5
- Draft PRs get a "Ready for review" button next to the can't-merge note, backed by the existing updatePrByUrl "ready" action. - The checks header counts are now filter checkboxes (failed / cancelled / running / successful / skipped); only failed and running are shown by default, replacing the whole-section collapse. - Files changed start fully collapsed with an Expand all / Collapse all button in the section header. - The "Viewed" checkbox moves from the file header row to a footer row under the expanded diff; marking viewed still folds the file. The now-unused headerTrailing plumbing is reverted from the shared diff components. Generated-By: PostHog Code Task-Id: 62132ab5-28e5-428b-922e-0773b75024a5
- Marking a file viewed collapses a diff that can be thousands of pixels tall, leaving the viewport staring at blank space below. Scroll the folded file container back into view after the collapse commits (scrollIntoView block:nearest on the next frame). - The comments section silently hid itself when the conversation- comments fetch failed but review threads were empty, which read as "no comments". Any source failure with nothing to show now renders the couldn't-load message instead. Generated-By: PostHog Code Task-Id: 62132ab5-28e5-428b-922e-0773b75024a5
Gate the merge button and its method dropdown like github.com: when any
CI check is failing, or the PR has merge conflicts (mergeable === false),
both are disabled and a red note explains why ("N checks are failing —
merging is blocked until they pass." / conflicts message). The gate
reuses the checks section's polling query, so it locks the moment a
check goes red and unlocks when a rerun goes green.
Generated-By: PostHog Code
Task-Id: 62132ab5-28e5-428b-922e-0773b75024a5
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found 5 issues in 4 files · 5 warnings. 5 warnings
Reviewed by React Doctor for commit |
|
Review feedback (greptile / React Doctor): - Block the merge buttons when CI status is unknown (checks fetch failed or still loading), not just when checks are red — a transient gh error no longer silently unlocks the merge. - Zod-parse the getPrInfoByUrl response instead of casting, and validate each comment line against the schema. - Lazy-init the file-container ref map. Comment loading fixes: - execGh now defaults maxBuffer to 32 MiB; Node's 1 MiB execFile default killed paginated gh api calls (comments, PR files) on busy PRs with "maxBuffer length exceeded". - getPrComments slims each comment to the schema fields inside gh's --jq (NDJSON per line; --slurp can't combine with --jq), shrinking the payload ~10x, and now also merges in PR review summaries — GitHub's conversation tab is both feeds. - Failures now throw with the real gh error instead of returning null, and the comments section surfaces that message under the couldn't-load line for diagnosability. Viewed UX: - Collapsed files get a "Viewed" checkbox in the header row (via the headerTrailing slot; NestedButton since the header is a <button>). - Expanded files get a "Collapse" link left of the footer checkbox; both it and mark-as-viewed share the scroll-back-into-view handling. Generated-By: PostHog Code Task-Id: 62132ab5-28e5-428b-922e-0773b75024a5
… gate - Closed (not merged) PRs get a "Reopen" button in the status banner, via the existing updatePrByUrl "reopen" action. - The five native-PR-review schema groups (PR info, checks, comments, approve, merge) now live once in @posthog/shared's git-domain and are re-exported by core's router-schemas and workspace-server's git schemas — addresses greptile's duplication finding; ~180 mirrored lines removed with all import paths unchanged. - getPrInfoByUrl carries GitHub's mergeable_state as mergeStateStatus. "blocked" (branch protection — e.g. a required approving review the PR author can't self-provide) and "behind" now disable the merge buttons with an explanation, matching github.com. Repos without protection rules report clean/unstable and are unaffected. Generated-By: PostHog Code Task-Id: 62132ab5-28e5-428b-922e-0773b75024a5
The activity log's "Commit pushed" entries carry a View/Hide diff toggle. On the inbox PR detail the main column already lists every changed file, so the per-commit diff is redundant there — thread a hideCommitDiffs flag from PullRequestDetail through ReportActivitySection and ArtefactLogList to ArtefactCommit, set under the same condition that renders the files-changed section. Other report detail surfaces keep the toggle. Generated-By: PostHog Code Task-Id: 62132ab5-28e5-428b-922e-0773b75024a5
There was a problem hiding this comment.
This PR exceeds the automated review size limits and introduces substantial new functionality (native PR review with diffs, comments, checks, approve & merge). The only reviews are from a bot on an older commit. Request a human team member review before re-requesting auto-approval.
What this does
Adds a native pull request review surface to PostHog Code, so a PR can be reviewed, approved, and merged without leaving the app.
Surfaces
/code/inbox/pulls/$reportId): below the Responder summary, the PR's changed files, comments, CI checks, and approve/merge actions now render inline./code/pr?prUrl=…): clicking the#123PR badge in the sidebar task list opens an in-app view (state badge, title, author, branches, ± stats, markdown description, then the same files/comments/checks/actions stack) instead of the browser. "Open in GitHub" remains as an escape hatch.Files changed
PatchedFileDiff/@pierre/diffsmachinery, respecting the user's diff settings), all collapsed by default with an Expand all / Collapse all button.N / M viewed.Comments
Checks
gh pr checks --json, sorted failed → cancelled → running → succeeded → skipped with colored status icons; rows open the check run in GitHub.Approve & merge
gh pr review --approve) and a merge button with method dropdown (merge / squash / rebase, viagh pr merge).Backend
New
GitServicemethods on the existingghCLI layer, each exposed through workspace-server and host-router tRPC with mirrored Zod schemas:getPrInfoByUrl,getPrChecks,getPrComments,approvePr,mergePr.Testing
pnpm typecheck— all 22 packages passbiome checkon touched packages — clean🤖 Generated with Claude Code