mirror of
https://github.com/block/buzz.git
synced 2026-11-27 19:52:31 +00:00
**Category:** fix **User Impact:** Buzz pull request, issue, and repository links now show compact, useful metadata cards in received messages, including messages sent by agents and the CLI. **Problem:** Sender-authored snapshots protect recipients from external preview fetches, but that change also removed recipient-side cards for trusted Buzz entity links when the sender did not attach snapshots. **Solution:** Resolve recognized Buzz entities only against the active relay and show signed repository identity, title, and compact builder context with the current inline Buzz mark in the favicon slot, but without avatars, thumbnails, or external image fetches. Entity metadata wins over conflicting sender snapshots, while unsupported or unavailable metadata retains a safe text fallback. <details> <summary>File changes</summary> **desktop/playwright.config.ts** Adds the entity-link regression spec to the smoke test project. **desktop/src/features/messages/ui/useComposerLinkPreviews.tsx** Treats recognized Buzz entity cards as complete without generating snapshot tags and retains fallback cards when relay metadata is absent. **desktop/src/shared/lib/useResolvedLinkPreviews.test.mjs** Covers kind-scoped entity detection, trusted relay metadata, root-scoped lifecycle queries, exact single-repository root binding, image-less pending state, and fallback behavior. **desktop/src/shared/lib/useResolvedLinkPreviews.ts** Resolves signed repository, pull request, and issue metadata from the active relay. Entity roots fail closed unless they carry exactly one matching repository tag; lifecycle queries are root-scoped before limits; successful metadata remains stable until relay/community reset, and PR commit context uses the immutable root event rather than an unindexed update query. **desktop/src/shared/ui/compact-link-preview-attachment.tsx** Uses Buzz repository identity as the compact card provider and avoids reserving thumbnail space for image-less entity cards. **desktop/src/shared/ui/markdown.tsx** Routes message cards through the combined entity/snapshot preview hook. **desktop/src/shared/ui/markdown/useMessageLinkPreviews.test.mjs** Proves relay-authenticated entity metadata beats a forged sender snapshot while preserving mixed-link content order. **desktop/src/shared/ui/markdown/useMessageLinkPreviews.ts** Combines recipient-resolved Buzz entities with sender-authored external snapshots using explicit trust precedence and first-seen ordering. **desktop/tests/e2e/entity-link-recipient-cards.spec.ts** Exercises repository identity, PR workflow context, repository metadata, image-less rendering, and composer send behavior for agent/CLI-style entity links. </details> ## Reproduction steps 1. Open a channel containing a message sent without `link-preview` tags whose content includes valid `buzz://pr`, `buzz://issue`, or `buzz://repo` links. 2. Confirm each card shows its repository identity and signed title; PRs/issues also show compact lifecycle context, and repositories show description/status/default branch. 3. Confirm the cards use the Buzz mark in the favicon slot with no avatar, thumbnail, or reserved image area. 4. Compose and send a message containing a Buzz entity link; confirm sending is not blocked waiting for a snapshot. 5. Send a message containing both a Buzz entity link and a snapshot-backed HTTPS link; confirm cards follow content order and the HTTPS link remains sender-snapshot-only. ## Screenshots ### Recipient view — Buzz-branded metadata cards Repository identity, title, and compact builder context render with the current inline Buzz mark in the favicon slot and no avatar, thumbnail, or reserved image space.  ## Validation At commit `7bc70b0a9f70392bd062ed25b1d2362cc4021a40` with a clean working tree: - Pre-push hooks passed: branch skew, desktop check, desktop typecheck, and full desktop unit suite - Full desktop unit suite: 4,560 passed - Purpose-built Playwright regression after a fresh E2E build: 2 passed - Screenshot regenerated from the same commit and visually inspected Originating conversation: Buzz channel `c2859932-b679-4091-9c7e-f5a65deddd64`, thread `93c3e7be59a8d1ec10b4992efd783a2a79f253a10f10d39746c6ad41b0d5bb42`. --------- Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
168 lines
5.9 KiB
TypeScript
168 lines
5.9 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
import { waitForAnimations } from "../helpers/animations";
|
|
import { installMockBridge, TEST_IDENTITIES } from "../helpers/bridge";
|
|
|
|
const SHOTS = "test-results/entity-link-recipient-cards";
|
|
|
|
// Regression coverage for buzz:// entity links posted WITHOUT sender
|
|
// snapshot tags (CLI / agent senders): #3818 moved external-link previews to
|
|
// sender-authored snapshots, which silently killed the recipient-side
|
|
// buzz://pr|issue|repo cards from #4695. These cards resolve their titles
|
|
// from the active relay itself, so they must render for recipients even when
|
|
// the message carries no link-preview tags.
|
|
|
|
const ALICE_PUBKEY = TEST_IDENTITIES.alice.pubkey;
|
|
const REPO_ADDRESS = `30617:${ALICE_PUBKEY}:relay-tools`;
|
|
const PR_ID = `e0${"ca4d".repeat(15)}ff`; // 64-hex event id
|
|
const PR_SUBJECT = "Restore recipient-side entity cards";
|
|
|
|
test("agent-style message with bare buzz:// links renders entity cards without snapshot tags", async ({
|
|
page,
|
|
}) => {
|
|
await page.addInitScript(
|
|
({ repoAddress, prId, alicePubkey, subject }) => {
|
|
window.__BUZZ_E2E_EXTRA_PROJECT_EVENTS__ = [
|
|
{
|
|
id: prId,
|
|
kind: 1618, // KIND_GIT_PULL_REQUEST
|
|
pubkey: alicePubkey,
|
|
created_at: Math.floor(Date.now() / 1000) - 60,
|
|
content: "PR body",
|
|
tags: [
|
|
["a", repoAddress],
|
|
["subject", subject],
|
|
["c", "abc123".padEnd(40, "0")],
|
|
["branch-name", "fix/entity-cards"],
|
|
["clone", "https://github.com/block/relay-tools.git"],
|
|
],
|
|
},
|
|
];
|
|
},
|
|
{
|
|
repoAddress: REPO_ADDRESS,
|
|
prId: PR_ID,
|
|
alicePubkey: ALICE_PUBKEY,
|
|
subject: PR_SUBJECT,
|
|
},
|
|
);
|
|
await installMockBridge(page);
|
|
await page.setViewportSize({ width: 900, height: 800 });
|
|
await page.goto("/", { waitUntil: "domcontentloaded" });
|
|
await page.getByTestId("channel-general").click();
|
|
await page.waitForFunction(
|
|
() => typeof window.__BUZZ_E2E_EMIT_MOCK_MESSAGE__ === "function",
|
|
);
|
|
|
|
// Simulate an agent/CLI sender: plain kind-9 message with bare buzz://
|
|
// URLs in the content and NO link-preview snapshot tags.
|
|
await page.evaluate(
|
|
({ prId, alicePubkey }) => {
|
|
window.__BUZZ_E2E_EMIT_MOCK_MESSAGE__?.({
|
|
channelName: "general",
|
|
pubkey: alicePubkey,
|
|
content: [
|
|
"PR is up — review when you can:",
|
|
`buzz://pr?id=${prId}&owner=${alicePubkey}&d=relay-tools`,
|
|
`Repo: buzz://repo?owner=${alicePubkey}&d=relay-tools`,
|
|
].join("\n"),
|
|
});
|
|
},
|
|
{ prId: PR_ID, alicePubkey: ALICE_PUBKEY },
|
|
);
|
|
|
|
const row = page
|
|
.getByTestId("message-row")
|
|
.filter({ hasText: "PR is up" })
|
|
.last();
|
|
await expect(row).toBeVisible();
|
|
|
|
// The PR card resolves builder metadata from the signed root and repository.
|
|
const prCard = row.locator('[data-link-preview="buzz-pull-request"]');
|
|
await expect(prCard).toBeVisible();
|
|
await expect(prCard).toContainText("relay-tools");
|
|
await expect(prCard).toContainText(PR_SUBJECT);
|
|
await expect(prCard).toContainText(
|
|
"Open · fix/entity-cards → main · abc1230",
|
|
);
|
|
await expect(prCard).toHaveAttribute("data-image-state", "none");
|
|
await expect(prCard.locator("[data-link-preview-thumbnail]")).toHaveCount(0);
|
|
await expect(
|
|
prCard.locator("[data-link-preview-hostname-buzz-mark]"),
|
|
).toBeVisible();
|
|
await expect(
|
|
prCard.locator("[data-link-preview-hostname-favicon]"),
|
|
).toHaveCount(0);
|
|
|
|
// The repository card uses its signed announcement metadata and remains
|
|
// image-less.
|
|
const repoCard = row.locator('[data-link-preview="buzz-repository"]');
|
|
await expect(repoCard).toBeVisible();
|
|
await expect(repoCard).toContainText("relay-tools");
|
|
await expect(repoCard).toContainText(
|
|
"Operator tooling and admin CLI for relay deployments.",
|
|
);
|
|
await expect(repoCard).toContainText("active · default: main");
|
|
await expect(repoCard).toHaveAttribute("data-image-state", "none");
|
|
await expect(repoCard.locator("[data-link-preview-thumbnail]")).toHaveCount(
|
|
0,
|
|
);
|
|
await expect(
|
|
repoCard.locator("[data-link-preview-hostname-buzz-mark]"),
|
|
).toBeVisible();
|
|
await expect(
|
|
repoCard.locator("[data-link-preview-hostname-favicon]"),
|
|
).toHaveCount(0);
|
|
expect(
|
|
await repoCard.evaluate((card) => card.getBoundingClientRect().height),
|
|
).toBeLessThan(84);
|
|
|
|
await waitForAnimations(page);
|
|
await page.screenshot({
|
|
animations: "disabled",
|
|
path: `${SHOTS}/01-recipient-entity-cards.png`,
|
|
});
|
|
});
|
|
|
|
test("desktop composer shows entity card and send is not blocked by missing snapshot", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page);
|
|
await page.setViewportSize({ width: 900, height: 800 });
|
|
await page.goto("/", { waitUntil: "domcontentloaded" });
|
|
await page.getByTestId("channel-general").click();
|
|
|
|
const repoLink = `buzz://repo?owner=${ALICE_PUBKEY}&d=relay-tools`;
|
|
await page.getByTestId("message-input").fill(`Check out ${repoLink}`);
|
|
|
|
// buzz:// links never produce snapshot tags, so the composer card must
|
|
// show as done (not stuck "processing") with zero ready snapshots.
|
|
const composerCard = page
|
|
.locator("[data-composer-link-previews]")
|
|
.locator('[data-link-preview="buzz-repository"]');
|
|
await expect(composerCard).toBeVisible();
|
|
await expect(page.locator("[data-composer-link-previews]")).toHaveAttribute(
|
|
"data-ready-snapshot-count",
|
|
"0",
|
|
);
|
|
|
|
await waitForAnimations(page);
|
|
await page.screenshot({
|
|
animations: "disabled",
|
|
path: `${SHOTS}/02-composer-entity-card.png`,
|
|
});
|
|
|
|
await page.getByTestId("send-message").click();
|
|
|
|
const row = page.getByTestId("message-row").last();
|
|
const repoCard = row.locator('[data-link-preview="buzz-repository"]');
|
|
await expect(repoCard).toBeVisible();
|
|
await expect(repoCard).toContainText("relay-tools");
|
|
|
|
await waitForAnimations(page);
|
|
await page.screenshot({
|
|
animations: "disabled",
|
|
path: `${SHOTS}/03-sent-entity-card.png`,
|
|
});
|
|
});
|