feat(inbox): add copy-link button to pull request detail#2692
Conversation
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
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/PullRequestDetail.tsx:48-56
**Duplicated `handleCopyLink` logic** — the identical 6-line clipboard handler now lives verbatim in `ReportDetail.tsx`, `AgentRunDetail.tsx`, and here. This is the third copy with no variation; a small shared hook (e.g. `useInboxCopyLink(report)`) or a plain utility function would satisfy the team's OnceAndOnlyOnce principle and make future changes (e.g. swapping the toast strings) a single-site edit.
```suggestion
const handleCopyLink = useInboxCopyLink(report);
```
Reviews (1): Last reviewed commit: "feat(inbox): add copy-link button to pul..." | Re-trigger Greptile |
| const handleCopyLink = () => { | ||
| const url = buildInboxDeeplink(report.id, report.title, { | ||
| isDevBuild: import.meta.env.DEV, | ||
| }); | ||
| navigator.clipboard | ||
| .writeText(url) | ||
| .then(() => toast.success("Link copied")) | ||
| .catch(() => toast.error("Couldn't copy link")); | ||
| }; |
There was a problem hiding this comment.
Duplicated
handleCopyLink logic — the identical 6-line clipboard handler now lives verbatim in ReportDetail.tsx, AgentRunDetail.tsx, and here. This is the third copy with no variation; a small shared hook (e.g. useInboxCopyLink(report)) or a plain utility function would satisfy the team's OnceAndOnlyOnce principle and make future changes (e.g. swapping the toast strings) a single-site edit.
| const handleCopyLink = () => { | |
| const url = buildInboxDeeplink(report.id, report.title, { | |
| isDevBuild: import.meta.env.DEV, | |
| }); | |
| navigator.clipboard | |
| .writeText(url) | |
| .then(() => toast.success("Link copied")) | |
| .catch(() => toast.error("Couldn't copy link")); | |
| }; | |
| const handleCopyLink = useInboxCopyLink(report); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/src/features/inbox/components/PullRequestDetail.tsx
Line: 48-56
Comment:
**Duplicated `handleCopyLink` logic** — the identical 6-line clipboard handler now lives verbatim in `ReportDetail.tsx`, `AgentRunDetail.tsx`, and here. This is the third copy with no variation; a small shared hook (e.g. `useInboxCopyLink(report)`) or a plain utility function would satisfy the team's OnceAndOnlyOnce principle and make future changes (e.g. swapping the toast strings) a single-site edit.
```suggestion
const handleCopyLink = useInboxCopyLink(report);
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Good catch — fixed in 3609308. Extracted the duplicated handler into a shared copyInboxReportLink(report) utility (packages/ui/src/features/inbox/utils/copyInboxReportLink.ts) and pointed all three call sites (ReportDetail, AgentRunDetail, and this one) at it, so the link format and toast strings are now a single-site edit.
Went with a plain utility function rather than a useInboxCopyLink hook because there's no query/mutation/subscription involved, and the repo convention is that hooks wrap exactly one of those.
There was a problem hiding this comment.
Purely additive UI change adding a copy-link button to PullRequestDetail, mirroring identical functionality that exists in sibling components. The bot reviewer's concern about duplicated handler logic is a valid refactoring suggestion but is explicitly a code quality/"could be refactored better" concern, not a production risk.
Dedupes the identical copy-deeplink handler across the report, run, and pull request detail views into a single utility.
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
There was a problem hiding this comment.
Clean refactor that extracts duplicated clipboard handler into a shared utility, plus adds the same copy-link button to PullRequestDetail. Import boundaries are respected (shared utility stays in @posthog/ui, imports only from @posthog/shared). The bot's duplication concern was the exact issue this PR addresses, and the author's reply confirms the fix. No business logic, data model, or API contract changes.
Problem
In the Inbox, pull request reports (the ones with the Open in GitHub button) had no way to copy a deep link to the report itself. Every other inbox detail screen — Reports and Runs — has a copy-deeplink button, but the PR detail view was missing it. Sometimes you still want to share a link to the inbox report, not just jump to GitHub.
Changes
Added the same copy-deeplink button to
PullRequestDetail.tsxthat already exists onReportDetail.tsxandAgentRunDetail.tsx:handleCopyLinkhandler that builds the inbox deep link viabuildInboxDeeplinkand writes it to the clipboard, with the existing "Link copied" / "Couldn't copy link" toasts.CopyIcon) placed in the header actions, just before Open in GitHub.So PR reports now have both the copy-link button and the Open-in-GitHub button.
How did you test this?
@posthog/uipackage — the change is clean (the only failures in the full-repo typecheck are pre-existing and unrelated: missing@xterm/addon-webgland in-flightcore/workspace-serverchanges onmain).Automatic notifications