From 51bc6343e2ee7879656758af77dbf93f18f56323 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Thu, 3 Dec 2026 23:02:46 +0100 Subject: [PATCH 1/5] test: pasted website link with destination padding keeps its thread URL label Co-authored-by: Claude Opus 5.5 --- ...website-link-keeps-thread-url-label.e2e.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 scripts/scenarios/padded-website-link-keeps-thread-url-label.e2e.ts diff --git a/scripts/scenarios/padded-website-link-keeps-thread-url-label.e2e.ts b/scripts/scenarios/padded-website-link-keeps-thread-url-label.e2e.ts new file mode 100644 index 0000000000000..0a35399cd5a74 --- /dev/null +++ b/scripts/scenarios/padded-website-link-keeps-thread-url-label.e2e.ts @@ -0,0 +1,42 @@ +/// +import { expect } from "e2e"; + +import { test, WEB } from "./t3.ts"; + +test( + "Pasting a padded website link keeps its thread URL label", + WEB, + async ({ t3, app, browser, screen }) => { + const project = await t3.project("demo"); + const linked = await t3.thread({ + project, + title: "Release checklist", + messages: ["Draft the checklist"], + }); + const target = await t3.thread({ project, title: "Release notes", messages: ["Start"] }); + await t3.open(target); + const composer = screen.getByRole("textbox"); + await composer.tap(); + + await browser.evaluate((threadId) => { + const environment = window.location.pathname.split("/")[1]; + const href = `https://app.t3.codes/threads/${environment}/${encodeURIComponent(threadId)}`; + const clipboardData = new DataTransfer(); + clipboardData.setData( + "text/plain", + `See [${href}]( https://example.com "Example") and ${href}`, + ); + const editor = document.activeElement; + if (!editor?.matches('[contenteditable="true"]')) throw new Error("Composer is not focused"); + return editor.dispatchEvent( + new ClipboardEvent("paste", { clipboardData, bubbles: true, cancelable: true }), + ); + }, linked.threadId); + + const chip = composer.getByText("Release checklist", { exact: true }); + await chip.first().waitFor(); + await app.screenshot("pasted-website-link"); + await expect(chip).toHaveCount(1); + await expect(composer.getByText(/\[https:\/\/app\.t3\.codes\/threads\//)).toBeVisible(); + }, +); From 5e3f7fc8f95f2d53e8d9dfe00002e5a9d963b414 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Thu, 3 Dec 2026 23:04:25 +0100 Subject: [PATCH 2/5] fix(shared): pasted website links with destination padding keep thread URL labels A link to another site whose destination starts after a space or line break was not recognized as a link, so a thread URL in its label became a thread chip. Co-authored-by: Claude Opus 5.5 --- packages/shared/src/threadLinks.test.ts | 6 ++++++ packages/shared/src/threadLinks.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/shared/src/threadLinks.test.ts b/packages/shared/src/threadLinks.test.ts index 88ddd37d41bc7..ffb20ec1059ea 100644 --- a/packages/shared/src/threadLinks.test.ts +++ b/packages/shared/src/threadLinks.test.ts @@ -709,6 +709,12 @@ describe("hosted thread links", () => { [`[Example](https://example.com/?next=${hosted})`], [`[ ${hosted} ](https://example.com)`], [`[${hosted}]( "Title")`], + [`[${hosted}]( https://example.com "Example")`], + [`[${hosted}](\n)`], + [ + `[${hosted}]( https://example.com) ${hosted}`, + `[${hosted}]( https://example.com) ${relabeled}`, + ], [`[${hosted}](t3-thread://v2/local/id "Title")`], [`[a](https://example.com/x_(y)) ${hosted}`, `[a](https://example.com/x_(y)) ${relabeled}`], [`(${hosted}) **${hosted}**`, `(${relabeled}) **${relabeled}**`], diff --git a/packages/shared/src/threadLinks.ts b/packages/shared/src/threadLinks.ts index 1ea778e7a9de1..99014dee1befa 100644 --- a/packages/shared/src/threadLinks.ts +++ b/packages/shared/src/threadLinks.ts @@ -64,7 +64,7 @@ const TITLE_SEPARATOR = String.raw`(?=[ \t\r\n])${DESTINATION_PADDING}`; const LINK_TITLE_END = new RegExp(`^${TITLE_SEPARATOR}${LINK_TITLE}${DESTINATION_END}`); const LINK_PATTERNS = [ String.raw`\[(?