mirror of
https://github.com/block/buzz.git
synced 2026-10-27 12:40:30 +00:00
Restore visible links for rich previews (#1378)
This commit is contained in:
@@ -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(
|
||||
</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>;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user