feat(PRO-544): vendor the hosted PR header (read-only)#61
Conversation
REST-shaped subset of GitHub's pull-request payload plus checks, reviews, and merge-status schemas — shared by the CLI server and SPA. Shaped to match hosted Stage's GitHubPullRequest so the vendored header consumes it unchanged.
Read-only gh adapters + HTTP routes for the run's current-branch PR, CI checks, reviews, and merge status. All resolve repoRoot/origin from the run, run gh in that worktree, and degrade to null/empty on any failure so PR context never breaks the review UI. Deployments need a GitHub App and are omitted. Covered by route integration tests using a fake gh on PATH.
Render the hosted Stage pull-request header atop the run view when a GitHub PR is detected for the current branch: status pill, title + number, GitHub link, author + opened-time, copy-able branch refs, merge-status pill, CI checks, and reviewer display. Components are vendored from the hosted monorepo with the oRPC data layer swapped for CLI-native gh-backed react-query hooks; write controls (merge, close/reopen, title edit, reviewer management) are deferred to the follow-up PR. Adds sonner toasts, avatar, and date-fns.
|
Ready to review this PR? Stage has broken it down into 8 individual chapters for you: Chapters generated by Stage for commit ec19604 on Jun 1, 2026 10:21pm UTC. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f42f1c60bb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
gh's GraphQL projection (gh pr view --json author/latestReviews) drops the [bot] login suffix, the avatar_url, and any bot signal — so GitHub App reviewers/authors rendered as regular users with the wrong avatar and a /<login> profile link. Source the author and reviewers from the REST API (gh api .../pulls/N and .../pulls/N/reviews) instead, which carries type "Bot", the [bot] login, and the real app avatar. getUserDisplay then renders the bot chip and /apps/<slug> link, matching hosted Stage. Drops the fabricated github.com/<login>.png avatar.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b88f7eba1d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Previously the run-id header flashed before the PR header swapped in once detection resolved. Gate the run view on the pull-request query's loading state: show a skeleton matching the header's two-row layout while it loads, then render the PR header, or fall back to the run-id header only when no PR is found. Avoids the layout shift.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75df41987b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Split github.ts into a github/ folder (repo identity, the gh exec helper, and the pull-request read adapters) so the GitHub integration is a cohesive module rather than one 486-line file. Matches the CLI's existing db//runs/ module-folder convention; importers now use github/index.js. No behavior change.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 003e321af5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Replace the hand-written skeleton with hosted Stage's PullRequestHeaderSkeleton (defined inline on its PR page) so the loading placeholder stays in sync with upstream rather than being a bespoke one-off.
Hosted is on lucide-react ^0.568.0, which redesigned the GitBranch glyph (among others). We were on ^0.562.0, so the branch icon in the PR header rendered with the older glyph. Match hosted's version so vendored icons render identically.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e4ce5a0bc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Addresses PR review feedback on the read layer: - getChecks/getReviews now use gh --paginate --slurp and merge pages, so PRs with >100 check runs or >30 reviews are no longer truncated (the old --paginate alone produced multi-doc output that failed JSON.parse). - Review folding no longer lets a later COMMENTED review supersede a standing APPROVED/CHANGES_REQUESTED decision (matches GitHub's effective state). - The reviews context returns an empty summary once the query settles instead of staying null, so Reviewers stops spinning forever when gh reviews fail. - copyToClipboard now handles promise rejection with an error toast.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10def37623
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
getReviews now lets requested_reviewers override an earlier submitted review, so re-requesting someone who already approved shows "Awaiting review" instead of the stale approval (matches GitHub, where re-request dismisses the review).
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cf4c72d. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf4c72dd6f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… memo - getReviews no longer downgrades a standing CHANGES_REQUESTED review to REQUESTED when the reviewer is re-requested — it keeps blocking until they approve or it's dismissed (a stale APPROVED/COMMENTED is still superseded). - The reviews context uses a module-level EMPTY_REVIEW_SUMMARY constant for the settled-empty fallback, so the context useMemo no longer recomputes (and re-renders all consumers) on every render.

Summary
Surfaces the GitHub PR for the current branch in the CLI's web UI by vendoring the hosted Stage pull-request header and feeding it entirely from the local
ghCLI. This is the read-only half of a two-PR stack; the follow-up adds write capability (merge, close/reopen, title edit, reviewer management) to reach full parity with the hosted header.Resolves the read-only portion of PRO-544.
Approach
The hosted header's markup is vendored verbatim; only its data layer is swapped — the hosted
orpcqueries become CLI-native react-query hooks hitting plain-HTTP routes backed bygh(the repo's AGENTS.md bans oRPC). All detection is live, requires no new persistence, and degrades to "no header shown" whenever a PR can't be resolved (non-GitHub remote,ghmissing/unauthenticated, no PR for the branch).Changes
GitHubPullRequest+ checks/reviews/merge-status wire schemas, matching hosted's shapes so components vendor unchanged.ghadapters + read routes for the current-branch PR, CI check-runs, reviews, and merge status (GraphQL viagh api graphql). Each resolves repoRoot/origin from the run and runsghin that worktree.date-fnstime formatting. Rendered atop the run view when a PR is detected.Out of scope (PR 2)
Write controls — they're rendered read-only here (static status pill, no inline title edit, reviewer display only). Deployment links require a GitHub App and are omitted.
Testing
pnpm typecheck,pnpm lint,pnpm buildall clean.ghonPATH; unit tests coverparseGitHubRepo/isGitHubRemote.Summary by cubic
Shows the GitHub PR for the current branch in the CLI web UI via a vendored, read‑only PR header powered by the local
ghCLI. Adds paginated PR data, fixes review state handling (including re‑requested reviewers), and hides the header when no PR exists (read‑only scope of PRO‑544).New Features
ghadapters + GET routes for current‑branch PR, CI checks, reviews, and merge status; skip non‑GitHub remotes and return null/empty on failure. Author/reviewer data is sourced from the GitHub REST API to preserve bot identity and avatars. Extracted into agithub/module.ghand unit tests for GitHub remote parsing. Adds@radix-ui/react-avatar,date-fns,sonner; bumpslucide-reactto^0.568.0.Bug Fixes
gh api --paginate --slurpand merge pages for checks/reviews to avoid truncation; review folding no longer lets a later COMMENTED override APPROVED/CHANGES_REQUESTED; a re‑requested reviewer shows as REQUESTED (overriding prior approval), while a re‑requested CHANGES_REQUESTED remains blocking.ghfails; stabilize the reviews memo to avoid extra re‑renders; clipboard copy shows an error toast on failure.Written for commit ec19604. Summary will update on new commits.