diff --git a/desktop/src/shared/ui/markdown.tsx b/desktop/src/shared/ui/markdown.tsx index 9ff25590f..1218ecbb8 100644 --- a/desktop/src/shared/ui/markdown.tsx +++ b/desktop/src/shared/ui/markdown.tsx @@ -25,7 +25,6 @@ import { useChannelNavigation } from "@/shared/context/ChannelNavigationContext" import { cn } from "@/shared/lib/cn"; import { extractSupportedLinkPreviews, - isSupportedLinkAutolinkLabel, parseSupportedLinkPreview, } from "@/shared/lib/linkPreview"; import { useResolvedLinkPreviews } from "@/shared/lib/useResolvedLinkPreviews"; @@ -1525,8 +1524,7 @@ function createMarkdownComponents( ), a: ({ children, href, ...props }) => { - const { imetaByUrl, linkPreviewHrefs, onOpenMessageLink } = - runtimeRef.current; + const { imetaByUrl, onOpenMessageLink } = runtimeRef.current; if (!interactive) { return {children}; } @@ -1601,13 +1599,6 @@ function createMarkdownComponents( ? parseSupportedLinkPreview(href) : null; const isLinearLink = supportedLinkPreview?.kind === "linear-issue"; - if ( - supportedLinkPreview && - linkPreviewHrefs.has(supportedLinkPreview.href) && - isSupportedLinkAutolinkLabel(label, supportedLinkPreview) - ) { - return null; - } return ( (interactive ? extractSupportedLinkPreviews(content) : []), [content, interactive], ); - const linkPreviewHrefs = React.useMemo( - () => new Set(linkPreviews.map((preview) => preview.href)), - [linkPreviews], - ); const runtimeRef = useLatestRef({ agentMentionPubkeysByName, channels, imetaByUrl, - linkPreviewHrefs, mentionPubkeysByName, onOpenChannel, onOpenMessageLink, diff --git a/desktop/src/shared/ui/markdown/types.ts b/desktop/src/shared/ui/markdown/types.ts index 567cfe164..d9924331a 100644 --- a/desktop/src/shared/ui/markdown/types.ts +++ b/desktop/src/shared/ui/markdown/types.ts @@ -27,7 +27,6 @@ export type MarkdownRuntime = { agentMentionPubkeysByName?: Record; channels: Channel[]; imetaByUrl?: ImetaLookup; - linkPreviewHrefs: ReadonlySet; mentionPubkeysByName?: Record; onOpenChannel: (channelId: string) => void; onOpenMessageLink: (link: ParsedMessageLink) => void; diff --git a/desktop/tests/e2e/messaging.spec.ts b/desktop/tests/e2e/messaging.spec.ts index 13c3aa6bf..ed32fbb83 100644 --- a/desktop/tests/e2e/messaging.spec.ts +++ b/desktop/tests/e2e/messaging.spec.ts @@ -99,6 +99,27 @@ test("long autolink wraps without widening the timeline", async ({ page }) => { .toBe("visible"); }); +test("supported link previews keep the message link visible", async ({ + page, +}) => { + const previewUrl = "https://github.com/block/sprout/pull/1334"; + + await page.goto("/"); + await page.getByTestId("channel-general").click(); + await expect(page.getByTestId("chat-title")).toHaveText("general"); + + await page.getByTestId("message-input").fill(previewUrl); + await page.getByTestId("send-message").click(); + + const row = page.getByTestId("message-row").last(); + await expect( + row.getByRole("link", { exact: true, name: previewUrl }), + ).toBeVisible(); + await expect( + row.locator('[data-link-preview="github-pull-request"]'), + ).toBeVisible(); +}); + test("send multiple messages in sequence", async ({ page }) => { const ts = Date.now(); const messages = [