Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions desktop/src/shared/ui/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -1525,8 +1524,7 @@ function createMarkdownComponents(
</SpoilerInline>
),
a: ({ children, href, ...props }) => {
const { imetaByUrl, linkPreviewHrefs, onOpenMessageLink } =
runtimeRef.current;
const { imetaByUrl, onOpenMessageLink } = runtimeRef.current;
if (!interactive) {
return <span className="font-medium text-current">{children}</span>;
}
Expand Down Expand Up @@ -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 (
<a
Expand Down Expand Up @@ -1958,15 +1949,10 @@ function MarkdownInner({
() => (interactive ? extractSupportedLinkPreviews(content) : []),
[content, interactive],
);
const linkPreviewHrefs = React.useMemo(
() => new Set(linkPreviews.map((preview) => preview.href)),
[linkPreviews],
);
const runtimeRef = useLatestRef<MarkdownRuntime>({
agentMentionPubkeysByName,
channels,
imetaByUrl,
linkPreviewHrefs,
mentionPubkeysByName,
onOpenChannel,
onOpenMessageLink,
Expand Down
1 change: 0 additions & 1 deletion desktop/src/shared/ui/markdown/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export type MarkdownRuntime = {
agentMentionPubkeysByName?: Record<string, string>;
channels: Channel[];
imetaByUrl?: ImetaLookup;
linkPreviewHrefs: ReadonlySet<string>;
mentionPubkeysByName?: Record<string, string>;
onOpenChannel: (channelId: string) => void;
onOpenMessageLink: (link: ParsedMessageLink) => void;
Expand Down
21 changes: 21 additions & 0 deletions desktop/tests/e2e/messaging.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Loading