-
Notifications
You must be signed in to change notification settings - Fork 53
feat(inbox): show live PR status on pull request detail #2694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||||||||||||||||||
| import { GitMerge, GitPullRequestIcon } from "@phosphor-icons/react"; | ||||||||||||||||||||||||||||||||||||
| import { GitMergeIcon, GitPullRequestIcon } from "@phosphor-icons/react"; | ||||||||||||||||||||||||||||||||||||
| import { cn } from "@posthog/quill"; | ||||||||||||||||||||||||||||||||||||
| import { usePrDetails } from "@posthog/ui/features/git-interaction/usePrDetails"; | ||||||||||||||||||||||||||||||||||||
| import { Tooltip } from "@radix-ui/themes"; | ||||||||||||||||||||||||||||||||||||
|
|
@@ -46,26 +46,32 @@ export function ReportImplementationPrLink({ | |||||||||||||||||||||||||||||||||||
| onLinkClick, | ||||||||||||||||||||||||||||||||||||
| }: ReportImplementationPrLinkProps) { | ||||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||||
| meta: { state, merged, isLoading }, | ||||||||||||||||||||||||||||||||||||
| meta: { state, merged, draft, isLoading }, | ||||||||||||||||||||||||||||||||||||
| } = usePrDetails(prUrl); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const isSm = size === "sm"; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // A draft PR is still `state === "open"` on GitHub, so check `draft` before | ||||||||||||||||||||||||||||||||||||
| // falling through to the open (green) styling. | ||||||||||||||||||||||||||||||||||||
| const colorClass = isLoading | ||||||||||||||||||||||||||||||||||||
| ? "bg-gray-4 text-gray-11 hover:bg-gray-5" | ||||||||||||||||||||||||||||||||||||
| : merged | ||||||||||||||||||||||||||||||||||||
| ? "bg-violet-4 text-violet-11 hover:bg-violet-5" | ||||||||||||||||||||||||||||||||||||
| : state === "closed" | ||||||||||||||||||||||||||||||||||||
| ? "bg-red-4 text-red-11 hover:bg-red-5" | ||||||||||||||||||||||||||||||||||||
| : "bg-green-4 text-green-11 hover:bg-green-5"; | ||||||||||||||||||||||||||||||||||||
| : draft | ||||||||||||||||||||||||||||||||||||
| ? "bg-gray-4 text-gray-11 hover:bg-gray-5" | ||||||||||||||||||||||||||||||||||||
| : "bg-green-4 text-green-11 hover:bg-green-5"; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const { reference: prReference, prNumber } = parseGitHubPrReference(prUrl); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const tooltip = merged | ||||||||||||||||||||||||||||||||||||
| ? `Merged – ${prReference}` | ||||||||||||||||||||||||||||||||||||
| : state === "closed" | ||||||||||||||||||||||||||||||||||||
| ? `Closed – ${prReference}` | ||||||||||||||||||||||||||||||||||||
| : prReference; | ||||||||||||||||||||||||||||||||||||
| : draft | ||||||||||||||||||||||||||||||||||||
| ? `Draft – ${prReference}` | ||||||||||||||||||||||||||||||||||||
| : `Open – ${prReference}`; | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
68
to
+74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Prompt To Fix With AIThis 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, and confirmed: |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const iconSize = isSm ? 10 : 12; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
@@ -88,7 +94,7 @@ export function ReportImplementationPrLink({ | |||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||
| {merged ? ( | ||||||||||||||||||||||||||||||||||||
| <GitMerge size={iconSize} weight="bold" /> | ||||||||||||||||||||||||||||||||||||
| <GitMergeIcon size={iconSize} weight="bold" /> | ||||||||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||||||||
| <GitPullRequestIcon size={iconSize} weight="bold" /> | ||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This renders
ReportImplementationPrLinkfor any truthyimplementation_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 byparsePrUrl, while this badge uses the raw value as an externalhref. 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.
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-schemeimplementation_pr_urlno longer becomes a clickable external link. Shipped in the follow-up #2695.