fix(sessions): Fix not copying URL from link-bubbles#2713
Open
mp-hog wants to merge 3 commits into
Open
Conversation
The conversation context menu's "Copy" only read the current text selection. Right-clicking a GitHub PR/issue chip creates no selection, and the chip (a Chip button) never exposed its URL — so "Copy" silently did nothing. Even once the URL is captured, the write was fired synchronously inside the Radix ContextMenu.Item onSelect, while the menu's focus scope is tearing down. In Electron/Chromium navigator.clipboard.writeText rejects with "Document is not focused" at that moment, leaving the previous clipboard contents. - GithubRefChip now exposes its href via a data-github-ref-url attribute on a display:contents wrapper, discoverable from any right-click target. - The context menu captures that URL on right-click and copies it (falling back to the text selection), with success/error toasts. - The clipboard write is deferred one task (copyFromContextMenu) so it runs after the menu closes and focus returns to the document. Adds helper unit tests, a GithubRefChip DOM-attribute test, and an integration test that drives the real right-click -> Copy flow through Radix ContextMenu. Generated-By: PostHog Code Task-Id: 3b559453-f506-4416-af2c-fdbb86a4d654
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
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/sessions/components/copyContextTarget.test.ts:54-68
**Prefer parameterised tests for table-driven cases**
The `resolveCopyText` and `getGithubRefUrlFromEventTarget` describe blocks each contain multiple `it()` calls with the same assertion shape and could be expressed more concisely as `it.each` tables. For example the three `resolveCopyText` cases are pure input → output pairs that map directly onto a data table. The same pattern applies to the four `getGithubRefUrlFromEventTarget` cases (the DOM setup can be hoisted outside the table).
Reviews (1): Last reviewed commit: "fix(sessions): copy PR/issue link from c..." | Re-trigger Greptile |
Convert the resolveCopyText and getGithubRefUrlFromEventTarget describe blocks to it.each tables, as they are pure input -> output cases sharing one assertion shape. Addresses review feedback. Generated-By: PostHog Code Task-Id: 3b559453-f506-4416-af2c-fdbb86a4d654
Reflow lines flagged by `biome ci` in SessionView.tsx and copyContextTarget.test.ts. No behaviour change. Generated-By: PostHog Code Task-Id: 3b559453-f506-4416-af2c-fdbb86a4d654
Contributor
|
Reviews (2): Last reviewed commit: "style(sessions): apply biome formatting" | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Right-clicking a GitHub PR/issue chip in a conversation and choosing Copy did nothing, the clipboard kept its previous contents.
Two causes:
window.getSelection(). Right-clicking never creates a selection, and the chip (GithubRefChip, aChipbutton) never exposed its URL — so there was nothing to copy.ContextMenu.Item onSelect, while the menu's focus scope is tearing down. In Electron/Chromiumnavigator.clipboard.writeTextrejects with "Document is not focused" at that instant, leaving the old clipboard contents.Fix
GithubRefChipexposes itshrefvia adata-github-ref-urlattribute on adisplay:contentswrapper, discoverable from any right-click target (icon, label, chip root).copyFromContextMenu) so it runs after the menu closes and focus returns to the document.Tests
getGithubRefUrlFromEventTarget,resolveCopyText, andcopyFromContextMenu(deferral + success/error callbacks).GithubRefChipDOM-attribute test.ContextMenuwith the realGithubRefChip.Manual verification
🤖 Generated with Claude Code