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 9b2b3379ef..324520a5bd 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
@@ -26,7 +26,8 @@ afterEach(() => {
const render = (
findings: PublishValidationFinding[],
canViewPublishLogs = true,
- items: PublishLog[] = []
+ items: PublishLog[] = [],
+ onLoadLog?: (item: PublishLog) => void
) => {
container = document.createElement("div");
document.body.appendChild(container);
@@ -38,6 +39,7 @@ const render = (
findings={findings}
canViewPublishLogs={canViewPublishLogs}
items={items}
+ onLoadLog={onLoadLog}
/>
);
@@ -206,6 +208,72 @@ test("Free hides log-derived issues, stage, and code", async () => {
expect(document.body.textContent).not.toContain("private-log-issue");
});
+test("loads a completed publish when Publish opens and shows its log inline", async () => {
+ const item: PublishLog = {
+ buildId: "build-1",
+ logHandle: "log-handle-1",
+ target: "site",
+ domains: ["example.com"],
+ findings: [],
+ status: "failed",
+ };
+ const onLoadLog = vi.fn();
+ const element = render(
+ [createFinding("warning", 0)],
+ true,
+ [item],
+ onLoadLog
+ );
+ openDetails(element);
+ expect(onLoadLog).not.toHaveBeenCalled();
+ const publishTab = Array.from(
+ document.body.querySelectorAll('[role="tab"]')
+ ).find((tab) => tab.textContent === "Publish");
+ await act(async () => userEvent.click(publishTab as HTMLElement));
+ expect(onLoadLog).toHaveBeenCalledWith(item);
+
+ item.logState = "available";
+ item.logText = "Unstructured runner output";
+ act(() => {
+ root?.render(
+
+
+
+ );
+ });
+ expect(document.body.textContent).toContain("Unstructured runner output");
+ expect(document.body.textContent).not.toContain("View detailed report");
+});
+
+test("shows unavailable instead of loading forever when a publish has no log handle", async () => {
+ const onLoadLog = vi.fn();
+ const element = render(
+ [createFinding("warning", 0)],
+ true,
+ [
+ {
+ buildId: "build-1",
+ target: "site",
+ domains: ["example.com"],
+ findings: [],
+ status: "failed",
+ },
+ ],
+ onLoadLog
+ );
+ openDetails(element);
+ const publishTab = Array.from(
+ document.body.querySelectorAll('[role="tab"]')
+ ).find((tab) => tab.textContent === "Publish");
+ await act(async () => userEvent.click(publishTab as HTMLElement));
+ expect(onLoadLog).not.toHaveBeenCalled();
+ expect(document.body.textContent).toContain("Publish logs are unavailable.");
+});
+
test("Free audit summaries do not expose long cached details", () => {
const longSummary = `Short reason ${"private context ".repeat(30)}`;
const element = render(
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 1a698425a8..3b5971c8c8 100644
--- a/apps/builder/app/builder/features/publish/publish-diagnostics-dialog.tsx
+++ b/apps/builder/app/builder/features/publish/publish-diagnostics-dialog.tsx
@@ -137,14 +137,12 @@ export const PublishDiagnosticsDialog = ({
onLoadLog?: (item: PublishLog) => void;
}) => {
const [internalOpen, setInternalOpen] = useState(false);
- const [selectedBuildId, setSelectedBuildId] = useState();
const [selectedFinding, setSelectedFinding] =
useState();
const isOpen = open ?? internalOpen;
const setIsOpen = onOpenChange ?? setInternalOpen;
const errors = findings.filter(({ severity }) => severity === "error");
const warnings = findings.filter(({ severity }) => severity === "warning");
- const selectedItem = items.find(({ buildId }) => buildId === selectedBuildId);
const defaultTab = initialTab ?? (errors.length > 0 ? "errors" : "warnings");
const [tab, setTab] = useState(defaultTab);
const activeTab =
@@ -160,18 +158,31 @@ export const PublishDiagnosticsDialog = ({
const reportText = findings.map(({ reportText }) => reportText).join("\n\n");
useEffect(() => {
- setSelectedBuildId(undefined);
setSelectedFinding(undefined);
setTab(defaultTab);
}, [target, isOpen, defaultTab]);
useEffect(() => {
if (canViewPublishLogs === false) {
- setSelectedBuildId(undefined);
setSelectedFinding(undefined);
}
}, [canViewPublishLogs]);
+ useEffect(() => {
+ if (isOpen === false || activeTab !== "publish" || !canViewPublishLogs) {
+ return;
+ }
+ for (const item of items) {
+ if (
+ item.status !== "pending" &&
+ item.logHandle !== undefined &&
+ item.logState === undefined
+ ) {
+ onLoadLog?.(item);
+ }
+ }
+ }, [activeTab, canViewPublishLogs, isOpen, items, onLoadLog]);
+
if (open === undefined && findings.length === 0) {
return null;
}
@@ -253,38 +264,6 @@ export const PublishDiagnosticsDialog = ({
{selectedFinding.link}
- ) : selectedItem !== undefined && canViewPublishLogs ? (
-
-
- Publish log
- {selectedItem.domains.join(", ") || "Static export"}
- {selectedItem.logState === "loading" ? (
- Loading logs…
- ) : selectedItem.logState === "available" ? (
-
-
- {selectedItem.logText}
-
-
- ) : (
- Publish logs are unavailable.
- )}
-
) : (
)}
+ {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
@@ -404,18 +404,6 @@ export const PublishDiagnosticsDialog = ({
{item.issuesOmitted} more issues not shown.
)}
- {canViewPublishLogs && item.status !== "pending" && (
-
- )}
{!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 8e829c472a..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
@@ -137,6 +137,21 @@ const record = () =>
})
);
+test("records a start time immediately and replaces it with the runner time", async () => {
+ render(true);
+ const beforeRecord = Date.now();
+ record();
+ const startedAt = Date.parse(session.items[0]?.startedAt ?? "");
+ expect(startedAt).toBeGreaterThanOrEqual(beforeRecord);
+ expect(startedAt).toBeLessThanOrEqual(Date.now());
+
+ await act(async () => session.loadLog(session.items[0]!));
+ expect(session.items[0]?.startedAt).toBe("2026-11-13T10:00:00.000Z");
+
+ render(false);
+ expect(session.items[0]?.startedAt).toBeUndefined();
+});
+
test("Free does not fetch logs, then Pro reads the full UTF-8 log from byte zero", async () => {
render(false);
record();
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 58f69f47ff..9319f018c4 100644
--- a/apps/builder/app/builder/features/publish/use-publish-logs.tsx
+++ b/apps/builder/app/builder/features/publish/use-publish-logs.tsx
@@ -134,7 +134,13 @@ export const usePublishLogs = (
if (isCurrent() === false) {
return;
}
- const accepted: PublishLog = { ...item, status: "pending" };
+ const accepted: PublishLog = {
+ ...item,
+ status: "pending",
+ startedAt: permission.current.allowed
+ ? new Date().toISOString()
+ : undefined,
+ };
retainedBuilds.current.delete(item.buildId);
retainedBuilds.current.add(item.buildId);
setItems((current) =>
@@ -212,7 +218,7 @@ export const usePublishLogs = (
return;
}
update(item.buildId, {
- startedAt: result.startedAt,
+ startedAt: result.startedAt ?? item.startedAt,
completedAt: result.completedAt,
failedStage: result.failedStage,
code: result.code,
@@ -248,7 +254,7 @@ export const usePublishLogs = (
...issues.filter(({ severity }) => severity === "warning"),
],
issuesOmitted,
- startedAt: result.startedAt,
+ startedAt: result.startedAt ?? item.startedAt,
completedAt: result.completedAt,
failedStage: result.failedStage,
code: result.code,