Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(cli): keep render filename timestamp local (#2470)
Miguel Ángel017183ad6611
diff --git a/packages/cli/src/commands/render.ts b/packages/cli/src/commands/render.tsindex 979c55746a..c5b684f35e 100644--- a/packages/cli/src/commands/render.ts+++ b/packages/cli/src/commands/render.ts@@ -76,6 +76,7 @@ import { VERSION } from "../version.js";import { isDevMode } from "../utils/env.js";import { buildDockerRunArgs, resolveDockerPlatform } from "../utils/dockerRunArgs.js";import { normalizeErrorMessage } from "../utils/errorMessage.js";+import { formatRenderOutputTimestamp } from "@hyperframes/core";import { runEnvironmentChecks } from "../browser/preflight.js";import { detectH264EncoderMode } from "../browser/ffmpeg.js";import { chromeLaunchRemediation } from "../browser/linuxDeps.js";@@ -610,16 +611,14 @@ export default defineCommand({// ── Resolve output path ───────────────────────────────────────────────const rendersDir = resolve("renders");const ext = FORMAT_EXT[format] ?? ".mp4";- // fallow-ignore-next-line code-duplicationconst now = new Date();- const datePart = now.toISOString().slice(0, 10);- const timePart = now.toTimeString().slice(0, 8).replace(/:/g, "-");+ const timestamp = formatRenderOutputTimestamp(now);const batchOutputTemplate = args.output? args.output- : join(rendersDir, `${project.name}_${datePart}_${timePart}_{index}${ext}`);+ : join(rendersDir, `${project.name}_${timestamp}_{index}${ext}`);const outputPath = args.output? resolve(args.output)- : join(rendersDir, `${project.name}_${datePart}_${timePart}${ext}`);+ : join(rendersDir, `${project.name}_${timestamp}${ext}`);// Ensure output directory existsif (!batchPath) mkdirSync(dirname(outputPath), { recursive: true });diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 5a7a0ae578..46997f6c20 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -231,6 +231,7 @@ export { createGSAPFrameAdapter } from "./adapters/gsap";// Text measurementexport { fitTextFontSize } from "./text/index.js";export type { FitTextOptions, FitTextResult } from "./text/index.js";+export { formatRenderOutputTimestamp } from "./utils/renderOutputTimestamp.js";// Runtime helpers (composition-side)export { getVariables } from "./runtime/getVariables.js";diff --git a/packages/core/src/utils/renderOutputTimestamp.test.ts b/packages/core/src/utils/renderOutputTimestamp.test.tsnew file mode 100644index 0000000000..44b8b5496a--- /dev/null+++ b/packages/core/src/utils/renderOutputTimestamp.test.ts@@ -0,0 +1,19 @@+import { describe, expect, it } from "vitest";+import { formatRenderOutputTimestamp } from "./renderOutputTimestamp.js";++describe("formatRenderOutputTimestamp", () => {+ it.each([+ ["late local evening", "2026-07-14T22:55:06-07:00", "2026-07-14_22-55-06"],+ ["single-digit calendar and clock fields", "2026-01-05T04:07:03-08:00", "2026-01-05_04-07-03"],+ ])("uses one padded local calendar for %s", (_name, input, expected) => {+ const previousTimezone = process.env.TZ;+ process.env.TZ = "America/Los_Angeles";++ try {+ expect(formatRenderOutputTimestamp(new Date(input))).toBe(expected);+ } finally {+ if (previousTimezone === undefined) delete process.env.TZ;+ else process.env.TZ = previousTimezone;+ }+ });+});diff --git a/packages/core/src/utils/renderOutputTimestamp.ts b/packages/core/src/utils/renderOutputTimestamp.tsnew file mode 100644index 0000000000..ff575f7e23--- /dev/null+++ b/packages/core/src/utils/renderOutputTimestamp.ts@@ -0,0 +1,7 @@+/** Format a render/job timestamp from one local calendar and clock. */+export function formatRenderOutputTimestamp(now: Date): string {+ const pad = (value: number): string => String(value).padStart(2, "0");+ const datePart = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;+ const timePart = `${pad(now.getHours())}-${pad(now.getMinutes())}-${pad(now.getSeconds())}`;+ return `${datePart}_${timePart}`;+}diff --git a/packages/studio-server/src/routes/render.ts b/packages/studio-server/src/routes/render.tsindex ce630b63c3..e8f04ab95e 100644--- a/packages/studio-server/src/routes/render.ts+++ b/packages/studio-server/src/routes/render.ts@@ -4,7 +4,7 @@ import { existsSync, readFileSync, mkdirSync, unlinkSync, readdirSync, statSyncimport { join } from "node:path";import type { StudioApiAdapter, RenderJobState } from "../types.js";import { VALID_CANVAS_RESOLUTIONS, type CanvasResolution } from "@hyperframes/parsers";-import { parseFps } from "@hyperframes/core";+import { formatRenderOutputTimestamp, parseFps } from "@hyperframes/core";import { resolveWithinProject } from "../helpers/safePath.js";import { isVariablesPayload, VARIABLES_PAYLOAD_ERROR } from "../helpers/variablesPayload.js";@@ -107,11 +107,8 @@ export function registerRenderRoutes(api: Hono, adapter: StudioApiAdapter): voidvariables = body.variables;}- // fallow-ignore-next-line code-duplicationconst now = new Date();- const datePart = now.toISOString().slice(0, 10);- const timePart = now.toTimeString().slice(0, 8).replace(/:/g, "-");- const jobId = `${project.id}_${datePart}_${timePart}`;+ const jobId = `${project.id}_${formatRenderOutputTimestamp(now)}`;const rendersDir = adapter.rendersDir(project);if (!existsSync(rendersDir)) mkdirSync(rendersDir, { recursive: true });const ext = FORMAT_EXT[format] ?? ".mp4";