feat(inbox): show live PR status on pull request detail#2694
Conversation
Surface the GitHub PR's live state (open / draft / merged / closed) as a colored badge in the pull request detail meta row, next to the diff stats. Wires up the previously-unused ReportImplementationPrLink via the existing usePrDetails hook, and teaches it to distinguish draft PRs.
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
There was a problem hiding this comment.
Small additive UI change: adds the PR status badge to the detail view and correctly differentiates draft PRs with gray styling. The icon import rename is a straightforward fix matching the phosphor-icons naming convention. No business logic, data models, or API contracts are affected.
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/ui/src/features/inbox/components/utils/ReportImplementationPrLink.tsx:68-74
The `tooltip` string is not guarded by `isLoading`, so while the badge correctly renders gray during a pending fetch, hovering it shows `"Open – owner/repo#123"` — reflecting default values rather than the actual state. `colorClass` already has the `isLoading` guard; applying the same to `tooltip` keeps both in sync.
```suggestion
const tooltip = isLoading
? prReference
: merged
? `Merged – ${prReference}`
: state === "closed"
? `Closed – ${prReference}`
: draft
? `Draft – ${prReference}`
: `Open – ${prReference}`;
```
Reviews (1): Last reviewed commit: "feat(inbox): show live PR status on pull..." | Re-trigger Greptile |
| const tooltip = merged | ||
| ? `Merged – ${prReference}` | ||
| : state === "closed" | ||
| ? `Closed – ${prReference}` | ||
| : prReference; | ||
| : draft | ||
| ? `Draft – ${prReference}` | ||
| : `Open – ${prReference}`; |
There was a problem hiding this comment.
The
tooltip string is not guarded by isLoading, so while the badge correctly renders gray during a pending fetch, hovering it shows "Open – owner/repo#123" — reflecting default values rather than the actual state. colorClass already has the isLoading guard; applying the same to tooltip keeps both in sync.
| const tooltip = merged | |
| ? `Merged – ${prReference}` | |
| : state === "closed" | |
| ? `Closed – ${prReference}` | |
| : prReference; | |
| : draft | |
| ? `Draft – ${prReference}` | |
| : `Open – ${prReference}`; | |
| const tooltip = isLoading | |
| ? prReference | |
| : merged | |
| ? `Merged – ${prReference}` | |
| : state === "closed" | |
| ? `Closed – ${prReference}` | |
| : draft | |
| ? `Draft – ${prReference}` | |
| : `Open – ${prReference}`; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/src/features/inbox/components/utils/ReportImplementationPrLink.tsx
Line: 68-74
Comment:
The `tooltip` string is not guarded by `isLoading`, so while the badge correctly renders gray during a pending fetch, hovering it shows `"Open – owner/repo#123"` — reflecting default values rather than the actual state. `colorClass` already has the `isLoading` guard; applying the same to `tooltip` keeps both in sync.
```suggestion
const tooltip = isLoading
? prReference
: merged
? `Merged – ${prReference}`
: state === "closed"
? `Closed – ${prReference}`
: draft
? `Draft – ${prReference}`
: `Open – ${prReference}`;
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3ee2f8198
ℹ️ 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".
| : prReference; | ||
| : draft | ||
| ? `Draft – ${prReference}` | ||
| : `Open – ${prReference}`; |
There was a problem hiding this comment.
Treat unknown PR details separately
When git.getPrDetailsByUrl cannot read the PR (for example the GitHub CLI is offline/unauthenticated, the repo is private, or the URL cannot be parsed), the host router returns { state: "unknown", merged: false, draft: false } in packages/host-router/src/routers/git.router.ts:512. This new default branch labels that case as Open (and the color fallback above is green), so the detail page can now show a failed status lookup as a live open PR. Please only render Open for state === "open" and use a neutral/unknown state otherwise.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed, and confirmed: getPrDetailsByUrl returns { state: "unknown", merged: false, draft: false } on failure (host-router default), which the badge was painting green/"Open". Fixed — once a lookup settles, the badge renders nothing unless state is one of open/closed/merged, so a failed lookup no longer shows as a live open PR. Shipped in the follow-up #2695 (#2694 had already merged).
| <ReportImplementationPrLink | ||
| prUrl={report.implementation_pr_url} | ||
| size="md" |
There was a problem hiding this comment.
Validate the PR URL before rendering the badge link
This renders ReportImplementationPrLink for any truthy implementation_pr_url, but that field is only typed as an arbitrary string and the tab predicate accepts any truthy value; the existing primary GitHub action is gated by parsePrUrl, while this badge uses the raw value as an external href. If Cloud or a malformed task result sends a non-GitHub URL (or an unsafe scheme), the pull-request detail now exposes a clickable external link that was previously suppressed. Please gate this badge on the parsed GitHub PR URL or sanitize the URL before passing it through.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good point. The badge now validates the URL with parsePrUrl (the same gate the "Open in GitHub" action uses) and renders nothing when it isn't a canonical GitHub PR URL — so a non-GitHub or unsafe-scheme implementation_pr_url no longer becomes a clickable external link. Shipped in the follow-up #2695.
…ort #2695, #2694) Inbox signal reports that have an `implementation_pr_url` now render a live PR-status badge (open / merged / closed / draft) on the report list rows, the tinder card, and the report detail screen — reusing the existing `usePrStatus` hook and `PrStatusBadge` component from the tasks feature. The badge only renders for a canonical GitHub PR URL and renders nothing while the state is loading or unresolvable (private repo / 404 / unparseable), rather than showing a misleading default "open" badge. This is gated by a new `hideWhenUnresolved` prop on `PrStatusBadge`; the existing task-header usage keeps its always-tappable neutral badge. A `size="sm"` variant keeps the badge compact on dense list rows. Ports the desktop behavior from #2695 (list cards) and #2694 (detail) to the mobile app. The desktop GraphQL batching is intentionally not ported; mobile relies on react-query caching of the public GitHub REST API. Generated-By: PostHog Code Task-Id: ba8e678f-1c24-4c21-abe3-5dc204adec1a
Problem
Inbox pull-request reports showed diff stats (
+490 −73) but no indication of the linked PR's actual state. From the report you couldn't tell whether the PR was still open, a draft, already merged, or closed without clicking through to GitHub.Changes
owner/repo#numberreference plus state.ReportImplementationPrLinkcomponent via the existingusePrDetailshook (git.getPrDetailsByUrl→{ state, merged, draft }). One request per detail view — no N+1.ReportImplementationPrLinkto distinguish draft PRs (it already received thedraftfield but ignored it; a draft is stillstate === "open"on GitHub).GitMergeicon forGitMergeIcon.Scope note
This covers the detail view only. The inbox list cards intentionally avoid N+1 by batching diff stats through a single GraphQL request (
getPrDiffStatsBatch). Adding live status to the cards cleanly means extending that GraphQL batch to also carrystate/isDraft— a small backend follow-up incore+workspace-server, kept out of this PR to keep it focused. Happy to do that next.How did you test this?
biome checkand@posthog/uitypecheck both clean.usePrDetailshook already used by code-review and command-center surfaces.Automatic notifications