Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
acc29c6
feat(studio-server): support png-sequence from the Studio render rout…
ym256-stanford Oct 18, 2026
d7d6992
fix(studio-server): a render delete only removes artifacts of its own…
ym256-stanford Oct 26, 2026
02e6294
fix(studio-server): refuse dot and empty render job ids on delete
ym256-stanford Oct 26, 2026
9e6968e
fix(studio-server): delete a directory render after its progress entr…
ym256-stanford Nov 8, 2026
93bc190
fix(studio-server): delete a directory render the server has no recor…
ym256-stanford Nov 14, 2026
8b1073f
docs(studio): describe the PNG sequence export, not only its delete
ym256-stanford Nov 14, 2026
fbf561a
fix(studio-server): stamp archived frames with their render time, cov…
ym256-stanford Nov 14, 2026
f84cf84
fix(studio-server): register the render-directory-stats subpath in th…
ym256-stanford Nov 14, 2026
02ba48b
fix(studio): keep a quality-bearing format last in the Renders format…
ym256-stanford Nov 14, 2026
bc049dc
refactor: trim the PNG-sequence route's comments to each file's base …
ym256-stanford Nov 14, 2026
95a1001
fix(studio-server): retain downloads and isolate colliding render rows
ym256-stanford Nov 17, 2026
983b593
fix(studio): recover render identities and validate fork diffs
ym256-stanford Nov 18, 2026
aeb8c34
fix(studio-server): harden render reads and canonical roots
ym256-stanford Nov 18, 2026
f4c12ba
Merge branch 'main' into design/studio-server-png-sequence
ym256-stanford Dec 3, 2026
fa34b9c
fix(studio-server): keep render identities working on more disks and …
ym256-stanford Dec 3, 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
24 changes: 22 additions & 2 deletions docs/studio/export.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ set those first.

| Setting | Choose |
| --- | --- |
| **Format** | **MP4** for sharing and uploading; **WebM** for the web and transparent overlays; **MOV** (ProRes) when another editor needs a high-quality master |
| **Format** | **MP4** for sharing and uploading; **WebM** for the web and transparent overlays; **MOV** (ProRes) when another editor needs a high-quality master; **GIF** for docs and chat (no audio, up to 30 fps); **PNG sequence** when a compositing tool needs one lossless image per frame |
| **Resolution** | **Auto** keeps the project's size. Bigger renders are slower and don't sharpen low-resolution footage |
| **Frame rate** | 30 unless the destination or the footage needs 24 or 60 |
| **Quality** | Hidden for MOV, which always uses ProRes quality |
| **Quality** | Hidden for MOV, which always uses ProRes quality, and for PNG sequence, which is lossless |
| **Use GPU encoding** | Faster on machines that support it |

**About video formats**, next to the settings, explains the choices.
Expand All @@ -31,6 +31,26 @@ set those first.
Each export becomes a row in **Renders**, with its progress. Cancel a running one, download or delete a finished
one, and **Hide finished** to tidy the list without deleting files.

A finished **PNG sequence** is a folder of numbered frames (`frame_000001.png`, `frame_000002.png`, …) plus an
`audio.m4a` track when the composition has sound. Its row shows a **PNG** badge and the frame count instead of a
video thumbnail, with the count appearing when the render finishes, without reloading Studio. There is nothing
to play in a new tab, so that control is hidden; **Download as ZIP** streams the numbered frames and optional
audio into an archive named after the output folder. Downloads keep working after progress tracking ends and
after restarting the server.

**Delete** removes a frame folder and its metadata, leaving a video of the same name alone. Deleting a video
removes its same-name MP4, WebM, MOV, and GIF variants and metadata, but not the frame folder. Cancel any running
render in that video family before deleting it.

If an older video and frame folder share a name, refresh render history before using their actions. Studio
gives the rows separate, persistent identities and refuses an old action whose target is ambiguous rather
than guessing. Ordinary folders without numbered PNG frames or metadata identifying that frame folder are
not treated as renders.

Moving or copying a project preserves its render files. At the new location, refresh render history to get
new download and delete links. Old links do not transfer to the moved project or copy; if the original
project is still registered, its links continue to act only on the original.

Before sending: open the file itself, watch the start and the end, check captions, cuts and sound at the busiest
moment, and give it a name that says which version it is. If a render fails, keep the error and see
[troubleshooting](/help#in-the-preview-and-browser-editor).
Expand Down
18 changes: 15 additions & 3 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pre-commit:
- name: typecheck
glob: "*.{ts,tsx}"
run: cd packages/core && node_modules/.bin/tsc --noEmit && cd ../studio && node_modules/.bin/tsc --noEmit -p tsconfig.check.json && cd ../.. && node_modules/.bin/tsc --noEmit -p scripts/tsconfig.json
# Mirrors the CI gate (same `--base origin/main` so the local hook can't
# pass on a branch CI would fail). Audits the working tree, which means
# Mirrors CI's new-only gate against main, using upstream/main in forks
# and origin/main otherwise. Audits the working tree, which means
# unstaged WIP in `packages/**` is part of the diff — stash before
# committing if that surprises you. `--gate new-only` (the default) only
# fails on issues introduced by the branch, not inherited findings.
Expand All @@ -37,7 +37,19 @@ pre-commit:
# env -u is safe in non-worktree contexts (no-op when var is unset).
# fallow reuses one base-snapshot cache per checkout; `audit-cache prune` drops caches unused for a day,
# including those of removed checkouts. The commit gets the audit's own status.
run: env -u GIT_DIR -u GIT_INDEX_FILE -u GIT_WORK_TREE sh -c 'node_modules/.bin/fallow audit --base origin/main --fail-on-issues; status=$?; node_modules/.bin/fallow audit-cache prune --max-age-days 1 > /dev/null; exit $status'
run: |
env -u GIT_DIR -u GIT_INDEX_FILE -u GIT_WORK_TREE sh -c '
base_ref=refs/remotes/origin/main
if git show-ref --verify --quiet refs/remotes/upstream/main; then
base_ref=refs/remotes/upstream/main
fi
base=$(git merge-base HEAD "$base_ref") || exit $?
printf "Fallow audit base: %s (%s)\n" "$base_ref" "$base" >&2
node_modules/.bin/fallow audit --base "$base" --fail-on-issues
status=$?
node_modules/.bin/fallow audit-cache prune --max-age-days 1 > /dev/null
exit "$status"
'
- name: cli-process-ownership
glob: "packages/cli/src/**/*.ts"
run: bun run check:cli-process-ownership
Expand Down
15 changes: 4 additions & 11 deletions packages/cli/src/commands/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { resolveGsapVendorDir } from "../server/gsapVendor.js";
import { failCommand, requestCliExit, scheduleCliExit } from "../utils/commandResult.js";
import { defineCommand } from "../utils/defineCommand.js";
import type { Example } from "./_examples.js";
import { mkdtempSync, readdirSync, readFileSync, statSync, writeFileSync, rmSync } from "node:fs";
import { mkdtempSync, readFileSync, statSync, writeFileSync, rmSync } from "node:fs";
import {
createRenderPlan,
resolveBrowserGpuForCli,
Expand Down Expand Up @@ -71,6 +71,7 @@ export const examples: Example[] = [
import { freemem, tmpdir } from "node:os";
import { resolve, dirname, join, basename } from "node:path";
import { execFileSync, spawn } from "node:child_process";
import { readRenderDirectoryStats } from "@hyperframes/studio-server/render-directory-stats";
import { loadProducer } from "../utils/producer.js";
import { outsideAssetsAllowed } from "../utils/receivedRender.js";
import { c } from "../ui/colors.js";
Expand Down Expand Up @@ -2121,16 +2122,8 @@ function readOutputFootprint(outputPath: string): { fileSize: string; isDirector
if (!stat.isDirectory()) return { fileSize: formatBytes(stat.size), isDirectory: false };
// png-sequence and hls write a directory; sum contained file sizes so the
// user sees the deliverable footprint, not the directory inode size.
let total = 0;
for (const entry of readdirSync(outputPath, { withFileTypes: true })) {
if (!entry.isFile()) continue;
try {
total += statSync(join(outputPath, entry.name)).size;
} catch {
// skip unreadable entries
}
}
return { fileSize: formatBytes(total), isDirectory: true };
const { size } = readRenderDirectoryStats(outputPath);
return { fileSize: formatBytes(size), isDirectory: true };
} catch {
return { fileSize: "unknown", isDirectory: false };
}
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/src/server/studioRenderTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Maps studio-triggered renders into the existing `render_complete` /
// `render_error` telemetry events with `source: "studio"`, so they land
// alongside CLI renders in one unified taxonomy.
//
// Kept in its own file so `studioServer.ts` only needs two function calls.
// ---------------------------------------------------------------------------

import { freemem } from "node:os";
Expand All @@ -22,7 +20,7 @@ import type { RenderCpuTelemetryPayload } from "../telemetry/renderCpu.js";
export interface StudioRenderOpts {
fps: Fps;
quality: string;
format?: "mp4" | "webm" | "mov" | "gif";
format?: "mp4" | "webm" | "mov" | "gif" | "png-sequence";
/** Named canvas preset the Studio request asked for; undefined renders at the composition's native dimensions. */
outputResolution?: CanvasResolution;
useGpu?: boolean;
Expand Down
176 changes: 172 additions & 4 deletions packages/cli/src/server/studioServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
writeFileSync,
} from "node:fs";
import { tmpdir } from "node:os";
import { basename, join } from "node:path";
import { basename, dirname, join } from "node:path";
import {
createProjectSignature,
fileContentVersion,
Expand All @@ -28,6 +28,7 @@ import { loadHyperframeRuntimeSource } from "@hyperframes/core";
import { loadRuntimeSource } from "./runtimeSource.js";
import { findFFmpeg, findFFprobe } from "../browser/ffmpeg.js";
import { createStudioServer, type StudioServer } from "./studioServer.js";
import { acquireRenderLock } from "../utils/renderLock.js";
import { historyWritesSettled } from "./studioServerTestFixture.js";
import { recordReceivedFiles } from "../utils/privateProjectFile.js";

Expand Down Expand Up @@ -437,7 +438,9 @@ describe("createStudioServer shutdown", () => {
const state = server.adapter.startRender(startRenderOpts("job-lowered", outputPath));
await vi.waitFor(() => expect(state.status, state.error).toBe("complete"), { timeout: 5_000 });
expect(state.audioLoweredDb).toBe(1.44);
const meta = JSON.parse(readFileSync(outputPath.replace(/\.mp4$/, ".meta.json"), "utf8"));
const meta = JSON.parse(
readFileSync(join(dirname(outputPath), "job-lowered.meta.json"), "utf8"),
);
expect(meta.audioLoweredDb).toBe(1.44);
});

Expand Down Expand Up @@ -501,7 +504,7 @@ describe("createStudioServer shutdown", () => {
});
await vi.waitFor(() => expect(state.status, state.error).toBe("complete"));
expect(readFileSync(outputPath, "utf8")).toBe("GIF89a");
expect(JSON.parse(readFileSync(join(projectDir, "out.meta.json"), "utf8"))).toMatchObject({
expect(JSON.parse(readFileSync(join(projectDir, "gif-job.meta.json"), "utf8"))).toMatchObject({
status: "complete",
});
});
Expand All @@ -511,7 +514,7 @@ describe("createStudioServer shutdown", () => {
async (lateCompletion) => {
const projectDir = tmpProject();
const outputPath = join(projectDir, "out.gif");
const metaPath = join(projectDir, "out.meta.json");
const metaPath = join(projectDir, "gif-job.meta.json");
producerState.executeRenderJob = async (_job, _dir, output, _progress, signal) => {
writeFileSync(output, "partial-gif");
writeFileSync(metaPath, "{}");
Expand All @@ -526,6 +529,171 @@ describe("createStudioServer shutdown", () => {
},
);

it("writes a PNG-sequence sidecar beside the directory, with its frame facts", async () => {
producerState.executeRenderJob = async (_job, _dir, outputPath) => {
mkdirSync(outputPath);
writeFileSync(join(outputPath, "frame_000000.png"), "aa");
writeFileSync(join(outputPath, "frame_000001.png"), "bbb");
writeFileSync(join(outputPath, "audio.m4a"), "c");
};
const rendersDir = mkdtempSync(join(tmpdir(), "hf-png-seq-"));
dirs.push(rendersDir);
const outputPath = join(rendersDir, "job-seq");
server = createStudioServer({ projectDir: tmpProject() });
const state = server.adapter.startRender({
...startRenderOpts("job-seq", outputPath),
format: "png-sequence",
});
expect(state.kind).toBe("directory");
await vi.waitFor(() => expect(state.status, state.error).toBe("complete"), { timeout: 5_000 });
const meta = JSON.parse(readFileSync(join(rendersDir, "job-seq.meta.json"), "utf8"));
expect(meta).toMatchObject({
status: "complete",
kind: "directory",
outputName: "job-seq",
frameCount: 2,
size: 6,
audioSidecar: true,
});
expect(existsSync(join(outputPath, ".meta.json"))).toBe(false);
});

it("writes explicit directory identity when PNG rendering fails before publishing output", async () => {
producerState.executeRenderJob = async () => {
throw new Error("PNG failed");
};
const rendersDir = mkdtempSync(join(tmpdir(), "hf-png-failure-"));
dirs.push(rendersDir);
const outputPath = join(rendersDir, "failed-frames");
server = createStudioServer({ projectDir: tmpProject() });
const state = server.adapter.startRender({
...startRenderOpts("failed-job", outputPath),
format: "png-sequence",
});
await vi.waitFor(() => expect(state.status).toBe("failed"), { timeout: 5_000 });
expect(
JSON.parse(readFileSync(join(rendersDir, "failed-job.meta.json"), "utf8")),
).toMatchObject({
status: "failed",
kind: "directory",
outputName: "failed-frames",
});
expect(existsSync(outputPath)).toBe(false);
});

it("removes a committed PNG-sequence directory and its sidecar when cancel races completion", async () => {
let finish!: () => void;
let started!: () => void;
const startedPromise = new Promise<void>((resolve) => {
started = resolve;
});
producerState.executeRenderJob = (_job, _dir, outputPath) => {
started();
return new Promise<void>((resolve) => {
finish = () => {
mkdirSync(outputPath);
writeFileSync(join(outputPath, "frame_000000.png"), "aa");
resolve();
};
});
};
const rendersDir = mkdtempSync(join(tmpdir(), "hf-png-cancel-"));
dirs.push(rendersDir);
const outputPath = join(rendersDir, "job-cancel");
writeFileSync(join(rendersDir, "job-cancel.meta.json"), '{"status":"failed"}');
server = createStudioServer({ projectDir: tmpProject() });
const state = server.adapter.startRender({
...startRenderOpts("job-cancel", outputPath),
format: "png-sequence",
});
await untilStarted(startedPromise, state);
state.cancel?.();
finish();
await vi.waitFor(() => expect(state.status).toBe("cancelled"), { timeout: 5_000 });
expect(existsSync(outputPath)).toBe(false);
expect(existsSync(join(rendersDir, "job-cancel.meta.json"))).toBe(false);
});

it.each(["visible", "missing"])(
"settles the CLI family-deletion fixture with %s history",
async (historyMode) => {
let finish!: () => void;
let aborted = false;
producerState.executeRenderJob = (_job, _dir, output, _progress, signal) => {
writeFileSync(output, "partial");
signal.addEventListener("abort", () => {
aborted = true;
});
return new Promise<void>((resolve) => {
finish = resolve;
});
};
const projectDir = tmpProject();
const activeServer = createStudioServer({ projectDir });
server = activeServer;
const response = await activeServer.app.request(
`/api/projects/${basename(projectDir)}/render`,
{
method: "POST",
headers: { "content-type": "application/json" },
body: '{"format":"mp4"}',
},
);
expect(response.status).toBe(200);
const { jobId } = await response.json();
await vi.waitFor(() => expect(typeof finish).toBe("function"));
const checkDeletion = async () => {
const renderRoot = join(projectDir, "renders");
const hiddenRoot = join(projectDir, "hidden-renders");
const mov = join(renderRoot, `${jobId}.mov`);
let alias = "";
let cancelling: ReturnType<typeof activeServer.app.request> | undefined;
try {
writeFileSync(mov, "keep");
const history = await (async () => {
if (historyMode === "missing") renameSync(renderRoot, hiddenRoot);
try {
return await (
await activeServer.app.request(`/api/projects/${basename(projectDir)}/renders`)
).json();
} finally {
if (historyMode === "missing") renameSync(hiddenRoot, renderRoot);
}
})();
alias = history.renders.find((row: { filename: string }) =>
row.filename.endsWith(".mov"),
).id;
cancelling = activeServer.app.request(`/api/render/${jobId}/cancel`, { method: "POST" });
await vi.waitFor(() => expect(aborted).toBe(true));
expect(
(await activeServer.app.request(`/api/render/${alias}`, { method: "DELETE" })).status,
).toBe(409);
expect(readFileSync(mov, "utf8")).toBe("keep");
} finally {
cancelling ??= activeServer.app.request(`/api/render/${jobId}/cancel`, {
method: "POST",
});
finish();
await cancelling;
}
expect(
(await activeServer.app.request(`/api/render/${alias}`, { method: "DELETE" })).status,
).toBe(200);
expect(existsSync(mov)).toBe(false);
};
try {
if (historyMode === "missing") {
await expect(checkDeletion()).rejects.toThrow(TypeError);
const release = await acquireRenderLock({ project: projectDir, wait: false });
release();
} else await checkDeletion();
} finally {
finish();
await activeServer.shutdown();
}
},
);

it("cancels an in-flight render's signal and waits for it before draining the browser pool", async () => {
const events: string[] = [];
let started!: () => void;
Expand Down
Loading
Loading