From af0664c8f5ee4e51a788031dca3d421248571a01 Mon Sep 17 00:00:00 2001 From: James Russo Date: Sat, 21 Nov 2026 06:27:45 +0000 Subject: [PATCH] fix(cli): show control characters as text in cloudrun and cloud printed lines (#8350) The cloudrun commands and the remaining cloud render and cloud delete lines now pass quoted text through terminalText / terminalLines before printing, including the adapter notice callbacks and the confirm question. JSON output is unchanged. Co-authored-by: Claude Fable 5.2 --- packages/cli/src/commands/cloud/delete.ts | 2 +- .../commands/cloud/render.terminal.test.ts | 68 +++++ packages/cli/src/commands/cloud/render.ts | 12 +- .../src/commands/cloud/terminalOutput.test.ts | 20 ++ .../cli/src/commands/cloudrun.output.test.ts | 251 ++++++++++++++++++ packages/cli/src/commands/cloudrun.ts | 55 ++-- 6 files changed, 377 insertions(+), 31 deletions(-) create mode 100644 packages/cli/src/commands/cloudrun.output.test.ts diff --git a/packages/cli/src/commands/cloud/delete.ts b/packages/cli/src/commands/cloud/delete.ts index 2fbed97ac4..3448050e8a 100644 --- a/packages/cli/src/commands/cloud/delete.ts +++ b/packages/cli/src/commands/cloud/delete.ts @@ -91,7 +91,7 @@ export default defineCommand({ async function confirmDelete(id: string): Promise { const clack = await import("../../ui/prompts.js"); const answer = await clack.confirm({ - message: `Delete render ${id}? This is irreversible.`, + message: `Delete render ${terminalText(id)}? This is irreversible.`, initialValue: false, }); return answer === true; diff --git a/packages/cli/src/commands/cloud/render.terminal.test.ts b/packages/cli/src/commands/cloud/render.terminal.test.ts index 3f88b09d2f..ace2cb6c53 100644 --- a/packages/cli/src/commands/cloud/render.terminal.test.ts +++ b/packages/cli/src/commands/cloud/render.terminal.test.ts @@ -163,4 +163,72 @@ describe.skipIf(process.platform === "win32")("cloud render on a terminal", () = await new Promise((resolve) => server.close(() => resolve())); } }); + + // fails without the fix: the asset id, the render id, the status and the download path are printed as they arrived. + it("prints reply ids, the status and the download path with control characters as visible escapes", async () => { + const odd = `${esc}[2Jx${String.fromCharCode(7)}`; + const shown = "\\x1b[2Jx\\x07"; + const renderId = `hfr${odd}`; + let polls = 0; + const server = createServer((request, response) => { + request.resume(); + request.on("end", () => { + const path = request.url ?? ""; + response.setHeader("content-type", "application/json"); + if (path === "/v3/assets/direct-uploads") { + const data = { + asset_id: `asst${odd}`, + upload_url: `${baseUrl}/upload`, + upload_headers: {}, + }; + return response.end(JSON.stringify({ data })); + } + if (path === "/upload") return response.end("{}"); + if (path.endsWith("/complete")) { + const data = { asset_id: `asst${odd}`, url: `${baseUrl}/project.zip` }; + return response.end(JSON.stringify({ data })); + } + if (path === "/video") return response.end("video"); + if (request.method === "POST") { + response.statusCode = 202; + return response.end(JSON.stringify({ data: { render_id: renderId } })); + } + const detail = + ++polls === 1 + ? { render_id: renderId, status: `waiting${odd}`, format: "mp4" } + : { + render_id: renderId, + status: "completed", + format: "mp4", + video_url: `${baseUrl}/video`, + }; + response.end(JSON.stringify({ data: detail })); + }); + }); + server.listen(0, "127.0.0.1"); + await once(server, "listening"); + const address = server.address(); + if (!address || typeof address === "string") throw new Error("Expected a TCP listener"); + const baseUrl = `http://127.0.0.1:${address.port}`; + vi.stubEnv("HEYGEN_API_URL", baseUrl); + try { + const human = await humanOutput([ + dir, + "--poll-interval", + "1", + "--output", + join(dir, "out.mp4"), + ]); + + expect(human.replace(colors, "")).not.toContain(esc); + expect(human).toContain(`asst${shown}`); + expect(human).toContain(`Polling hfr${shown} every 1s`); + expect(human).toContain(`waiting${shown}`); + expect(human).toContain("Downloading to "); + expect(human).toContain("video\\x1b]0;x\\x07\\x1b[2J/out.mp4"); + } finally { + server.closeAllConnections(); + await new Promise((resolve) => server.close(() => resolve())); + } + }); }); diff --git a/packages/cli/src/commands/cloud/render.ts b/packages/cli/src/commands/cloud/render.ts index 9e86388de0..6e05e29e73 100644 --- a/packages/cli/src/commands/cloud/render.ts +++ b/packages/cli/src/commands/cloud/render.ts @@ -374,15 +374,15 @@ export default defineCommand({ ); } else { console.log(""); - console.log(`${c.success("✓")} Submitted ${c.accent(renderId)}`); - console.log(c.dim(` Poll with: hyperframes cloud get ${renderId}`)); + console.log(`${c.success("✓")} Submitted ${c.accent(terminalText(renderId))}`); + console.log(c.dim(` Poll with: hyperframes cloud get ${terminalText(renderId)}`)); } return; } if (!asJson) { console.log(""); - console.log(c.dim(` Polling ${renderId} every ${pollIntervalMs / 1000}s …`)); + console.log(c.dim(` Polling ${terminalText(renderId)} every ${pollIntervalMs / 1000}s …`)); } const detail = await pollWithProgress(client, renderId, asJson, { @@ -1063,7 +1063,7 @@ async function maybeUploadProject( if (!asJson) { console.log( c.dim( - ` asset_id: ${c.accent(uploaded.asset_id)} · ${formatDuration(Date.now() - uploadStart)}`, + ` asset_id: ${c.accent(terminalText(uploaded.asset_id))} · ${formatDuration(Date.now() - uploadStart)}`, ), ); } @@ -1196,7 +1196,7 @@ export function logsTick( } function formatTickLine(detail: HyperframesRenderDetail, elapsedMs: number): string { - const status = colorStatus(detail.status); + const status = colorStatus(terminalText(detail.status)); return `${status} ${c.dim(formatDuration(elapsedMs))}`; } @@ -1242,7 +1242,7 @@ async function streamVideo( // `downloadToFile` creates the parent directory and preserves existing output on failure. if (!asJson) { console.log(""); - console.log(`${c.accent("◆")} Downloading to ${c.accent(destPath)}`); + console.log(`${c.accent("◆")} Downloading to ${c.accent(terminalText(destPath))}`); } try { const result = await downloadToFile(url, destPath); diff --git a/packages/cli/src/commands/cloud/terminalOutput.test.ts b/packages/cli/src/commands/cloud/terminalOutput.test.ts index 913d35cac4..b1725d5d88 100644 --- a/packages/cli/src/commands/cloud/terminalOutput.test.ts +++ b/packages/cli/src/commands/cloud/terminalOutput.test.ts @@ -12,6 +12,13 @@ vi.mock("../../cloud/index.js", async (importOriginal) => ({ createCloudClient: async () => client, })); +const ask = vi.hoisted(() => ({ confirm: vi.fn() })); +vi.mock("../../ui/prompts.js", () => ask); +vi.mock("../../utils/attendedTerminal.js", async (importOriginal) => ({ + ...(await importOriginal()), + isUnattended: () => false, +})); + const { default: get } = await import("./get.js"); const { default: list } = await import("./list.js"); const { default: remove } = await import("./delete.js"); @@ -99,4 +106,17 @@ describe("cloud subcommands on a terminal", () => { expect(human.replace(colors, "")).not.toContain(esc); expect(human).toContain(`r1${shown}`); }); + + // fails without the fix: the question repeats the id as it was typed. + it("delete asks about an id with control characters as visible escapes", async () => { + ask.confirm.mockResolvedValue(false); + client.deleteRender.mockClear(); + + await expect(output(remove, [`r1${osc}`])).rejects.toThrow("Command failed"); + + expect(ask.confirm).toHaveBeenCalledWith( + expect.objectContaining({ message: `Delete render r1${shown}? This is irreversible.` }), + ); + expect(client.deleteRender).not.toHaveBeenCalled(); + }); }); diff --git a/packages/cli/src/commands/cloudrun.output.test.ts b/packages/cli/src/commands/cloudrun.output.test.ts new file mode 100644 index 0000000000..4aabe75cfc --- /dev/null +++ b/packages/cli/src/commands/cloudrun.output.test.ts @@ -0,0 +1,251 @@ +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { consumeCommandResult } from "../utils/commandResult.js"; + +const ESC = String.fromCharCode(27); +const ODD = `od${ESC}[2Jd\x07`; +const SHOWN = "od\\x1b[2Jd\\x07"; + +const adapter = vi.hoisted(() => ({ + getRenderProgress: vi.fn(), + renderToCloudRun: vi.fn(), + deploySite: vi.fn(), + getTerraformModuleDir: vi.fn(), + spawnSync: vi.fn(), +})); +vi.mock("@hyperframes/gcp-cloud-run/sdk", () => ({ + getRenderProgress: adapter.getRenderProgress, + renderToCloudRun: adapter.renderToCloudRun, + deploySite: adapter.deploySite, +})); +vi.mock("@hyperframes/gcp-cloud-run/terraform", () => ({ + getTerraformModuleDir: adapter.getTerraformModuleDir, +})); +vi.mock("node:child_process", async (importOriginal) => ({ + ...(await importOriginal()), + spawnSync: adapter.spawnSync, +})); + +const { default: cloudrunCommand } = await import("./cloudrun.js"); + +const lines: string[] = []; +let work: string; + +const printed = (): string => lines.join("\n").replace(new RegExp(`${ESC}\\[[0-9;]*m`, "g"), ""); + +function expectNoControlCharacters(): void { + expect(printed()).not.toContain(ESC); + expect(printed()).not.toContain("\x07"); +} + +function run(args: Record): Promise { + return Promise.resolve( + cloudrunCommand.run?.({ args, rawArgs: [], cmd: cloudrunCommand } as never), + ); +} + +function progress(over: Record): Record { + return { + status: "succeeded", + overallProgress: 1, + framesRendered: 30, + totalFrames: 30, + costs: { displayCost: "$0.01" }, + outputFile: null, + errors: [], + ...over, + }; +} + +const size = { width: "1920", height: "1080", fps: "30" }; + +beforeEach(() => { + lines.length = 0; + work = mkdtempSync(join(tmpdir(), "hf-cloudrun-output-")); + vi.stubEnv("HYPERFRAMES_CONFIG_DIR", join(work, "config")); + mkdirSync(join(work, "config")); + writeFileSync( + join(work, "config", "cloudrun-state.json"), + JSON.stringify({ + projectId: "demo", + region: "us-central1", + bucketName: "demo-bucket", + serviceUrl: "https://demo.example", + workflowId: "demo-workflow", + }), + ); + for (const method of ["log", "error", "warn"] as const) + vi.spyOn(console, method).mockImplementation((...args: unknown[]) => { + lines.push(args.join(" ")); + }); + vi.spyOn(process.stdout, "write").mockImplementation((chunk: unknown) => { + lines.push(String(chunk)); + return true; + }); + for (const fake of Object.values(adapter)) fake.mockReset(); +}); + +afterEach(() => { + consumeCommandResult(); + vi.restoreAllMocks(); + vi.unstubAllEnvs(); + rmSync(work, { recursive: true, force: true }); +}); + +describe("cloudrun output for people", () => { + // fails without the fix: the subcommand is repeated as it was typed. + it("shows control characters in an unknown subcommand as text", async () => { + await expect(run({ subcommand: `ren${ODD}der` })).rejects.toThrow(); + expect(printed()).toContain(`Unknown subcommand: ren${SHOWN}der`); + expectNoControlCharacters(); + }); + + // fails without the fix: the verb is repeated as it was typed. + it("shows control characters in an unknown sites verb as text", async () => { + await expect(run({ subcommand: "sites", target: `cre${ODD}ate` })).rejects.toThrow(); + expect(printed()).toContain(`unknown verb "cre${SHOWN}ate"`); + expectNoControlCharacters(); + }); + + // fails without the fix: the notice and the site rows are printed as they arrived. + it("sites create shows control characters in a notice and the reply as text", async () => { + adapter.deploySite.mockImplementation(async (options: { onNotice?: (m: string) => void }) => { + options.onNotice?.(`left out ${ODD}\nsecond line`); + return { siteId: `site-${ODD}`, projectGcsUri: `gs://site/${ODD}`, bytes: 3, uploaded: true }; + }); + await run({ subcommand: "sites", target: "create", extra: join(work, "project") }); + expect(printed()).toContain(`left out ${SHOWN}\nsecond line`); + expect(printed()).toContain(`site=site-${SHOWN} (3 bytes)`); + expect(printed()).toContain(`gs://site/${SHOWN}`); + expectNoControlCharacters(); + }); + + // fails without the fix: the notice and the started render's rows are printed as they arrived. + it("render shows control characters in a notice and the started render as text", async () => { + adapter.renderToCloudRun.mockImplementation( + async (options: { onNotice?: (m: string) => void }) => { + options.onNotice?.(`left out ${ODD}`); + return { + renderId: `id-${ODD}`, + outputGcsUri: `gs://out/${ODD}`, + executionName: `exec-${ODD}`, + }; + }, + ); + await run({ subcommand: "render", target: join(work, "project"), ...size }); + for (const shown of ["left out ", "renderId=id-", "gs://out/", "cloudrun progress exec-"]) + expect(printed()).toContain(`${shown}${SHOWN}`); + expectNoControlCharacters(); + }); + + // fails without the fix: the status while waiting, the output address and the cost are printed as they arrived. + it("render --wait shows control characters in the status and the finished output as text", async () => { + adapter.renderToCloudRun.mockResolvedValue({ + renderId: "id", + outputGcsUri: "gs://out", + executionName: "exec", + }); + adapter.getRenderProgress + .mockResolvedValueOnce(progress({ status: "running" })) + .mockResolvedValueOnce( + progress({ + status: "succeeded", + outputFile: { gcsUri: `gs://done/${ODD}` }, + costs: { displayCost: `$1 ${ODD}` }, + }), + ); + await run({ + subcommand: "render", + target: join(work, "project"), + ...size, + wait: true, + "wait-interval-ms": "1", + }); + expect(printed()).toContain(`gs://done/${SHOWN} ($1 ${SHOWN})`); + expectNoControlCharacters(); + + lines.length = 0; + adapter.getRenderProgress + .mockResolvedValueOnce(progress({ status: "running" })) + .mockResolvedValueOnce( + progress({ + status: `lost${ODD}`, + errors: [{ state: `Chunk${ODD}`, cause: `why ${ODD}\nmore` }], + }), + ); + await expect( + run({ + subcommand: "render", + target: join(work, "project"), + ...size, + wait: true, + "wait-interval-ms": "1", + }), + ).rejects.toThrow("Command failed"); + expect(printed()).toContain(`status=lost${SHOWN} `); + expect(printed()).toContain(`✗ render lost${SHOWN}`); + expect(printed()).toContain(`Chunk${SHOWN}: why ${SHOWN}\nmore`); + expectNoControlCharacters(); + }); + + // fails without the fix: the status, output address, cost and failure rows are printed as they arrived. + it("progress shows control characters in a reply as text", async () => { + adapter.getRenderProgress.mockResolvedValue( + progress({ + status: `fail${ODD}`, + outputFile: { gcsUri: `gs://done/${ODD}` }, + costs: { displayCost: `$1 ${ODD}` }, + errors: [{ state: `Render${ODD}`, cause: `why ${ODD}\nmore` }], + }), + ); + await run({ subcommand: "progress", target: "exec-1" }); + expect(printed()).toContain(`status=fail${SHOWN} progress=100%`); + expect(printed()).toContain(`output=gs://done/${SHOWN}`); + expect(printed()).toContain(`cost=$1 ${SHOWN}`); + expect(printed()).toContain(`error Render${SHOWN}: why ${SHOWN}\nmore`); + expectNoControlCharacters(); + }); + + // fails without the fix: the batch path is repeated as it was typed. + it("render-batch shows control characters in a missing batch path as text", async () => { + await expect( + run({ subcommand: "render-batch", target: "project", batch: `no${ODD}.jsonl`, ...size }), + ).rejects.toThrow(); + expect(printed()).toContain(`batch file not found: no${SHOWN}.jsonl`); + expectNoControlCharacters(); + }); + + // fails without the fix: the notice and each failed row's key and reason are printed as they arrived. + it("render-batch shows control characters in a notice and a failed row as text", async () => { + const batch = join(work, "batch.jsonl"); + writeFileSync(batch, JSON.stringify({ outputKey: `key-${ODD}` })); + adapter.deploySite.mockImplementation(async (options: { onNotice?: (m: string) => void }) => { + options.onNotice?.(`left out ${ODD}`); + return { siteId: "site", projectGcsUri: "gs://site", bytes: 3, uploaded: true }; + }); + adapter.renderToCloudRun.mockRejectedValue(new Error(`refused ${ODD}\nsecond line`)); + await expect( + run({ subcommand: "render-batch", target: join(work, "project"), batch, ...size }), + ).rejects.toThrow("Command failed"); + expect(printed()).toContain(`left out ${SHOWN}`); + expect(printed()).toContain(`✗ key-${SHOWN}: refused ${SHOWN}\nsecond line`); + expectNoControlCharacters(); + }); + + // fails without the fix: the project, the image built from it and the stack's outputs are printed as they arrived. + it("deploy shows control characters in the project, the image and the outputs as text", async () => { + const terraformDir = join(work, "repo", "packages", "gcp-cloud-run", "terraform"); + mkdirSync(terraformDir, { recursive: true }); + writeFileSync(join(work, "repo", "packages", "gcp-cloud-run", "Dockerfile"), ""); + adapter.getTerraformModuleDir.mockReturnValue(terraformDir); + adapter.spawnSync.mockReturnValue({ status: 0, stdout: `out-${ODD}`, stderr: "" }); + await run({ subcommand: "deploy", project: `proj${ODD}` }); + expect(printed()).toContain(`Enabling required APIs on proj${SHOWN}`); + expect(printed()).toContain(`us-central1-docker.pkg.dev/proj${SHOWN}/hyperframes/`); + expect(printed()).toContain(`bucket=out-${SHOWN} workflow=out-${SHOWN}`); + expect(printed()).toContain(`service=out-${SHOWN}`); + expectNoControlCharacters(); + }); +}); diff --git a/packages/cli/src/commands/cloudrun.ts b/packages/cli/src/commands/cloudrun.ts index 8d0be08d2c..03d56d1655 100644 --- a/packages/cli/src/commands/cloudrun.ts +++ b/packages/cli/src/commands/cloudrun.ts @@ -18,7 +18,7 @@ import { type SpawnSyncReturns, spawnSync } from "node:child_process"; import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { join, resolve } from "node:path"; import { defineCommand } from "../utils/defineCommand.js"; -import { type CanvasResolution } from "@hyperframes/core"; +import { type CanvasResolution, terminalLines, terminalText } from "@hyperframes/core"; import { parseOutputResolutionFlag } from "../utils/parseOutputResolution.js"; import type { Example } from "./_examples.js"; import { c } from "../ui/colors.js"; @@ -265,7 +265,7 @@ export default defineCommand({ case "destroy": return runDestroy(args); default: - console.error(`${c.error("Unknown subcommand:")} ${subcommand}\n${HELP}`); + console.error(`${c.error("Unknown subcommand:")} ${terminalText(subcommand)}\n${HELP}`); failUsage(); } }, @@ -348,7 +348,7 @@ async function runDeploy(args: Record): Promise { const tfDir = getTerraformModuleDir(); const repoRoot = findRepoRoot(tfDir); - console.log(`→ Enabling required APIs on ${project}`); + console.log(`→ Enabling required APIs on ${terminalText(project)}`); run("gcloud", [ "services", "enable", @@ -401,7 +401,7 @@ async function runDeploy(args: Record): Promise { .replace(/[^0-9]/g, "") .slice(0, 14); image = `${region}-docker.pkg.dev/${project}/${repo}/hyperframes-render:${tag}`; - console.log(`→ Building + pushing ${image} via Cloud Build`); + console.log(`→ Building + pushing ${terminalText(image)} via Cloud Build`); run("gcloud", [ "builds", "submit", @@ -431,8 +431,10 @@ async function runDeploy(args: Record): Promise { workflowId: capture("terraform", ["output", "-raw", "workflow_name"], { cwd: tfDir }), }; writeState(state); - console.log(`${c.accent("✓ deployed.")} bucket=${state.bucketName} workflow=${state.workflowId}`); - console.log(` service=${state.serviceUrl}`); + console.log( + `${c.accent("✓ deployed.")} bucket=${terminalText(state.bucketName)} workflow=${terminalText(state.workflowId)}`, + ); + console.log(` service=${terminalText(state.serviceUrl)}`); console.log( ` Next: ${c.accent("hyperframes cloudrun render ./my-project --width 1920 --height 1080 --wait")}`, ); @@ -503,7 +505,7 @@ function writeCloudBuildConfig(image: string): string { async function runSites(args: Record): Promise { if (args.target !== "create") { console.error( - `[cloudrun sites] unknown verb "${String(args.target)}". Only "create" is supported.`, + `[cloudrun sites] unknown verb "${terminalText(String(args.target))}". Only "create" is supported.`, ); failUsage(); } @@ -519,14 +521,14 @@ async function runSites(args: Record): Promise { bucketName: state.bucketName, siteId: args["site-id"] as string | undefined, includeOutsideFiles: args["include-outside-files"] === true, - onNotice: (message) => console.error(message), + onNotice: (message) => console.error(terminalLines(message)), }); if (args.json) { console.log(JSON.stringify(handle, null, 2)); } else { console.log( `${handle.uploaded ? c.accent("✓ uploaded") : c.dim("• already present")} ` + - `site=${handle.siteId} (${handle.bytes} bytes)\n ${handle.projectGcsUri}`, + `site=${terminalText(handle.siteId)} (${handle.bytes} bytes)\n ${terminalText(handle.projectGcsUri)}`, ); } } @@ -571,7 +573,7 @@ async function runRender(args: Record): Promise { const handle = await renderToCloudRun({ projectDir: resolve(projectDir), includeOutsideFiles: args["include-outside-files"] === true, - onNotice: (message) => console.error(message), + onNotice: (message) => console.error(terminalLines(message)), config: config as Parameters[0]["config"], bucketName: state.bucketName, projectId: state.projectId, @@ -585,10 +587,10 @@ async function runRender(args: Record): Promise { if (!args.wait) { if (args.json) console.log(JSON.stringify(handle, null, 2)); else { - console.log(`${c.accent("✓ render started")} renderId=${handle.renderId}`); - console.log(` output → ${handle.outputGcsUri}`); + console.log(`${c.accent("✓ render started")} renderId=${terminalText(handle.renderId)}`); + console.log(` output → ${terminalText(handle.outputGcsUri)}`); console.log( - ` progress: ${c.accent(`hyperframes cloudrun progress ${handle.executionName}`)}`, + ` progress: ${c.accent(`hyperframes cloudrun progress ${terminalText(handle.executionName)}`)}`, ); } return; @@ -598,18 +600,19 @@ async function runRender(args: Record): Promise { while (progress.status === "running") { await new Promise((r) => setTimeout(r, intervalMs)); progress = await getRenderProgress({ executionName: handle.executionName }); - if (!args.json) process.stdout.write(`\r status=${progress.status} `); + if (!args.json) process.stdout.write(`\r status=${terminalText(progress.status)} `); } if (!args.json) process.stdout.write("\n"); if (args.json) { console.log(JSON.stringify(progress, null, 2)); } else if (progress.status === "succeeded") { console.log( - `${c.accent("✓ done.")} ${progress.outputFile?.gcsUri} (${progress.costs.displayCost})`, + `${c.accent("✓ done.")} ${terminalText(String(progress.outputFile?.gcsUri))} (${terminalText(progress.costs.displayCost)})`, ); } else { - console.error(`${c.error("✗ render " + progress.status)}`); - for (const e of progress.errors) console.error(` ${e.state}: ${e.cause}`); + console.error(`${c.error("✗ render " + terminalText(progress.status))}`); + for (const e of progress.errors) + console.error(` ${terminalText(e.state)}: ${terminalLines(e.cause)}`); failCommand(); } } @@ -629,12 +632,15 @@ async function runProgress(args: Record): Promise { console.log(JSON.stringify(progress, null, 2)); return; } - console.log(`status=${progress.status} progress=${(progress.overallProgress * 100).toFixed(0)}%`); + console.log( + `status=${terminalText(progress.status)} progress=${(progress.overallProgress * 100).toFixed(0)}%`, + ); if (progress.totalFrames) console.log(`frames=${progress.framesRendered}/${progress.totalFrames}`); - if (progress.outputFile) console.log(`output=${progress.outputFile.gcsUri}`); - console.log(`cost=${progress.costs.displayCost}`); - for (const e of progress.errors) console.error(` error ${e.state}: ${e.cause}`); + if (progress.outputFile) console.log(`output=${terminalText(progress.outputFile.gcsUri)}`); + console.log(`cost=${terminalText(progress.costs.displayCost)}`); + for (const e of progress.errors) + console.error(` error ${terminalText(e.state)}: ${terminalLines(e.cause)}`); } // ── render-batch ──────────────────────────────────────────────────────────── @@ -672,7 +678,7 @@ async function runRenderBatch(args: Record): Promise { const fps = resolveCloudRunFps(args, projectDir, "render-batch"); buildRenderConfig(args, fps, width, height, undefined); if (!existsSync(resolve(batchPath))) { - console.error(`[cloudrun render-batch] batch file not found: ${batchPath}`); + console.error(`[cloudrun render-batch] batch file not found: ${terminalText(batchPath)}`); failCommand(); } const entries = parseBatchFile(resolve(batchPath)); @@ -704,7 +710,7 @@ async function runRenderBatch(args: Record): Promise { bucketName: state.bucketName, siteId: args["site-id"] as string | undefined, includeOutsideFiles: args["include-outside-files"] === true, - onNotice: (message) => console.error(message), + onNotice: (message) => console.error(terminalLines(message)), }); const results: Array<{ outputKey: string; executionName?: string; error?: string }> = []; @@ -745,7 +751,8 @@ async function runRenderBatch(args: Record): Promise { console.log( `${c.accent("✓ started")} ${results.length - failed.length}/${results.length} renders`, ); - for (const r of failed) console.error(` ✗ ${r.outputKey}: ${r.error}`); + for (const r of failed) + console.error(` ✗ ${terminalText(r.outputKey)}: ${terminalLines(r.error ?? "")}`); } if (failed.length > 0) failCommand(); }