Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(web): remove html preview download overlay (#1123)
Genera8c189955122
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.cssindex 72318b67f..e55852a83 100644--- a/src/web/src/app/globals.css+++ b/src/web/src/app/globals.css@@ -2438,7 +2438,6 @@ html.dark .blog-content [data-rehype-pretty-code-figure] span {/* ── Streamdown block actions: unified styling (matches MessageActionsToolbar) ── */[data-streamdown="code-block-actions"],[data-streamdown="mermaid-block-actions"],-[data-html-preview-actions],[data-streamdown="table-wrapper"]>div:first-child:not(:has([data-streamdown="table"])) {opacity: 0;pointer-events: none;@@ -2454,7 +2453,6 @@ html.dark .blog-content [data-rehype-pretty-code-figure] span {[data-streamdown="code-block-actions"] button,[data-streamdown="mermaid-block-actions"] button,-[data-html-preview-actions] button,[data-streamdown="table-wrapper"]>div:first-child:not(:has([data-streamdown="table"])) button {width: 1.5rem !important;height: 1.5rem !important;@@ -2470,7 +2468,6 @@ html.dark .blog-content [data-rehype-pretty-code-figure] span {[data-streamdown="code-block-actions"] button:not(:disabled):is(:hover, :focus-visible),[data-streamdown="mermaid-block-actions"] button:not(:disabled):is(:hover, :focus-visible),-[data-html-preview-actions] button:not(:disabled):is(:hover, :focus-visible),[data-streamdown="table-wrapper"]>div:first-child:not(:has([data-streamdown="table"])) button:not(:disabled):is(:hover, :focus-visible) {background: var(--muted) !important;color: var(--foreground) !important;@@ -2478,24 +2475,11 @@ html.dark .blog-content [data-rehype-pretty-code-figure] span {[data-streamdown="code-block-actions"] button svg,[data-streamdown="mermaid-block-actions"] button svg,-[data-html-preview-actions] button svg,[data-streamdown="table-wrapper"]>div:first-child:not(:has([data-streamdown="table"])) button svg {width: 0.875rem !important;height: 0.875rem !important;}-[data-html-preview]:is(:hover, :focus-within) [data-html-preview-actions] {- opacity: 1;- pointer-events: auto;-}--@media (hover: none), (pointer: coarse) {- [data-html-preview-actions] {- opacity: 1;- pointer-events: auto;- }-}-/* ── Streamdown block actions: dropdown popups ── */[data-streamdown="code-block-actions"] .absolute,[data-streamdown="mermaid-block-actions"] .absolute,diff --git a/src/web/src/components/community/messages/html-attachment-preview.dom.test.tsx b/src/web/src/components/community/messages/html-attachment-preview.dom.test.tsxindex b8557fdda..ef7a81ae8 100644--- a/src/web/src/components/community/messages/html-attachment-preview.dom.test.tsx+++ b/src/web/src/components/community/messages/html-attachment-preview.dom.test.tsx@@ -33,13 +33,11 @@ function BackListener({ replacePath }: { replacePath: (path: string) => void })afterEach(() => { for (const owner of owners.splice(0)) owner.queryClient.clear(); vi.restoreAllMocks(); vi.unstubAllGlobals(); vi.unstubAllEnvs(); theme.resolvedTheme = "light"; vi.useRealTimers() })describe("HTML attachment frame", () => {- it("keeps the filename out of content and groups floating preview actions", () => {+ it("keeps the filename out of content without host actions or hidden download controls", () => {const view = setup()- const actions = view.getByRole("group", { name: "HTML preview actions" })expect(view.queryByText(file.name)).toBeNull()- expect(actions).toContainElement(view.getByTestId(tid.htmlPreviewDownload("a1")))- expect(actions.querySelectorAll("button")).toHaveLength(1)- expect(view.queryByRole("button", { name: /Expand HTML preview|Close fullscreen preview/ })).toBeNull()+ expect(view.queryByRole("group", { name: "HTML preview actions" })).toBeNull()+ expect(view.container.querySelectorAll("button, a[download], [data-html-preview-actions]")).toHaveLength(0)expect(view.queryByRole("dialog")).toBeNull()expect(view.getByTestId(tid.htmlPreview("a1"))).not.toHaveAttribute("aria-modal")expect(view.getByTestId(tid.htmlPreview("a1"))).toHaveAccessibleName(file.name)@@ -71,11 +69,11 @@ describe("HTML attachment frame", () => {const frame = view.getByTestId(tid.htmlPreviewFrame("a1"))expect(frame).toHaveAttribute("src", `${file.url}?preview=html&v=1.2.3`)const download = view.owner.queryClient.getQueryCache().find({ queryKey: attachmentDownloadKey(view.owner, file), exact: true })- expect(download).toBeDefined()+ expect(download).toBeUndefined()vi.stubEnv("NEXT_PUBLIC_APP_VERSION", "1.2.4+build &next=2")view.rerender(view.tree(<HtmlAttachmentPreview attachment={file} />))expect(frame).toHaveAttribute("src", `${file.url}?preview=html&v=1.2.4%2Bbuild%20%26next%3D2`)- expect(view.owner.queryClient.getQueryCache().find({ queryKey: attachmentDownloadKey(view.owner, file), exact: true })).toBe(download)+ expect(view.owner.queryClient.getQueryCache().find({ queryKey: attachmentDownloadKey(view.owner, file), exact: true })).toBeUndefined()expect(file.url).toBe("/api/community/channels/c1/attachments/a1")})it("posts updated Alook theme without replacing the document", () => {@@ -96,10 +94,12 @@ describe("HTML attachment frame", () => {const view = setup()const preview = view.getByTestId(tid.htmlPreview("a1"))const loading = view.getByRole("status", { name: "Loading preview" })+ expect(preview.querySelectorAll("button, a[download], [data-html-preview-actions]")).toHaveLength(0)expect(loading.textContent).toBe("")expect(loading.querySelector("svg")).toHaveAttribute("aria-hidden", "true")expect(preview.style.height).toBe("320px")expect(view.queryByTestId(tid.htmlPreviewFrame("a1"))).toBeNull()+ expect([...preview.children]).toEqual([loading])act(() => intersect!([{ isIntersecting: true } as IntersectionObserverEntry], {} as IntersectionObserver))const frame = view.getByTestId(tid.htmlPreviewFrame("a1")) as HTMLIFrameElementexpect(preview.style.height).toBe("")@@ -111,6 +111,8 @@ describe("HTML attachment frame", () => {expect(view.queryByRole("status", { name: "Loading preview" })).toBeNull()expect(view.getByTestId(tid.htmlPreviewFrame("a1"))).toBe(frame)expect(preview).toHaveAttribute("data-html-preview-status", "ready")+ expect(preview.querySelectorAll("button, a[download], [data-html-preview-actions]")).toHaveLength(0)+ expect([...preview.children]).toEqual([frame])})it("leaves native Back to the normal page route with an inline preview", () => {const originalUrl = window.location.href@@ -159,9 +161,10 @@ describe("HTML attachment frame", () => {const view = setup()act(() => vi.advanceTimersByTime(15_000))expect(view.queryByTestId(tid.htmlPreviewFrame("a1"))).toBeNull()- expect(view.getByRole("status")).toHaveTextContent("Preview unavailable")+ expect(view.getByRole("status").textContent).toBe("Preview unavailable.")expect(view.getAllByTestId(tid.htmlPreview("a1"))).toHaveLength(1)- expect(view.getByTestId(tid.htmlPreviewDownload("a1"))).toBeEnabled()+ expect([...view.getByTestId(tid.htmlPreview("a1")).children]).toEqual([view.getByRole("status")])+ expect(view.container.querySelectorAll("button, a[download], [data-html-preview-actions]")).toHaveLength(0)expect(view.queryByRole("status", { name: "Loading preview" })).toBeNull()})})diff --git a/src/web/src/components/community/messages/html-attachment-preview.tsx b/src/web/src/components/community/messages/html-attachment-preview.tsxindex 75e852695..5ed600b2a 100644--- a/src/web/src/components/community/messages/html-attachment-preview.tsx+++ b/src/web/src/components/community/messages/html-attachment-preview.tsx@@ -3,15 +3,13 @@import { useQuery } from "@tanstack/react-query"import { useSelector } from "@tanstack/react-store"import { useEffect, useMemo, useRef, useState } from "react"-import { Download, LoaderCircle } from "lucide-react"+import { LoaderCircle } from "lucide-react"import { useTheme } from "next-themes"import { collectHtmlPreviewFonts, loadHtmlPreviewFonts } from "@/lib/community/html-preview-fonts"import { applicationKey, assertApplicationOwner, captureApplicationOwner, useApplicationOwner } from "@/lib/application-owner"import { HTML_PREVIEW_SANDBOX, HTML_PREVIEW_THEME_VARIABLES } from "@/lib/community/html-preview-policy"import type { FileAttachment } from "@/lib/community/models/message"-import { useAttachmentDownload, attachmentDownloadStatusText } from "@/lib/community/attachment-download"import { tid } from "@/lib/community/testids"-import { buttonVariants } from "@/components/ui/button"export function HtmlAttachmentPreview({ attachment }: { attachment: FileAttachment & { id: string } }) {const owner = useApplicationOwner()@@ -42,7 +40,6 @@ function HtmlPreviewDocument({ attachment }: { attachment: FileAttachment & { idconst root = useRef<HTMLDivElement>(null)const frame = useRef<HTMLIFrameElement>(null)const ready = useRef(false)- const download = useAttachmentDownload(attachment)const id = attachment.idconst url = `${attachment.url}?preview=html&v=${encodeURIComponent(process.env.NEXT_PUBLIC_APP_VERSION ?? "")}`const error = status === "error"@@ -100,22 +97,8 @@ function HtmlPreviewDocument({ attachment }: { attachment: FileAttachment & { idclassName="relative m-0 block w-full min-w-0 max-w-full overflow-hidden rounded-none border-0 bg-transparent p-0 text-foreground"style={!mounted && !error ? { height } : undefined}>- <div role="group" aria-label="HTML preview actions" data-html-preview-actions className="absolute top-1.5 right-1.5 z-10 flex items-center">- <button- type="button"- data-testid={tid.htmlPreviewDownload(id)}- className={buttonVariants({ variant: "ghost", size: "icon" })}- onClick={() => download.state.status === "downloading" ? download.cancel() : void download.start()}- aria-label={download.state.status === "downloading" ? "Cancel download" : `Download ${attachment.name}`}- aria-busy={download.state.status === "downloading"}- title={attachmentDownloadStatusText(download.state) ?? `Download ${attachment.name}`}- >- {download.state.status === "downloading" ? <LoaderCircle className="size-4 motion-safe:animate-spin" /> : <Download className="size-4" />}- <span className="sr-only" aria-live="polite">{attachmentDownloadStatusText(download.state)}</span>- </button>- </div>{error ? (- <div role="status" className="p-4 text-sm text-muted-foreground">Preview unavailable. You can download this file.</div>+ <div role="status" className="p-4 text-sm text-muted-foreground">Preview unavailable.</div>) : (<>{status === "loading" && <div role="status" aria-label="Loading preview" className="pointer-events-none absolute inset-0 flex items-center justify-center text-muted-foreground">diff --git a/src/web/src/lib/community/testids.ts b/src/web/src/lib/community/testids.tsindex 246153c8e..94ae71d4e 100644--- a/src/web/src/lib/community/testids.ts+++ b/src/web/src/lib/community/testids.ts@@ -207,7 +207,6 @@ export const tid = {threadOpenerImage: (index: number) => `community-thread-opener-image-${index}`,htmlPreview: (id: string) => `community-html-preview-${id}`,htmlPreviewFrame: (id: string) => `community-html-preview-frame-${id}`,- htmlPreviewDownload: (id: string) => `community-html-preview-download-${id}`,attachmentCard: (name: string) => `community-attachment-card-${name}`,attachmentPreviewSheet: "community-attachment-preview-sheet",attachmentPreviewDownload: "community-attachment-preview-download",diff --git a/src/web/src/test/e2e-ui/20-community-attachment-thumbnails.spec.ts b/src/web/src/test/e2e-ui/20-community-attachment-thumbnails.spec.tsindex cbbe2caa1..0782cf1df 100644--- a/src/web/src/test/e2e-ui/20-community-attachment-thumbnails.spec.ts+++ b/src/web/src/test/e2e-ui/20-community-attachment-thumbnails.spec.ts@@ -895,7 +895,7 @@ test("HTML attachment markers render once with interactive isolated content acroconst { page } = await actors.asUser("alice", { colorScheme: null })const channelPath = `/c/channels/${serverId}/${channelId}`await page.goto(channelPath)- const html = '<!doctype html><html><head><style>body{padding:16px;background:var(--background);color:var(--foreground)}button{background:var(--primary);color:var(--primary-foreground)}.row{height:64px}</style></head><body><h2>Interactive HTML</h2><button onclick="document.getElementById(\'rows\').insertAdjacentHTML(\'beforeend\',\'<div class=row>Added row</div>\');document.getElementById(\'count\').textContent=Number(document.getElementById(\'count\').textContent)+1">Add row</button><output id="count">0</output><div id="rows"></div><p id="isolation"></p><script>try{parent.document.body;document.getElementById("isolation").textContent="parent accessible"}catch(e){document.getElementById("isolation").textContent="parent isolated"}</script></body></html>'+ const html = '<!doctype html><html><head><style>body{padding:16px;background:var(--background);color:var(--foreground)}button{background:var(--primary);color:var(--primary-foreground)}.row{height:64px}</style></head><body><h2>Interactive HTML</h2><button onclick="document.getElementById(\'rows\').insertAdjacentHTML(\'beforeend\',\'<div class=row>Added row</div>\');document.getElementById(\'count\').textContent=Number(document.getElementById(\'count\').textContent)+1">Add row</button><output id="count">0</output><button style="position:absolute;right:6px;top:6px;width:24px;height:24px;padding:0" aria-label="Use top-right content" onclick="document.getElementById(\'corner-count\').textContent=Number(document.getElementById(\'corner-count\').textContent)+1">+</button><output id="corner-count">0</output><div id="rows"></div><p id="isolation"></p><script>try{parent.document.body;document.getElementById("isolation").textContent="parent accessible"}catch(e){document.getElementById("isolation").textContent="parent isolated"}</script></body></html>'async function upload(name: string, mimeType: string, content: string) {const response = await confirmCommunityFixtureApiResponse(page.request.post(`/api/community/channels/${channelId}/attachments`, {headers: CURRENT_COMMUNITY_FIXTURE_HEADERS,@@ -925,10 +925,12 @@ test("HTML attachment markers render once with interactive isolated content acroexpect(await iframe.getAttribute("sandbox")).not.toContain("allow-same-origin")const content = iframe.contentFrame()await expect(content.locator("#isolation")).toHaveText("parent isolated")- const actions = preview.getByRole("group", { name: "HTML preview actions" })+ const hostControls = preview.locator("button, a[download], [data-html-preview-actions]")+ await expect(hostControls).toHaveCount(0)+ await expect(preview.locator(":scope > *")).toHaveCount(1)+ await expect(preview.locator(":scope > iframe")).toHaveCount(1)await expect(preview).toHaveCSS("border-top-width", "0px")await expect(preview.getByText("interactive.html", { exact: true })).toHaveCount(0)- await expect(actions).toHaveCSS("position", "absolute")async function appearance(mode: "Light" | "Dark") {await page.getByTestId(tid.userSettingsOpen).click()await page.getByTestId(tid.settingsTab("appearance")).click()@@ -961,18 +963,21 @@ test("HTML attachment markers render once with interactive isolated content acroexpect(await iframe.evaluate((element, original) => element === original, initialFrame)).toBe(true)await initialFrame?.dispose()await page.mouse.move(0, 0)- await expect(actions).toHaveCSS("opacity", "0")+ await expect(hostControls).toHaveCount(0)await preview.hover()- await expect(actions).toHaveCSS("opacity", "1")+ await expect(hostControls).toHaveCount(0)+ await content.getByRole("button", { name: "Use top-right content", exact: true }).click()+ await expect(content.locator("#corner-count")).toHaveText("1")await page.mouse.move(0, 0)- await message.getByTestId(tid.htmlPreviewDownload(attachmentId)).focus()- await expect(actions).toHaveCSS("opacity", "1")+ await iframe.click({ position: { x: 2, y: 2 } })+ await page.keyboard.press("Tab")+ await expect(content.getByRole("button", { name: "Add row" })).toBeFocused()+ await expect(hostControls).toHaveCount(0)const beforeHeight = await iframe.evaluate((element) => element.getBoundingClientRect().height)- await content.getByRole("button", { name: "Add row" }).click()+ await page.keyboard.press("Enter")await expect(content.locator("#count")).toHaveText("1")await expect.poll(() => iframe.evaluate((element) => element.getBoundingClientRect().height)).toBeGreaterThan(beforeHeight)- await expect(actions.getByRole("button")).toHaveCount(1)- await expect(actions.getByRole("button", { name: "Download interactive.html", exact: true })).toBeVisible()+ await expect(hostControls).toHaveCount(0)await expect(preview).not.toHaveAttribute("aria-modal", "true")const previewUrl = await iframe.getAttribute("src")@@ -992,12 +997,14 @@ test("HTML attachment markers render once with interactive isolated content acroconst readerPreview = reader.getByTestId(tid.message(messageId)).getByTestId(tid.htmlPreview(attachmentId))await expect(readerPreview).toHaveAttribute("data-html-preview-status", "ready")await expect(readerPreview.getByTestId(tid.htmlPreviewFrame(attachmentId)).contentFrame().getByRole("button", { name: "Add row" })).toBeVisible()- await expect(readerPreview.getByRole("group", { name: "HTML preview actions" })).toHaveCSS("opacity", "1")- await expect(readerPreview.getByRole("group", { name: "HTML preview actions" }).getByRole("button")).toHaveCount(1)- await expect(readerPreview.getByTestId(tid.htmlPreviewDownload(attachmentId))).toHaveCSS("width", "24px")- await expect(readerPreview.getByTestId(tid.htmlPreviewDownload(attachmentId))).toHaveCSS("height", "24px")+ await expect(readerPreview.locator("button, a[download], [data-html-preview-actions]")).toHaveCount(0)await expect(readerPreview).not.toHaveAttribute("aria-modal", "true")await expect(readerPreview.getByTestId(tid.htmlPreviewFrame(attachmentId)).contentFrame().locator("#count")).toHaveText("0")+ await readerPreview.getByTestId(tid.htmlPreviewFrame(attachmentId)).contentFrame().getByRole("button", { name: "Add row" }).tap()+ await expect(readerPreview.getByTestId(tid.htmlPreviewFrame(attachmentId)).contentFrame().locator("#count")).toHaveText("1")+ await readerPreview.getByTestId(tid.htmlPreviewFrame(attachmentId)).contentFrame().getByRole("button", { name: "Use top-right content", exact: true }).tap()+ await expect(readerPreview.getByTestId(tid.htmlPreviewFrame(attachmentId)).contentFrame().locator("#corner-count")).toHaveText("1")+ await expect(readerPreview.locator("button, a[download], [data-html-preview-actions]")).toHaveCount(0)const { page: outsider } = await actors.asUser("carol")const denied = await outsider.request.get(previewUrl!)expect(denied.status()).toBe(404)@@ -1030,6 +1037,8 @@ test("HTML attachment markers render once with interactive isolated content acroawait transparentPreview.scrollIntoViewIfNeeded()await expect.poll(heldPreview.held).toBeGreaterThan(0)await expect(transparentPreview).toHaveAttribute("data-html-preview-status", "loading")+ await expect(transparentPreview.locator("button, a[download], [data-html-preview-actions]")).toHaveCount(0)+ await expect(transparentPreview.locator(":scope > *")).toHaveCount(2)const loadingStatus = transparentPreview.getByRole("status", { name: "Loading preview" })await expect(loadingStatus).toBeVisible()const region = await boundingRect(transparentPreview)@@ -1040,6 +1049,8 @@ test("HTML attachment markers render once with interactive isolated content acroloading = await captureCanvas("transparent-canvas-dark-host-loading.png")} finally { await heldPreview.release() }await expect(transparentPreview).toHaveAttribute("data-html-preview-status", "ready")+ await expect(transparentPreview.locator(":scope > *")).toHaveCount(1)+ await expect(transparentPreview.locator(":scope > iframe")).toHaveCount(1)await expect(transparentPreview.getByRole("status", { name: "Loading preview" })).toHaveCount(0)await expect(transparentFrame).toHaveCSS("color-scheme", "dark")const transparentContent = transparentFrame.contentFrame()@@ -1080,7 +1091,6 @@ test("HTML attachment markers render once with interactive isolated content acroreturn { canvas, authored, carrier }}const canvasSamples = []- const transparentActions = transparentPreview.getByRole("group", { name: "HTML preview actions" })for (const mode of ["Light", "Dark"] as const) {await appearance(mode)await expect(transparentFrame).toHaveCSS("color-scheme", mode.toLowerCase())@@ -1104,9 +1114,7 @@ test("HTML attachment markers render once with interactive isolated content acroawait expect(transparentContent.locator("#authored")).toHaveCSS("color", "rgb(17, 34, 51)")const inline = await transparentPixels(`transparent-canvas-${mode.toLowerCase()}-inline.png`)await transparentPreview.hover()- await expect(transparentActions).toHaveCSS("opacity", "1")- await expect(transparentActions).toHaveCSS("pointer-events", "auto")- await expect(transparentActions.getByRole("button")).toHaveCount(1)+ await expect(transparentPreview.locator("button, a[download], [data-html-preview-actions]")).toHaveCount(0)await expect(transparentPreview).not.toHaveAttribute("aria-modal", "true")await expect(transparentContent.locator("#state")).toHaveValue("retained edit")canvasSamples.push({ mode, growth, inline })diff --git a/src/web/src/test/e2e-ui/70-renderer-action-themes.spec.ts b/src/web/src/test/e2e-ui/70-renderer-action-themes.spec.tsindex 1b9a82bf4..03f2ca847 100644--- a/src/web/src/test/e2e-ui/70-renderer-action-themes.spec.ts+++ b/src/web/src/test/e2e-ui/70-renderer-action-themes.spec.ts@@ -1,12 +1,10 @@-import { readFile } from "node:fs/promises"import type { Locator, Page } from "@playwright/test"import { test, expect } from "./_fixtures/case-fixture"import { gotoAfterUserWsAuth } from "./_fixtures/actions"import { confirmCommunityFixtureApiResponse, CURRENT_COMMUNITY_FIXTURE_HEADERS } from "./_fixtures/business-contract"-import { holdRoute } from "./_fixtures/held-route"import { tid } from "./_fixtures/testids"-const HTML = "<!doctype html><html><body><p>Renderer action theme fixture</p></body></html>"+const HTML = '<!doctype html><html><body><p>Renderer action theme fixture</p><button style="position:absolute;right:6px;top:6px;width:24px;height:24px;padding:0" aria-label="Use preview" onclick="document.querySelector(\'output\').textContent=Number(document.querySelector(\'output\').textContent)+1">+</button><output>0</output></body></html>'const TABLE_ACTIONS = ':scope > div:first-child:not(:has([data-streamdown="table"]))'async function colors(control: Locator, group: Locator) {@@ -95,7 +93,7 @@ async function inspectMenu(page: Page, block: Locator, group: Locator, trigger:}for (const viewport of [{ width: 390, height: 844 }, { width: 834, height: 1112 }, { width: 1280, height: 900 }]) {- test(`shared renderer actions use readable theme pairs on hover and focus at ${viewport.width}px`, async ({ caseActors, caseResources }, testInfo) => {+ test(`shared renderer actions use readable theme pairs on hover and focus at ${viewport.width}px`, async ({ caseActors }, testInfo) => {test.setTimeout(120_000)const actors = await caseActors(["alice"])const serverId = await actors.seed.seedServer("alice", `Action themes ${Date.now()}`)@@ -123,13 +121,26 @@ for (const viewport of [{ width: 390, height: 844 }, { width: 834, height: 1112const preview = page.getByTestId(tid.message(htmlMessageId)).getByTestId(tid.htmlPreview(attachmentId))await preview.scrollIntoViewIfNeeded()await expect(preview).toHaveAttribute("data-html-preview-status", "ready")+ const mermaid = page.getByTestId(tid.message(mermaidId)).locator('[data-streamdown="mermaid-block"]')+ await mermaid.scrollIntoViewIfNeeded()+ await expect(mermaid.locator("svg .node")).toHaveCount(2)const messageWrites: string[] = []+ const rawHtmlRequests: string[] = []page.on("request", request => {- if (request.method() !== "GET" && /\/api\/community\/(?:channels\/[^/]+\/messages|messages\/[^/]+)$/.test(new URL(request.url()).pathname)) {- messageWrites.push(`${request.method()} ${new URL(request.url()).pathname}`)+ const url = new URL(request.url())+ if (request.method() !== "GET" && /\/api\/community\/(?:channels\/[^/]+\/messages|messages\/[^/]+)$/.test(url.pathname)) {+ messageWrites.push(`${request.method()} ${url.pathname}`)}+ if (url.pathname === `/api/community/channels/${channelId}/attachments/${attachmentId}` && url.searchParams.get("preview") !== "html") rawHtmlRequests.push(request.url())})const samples = []+ const htmlFrame = preview.getByTestId(tid.htmlPreviewFrame(attachmentId))+ const htmlContent = htmlFrame.contentFrame()+ const htmlHostControls = preview.locator("button, a[download], [data-html-preview-actions]")+ await expect(htmlHostControls).toHaveCount(0)+ await expect(preview.locator(":scope > *")).toHaveCount(1)+ await expect(preview.locator(":scope > iframe")).toHaveCount(1)+ let htmlActivations = 0for (const mode of ["light", "dark"] as const) {await page.emulateMedia({ colorScheme: mode })await expect.poll(() => page.evaluate(() => ({ media: matchMedia("(prefers-color-scheme: dark)").matches,@@ -139,7 +150,6 @@ for (const viewport of [{ width: 390, height: 844 }, { width: 834, height: 1112if (consumer === "redacted") await expect(block.locator("[data-redacted]")).toHaveCount(1)samples.push({ mode, consumer, controls: await inspectGroup(page, block, block.locator('[data-streamdown="code-block-actions"]'), ["Copy Code"]) })}- const mermaid = page.getByTestId(tid.message(mermaidId)).locator('[data-streamdown="mermaid-block"]')await mermaid.scrollIntoViewIfNeeded()await expect(mermaid.locator("svg .node")).toHaveCount(2)const mermaidActions = mermaid.locator('[data-streamdown="mermaid-block-actions"]')@@ -157,36 +167,34 @@ for (const viewport of [{ width: 390, height: 844 }, { width: 834, height: 1112menu: await inspectMenu(page, fullscreenTable, fullscreenActions, "Copy table", ["Copy table as Markdown", "Copy table as CSV", "Copy table as TSV"]) })await fullscreenActions.getByTitle("Exit fullscreen", { exact: true }).click()await expect(fullscreen).toHaveCount(0)- const htmlActions = preview.getByRole("group", { name: "HTML preview actions" })- samples.push({ mode, consumer: "html", controls: await inspectGroup(page, preview, htmlActions, ["Download theme.html"]) })- const downloadButton = preview.getByTestId(tid.htmlPreviewDownload(attachmentId))- const started = page.waitForEvent("download")- await downloadButton.click()- const download = await started- expect(download.suggestedFilename()).toBe("theme.html")- const path = await download.path()- expect(path).not.toBeNull()- expect(await readFile(path!, "utf8")).toBe(HTML)- const originalUrl = new URL(`/api/community/channels/${channelId}/attachments/${attachmentId}`, page.url()).href- const held = await holdRoute(page, originalUrl, caseResources)- const aborted = page.waitForEvent("requestfailed", { predicate: request => request.url() === originalUrl })- try {- await downloadButton.click()- await expect.poll(held.held).toBe(1)- await expect(downloadButton).toHaveAccessibleName("Cancel download")- await expect(downloadButton).toHaveAttribute("aria-busy", "true")- samples.push({ mode, consumer: "html-cancel", controls: await inspectControl(page, htmlActions, downloadButton, true, preview) })- await downloadButton.click()- await expect(downloadButton).toHaveAccessibleName("Download theme.html")- await expect(downloadButton).toHaveAttribute("aria-busy", "false")- } finally { await held.release() }- expect((await aborted).failure()?.errorText).toContain("ERR_ABORTED")+ await preview.scrollIntoViewIfNeeded()+ await expect(htmlHostControls).toHaveCount(0)+ await preview.hover()+ await expect(htmlHostControls).toHaveCount(0)+ const htmlButton = htmlContent.getByRole("button", { name: "Use preview", exact: true })+ const corner = await htmlButton.boundingBox()+ const frameBounds = await htmlFrame.boundingBox()+ expect(corner).not.toBeNull()+ expect(frameBounds).not.toBeNull()+ expect(Math.abs(frameBounds!.x + frameBounds!.width - corner!.x - corner!.width - 6)).toBeLessThanOrEqual(1)+ expect(Math.abs(corner!.y - frameBounds!.y - 6)).toBeLessThanOrEqual(1)+ await htmlButton.click()+ await expect(htmlContent.locator("output")).toHaveText(String(++htmlActivations))+ await testInfo.attach(`html-preview-host-${viewport.width}-${mode}.png`, { body: await page.screenshot(), contentType: "image/png" })+ await htmlFrame.click({ position: { x: 2, y: 2 } })+ await page.keyboard.press("Tab")+ await expect(htmlButton).toBeFocused()+ await expect(htmlHostControls).toHaveCount(0)+ await page.keyboard.press("Enter")+ await expect(htmlContent.locator("output")).toHaveText(String(++htmlActivations))+ samples.push({ mode, consumer: "html", hostControls: await htmlHostControls.count(), corner, frameBounds, activations: htmlActivations })expect(messageWrites).toEqual([])+ expect(rawHtmlRequests).toEqual([])expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)}await testInfo.attach(`renderer-actions-${viewport.width}-themes.json`, { body: JSON.stringify({ viewport,- input: "mouse hover/click and scripted focus after keyboard Tab; not a complete Tab-entry or pure-touch journey",+ input: "shared controls: mouse hover/click and scripted focus after Tab; HTML: click blank iframe area, native Tab/Enter; not a page-start Tab or pure-touch journey",media: await page.evaluate(() => ({ coarse: matchMedia("(pointer: coarse)").matches, hover: matchMedia("(hover: hover)").matches })),- serverId, channelId, codeId, redactedId, mermaidId, tableId, htmlMessageId, attachmentId, messageWrites, samples }), contentType: "application/json" })+ serverId, channelId, codeId, redactedId, mermaidId, tableId, htmlMessageId, attachmentId, messageWrites, rawHtmlRequests, samples }), contentType: "application/json" })})}