Skip to content

feat(inbox): show live PR status on pull request detail#2694

Merged
andrewm4894 merged 1 commit into
mainfrom
andy/inbox-live-pr-status
Jun 16, 2026
Merged

feat(inbox): show live PR status on pull request detail#2694
andrewm4894 merged 1 commit into
mainfrom
andy/inbox-live-pr-status

Conversation

@andrewm4894

Copy link
Copy Markdown
Member

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

  • Surface the GitHub PR's live status as a colored badge in the pull request detail meta row, next to the diff stats:
    • Open → green
    • Draft → gray
    • Merged → violet (with a merge icon)
    • Closed → red
  • The badge links to the PR and tooltips the full owner/repo#number reference plus state.
  • This wires up the previously-unused ReportImplementationPrLink component via the existing usePrDetails hook (git.getPrDetailsByUrl{ state, merged, draft }). One request per detail view — no N+1.
  • Taught ReportImplementationPrLink to distinguish draft PRs (it already received the draft field but ignored it; a draft is still state === "open" on GitHub).
  • Drive-by: swapped the deprecated GitMerge icon for GitMergeIcon.

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 carry state/isDraft — a small backend follow-up in core + workspace-server, kept out of this PR to keep it focused. Happy to do that next.

How did you test this?

  • biome check and @posthog/ui typecheck both clean.
  • Reused the existing, already-designed badge component and the usePrDetails hook already used by code-review and command-center surfaces.
  • Local manual verification of the badge states in the running app (by the author).

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

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.
@andrewm4894 andrewm4894 self-assigned this Jun 16, 2026
@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit a3ee2f8.

@andrewm4894 andrewm4894 added the Stamphog This will request an autostamp by stamphog on small changes label Jun 16, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix 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

Comment on lines 68 to +74
const tooltip = merged
? `Merged – ${prReference}`
: state === "closed"
? `Closed – ${prReference}`
: prReference;
: draft
? `Draft – ${prReference}`
: `Open – ${prReference}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Suggested change
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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch — fixed. The tooltip is now guarded by isLoading (it shows just the PR reference while the status is pending), keeping it in sync with colorClass. Since #2694 already merged, this ships in the follow-up #2695 (commit 23c9e0d).

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

Copy link
Copy Markdown

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: 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}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Comment on lines +68 to +70
<ReportImplementationPrLink
prUrl={report.implementation_pr_url}
size="md"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@andrewm4894 andrewm4894 merged commit 07c52f9 into main Jun 16, 2026
23 checks passed
@andrewm4894 andrewm4894 deleted the andy/inbox-live-pr-status branch June 16, 2026 09:29
Gilbert09 added a commit that referenced this pull request Jun 16, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant