diff --git a/apps/builder/app/builder/features/publish/publish-diagnostics-dialog.test.tsx b/apps/builder/app/builder/features/publish/publish-diagnostics-dialog.test.tsx index 711b5cc297..8b57deefe4 100644 --- a/apps/builder/app/builder/features/publish/publish-diagnostics-dialog.test.tsx +++ b/apps/builder/app/builder/features/publish/publish-diagnostics-dialog.test.tsx @@ -328,7 +328,7 @@ test("lists each publish domain and copies the full loaded log", async () => { expect(copied).toContain("third.example"); }); -test("shows separate collapsible steps and copies only the selected step", async () => { +test("collapses each complete publish and copies its full log from the header", async () => { const writeText = vi.fn(async (_text: string) => {}); Object.defineProperty(navigator, "clipboard", { configurable: true, @@ -341,51 +341,44 @@ test("shows separate collapsible steps and copies only the selected step", async { buildId: "build-1", target: "site", - domains: ["example.com"], + domains: ["first.example"], findings: [], status: "failed", logState: "available", - logText: "\nBuild (failure)\nfailed\n\nDeploy\ndone\n", - logSteps: [ - { name: "Build", status: "failure", text: "failed\n" }, - { name: "Deploy", status: "success", text: "done\n" }, - ], + logText: "Complete first publish log", + }, + { + buildId: "build-2", + target: "site", + domains: ["second.example"], + findings: [], + status: "success", + logState: "available", + logText: "Complete second publish log", }, ], undefined, true ); - const buttons = Array.from( + const triggers = Array.from( document.body.querySelectorAll("button[aria-labelledby]") ); - const labelOf = (button: HTMLButtonElement) => - document.getElementById(button.getAttribute("aria-labelledby") ?? "") - ?.textContent; - const build = buttons.find((button) => labelOf(button) === "Build"); - const deploy = buttons.find((button) => labelOf(button) === "Deploy"); - expect(build).toBeDefined(); - expect(deploy).toBeDefined(); - expect(build?.getAttribute("aria-expanded")).toBe("true"); - expect(deploy?.getAttribute("aria-expanded")).toBe("false"); - await act(async () => userEvent.click(deploy!)); - expect(deploy?.getAttribute("aria-expanded")).toBe("true"); + expect(triggers).toHaveLength(2); + expect(triggers[0]?.getAttribute("aria-expanded")).toBe("true"); + expect(triggers[1]?.getAttribute("aria-expanded")).toBe("false"); + expect(document.body.textContent).toContain("Complete first publish log"); + expect(document.body.textContent).not.toContain( + "Complete second publish log" + ); + await act(async () => userEvent.click(triggers[1]!)); + expect(document.body.textContent).toContain("Complete second publish log"); const copyButtons = document.body.querySelectorAll( 'button[aria-label="Copy log"]' ); expect(copyButtons).toHaveLength(2); await act(async () => userEvent.click(copyButtons[1]!)); - expect(writeText).toHaveBeenCalledWith("done\n"); - expect(deploy?.getAttribute("aria-expanded")).toBe("true"); - await act(async () => - userEvent.click( - document.body.querySelector( - 'button[aria-label="Copy all reports"]' - )! - ) - ); - expect(writeText).toHaveBeenLastCalledWith( - "example.com\n\nBuild (failure)\nfailed\n\nDeploy\ndone\n" - ); + expect(writeText).toHaveBeenCalledWith("Complete second publish log"); + expect(triggers[1]?.getAttribute("aria-expanded")).toBe("true"); }); test("publish failure is plain text and links to the Publish tab", async () => { diff --git a/apps/builder/app/builder/features/publish/publish-diagnostics-dialog.tsx b/apps/builder/app/builder/features/publish/publish-diagnostics-dialog.tsx index aa145ffa9d..3ed9058638 100644 --- a/apps/builder/app/builder/features/publish/publish-diagnostics-dialog.tsx +++ b/apps/builder/app/builder/features/publish/publish-diagnostics-dialog.tsx @@ -343,164 +343,149 @@ export const PublishDiagnosticsDialog = ({ {items.length === 0 && ( No publishes in this session. )} - {items.map((item) => { + {items.map((item, index) => { const duration = getPublishDuration(item); return ( - - {item.domains.length > 0 ? ( - - {item.domains.map((domain) => ( - - {domain} - - ))} - - ) : ( - Static export - )} - - {item.status === "pending" - ? "Publishing started" - : item.status === "success" - ? "Published" - : "Publish failed"} - - {canViewPublishLogs && - item.startedAt !== undefined && ( - - Started:{" "} - {new Date(item.startedAt).toLocaleString()} - - )} - {canViewPublishLogs && duration !== undefined && ( - Duration: {duration}s - )} - {canViewPublishLogs && - item.status === "failed" && - (item.failedStage !== undefined || - item.code !== undefined) && ( - - {[ - item.failedStage, - item.code?.replaceAll("_", " "), - ] - .filter(Boolean) - .join(" · ")} - - )} - {canViewPublishLogs && - item.status !== "pending" && - (item.logState === "available" ? ( - item.logSteps === undefined ? ( - - {item.logText} - - ) : ( - item.logSteps.map((step, index) => ( - - - - } - suffix={ - - - event.stopPropagation() - } - > - - - + + + + } + suffix={ + canViewPublishLogs && + item.logState === "available" && + item.logText !== undefined && ( + + + event.stopPropagation() } > - - {step.name} - - - - - - {step.text} - - - - )) - ) - ) : ( - - {item.logHandle === undefined || - item.logState === "unavailable" - ? "Publish logs are unavailable." - : "Loading logs…"} - - ))} - {item.findings.length > 0 && ( - - Audit - {item.findings.map((finding, index) => ( - - {canViewPublishLogs - ? (finding.summary ?? finding.title) - : shortFinding(finding)} - - ))} - - )} - {canViewPublishLogs && - item.issues !== undefined && - item.issues.length > 0 && ( - Build - )} - {canViewPublishLogs && - item.issues?.map((issue, index) => ( - + + + ) } > - {issue.message} - - ))} - {canViewPublishLogs && - (item.issuesOmitted ?? 0) > 0 && ( - - {item.issuesOmitted} more issues not shown. - - )} - {!canViewPublishLogs && ( - - Upgrade to Pro to view publish logs. - - )} - - + + {item.domains.length > 0 + ? item.domains.join(" · ") + : "Static export"} + + + + + + + {item.status === "pending" + ? "Publishing started" + : item.status === "success" + ? "Published" + : "Publish failed"} + + {canViewPublishLogs && + item.startedAt !== undefined && ( + + Started:{" "} + {new Date( + item.startedAt + ).toLocaleString()} + + )} + {canViewPublishLogs && + duration !== undefined && ( + Duration: {duration}s + )} + {canViewPublishLogs && + item.status === "failed" && + (item.failedStage !== undefined || + item.code !== undefined) && ( + + {[ + item.failedStage, + item.code?.replaceAll("_", " "), + ] + .filter(Boolean) + .join(" · ")} + + )} + {canViewPublishLogs && + item.status !== "pending" && + (item.logState === "available" ? ( + + {item.logText} + + ) : ( + + {item.logHandle === undefined || + item.logState === "unavailable" + ? "Publish logs are unavailable." + : "Loading logs…"} + + ))} + {item.findings.length > 0 && ( + + Audit + {item.findings.map((finding, index) => ( + + {canViewPublishLogs + ? (finding.summary ?? finding.title) + : shortFinding(finding)} + + ))} + + )} + {canViewPublishLogs && + item.issues !== undefined && + item.issues.length > 0 && ( + Build + )} + {canViewPublishLogs && + item.issues?.map((issue, index) => ( + + {issue.message} + + ))} + {canViewPublishLogs && + (item.issuesOmitted ?? 0) > 0 && ( + + {item.issuesOmitted} more issues not + shown. + + )} + {!canViewPublishLogs && ( + + Upgrade to Pro to view publish logs. + + )} + + + + + ); })} diff --git a/apps/builder/app/builder/features/publish/use-publish-logs.test.tsx b/apps/builder/app/builder/features/publish/use-publish-logs.test.tsx index d5b88f9aa9..9dd747e95d 100644 --- a/apps/builder/app/builder/features/publish/use-publish-logs.test.tsx +++ b/apps/builder/app/builder/features/publish/use-publish-logs.test.tsx @@ -175,30 +175,6 @@ test("Free does not fetch logs, then Pro reads the full UTF-8 log from byte zero expect(session.items[0]?.issues).toBeUndefined(); }); -test("decodes structured step boundaries without reading headings from log text", () => { - const first = new TextEncoder().encode("\nBuild\nfailed €\n"); - const second = new TextEncoder().encode("\nDeploy\ndone\n"); - const bytes = new Uint8Array([...first, ...second]); - const chunks = [ - encoded([...bytes.subarray(0, first.length - 3)]), - encoded([...bytes.subarray(first.length - 3)]), - ]; - expect( - sessionModule.decodePublishLogSteps(chunks, [ - { name: "Build", status: "failure", offset: 0, contentOffset: 7 }, - { - name: "Deploy", - status: "success", - offset: first.length, - contentOffset: first.length + 8, - }, - ]) - ).toEqual([ - { name: "Build", status: "failure", text: "failed €\n" }, - { name: "Deploy", status: "success", text: "done\n" }, - ]); -}); - test("missing execution handle does not retry an accepted publish", () => { render(false); act(() => diff --git a/apps/builder/app/builder/features/publish/use-publish-logs.tsx b/apps/builder/app/builder/features/publish/use-publish-logs.tsx index c5cc268dab..9319f018c4 100644 --- a/apps/builder/app/builder/features/publish/use-publish-logs.tsx +++ b/apps/builder/app/builder/features/publish/use-publish-logs.tsx @@ -18,7 +18,6 @@ export type PublishLog = { issuesOmitted?: number; logState?: "loading" | "available" | "unavailable"; logText?: string; - logSteps?: { name: string; status: string; text: string }[]; }; const decodeChunk = (chunk: string) => { @@ -35,37 +34,6 @@ export const decodePublishLog = (chunks: string[]) => { .join(""); }; -export const decodePublishLogSteps = ( - chunks: string[], - steps: { - name: string; - status: string; - offset: number; - contentOffset: number; - }[] -) => { - const decoded = chunks.map(decodeChunk); - const bytes = new Uint8Array( - decoded.reduce((total, chunk) => total + chunk.byteLength, 0) - ); - let offset = 0; - for (const chunk of decoded) { - bytes.set(chunk, offset); - offset += chunk.byteLength; - } - const decoder = new TextDecoder(); - return steps.map((step, index) => ({ - name: step.name, - status: step.status, - text: decoder.decode( - bytes.subarray( - step.contentOffset, - steps[index + 1]?.offset ?? bytes.length - ) - ), - })); -}; - export const getPublishDuration = (item: PublishLog) => { if (item.startedAt === undefined || item.completedAt === undefined) { return; @@ -148,7 +116,6 @@ export const usePublishLogs = ( issuesOmitted: undefined, logState: undefined, logText: undefined, - logSteps: undefined, })) ); } @@ -234,12 +201,6 @@ export const usePublishLogs = ( try { let cursor: number | undefined; const chunks: string[] = []; - const steps: { - name: string; - status: string; - offset: number; - contentOffset: number; - }[] = []; const issues: NonNullable = []; let issuesOmitted = 0; while (isReadCurrent()) { @@ -268,7 +229,6 @@ export const usePublishLogs = ( return; } chunks.push(log.chunk); - steps.push(...(log.steps ?? [])); for (const issue of log.issues ?? []) { if (issues.length < 20) { issues.push(issue); @@ -289,10 +249,6 @@ export const usePublishLogs = ( update(item.buildId, { logState: "available", logText: decodePublishLog(chunks), - logSteps: - steps.length > 0 - ? decodePublishLogSteps(chunks, steps) - : undefined, issues: [ ...issues.filter(({ severity }) => severity === "error"), ...issues.filter(({ severity }) => severity === "warning"), diff --git a/packages/trpc-interface/src/shared/deployment-contract.test.ts b/packages/trpc-interface/src/shared/deployment-contract.test.ts index ec59e9d659..7c9b54b080 100644 --- a/packages/trpc-interface/src/shared/deployment-contract.test.ts +++ b/packages/trpc-interface/src/shared/deployment-contract.test.ts @@ -30,22 +30,6 @@ test("the public deployment contract validates publish and status-only log reque code: "cancelled", }).availability ).toBe("available"); - const page = publishLogOutput.parse({ - availability: "available", - outcome: "failed", - logAvailability: "available", - log: { - encoding: "base64url", - chunk: "ZmFpbGVk", - complete: true, - steps: [ - { name: "Build", status: "failure", offset: 0, contentOffset: 7 }, - ], - }, - }); - expect(page.availability === "available" && page.log?.steps).toEqual([ - { name: "Build", status: "failure", offset: 0, contentOffset: 7 }, - ]); expect( publishLogInput.safeParse({ buildId: "build-1", diff --git a/packages/trpc-interface/src/shared/deployment-contract.ts b/packages/trpc-interface/src/shared/deployment-contract.ts index 4318d68136..f158f823c3 100644 --- a/packages/trpc-interface/src/shared/deployment-contract.ts +++ b/packages/trpc-interface/src/shared/deployment-contract.ts @@ -69,16 +69,6 @@ export const publishLogOutput = z.discriminatedUnion("availability", [ chunk: z.string().max(400_000), complete: z.boolean(), nextCursor: z.number().int().nonnegative().safe().optional(), - steps: z - .array( - z.object({ - name: z.string(), - status: z.string(), - offset: z.number().int().nonnegative().safe(), - contentOffset: z.number().int().nonnegative().safe(), - }) - ) - .optional(), issues: z .array( z.object({