From a3784fc00a579297d5b16227bfdeba17d2aed470 Mon Sep 17 00:00:00 2001 From: Taylor Ho Date: Wed, 8 Apr 2026 14:14:34 -1000 Subject: [PATCH] feat(desktop): make PR smart chips copy the full URL on text selection The visible chip label (icon + owner/repo#number) is marked user-select:none while a hidden zero-width span holds the full URL for clipboard copy. Adds an e2e test verifying the DOM structure. Co-Authored-By: Claude Opus 4.6 (1M context) --- desktop/src/shared/ui/markdown.tsx | 9 ++++++--- desktop/tests/e2e/smart-links.spec.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/desktop/src/shared/ui/markdown.tsx b/desktop/src/shared/ui/markdown.tsx index ad980a6b4..84fcf0b9b 100644 --- a/desktop/src/shared/ui/markdown.tsx +++ b/desktop/src/shared/ui/markdown.tsx @@ -52,13 +52,16 @@ function createMarkdownComponents( return ( - - {owner}/{repo}#{number} + + {href} ); } diff --git a/desktop/tests/e2e/smart-links.spec.ts b/desktop/tests/e2e/smart-links.spec.ts index e047c604a..8030492f6 100644 --- a/desktop/tests/e2e/smart-links.spec.ts +++ b/desktop/tests/e2e/smart-links.spec.ts @@ -46,6 +46,32 @@ test("GitHub PR chip links open in new tab", async ({ page }) => { await expect(prChip).toHaveAttribute("rel", "noreferrer"); }); +test("selecting a PR chip copies the full URL, not the chip label", async ({ + page, +}) => { + const prUrl = "https://github.com/block/goose2/pull/125"; + + await page.goto("/"); + await page.getByTestId("channel-general").click(); + await expect(page.getByTestId("chat-title")).toHaveText("general"); + + const input = page.getByTestId("message-input"); + await input.fill(prUrl); + await page.getByTestId("send-message").click(); + + const lastRow = page.getByTestId("message-row").last(); + const prChip = lastRow.locator("a", { hasText: "block/goose2#125" }); + await expect(prChip).toBeVisible(); + + // The hidden span should contain the full URL for selection/copy + const hiddenUrl = prChip.locator("span.overflow-hidden"); + await expect(hiddenUrl).toHaveText(prUrl); + + // The visible label should not be selectable + const visibleLabel = prChip.locator("span.select-none"); + await expect(visibleLabel).toBeVisible(); +}); + test("non-PR GitHub links render as regular links", async ({ page }) => { const repoUrl = "https://github.com/block/sprout"; const message = `Check out ${repoUrl}`;