fix: Make publish diagnostics selectable and align static export status (#6703)

Warnings and publish logs should be easy to select, and static export
should show the same kind of result alert as site publish. This PR fixes
those Builder behaviors without changing the publish pipeline.

## Checklist

- [x] Make warning text selectable while keeping finding details on a
separate link. Publish-log text remains selectable, with collapsibles
and copy buttons unchanged.
- [x] Show static-export success and failure in result alerts that open
the matching Diagnostics tab; remove the redundant status icon while
keeping button progress.
- [x] Notify the user if a static-export audit rejection arrives after
the Export popover closes; keep the inline-only notice while it is open.
- [x] Preserve a persisted static-build failure indicator after Builder
reload, without linking to session-only diagnostics.
- [x] Add regression tests for both cases and verify 197 publish tests,
Builder typecheck, root lint, formatting, and diff checks locally. Each
new test failed without its fix and passed afterward.
- [x] Update the authoritative static-export guide to explain what
remains after reload.
- [x] Confirm the main workflow, PR lint, submodule check, and approved
visual regression pass on the final commit.

No database or package contract changes. Wrangler telemetry is a
separate SaaS publish-job setting and is not changed here. No local
screenshots were taken, as previously requested. The intended visual
changes were reviewed from CI screenshots and approved.

A live staging publish/log read across this Builder PR and SaaS #684
remains unverified because the staging account reached its daily publish
limit. No quota was changed.

Replaces #6702.

Closes #6701
This commit is contained in:
Oleg Isonen authored and GitHub committed 2026-11-15 20:27:18 +01:00
1 parent 896a383e32
commit 82bd484b9d
8 files changed
+209 -143

No files matched your search

@@ -146,7 +146,7 @@ test.each(["findings", "details", "publish"] as const)(
);
if (view === "details") {
const finding = Array.from(document.body.querySelectorAll("button")).find(
(button) => button.textContent === "finding"
(button) => button.textContent === "Show more"
);
await act(async () => userEvent.click(finding!));
}
@@ -222,7 +222,7 @@ test("shows all mixed findings, counted tabs, selectable text, and copy-all", as
expect(document.body.querySelector('[draggable="true"]')).not.toBeNull();
const firstFinding = Array.from(
document.body.querySelectorAll("button")
).find((button) => button.textContent === "error-0");
).find((button) => button.textContent === "Show more");
expect(firstFinding).toBeDefined();
await act(async () => userEvent.click(firstFinding as HTMLElement));
const selectableText = Array.from(document.body.querySelectorAll("*")).find(
@@ -244,7 +244,7 @@ test("shows all mixed findings, counted tabs, selectable text, and copy-all", as
expect(document.body.textContent).not.toContain("error-0");
const warningFinding = Array.from(
document.body.querySelectorAll("button")
).find((button) => button.textContent === "warning-0");
).find((button) => button.textContent === "Show more");
await act(async () => userEvent.click(warningFinding as HTMLElement));
const warningBack = Array.from(document.body.querySelectorAll("button")).find(
(button) => button.textContent === "Back"
@@ -282,6 +282,25 @@ test.each(["error", "warning"] as const)(
}
);
test("warning text can be selected without opening its details", async () => {
render([createFinding("warning", 0)], { open: true });
const warning = Array.from(
document.body.querySelectorAll<HTMLElement>('[role="tabpanel"] div')
).find(
(element) =>
element.textContent === "warning-0" &&
getComputedStyle(element).userSelect === "text"
);
expect(warning).toBeDefined();
await act(async () => userEvent.click(warning!));
expect(document.body.textContent).not.toContain("Back");
const showMore = Array.from(document.body.querySelectorAll("button")).find(
(button) => button.textContent === "Show more"
);
await act(async () => userEvent.click(showMore!));
expect(document.body.textContent).toContain("details-warning-0");
});
test("Free shows the actual short error without details, navigation, or report copy", () => {
const element = render(
[
@@ -773,7 +792,7 @@ test("Show element closes the diagnostics dialog on ordinary navigation", async
]);
openDetails(element);
const finding = Array.from(document.body.querySelectorAll("button")).find(
(button) => button.textContent === "Invalid element"
(button) => button.textContent === "Show more"
);
await act(async () => userEvent.click(finding as HTMLElement));
const link =
@@ -141,13 +141,25 @@ const FindingList = ({
)}
</Text>
) : canViewPublishLogs ? (
<Button
type="button"
color="ghost"
onClick={() => onSelect(finding)}
>
{finding.title}
</Button>
<Flex align="center" gap={1} wrap="wrap">
<Text variant="labels" userSelect="text">
{finding.title}
</Text>
{(finding.details !== undefined ||
finding.link !== undefined) && (
<Link
as="button"
type="button"
variant="inherit"
color="inherit"
underline="always"
css={{ border: 0, padding: 0, background: "none" }}
onClick={() => onSelect(finding)}
>
Show more
</Link>
)}
</Flex>
) : (
<Text variant="labels" userSelect="text">
{shortFinding(finding)}
@@ -245,19 +245,25 @@ const completeChecks = async (fail: boolean) => {
};
const openErrors = async (target: "site" | "static") => {
if (target === "site") {
const issues = Array.from(
const findIssues = () =>
Array.from(
document.body.querySelectorAll<HTMLButtonElement>("button")
).find((button) => button.textContent?.trim() === "See issues");
if (target === "static") {
await vi.waitFor(async () => {
await act(async () => {});
expect(findIssues()).toBeDefined();
});
}
const issues = findIssues();
if (issues !== undefined) {
await act(async () => userEvent.click(issues));
} else if (target === "site") {
const status = document.body.querySelector<HTMLButtonElement>(
'button[aria-label^="Publish log:"]'
);
expect(issues ?? status).toBeDefined();
if (issues !== undefined) {
await act(async () => userEvent.click(issues));
} else {
await act(async () => status?.click());
}
expect(status).not.toBeNull();
await act(async () => status?.click());
}
const findErrors = () =>
Array.from(
@@ -325,6 +331,27 @@ test.each([
}
);
test("static audit rejection notifies after Export closes", async () => {
await mount("static");
await clickPublish("static");
await completeChecks(false);
await act(async () => publishDialog.set("none"));
await act(async () => {
dispatch.resolve({
success: false,
auditFindings: [{ severity: "error", message: "server rejection" }],
});
await dispatch.promise;
});
await vi.waitFor(async () => {
await act(async () => {});
expect(toast.error).toHaveBeenCalledExactlyOnceWith("server rejection");
});
await mount("static");
const errors = await openErrors("static");
expect(errors?.textContent).toContain("server rejection");
});
test("closing Publish clears a completed validation", async () => {
stores.$pages.set({
pages: new Map(),
@@ -394,10 +421,6 @@ test.each([
if (order === "server-first") {
await completeChecks(false);
}
const status = document.body.querySelector<HTMLButtonElement>(
'button[aria-label="Publish log: Static export"]'
);
await act(async () => status?.click());
const errors = await openErrors("static");
expect(errors?.textContent).toContain(message);
}
@@ -449,18 +472,8 @@ test.each(["request", "transport"] as const)(
}
await dispatch.promise.catch(() => {});
});
await act(async () =>
vi.waitFor(() =>
expect(toast.error).toHaveBeenCalledWith(
failure === "request" ? "static rejection" : "static transport"
)
)
);
const staticStatus = document.body.querySelector<HTMLButtonElement>(
'button[aria-label="Publish log: Static export"]'
);
expect(staticStatus).toBeDefined();
await act(async () => staticStatus?.click());
expect(toast.error).not.toHaveBeenCalled();
expect(document.body.querySelector('[role="alert"]')).not.toBeNull();
const staticErrors = await openErrors("static");
expect(staticErrors?.textContent).toContain(
failure === "request" ? "static rejection" : "static transport"
@@ -579,6 +592,23 @@ test.each(["site", "static"] as const)(
}
);
test("static check failure stays in the Export alert without a toast", async () => {
await mount("static");
await clickPublish("static");
await completeChecks(true);
expect(toast.error).not.toHaveBeenCalled();
await act(async () => {
dispatch.resolve({
success: false,
auditFindings: [{ severity: "error", message: "server rejection" }],
});
await dispatch.promise;
});
const errors = await openErrors("static");
expect(errors?.textContent).toContain("server rejection");
expect(toast.error).not.toHaveBeenCalled();
});
test("an accepted site failure links to its own publish log", async () => {
await mount("site");
await clickPublish("site");
@@ -716,15 +746,17 @@ test.each([
});
await dispatch.promise;
});
await act(async () =>
vi.waitFor(() =>
expect(
document.body.querySelector<HTMLButtonElement>(
'button[aria-label^="Publish log:"]'
)
).not.toBeNull()
)
);
if (target === "site") {
await act(async () =>
vi.waitFor(() =>
expect(
document.body.querySelector<HTMLButtonElement>(
'button[aria-label^="Publish log:"]'
)
).not.toBeNull()
)
);
}
checks = deferred<unknown>();
dispatch = deferred<unknown>();
await mount(target);
@@ -746,12 +778,6 @@ test.each([
await dispatch.promise.catch(() => {});
});
await completeChecks(false);
if (target === "static") {
const status = document.body.querySelector<HTMLButtonElement>(
'button[aria-label="Publish log: Static export"]'
);
await act(async () => status?.click());
}
const errors = await openErrors(target);
expect(errors?.textContent).toContain(message);
expect(errors?.textContent).not.toContain("older build issue");
@@ -641,7 +641,7 @@ test.each(["validation", "publish"] as const)(
await toggle("publish");
expect(banner()).toBeDefined();
const report = await openReport("Warnings");
expect(report?.querySelector("button")).not.toBeNull();
expect(report?.textContent?.trim()).toBeTruthy();
}
);
@@ -665,7 +665,7 @@ test("an older validation cannot replace a newer report", async () => {
expect(banner()).toBeDefined();
expect(button("Validated")).toBeDefined();
const report = await openReport("Warnings");
expect(report?.querySelector("button")).not.toBeNull();
expect(report?.textContent?.trim()).toBeTruthy();
});
test("older publish diagnostics cannot replace a newer operation", async () => {
@@ -685,7 +685,7 @@ test("older publish diagnostics cannot replace a newer operation", async () => {
await act(async () => old.resolve(checks));
expect(banner()).toBeDefined();
const report = await openReport("Warnings");
expect(report?.querySelector("button")).not.toBeNull();
expect(report?.textContent?.trim()).toBeTruthy();
});
test("reopening restores validated domains and publishes only those domains", async () => {
@@ -785,19 +785,14 @@ test.each(["site", "static"] as const)(
);
await waitFor(() => {
if (first === "static") {
expect(document.body.querySelector('[role="tablist"]')).not.toBeNull();
expect(button("See issues")).toBeDefined();
} else {
expect(banner()).toBeDefined();
expect(button("Publish")?.disabled).toBe(false);
}
});
if (first === "static") {
// Close the report before returning to the other publish target.
const close = document.body.querySelector<HTMLButtonElement>(
'[role="dialog"] button[aria-label="Close"]'
);
expect(close).not.toBeNull();
await act(async () => close?.click());
await toggle("none");
}
target = first === "site" ? "static" : "site";
if (target === "static") {
@@ -814,16 +809,8 @@ test.each(["site", "static"] as const)(
).toHaveLength(2)
);
if (target === "static") {
await waitFor(() =>
expect(document.body.querySelector('[role="tablist"]')).not.toBeNull()
);
await act(async () =>
document.body
.querySelector<HTMLButtonElement>(
'[role="dialog"] button[aria-label="Close"]'
)
?.click()
);
await waitFor(() => expect(button("See issues")).toBeDefined());
await toggle("none");
}
if (first === "site") {
await toggle("publish");
@@ -832,18 +819,8 @@ test.each(["site", "static"] as const)(
expect(report?.textContent).not.toContain("static diagnostic");
} else {
await selectStatic();
const reportButton = document.body.querySelector<HTMLButtonElement>(
'button[aria-label="Publish log: Static export"]'
);
expect(reportButton).not.toBeNull();
await act(async () => reportButton?.click());
await waitFor(() =>
expect(document.body.querySelector('[role="tablist"]')).not.toBeNull()
);
expect(
document.body.querySelector('[role="tabpanel"][data-state="active"]')
?.textContent
).toContain("static diagnostic");
const report = await openReport("Errors");
expect(report.textContent).toContain("static diagnostic");
}
}
);
@@ -62,7 +62,7 @@ beforeAll(async () => {
...projectStore.get(),
latestStaticBuild:
publishRequests === 0
? null
? (projectStore.get()?.latestStaticBuild ?? null)
: {
buildId: "static-1",
updatedAt: new Date().toISOString(),
@@ -187,11 +187,32 @@ test("reopening an active static publish keeps one status owner and one download
expect(downloads).toHaveBeenCalledExactlyOnceWith("/cgi/static/ssg/site.zip");
expect(staticButton()?.dataset.state).not.toBe("pending");
expect(staticButton()?.disabled).toBe(false);
expect(document.body.querySelector('[role="status"]')).not.toBeNull();
expect(document.body.textContent).toContain("Downloaded");
expect(publishRequests).toBe(1);
expect(jobRequests).toBe(2);
});
test("a persisted static failure remains visible without session diagnostics", async () => {
projectStore.set({
...createProject(),
latestStaticBuild: {
buildId: "previous-static-build",
projectId: "project-a",
updatedAt: new Date().toISOString(),
publishStatus: "FAILED",
},
});
await render(true);
expect(document.body.querySelector('[role="alert"]')).not.toBeNull();
expect(document.body.textContent).toContain("Download failed");
expect(
Array.from(document.body.querySelectorAll("button")).some(
(button) => button.textContent === "See issues"
)
).toBe(false);
});
test("project navigation suppresses an old static download and error toast", async () => {
vi.useFakeTimers();
const errorToast = vi.spyOn(toast, "error").mockImplementation(() => "");
@@ -246,14 +267,13 @@ test("a failed static runner clears progress without starting a download", async
await act(async () => vi.advanceTimersByTimeAsync(15_100));
expect(jobRequests).toBe(2);
expect(downloads).not.toHaveBeenCalled();
expect(errorToast).toHaveBeenCalledOnce();
expect(errorToast).not.toHaveBeenCalled();
expect(staticButton()?.dataset.state).not.toBe("pending");
expect(staticButton()?.disabled).toBe(false);
expect(document.body.querySelector('[role="alert"]')).not.toBeNull();
await act(async () =>
document.body
.querySelector<HTMLButtonElement>(
'button[aria-label="Publish log: Static export"]'
)
Array.from(document.body.querySelectorAll<HTMLButtonElement>("button"))
.find((button) => button.textContent === "See issues")
?.click()
);
const errors = Array.from(
@@ -277,7 +297,7 @@ test("a failed static runner clears progress without starting a download", async
).not.toBeNull();
});
test("the static status reopens an audit rejection instead of an older successful publish", async () => {
test("the static failure alert opens an audit rejection instead of an older successful publish", async () => {
getJobStatus = "success";
projectStore.set(createProject());
await render(true);
@@ -298,8 +318,15 @@ test("the static status reopens an audit rejection instead of an older successfu
?.textContent;
await vi.waitFor(async () => {
await act(async () => {});
expect(activeTab()).toBe("Errors");
expect(document.body.querySelector('[role="alert"]')).not.toBeNull();
});
expect(activeTab()).toBeUndefined();
await act(async () =>
Array.from(document.body.querySelectorAll<HTMLButtonElement>("button"))
.find((button) => button.textContent === "See issues")
?.click()
);
expect(activeTab()).toBe("Errors");
await act(async () =>
document.body
.querySelector<HTMLButtonElement>('button[aria-label="Close"]')
@@ -311,10 +338,8 @@ test("the static status reopens an audit rejection instead of an older successfu
});
await render(true);
await act(async () =>
document.body
.querySelector<HTMLButtonElement>(
'button[aria-label="Publish log: Static export"]'
)
Array.from(document.body.querySelectorAll<HTMLButtonElement>("button"))
.find((button) => button.textContent === "See issues")
?.click()
);
expect(activeTab()).toBe("Errors");
@@ -68,7 +68,6 @@ import { CollapsibleDomainSection } from "./collapsible-domain-section";
import {
ActivityIcon,
AlertIcon,
CheckCircleIcon,
CopyIcon,
GearIcon,
UpgradeIcon,
@@ -618,19 +617,13 @@ const PublishStatic = ({
const { status, statusContent } =
project.latestStaticBuild == null
? { status: "LOADED" as const, statusContent: "Not published" }
? { status: "LOADED" as const, statusContent: undefined }
: getStaticPublishStatusDisplay(project.latestStaticBuild);
const latestPublish = publishes.find((item) => item.target === "static");
const logStatus =
staticFailureFinding !== undefined
? "FAILED"
: latestPublish?.status === "pending"
? "PENDING"
: latestPublish?.status === "failed"
? "FAILED"
: latestPublish?.status === "success"
? "PUBLISHED"
: status;
const hasSessionFailure =
staticFailureFinding !== undefined || latestPublish?.status === "failed";
const persistedFailure = latestPublish === undefined && status === "FAILED";
const hasFailed = hasSessionFailure || persistedFailure;
const isPublishInProgress =
isPublishing ||
@@ -641,40 +634,35 @@ const PublishStatic = ({
return (
<Flex gap={2} shrink={false} direction={"column"}>
{latestPublish?.status === "success" &&
{hasFailed && (
<PanelBanner variant="error" role="alert">
<Flex align="center" justify="between" gap={2}>
<Text css={{ flex: 1, minWidth: 0 }}>
{staticFailureFinding?.title ??
(persistedFailure ? statusContent : "Publish failed")}
</Text>
{hasSessionFailure && (
<Button
type="button"
color="ghost"
css={{ flexShrink: 0 }}
onClick={() => onOpenReport("errors")}
>
See issues
</Button>
)}
</Flex>
</PanelBanner>
)}
{!hasFailed &&
latestPublish?.status === "success" &&
latestPublish.staticName !== undefined &&
!isPublishInProgress &&
staticFailureFinding === undefined && (
!isPublishInProgress && (
<PublishSuccessBanner
message="Downloaded"
onOpen={() => onOpenReport("publish")}
/>
)}
<Flex gap={2} align="center">
<Tooltip
content={
staticFailureFinding?.title ??
(latestPublish?.status === "failed"
? "Publish failed"
: statusContent)
}
>
<IconButton
type="button"
aria-label="Publish log: Static export"
onClick={() => onOpenReport()}
>
{logStatus === "FAILED" ? (
<AlertIcon />
) : logStatus === "PUBLISHED" ? (
<CheckCircleIcon />
) : (
<InfoCircleIcon />
)}
</IconButton>
</Tooltip>
</Flex>
<Tooltip
content={isPublishInProgress ? "Preparing static site" : undefined}
>
@@ -341,7 +341,10 @@ export const PublishButton = ({ projectId }: PublishProps) => {
setPublishError: setPublishStatusError,
isCurrentProject,
});
} else if (result?.status === "FAILED") {
} else if (
result?.status === "FAILED" &&
$publishDialog.get() !== "export"
) {
toast.error(result.statusContent);
}
onResult?.(result);
@@ -411,7 +414,10 @@ export const PublishButton = ({ projectId }: PublishProps) => {
domains,
});
}
if (target === "static" || $publishDialog.get() !== "publish") {
if (
$publishDialog.get() !==
(target === "static" ? "export" : "publish")
) {
toast.error(target === "static" ? message.slice(0, 200) : message);
}
}
@@ -1040,7 +1046,7 @@ export const PublishButton = ({ projectId }: PublishProps) => {
if (isCurrentProject() && diagnostics.isCurrent()) {
reportPublishValidationFailure(error, diagnostics.setFindings, {
publishingContinues: true,
showToast: true,
showToast: $publishDialog.get() !== "export",
});
}
},
@@ -1060,14 +1066,22 @@ export const PublishButton = ({ projectId }: PublishProps) => {
...findings,
...getServerPublishFindings(publishResult.auditFindings),
]);
openStaticReport("errors");
if ($publishDialog.get() !== "export") {
toast.error(
publishResult.auditFindings
.find((finding) => finding.severity === "error")
?.message.slice(0, 200) ?? "Publish failed"
);
}
return;
}
diagnostics.finish((findings) => [
...findings,
getPublishErrorFinding(publishResult.error),
]);
toast.error(publishResult.error.slice(0, 200));
if ($publishDialog.get() !== "export") {
toast.error(publishResult.error.slice(0, 200));
}
return;
}
const accepted = record({
@@ -1082,7 +1096,11 @@ export const PublishButton = ({ projectId }: PublishProps) => {
toast.error('File name must be defined in "result"');
}
const outcome = await waitForCompletion(accepted);
if (isCurrentProject() && outcome?.status === "FAILED") {
if (
isCurrentProject() &&
outcome?.status === "FAILED" &&
$publishDialog.get() !== "export"
) {
toast.error(outcome.statusContent);
}
},
+4 -3
View File
@@ -35,9 +35,10 @@ the **Publish** tab. Free plans can open the tab but cannot view its logs.
The export contains a static site consisting of HTML, CSS, JS, and images ready to be uploaded to another platform.
To check an export, open **Publish**, choose **Export**, and click the status
icon beside the static-site build button.
Its **Warnings**, **Errors**, and **Publish** tabs work like the [publish details for a domain](../foundations/publishing-and-custom-domains.md#publish-details):
If an export fails while Builder remains open, choose **See issues** in the
failure notice to open Diagnostics. After reloading Builder, the last failure
remains visible, but that session's issues and logs are no longer available.
The **Warnings**, **Errors**, and **Publish** tabs work like the [publish details for a domain](../foundations/publishing-and-custom-domains.md#publish-details):
Publish shows exports started in this Builder tab, while Warnings and Errors
show current project checks. Full logs, when available on your plan, open from
Publish in the same dialog.