Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7c83961
fix(cli): batch render outputs stay inside the --output folder
michaelwang11394 Nov 14, 2026
d047a58
fix(cli): project text shows control characters as visible escapes
michaelwang11394 Nov 14, 2026
661130a
fix(studio-server): waveform and peaks key one cache entry per file a…
michaelwang11394 Nov 14, 2026
7425954
fix(studio-server): preview stills run at most four at a time
michaelwang11394 Nov 14, 2026
60266c0
fix(cli): batch output folder check keeps backslash names and row-nam…
michaelwang11394 Nov 15, 2026
b0e3049
fix(cli): lint header shows control characters in file names as escapes
michaelwang11394 Nov 15, 2026
4c47513
fix(studio-server): a finished or in-progress still never waits for a…
michaelwang11394 Nov 15, 2026
96959aa
chore: raise the studio-server packed budget to 172000
michaelwang11394 Nov 15, 2026
9ec0d32
fix(core,studio-server): a preview served to another site offers no e…
michaelwang11394 Nov 15, 2026
3f3c735
fix(studio-server): a media still stops when no request waits on it
michaelwang11394 Nov 15, 2026
0448d37
test(studio-server): group the still cancellation tests after the rea…
michaelwang11394 Nov 15, 2026
2c18b57
fix(studio-server): a preview framed by another site is never revalid…
michaelwang11394 Nov 15, 2026
7c1c8fb
Merge pull request #7793 from heygen-com/sec-hf5-1114
michaelwang11394 Nov 15, 2026
80569b9
fix(cli): check findings and keyframes headers show control character…
michaelwang11394 Nov 15, 2026
f42c0ec
test(studio-server): a request sharing an abandoned still waiter gets…
michaelwang11394 Nov 15, 2026
39e8e23
chore(studio-server): raise the unpacked size budget for the still jo…
michaelwang11394 Nov 15, 2026
0147050
Merge origin/main into sec-studio4-1114
michaelwang11394 Nov 15, 2026
07c8cae
Merge origin/main into sec-studio4-1114
michaelwang11394 Nov 15, 2026
e5dced6
fix(cli): layout and contrast lines in check show control characters …
michaelwang11394 Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/concepts/variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ npx hyperframes render \
--output "renders/{name}.mp4"
```

Every output stays inside the folder written before the first placeholder
(`renders/` here). A row value may name a subfolder of it, but a value that
leads outside it, such as `../other`, stops the batch before anything renders.
A template that starts with a placeholder, such as `--output "{path}"`, names
no folder, so each row's value is used as the whole output path, absolute
paths included.

Start with the default single-row concurrency. Increase `--batch-concurrency`
only after one real render is stable and the machine has enough memory for
several renders at once.
Expand Down
66 changes: 66 additions & 0 deletions packages/cli/src/commands/batchRender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,72 @@ describe("prepareBatchRender", () => {
expect(prepared.manifestPath).toBe(resolve(outDir, "manifest.json"));
});

it("keeps row values that name subfolders inside the --output folder", () => {
const batchPath = writeJson("rows.json", '[{"name":"eu/acme"},{"name":"x/../northstar"}]');
const outDir = join(tmpDir, "renders");
const prepared = prepareBatchRender({
batchPath,
outputTemplate: join(outDir, "{name}.mp4"),
indexPath: writeIndex(),
strictVariables: false,
quiet: true,
json: false,
});

expect(prepared.rows.map((row) => row.outputPath)).toEqual([
resolve(outDir, "eu", "acme.mp4"),
resolve(outDir, "northstar.mp4"),
]);
});

it.each([
{ template: join("renders", "{name}.mp4"), name: "../escaped" },
{ template: join("renders", "v{name}.mp4"), name: "/../../escaped" },
])("refuses a row value that leaves the folder of $template", ({ template, name }) => {
const batchPath = writeJson("rows.json", JSON.stringify([{ name }]));
const error = expectBatchError(
() =>
prepareBatchRender({
batchPath,
outputTemplate: join(tmpDir, template),
indexPath: writeIndex(),
strictVariables: false,
quiet: true,
json: false,
}),
"Batch output outside --output folder",
);
expect(error.message).toMatch(/Row 0 resolves to/);
});

it("keeps a backslash in a row value or file name on every platform", () => {
const batchPath = writeJson("rows.json", '[{"name":"a\\\\b"}]');
const outDir = join(tmpDir, "renders\\");
const prepared = prepareBatchRender({
batchPath,
outputTemplate: `${outDir}{name}.mp4`,
indexPath: writeIndex(),
strictVariables: false,
quiet: true,
json: false,
});
expect(prepared.rows[0]?.outputPath).toBe(resolve(`${outDir}a\\b.mp4`));
});

it("lets the rows name the whole path when the template starts with a placeholder", () => {
const elsewhere = join(tmpDir, "elsewhere", "launch.mp4");
const batchPath = writeJson("rows.json", JSON.stringify([{ path: elsewhere }]));
const prepared = prepareBatchRender({
batchPath,
outputTemplate: "{path}",
indexPath: writeIndex(),
strictVariables: false,
quiet: true,
json: false,
});
expect(prepared.rows[0]?.outputPath).toBe(resolve(elsewhere));
});

it("rejects output collisions before rendering", () => {
const batchPath = writeJson("rows.json", '[{"name":"Alice"},{"name":"Bob"}]');
const error = expectBatchError(
Expand Down
23 changes: 22 additions & 1 deletion packages/cli/src/commands/batchRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { failCommand } from "../utils/commandResult.js";
import { writeFileSync } from "node:fs";
import { makeOutputFolder } from "../utils/outputFolder.js";
import { readJsonFileText } from "../utils/jsonFlag.js";
import { dirname, join, resolve, sep } from "node:path";
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
import { c } from "../ui/colors.js";
import { errorBox } from "../ui/format.js";
import { normalizeErrorMessage as errorMessage } from "../utils/errorMessage.js";
Expand Down Expand Up @@ -155,6 +155,26 @@ export function resolveOutputTemplate(
);
}

function folderOfPrefix(prefix: string): string {
return prefix.endsWith("/") || prefix.endsWith(sep) ? resolve(prefix) : dirname(resolve(prefix));
}

function checkOutputsInsideTemplateFolder(rows: readonly PreparedBatchRow[], template: string) {
const firstPlaceholder = template.search(PLACEHOLDER_RE);
if (firstPlaceholder <= 0) return;
const folder = folderOfPrefix(template.slice(0, firstPlaceholder));
for (const row of rows) {
const rel = relative(folder, row.outputPath);
const outside = rel === "" || rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel);
if (!outside) continue;
throw new BatchRenderInputError(
"Batch output outside --output folder",
`Row ${row.index} resolves to ${row.outputPath}, outside ${folder}.`,
"Row values may name subfolders of the --output folder but not leave it.",
);
}
}

function isSameOrChildPath(path: string, parent: string): boolean {
return path === parent || path.startsWith(parent.endsWith(sep) ? parent : parent + sep);
}
Expand Down Expand Up @@ -262,6 +282,7 @@ export function prepareBatchRender(options: PrepareBatchRenderOptions): Prepared
variables,
outputPath: resolve(resolveOutputTemplate(options.outputTemplate, variables, index)),
}));
checkOutputsInsideTemplateFolder(rows, options.outputTemplate);
const manifestPath = join(
commonOutputDirectory(rows.map((row) => row.outputPath)),
"manifest.json",
Expand Down
76 changes: 75 additions & 1 deletion packages/cli/src/commands/check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import type {
LayoutOverflow,
LayoutRect,
} from "../utils/layoutAudit.js";
import type { CraftFrame, SeekClock } from "../utils/checkTypes.js";
import type { CheckContrastFinding, CraftFrame, SeekClock } from "../utils/checkTypes.js";
import type { ProjectDir } from "../utils/project.js";

const PROJECT: ProjectDir = {
Expand Down Expand Up @@ -803,6 +803,80 @@ it("distinguishes unavailable HDR inspection from no promotion", async () => {
expect(report.hdr).toEqual({ autoPromotion: null, inspection: "unavailable" });
});

it("prints composition text in a finding with its control characters as visible escapes", async () => {
const planted: CheckFinding = {
code: "audio_source_unreadable",
severity: "error",
message: "voice\u001b[2K.wav has no audio",
selector: "#v\u001b]0;t\u0007",
dataAttributes: {},
sourceFile: "scene\u009b2J.html",
fixHint: "use \u001b]52;c;Y2xpcA==\u0007",
bbox: { x: 0, y: 0, width: 0, height: 0 },
time: 1,
};
const { report } = await runScenario(
fakeDriver(),
{},
{ inspectAudio: vi.fn(async () => [planted]) },
);
const log = vi.spyOn(console, "log").mockImplementation(() => undefined);
const command = createCheckCommand({
resolveProject: () => PROJECT,
runPipeline: vi.fn(async () => report),
prepareMedia: vi.fn(async () => []),
withMeta: (value) => value,
});

await runCommand(command, { rawArgs: [] }).catch(() => undefined);

const out = log.mock.calls.map((call) => String(call[0] ?? "")).join("\n");
for (const control of ["\u0007", "\u001b]", "\u001b[2K", "\u009b"])
expect(out).not.toContain(control);
expect(out).toContain("voice\\x1b[2K.wav has no audio");
expect(out).toContain("scene\\x9b2J.html #v\\x1b]0;t\\x07");
expect(out).toContain("Fix: use \\x1b]52;c;Y2xpcA==\\x07");
});

it("prints a contrast finding's selector, colour and source with control characters escaped", async () => {
const planted: CheckContrastFinding = {
code: "contrast_aa_failure",
severity: "error",
message: "low contrast",
selector: "#t\u001b]0;x\u0007",
dataAttributes: {},
sourceFile: "scene\u009b2J.html",
bbox: { x: 0, y: 0, width: 0, height: 0 },
time: 1,
fg: "#777",
bg: "#888",
ratio: 1.2,
requiredRatio: 4.5,
suggestedColor: "#000\u001b[2K",
large: false,
};
const { report } = await runScenario(fakeDriver());
const plantedReport = {
...report,
contrast: { ...report.contrast, enabled: true, findings: [planted], errorCount: 1 },
};
const log = vi.spyOn(console, "log").mockImplementation(() => undefined);
const command = createCheckCommand({
resolveProject: () => PROJECT,
runPipeline: vi.fn(async () => plantedReport),
prepareMedia: vi.fn(async () => []),
withMeta: (value) => value,
});

await runCommand(command, { rawArgs: [] }).catch(() => undefined);

const out = log.mock.calls.map((call) => String(call[0] ?? "")).join("\n");
for (const control of ["\u0007", "\u001b]", "\u001b[2K", "\u009b"])
expect(out).not.toContain(control);
expect(out).toContain("#t\\x1b]0;x\\x07 1.2:1");
expect(out).toContain("Try #000\\x1b[2K; source scene\\x9b2J.html");
});

it("fails the check on an audio error and reports it in its own section", async () => {
const unreadable: CheckFinding = {
code: "audio_source_unreadable",
Expand Down
12 changes: 7 additions & 5 deletions packages/cli/src/commands/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { ArgsDef } from "citty";
import type { Example } from "./_examples.js";
import { parseAt } from "./layout.js";
import { c } from "../ui/colors.js";
import { terminalText } from "../utils/terminalText.js";
import { registerBrowserSessionCleanup } from "../browser/launch.js";
import { normalizeErrorMessage } from "../utils/errorMessage.js";
import { CliUsageError, failUsage, setCommandExitCode } from "../utils/commandResult.js";
Expand Down Expand Up @@ -847,9 +848,10 @@ function printContrastSection(report: CheckReport): void {
}
for (const finding of section.findings) {
console.log(
` ${c.error("✗")} ${finding.selector} ${finding.ratio}:1 (need ${finding.requiredRatio}:1, ${formatFindingTimes(finding)})`,
` ${c.error("✗")} ${terminalText(finding.selector)} ${finding.ratio}:1 (need ${finding.requiredRatio}:1, ${formatFindingTimes(finding)})`,
);
console.log(` ${c.dim(`Try ${finding.suggestedColor}; source ${finding.sourceFile}`)}`);
const source = `Try ${terminalText(finding.suggestedColor)}; source ${terminalText(finding.sourceFile)}`;
console.log(` ${c.dim(source)}`);
}
printCounts(section);
}
Expand Down Expand Up @@ -883,10 +885,10 @@ function printSnapshotSection(report: CheckReport): void {
}

function printFinding(finding: CheckFinding): void {
const where = `${finding.sourceFile} ${finding.selector} ${formatFindingTimes(finding)}`;
console.log(` ${findingIcon(finding)} ${finding.code}: ${finding.message}`);
const where = `${terminalText(finding.sourceFile)} ${terminalText(finding.selector)} ${formatFindingTimes(finding)}`;
console.log(` ${findingIcon(finding)} ${finding.code}: ${terminalText(finding.message)}`);
console.log(` ${c.dim(where)}`);
if (finding.fixHint) console.log(` ${c.dim(`Fix: ${finding.fixHint}`)}`);
if (finding.fixHint) console.log(` ${c.dim(`Fix: ${terminalText(finding.fixHint)}`)}`);
}

function findingIcon(finding: CheckFinding): string {
Expand Down
10 changes: 7 additions & 3 deletions packages/cli/src/commands/compositions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ensureDOMParser } from "../utils/dom.js";
import { resolveProject } from "../utils/project.js";
import { resolveReferencedStart } from "@hyperframes/engine";
import { withMeta } from "../utils/updateCheck.js";
import { terminalText } from "../utils/terminalText.js";

interface CompositionInfo {
id: string;
Expand Down Expand Up @@ -208,16 +209,19 @@ export default defineCommand({
console.log();

// Calculate padding for alignment
const maxIdLen = compositions.reduce((max, comp) => Math.max(max, comp.id.length), 0);
const maxIdLen = compositions.reduce(
(max, comp) => Math.max(max, terminalText(comp.id).length),
0,
);

for (const comp of compositions) {
const id = c.accent(comp.id.padEnd(maxIdLen));
const id = c.accent(terminalText(comp.id).padEnd(maxIdLen));
const duration = c.bold(`${comp.duration.toFixed(1)}s`);
const resolution = c.dim(`${comp.width}×${comp.height}`);
const elements = c.dim(
`${comp.elementCount} ${comp.elementCount === 1 ? "element" : "elements"}`,
);
const source = comp.source ? c.dim(` ← ${comp.source}`) : "";
const source = comp.source ? c.dim(` ← ${terminalText(comp.source)}`) : "";

console.log(` ${id} ${duration} ${resolution} ${elements}${source}`);
}
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/commands/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from "@hyperframes/core/runtime/composition-length";
import { readDataDurationSeconds } from "@hyperframes/parsers/media-duration";
import { heardClips } from "../utils/projectMedia.js";
import { terminalText } from "../utils/terminalText.js";
import { c } from "../ui/colors.js";
import { formatBytes, label } from "../ui/format.js";
import { ensureDOMParser } from "../utils/dom.js";
Expand Down Expand Up @@ -129,7 +130,9 @@ export default defineCommand({
console.log(label("Size", formatBytes(size)));
for (const clip of heard ?? []) {
const until = clip.end > 0 ? `${clip.end.toFixed(2)}s` : "its end";
console.log(label("Heard", `${clip.src} ${clip.start.toFixed(2)}s to ${until}`));
console.log(
label("Heard", `${terminalText(clip.src)} ${clip.start.toFixed(2)}s to ${until}`),
);
}
},
});
3 changes: 2 additions & 1 deletion packages/cli/src/commands/keyframes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from "@hyperframes/core/gsap-parser";
import type { Example } from "./_examples.js";
import { c } from "../ui/colors.js";
import { terminalText } from "../utils/terminalText.js";
import { ensureDOMParser } from "../utils/dom.js";
import { resolveProject } from "../utils/project.js";
import { withMeta } from "../utils/updateCheck.js";
Expand Down Expand Up @@ -999,7 +1000,7 @@ function printCompositionTweens(cmp: SurfacedComposition): void {
// Print one composition's traces + tweens (skipping strokes already shown in a trace).
function printComposition(cmp: SurfacedComposition): void {
if (isEmptyComposition(cmp)) return;
console.log(c.bold(`${cmp.composition}`) + c.dim(` (${cmp.source})`));
console.log(c.bold(terminalText(cmp.composition)) + c.dim(` (${terminalText(cmp.source)})`));
for (const tr of cmp.traces) printTrace(tr);
printCompositionTweens(cmp);
for (const cssKeyframes of cmp.cssKeyframes) printCssKeyframes(cssKeyframes);
Expand Down
14 changes: 14 additions & 0 deletions packages/cli/src/commands/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ describe("lint command exit handling", () => {
expect(vi.mocked(process.exit)).not.toHaveBeenCalled();
expect(consumeCommandResult().exitCode).toBe(1);
});

it("names a file with control characters in it as visible escapes", async () => {
const log = vi.spyOn(console, "log").mockImplementation(() => {});
lintProjectMock.mockResolvedValue({
results: [{ result: { findings: [] }, file: "a\u001b]0;t\u0007.html" }],
totalErrors: 0,
totalWarnings: 0,
totalInfos: 0,
});
await run({ json: false, verbose: false });
const header = String(log.mock.calls.find((call) => String(call[0]).includes("Linting"))?.[0]);
expect(header).toContain("proj/a\\x1b]0;t\\x07.html");
expect(header).not.toContain("\u001b]");
});
});

describe("lint --lint-verbose", () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/commands/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { isUnderCompositions, resolveLintTarget } from "../utils/project.js";
import { trackLintRun } from "../telemetry/lintRun.js";
import { getRunId } from "../telemetry/runId.js";
import { withMeta } from "../utils/updateCheck.js";
import { terminalText } from "../utils/terminalText.js";

export default defineCommand({
meta: {
Expand Down Expand Up @@ -96,7 +97,9 @@ export default defineCommand({
const fileCount = lintResult.results.length;
const fileLabel =
fileCount === 1 ? (lintResult.results[0]?.file ?? "index.html") : `${fileCount} files`;
console.log(`${c.accent("◆")} Linting ${c.accent(`${project.name}/${fileLabel}`)}`);
console.log(
`${c.accent("◆")} Linting ${c.accent(terminalText(`${project.name}/${fileLabel}`))}`,
);
if (unmounted.length > 0) console.log(c.dim(unmountedNotice(unmounted.length)));
console.log();

Expand Down
16 changes: 16 additions & 0 deletions packages/cli/src/utils/layoutAudit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@ describe("layoutAudit helpers", () => {
expect(formatted).toContain("Fix: Increase container padding");
});

it("shows control characters in composition text as visible escapes", () => {
const formatted = formatLayoutIssue({
...issue("text_box_overflow", "error"),
selector: "#h\u001b]0;t\u0007",
containerSelector: ".b\u009b2J",
text: "Plan\u001b[2K",
message: "clipped\u001b[1A",
fixHint: "pad \u001b]52;c;Y2xpcA==\u0007",
});

for (const control of ["\u0007", "\u001b", "\u009b"]) expect(formatted).not.toContain(control);
expect(formatted).toContain("#h\\x1b]0;t\\x07 inside .b\\x9b2J");
expect(formatted).toContain('"Plan\\x1b[2K" — clipped\\x1b[1A');
expect(formatted).toContain("\n Fix: pad \\x1b]52;c;Y2xpcA==\\x07");
});

it("formats collapsed issue time ranges", () => {
const formatted = formatLayoutIssue({
...issue("text_box_overflow", "error"),
Expand Down
Loading
Loading