Skip to content

feat(inbox): add copy-link button to pull request detail#2692

Merged
andrewm4894 merged 2 commits into
mainfrom
andy/inbox-pr-copy-link
Jun 16, 2026
Merged

feat(inbox): add copy-link button to pull request detail#2692
andrewm4894 merged 2 commits into
mainfrom
andy/inbox-pr-copy-link

Conversation

@andrewm4894

Copy link
Copy Markdown
Member

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.tsx that already exists on ReportDetail.tsx and AgentRunDetail.tsx:

  • A handleCopyLink handler that builds the inbox deep link via buildInboxDeeplink and writes it to the clipboard, with the existing "Link copied" / "Couldn't copy link" toasts.
  • An outline icon button (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?

  • Typechecked the @posthog/ui package — the change is clean (the only failures in the full-repo typecheck are pre-existing and unrelated: missing @xterm/addon-webgl and in-flight core/workspace-server changes on main).
  • Reused the exact copy-link pattern already shipped on the sibling detail views; no new behavior invented.

Automatic notifications

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

@andrewm4894 andrewm4894 self-assigned this Jun 16, 2026
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 3609308.

@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/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

@andrewm4894 andrewm4894 added the Stamphog This will request an autostamp by stamphog on small changes label Jun 16, 2026
Comment on lines +48 to +56
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"));
};

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

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

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

github-actions[bot]
github-actions Bot previously approved these changes 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.

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.
@github-actions github-actions Bot dismissed their stale review June 16, 2026 08:52

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

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

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.

@andrewm4894 andrewm4894 merged commit d46a92c into main Jun 16, 2026
23 checks passed
@andrewm4894 andrewm4894 deleted the andy/inbox-pr-copy-link branch June 16, 2026 09:07
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