Skip to content

feat(PRO-544): vendor the hosted PR header (read-only)#61

Merged
dastratakos merged 11 commits into
mainfrom
dean/pro-544-pr-header-readonly
Jun 2, 2026
Merged

feat(PRO-544): vendor the hosted PR header (read-only)#61
dastratakos merged 11 commits into
mainfrom
dean/pro-544-pr-header-readonly

Conversation

@dastratakos
Copy link
Copy Markdown
Contributor

@dastratakos dastratakos commented Jun 1, 2026

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 gh CLI. 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 orpc queries become CLI-native react-query hooks hitting plain-HTTP routes backed by gh (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, gh missing/unauthenticated, no PR for the branch).

Changes

  • types: REST-shaped GitHubPullRequest + checks/reviews/merge-status wire schemas, matching hosted's shapes so components vendor unchanged.
  • cli: gh adapters + read routes for the current-branch PR, CI check-runs, reviews, and merge status (GraphQL via gh api graphql). Each resolves repoRoot/origin from the run and runs gh in that worktree.
  • web: vendored header (status pill, title + #number, GitHub link, author + opened-time, copy-able branch refs, merge-status pill, CI checks, reviewer display) + supporting shadcn primitives (avatar, badge, input, sonner) and date-fns time 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 build all clean.
  • Route integration tests drive each endpoint through the real server + SQLite using a fake gh on PATH; unit tests cover parseGitHubRepo/isGitHubRemote.

Open in Stage

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 gh CLI. 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

    • CLI: gh adapters + 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 a github/ module.
    • Web: Renders the PR header on the run page (status pill, title + #, GitHub link, author + opened time, copyable branches with Shift+C, merge‑status pill, CI checks popover, reviewer avatars). Uses a vendored skeleton while detecting the PR; actions remain read‑only.
    • Types/Tests: Shared REST‑shaped wire schemas for PR, checks, reviews, and merge status; route integration tests with a fake gh and unit tests for GitHub remote parsing. Adds @radix-ui/react-avatar, date-fns, sonner; bumps lucide-react to ^0.568.0.
  • Bug Fixes

    • CLI: Use gh api --paginate --slurp and 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.
    • Web: Reviews context resolves to an empty summary after load so the Reviewers popover stops spinning when gh fails; 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.

Review in cubic

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.
@stage-review
Copy link
Copy Markdown

stage-review Bot commented Jun 1, 2026

Ready to review this PR? Stage has broken it down into 8 individual chapters for you:

Title
1 Define shared pull request wire schemas
2 Implement GitHub CLI adapters
3 Wire pull request API routes
4 Add web UI dependencies and primitives
5 Implement web data hooks and utilities
6 Build vendored pull request components
7 Integrate pull request header into UI
8 Other changes
Open in Stage

Chapters generated by Stage for commit ec19604 on Jun 1, 2026 10:21pm UTC.

Comment thread packages/web/src/components/pull-request/reviewers.tsx
Comment thread packages/web/src/components/pull-request/reviewers.tsx
Comment thread packages/cli/src/github/pull-request.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/cli/src/github/pull-request.ts Outdated
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.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/cli/src/github/pull-request.ts Outdated
Comment thread packages/web/src/lib/pull-request-context.tsx Outdated
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.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/cli/src/routes/pull-request.ts
Comment thread packages/web/src/lib/pull-request-context.tsx
Comment thread packages/web/src/components/shared/reviewer-avatars.tsx
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.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/cli/src/github/pull-request.ts
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.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/cli/src/github/pull-request.ts
Comment thread packages/web/src/components/pull-request/pull-request-header.tsx
@dastratakos dastratakos changed the title feat: vendor the hosted PR header (read-only) [PRO-544] feat(PRO-544): vendor the hosted PR header (read-only) Jun 1, 2026
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.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/cli/src/github/pull-request.ts
Comment thread packages/web/src/lib/pull-request-context.tsx Outdated
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).
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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.

Comment thread packages/web/src/components/ui/input.tsx
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/cli/src/github/pull-request.ts
… 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.
@dastratakos dastratakos merged commit 04aacb6 into main Jun 2, 2026
5 checks passed
@dastratakos dastratakos deleted the dean/pro-544-pr-header-readonly branch June 2, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant