fix(cli): print check and validate setup commands on their own lines (#8381)

* fix(cli): print check and validate setup commands on their own lines

When no browser can be set up on Linux ARM64, check and validate now
print the setup commands on lines of their own after the reason.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* fix(cli): split setup commands only for a stopped check

A finding with any other code keeps its whole message on one line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
James Russo
2026-11-21 15:45:43 +00:00
committed by GitHub
co-authored by Claude Fable 5.2
parent 40cc86252d
commit 88f7d4052d
7 changed files with 129 additions and 12 deletions
+4
View File
@@ -1343,6 +1343,10 @@ npx hyperframes check [dir] --at 1.5,4,7.25
npx hyperframes check [dir] --strict # warnings fail too
```
When `check` or the deprecated `validate` fails because no browser can be set up
on Linux ARM64, the reason stays on the failure line and the setup commands
follow it on lines of their own, ready to copy. `--json` output is unchanged.
`check` runs the linter first. A lint error fails the check but does not stop
it: the browser checks still run and both are reported, unless the lint error
leaves no composition to load (a root with no `data-composition-id`).
+6 -5
View File
@@ -24,7 +24,11 @@ import {
} from "@hyperframes/engine/chrome-host-ceiling";
import { getFreeDiskMb } from "../telemetry/system.js";
import { BrowserDownloadStalledError, installInChild } from "./installInChild.js";
import { normalizeErrorMessage, SetupStepsError } from "../utils/errorMessage.js";
import {
LINUX_ARM_BROWSER_STEPS,
normalizeErrorMessage,
SetupStepsError,
} from "../utils/errorMessage.js";
import { runRenderSetupWorker } from "../utils/cancellableProcess.js";
import { unzipArchive } from "./unzipArchive.js";
import {
@@ -526,10 +530,7 @@ async function ensureLinuxArmBrowser(options?: EnsureBrowserOptions): Promise<Br
// Could not auto-install — give clear manual instructions.
throw new SetupStepsError(
`Chrome Headless Shell is not available for Linux ARM64 (DGX Spark, GB10, Jetson).`,
`Install Chromium manually and point hyperframes to it:\n\n` +
` sudo apt-get install -y chromium-browser\n` +
` export HYPERFRAMES_BROWSER_PATH=$(which chromium-browser)\n\n` +
`Then re-run your command. The HYPERFRAMES_BROWSER_PATH env var persists for the session.`,
LINUX_ARM_BROWSER_STEPS,
);
}
+67
View File
@@ -24,6 +24,7 @@ vi.mock("../telemetry/events.js", () => ({
import { contrastRatio, parseColorRGBA } from "./contrast-bg.js";
import { createCheckCommand, parseCheckRange, parseSafeZone } from "./check.js";
import { assertKnownFlags } from "../utils/reject-unknown-flags.js";
import { LINUX_ARM_BROWSER_STEPS } from "../utils/errorMessage.js";
import { readConfig } from "../telemetry/config.js";
import {
CheckCopiesUnfinishedError,
@@ -528,6 +529,72 @@ describe("check --prepare-media", () => {
expect(human).toContain("video\\x1b]0;x\\x07\\x1b[2J");
consumeCommandResult();
});
// fails without the fix: the setup commands were joined to the reason with `\x0a`
it("prints the setup commands of a failed check on lines of their own", async () => {
const reason = `No browser\nhere\n\n${LINUX_ARM_BROWSER_STEPS} (while launching)`;
const error = vi.spyOn(console, "error").mockImplementation(() => undefined);
const log = vi.spyOn(console, "log").mockImplementation(() => undefined);
const run = (rawArgs: string[]) =>
runCommand(
createCheckCommand({
resolveProject: () => PROJECT,
runPipeline: vi.fn(async () => Promise.reject(new Error(reason))),
prepareMedia: vi.fn(async () => []),
withMeta: (value) => value,
}),
{ rawArgs },
).then(consumeCommandResult);
await run([]);
await run(["--json"]);
const { report } = await runScenario(fakeDriver());
const finding = { ...runtimeError(), code: "check_runtime_failure", message: reason };
await runCommand(
createCheckCommand({
resolveProject: () => PROJECT,
runPipeline: async () => ({
...report,
runtime: { ...report.runtime, ok: false, errorCount: 1, findings: [finding] },
}),
prepareMedia: vi.fn(),
withMeta: (value) => value,
}),
{ rawArgs: [] },
).then(consumeCommandResult);
const human = log.mock.calls.map((call) => call.join(" ")).join("\n");
expect(human).toContain("check_runtime_failure: No browser\\x0ahere (while launching)\n");
expect(human).toContain(`\n\n${LINUX_ARM_BROWSER_STEPS}\n`);
const printed = error.mock.calls.map((call) => call.join(" ")).join("\n");
expect(printed).toContain(
`Check failed: No browser\\x0ahere (while launching)\n\n${LINUX_ARM_BROWSER_STEPS}\n`,
);
const answer = log.mock.calls.map((call) => String(call[0])).find((text) => text[0] === "{");
expect(JSON.parse(answer!).error.message).toBe(reason);
});
it("keeps a finding with another code on one line even when it carries the setup text", async () => {
const message = `From the page\n\n${LINUX_ARM_BROWSER_STEPS}`;
const log = vi.spyOn(console, "log").mockImplementation(() => undefined);
const { report } = await runScenario(fakeDriver());
const finding = { ...runtimeError(), message };
expect(finding.code).not.toBe("check_runtime_failure");
await runCommand(
createCheckCommand({
resolveProject: () => PROJECT,
runPipeline: async () => ({
...report,
runtime: { ...report.runtime, ok: false, errorCount: 1, findings: [finding] },
}),
prepareMedia: vi.fn(),
withMeta: (value) => value,
}),
{ rawArgs: [] },
).then(consumeCommandResult);
const human = log.mock.calls.map((call) => call.join(" ")).join("\n");
expect(human).toContain(`${finding.code}: ${message.replaceAll("\n", "\\x0a")}\n`);
expect(human).not.toContain(LINUX_ARM_BROWSER_STEPS);
});
});
describe("skip contrast in motion", () => {
+10 -5
View File
@@ -20,7 +20,7 @@ import type { Example } from "./_examples.js";
import { parseAt } from "./layout.js";
import { c } from "../ui/colors.js";
import { registerBrowserSessionCleanup } from "../browser/launch.js";
import { normalizeErrorMessage } from "../utils/errorMessage.js";
import { normalizeErrorMessage, splitStepsWrittenByCli } from "../utils/errorMessage.js";
import { CliUsageError, failUsage, setCommandExitCode } from "../utils/commandResult.js";
import { swallowedFlagUsageError } from "../utils/reject-unknown-flags.js";
import { formatLayoutIssue } from "../utils/layoutAudit.js";
@@ -422,7 +422,9 @@ function reportCheckFailure(
const code = usage ? error.code : "runtime_error";
console.log(JSON.stringify(addMeta(jsonFailure(code, message)), null, 2));
} else {
console.error(`${c.error("✗")} Check failed: ${terminalText(message)}`);
const { summary, stepsWrittenByCli } = splitStepsWrittenByCli(message);
console.error(`${c.error("✗")} Check failed: ${terminalText(summary)}`);
if (stepsWrittenByCli) console.error(`\n${stepsWrittenByCli}\n`);
}
if (usage) failUsage();
setCommandExitCode(1);
@@ -902,10 +904,13 @@ function printSnapshotSection(report: CheckReport): void {
function printFinding(finding: CheckFinding): void {
const where = `${terminalText(finding.sourceFile)} ${terminalText(finding.selector)} ${formatFindingTimes(finding)}`;
console.log(
` ${findingIcon(finding)} ${terminalText(finding.code)}: ${terminalText(finding.message)}`,
);
const { summary, stepsWrittenByCli } =
finding.code === "check_runtime_failure"
? splitStepsWrittenByCli(finding.message)
: { summary: finding.message, stepsWrittenByCli: undefined };
console.log(` ${findingIcon(finding)} ${terminalText(finding.code)}: ${terminalText(summary)}`);
console.log(` ${c.dim(where)}`);
if (stepsWrittenByCli) console.log(`\n${stepsWrittenByCli}\n`);
if (finding.fixHint) console.log(` ${c.dim(`Fix: ${terminalText(finding.fixHint)}`)}`);
}
@@ -22,6 +22,7 @@ import {
shouldIgnoreHttpError,
} from "./validate.js";
import { waitForPreferredSeekTarget } from "../capture/captureCompositionFrame.js";
import { LINUX_ARM_BROWSER_STEPS } from "../utils/errorMessage.js";
import type { ProjectLintResult } from "../utils/lintProject.js";
// validateInBrowser lazy-loads the producer localize helpers via loadProducer;
@@ -441,6 +442,24 @@ describe("validate text report", () => {
}
});
// fails without the fix: the setup commands were joined to the reason with `\x0a`
it("prints the setup commands of a failed run on lines of their own", () => {
const reason = `No browser\nhere\n\n${LINUX_ARM_BROWSER_STEPS}`;
const error = vi.spyOn(console, "error").mockImplementation(() => {});
const log = vi.spyOn(console, "log").mockImplementation(() => {});
try {
emitFailureReport(reason, false);
emitFailureReport(reason, true);
expect(error.mock.calls.map((args) => args.join(" ")).join("\n")).toContain(
`No browser\\x0ahere\n\n${LINUX_ARM_BROWSER_STEPS}\n`,
);
expect(JSON.parse(String(log.mock.calls.at(-1)![0])).error.message).toBe(reason);
} finally {
error.mockRestore();
log.mockRestore();
}
});
it("prints a failure message with control characters as visible escapes", () => {
const error = vi.spyOn(console, "error").mockImplementation(() => {});
try {
+4 -2
View File
@@ -12,7 +12,7 @@ import { tmpdir } from "node:os";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { resolveProject, type ProjectDir } from "../utils/project.js";
import { normalizeErrorMessage } from "../utils/errorMessage.js";
import { normalizeErrorMessage, splitStepsWrittenByCli } from "../utils/errorMessage.js";
import type { ProjectLintResult } from "../utils/lintProject.js";
import { resolveCompositionViewportFromHtml } from "../utils/compositionViewport.js";
import {
@@ -657,7 +657,9 @@ export function emitFailureReport(message: string, asJson: boolean): void {
);
return;
}
console.error(`${c.error("✗")} ${terminalText(message)}`);
const { summary, stepsWrittenByCli } = splitStepsWrittenByCli(message);
console.error(`${c.error("✗")} ${terminalText(summary)}`);
if (stepsWrittenByCli) console.error(`\n${stepsWrittenByCli}\n`);
}
export default defineCommand({
+19
View File
@@ -21,6 +21,25 @@ export class SetupStepsError extends Error {
}
}
export const LINUX_ARM_BROWSER_STEPS =
`Install Chromium manually and point hyperframes to it:\n\n` +
` sudo apt-get install -y chromium-browser\n` +
` export HYPERFRAMES_BROWSER_PATH=$(which chromium-browser)\n\n` +
`Then re-run your command. The HYPERFRAMES_BROWSER_PATH env var persists for the session.`;
export function splitStepsWrittenByCli(message: string): {
summary: string;
stepsWrittenByCli?: string;
} {
const joined = `\n\n${LINUX_ARM_BROWSER_STEPS}`;
const at = message.indexOf(joined);
if (at === -1) return { summary: message };
return {
summary: message.slice(0, at) + message.slice(at + joined.length),
stepsWrittenByCli: LINUX_ARM_BROWSER_STEPS,
};
}
export function normalizeErrorMessage(error: unknown): string {
if (error instanceof Error) return namedAfterCrash(error.message);
if (typeof error === "string") return error;