Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

refactor([issue-3022]): collapse the clip-length aliases onto the one shared list

[._.]/ Adam Eivy26ee00a96c51
diff --git a/client/src/components/sprites/WalkWorkflow.jsx b/client/src/components/sprites/WalkWorkflow.jsx
index 08b2a403f3..a9b9a34802 100644
--- a/client/src/components/sprites/WalkWorkflow.jsx
+++ b/client/src/components/sprites/WalkWorkflow.jsx
@@ -12,7 +12,7 @@ import CycleTarget from './CycleTarget.jsx';
import SpritePreview from './SpritePreview.jsx';
import { useAsyncAction } from '../../hooks/useAsyncAction.js';
import { spriteAssetUrl, checkerboardStyle, PIXELATED } from './spriteAssets.js';
-import { GROK_VIDEO_DURATIONS, GROK_VIDEO_DEFAULT_DURATION } from '../../lib/grokVideoClip.js';
+import { GROK_VIDEO_DURATIONS } from '../../lib/grokVideoClip.js';
import {
WALK_PHASES, WALK_DEFAULT_FRAME_COUNT, WALK_DEFAULT_FPS,
} from '../../lib/spriteTrimmer.js';
@@ -29,33 +29,25 @@ const CELL_PX = 96; // preview cell size — the strip animates at 96px/frame
// 8, an imported redraw cycle can pack 12 — #2924), so the single keyframe
// rule reads it from a per-preview custom property instead of hardcoding 8.
const LOOP_KEYFRAMES = '@keyframes sprite-walk-loop { to { background-position-x: var(--sprite-walk-loop-end) } }';
-// Grok image_to_video clip lengths, from the client mirror of the server list
-// (`lib/grokVideoClip.js` — a server test fails if the two drift). grok's tool
-// offers ONLY 6s/10s and silently renders 6s for anything shorter: requesting
-// 2s or 3s returns the same 6.04s clip, at the same render cost — measured
-// three ways in #3022, and reported by grok's own agent. So the picker offers
-// exactly what it can deliver rather than advertising a saving that doesn't
-// exist. A 6s clip yields ~73 source frames where the packer consumes at most
-// 16; the CYCLE'S look (walk vs run) is set by the frame-count + speed controls
-// below, not the clip length. Re-exported under the walk-flavored names the
-// Sprites page already imports to seed its lifted `duration` state.
-export const WALK_DURATIONS = GROK_VIDEO_DURATIONS;
-export const WALK_DEFAULT_DURATION = GROK_VIDEO_DEFAULT_DURATION;
+// Clip length only decides how much source footage the packer can choose from;
+// the CYCLE'S look (walk vs run) comes from the frame-count + speed controls.
+// The offered lengths live in lib/grokVideoClip.js — see there for why 6s/10s
+// are the only two (#3022).
// Delivered clip length for a run, when the server managed to probe it
// (`sourceVideoSeconds` is absent on older runs and when ffprobe is missing —
// absent means UNKNOWN, so render nothing rather than implying a 0s clip).
// A mismatch against the requested `duration` is worth surfacing: it is the
-// visible evidence of grok's clamp, and the thing that would tell us the
-// clamp had changed.
-export function clipLengthLabel(run) {
+// visible evidence that grok rendered something other than what was asked for.
+function clipLengthLabel(run) {
const delivered = Number(run?.sourceVideoSeconds);
if (!(delivered > 0)) return null;
- const shown = `${delivered.toFixed(1)}s clip`;
const requested = Number(run?.duration);
- return requested > 0 && Math.abs(requested - delivered) >= 0.5
- ? { text: `${shown} (asked ${requested}s)`, mismatch: true }
- : { text: shown, mismatch: false };
+ const mismatch = requested > 0 && Math.abs(requested - delivered) >= 0.5;
+ return {
+ text: `${delivered.toFixed(1)}s clip${mismatch ? ` (asked ${requested}s)` : ''}`,
+ mismatch,
+ };
}
// The deterministic-postprocess authoring knobs (frame count + preview fps) and
@@ -666,7 +658,7 @@ export default function WalkWorkflow({
onChange={(e) => onDurationChange(Number(e.target.value))}
className="bg-port-bg border border-port-border rounded px-2 py-1 text-sm text-white"
>
- {WALK_DURATIONS.map((d) => <option key={d} value={d}>{d}s</option>)}
+ {GROK_VIDEO_DURATIONS.map((d) => <option key={d} value={d}>{d}s</option>)}
</select>
</label>
</div>
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index 62e9c498fd..c54b736b8a 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -37,11 +37,11 @@ grep -i "what you want to do" client/src/lib/README.md
| `beatColors.js` | `BEAT_KIND_COLORS` + `getBeatKindColor(kind)` — per-kind display colors for reader-map emotional beats (kinds defined server-side in `storyArc.js`). Keeps every beat visualization consistent. |
| `beatGrid.js` | Music-video beat-quantized timeline arranger (#1854). `buildBeatGridPoints(audioAnalysis)` merges beats/downbeats/section edges into one ranked snap-point list; `snapTimeToGrid(timeSec, gridPoints, toleranceSec)` finds the nearest point within tolerance; `computeSceneSpans(scenes, durationSec)` lays out scenes without a persisted `startSec`/`endSec` contiguously as a display-only fallback; `computeDragSpan({kind, startSpan, deltaSec, gridPoints, ...})` resolves a timeline drag gesture (`'move'` or `'right'` — no `'left'`, since the render can only trim from a clip's own frame 0) into a new span; `shouldMarkBeatAligned({kind, snapped, wasPersisted})` gates the `beatAligned` flag so a reposition-only drag can't silently promote an unpersisted scene's placeholder fallback duration into a "saved exactly" render duration; `autoArrangeScenes(scenes, audioAnalysis)` proposes a full `{ sceneId, startSec, endSec, beatAligned }[]` arrangement by distributing scenes across song sections weighted by each section's `energy` (#1915). Used by `components/musicVideo/BeatTimeline.jsx` and `pages/MusicVideo.jsx`. |
| `bibleLimits.js` | Mirror of `server/lib/storyBible.js` `BIBLE_LIMITS`. |
-| `grokVideoClip.js` | Mirror of `server/lib/grokVideoClip.js` — `GROK_VIDEO_DURATIONS` (`[6, 10]`) + `GROK_VIDEO_DEFAULT_DURATION`, the clip lengths grok's `image_to_video` actually delivers. |
| `catalogTypes.js` | Client mirror of `server/lib/catalogTypes.js` — catalog ingredient type registry (label, badge color, primary-content key/label, snippet fallback chain, per-type editor field list) for the Catalog list/picker/editor. |
| `creativeDirectorPlan.js` | Pure presentation helpers for the CD studio Plan board (CDO Phase 4) — annotate `plan.steps[]` with tool cost-class/timing/approval flags, cost/status summaries, owning-surface deep links, status/cost badge tone maps. |
| `creativeDirectorPreview.js` | `selectProjectPreview(project)` → `{ kind: 'video'\|'image'\|'audio'\|'none', jobId?, src?, poster?, label, durationSec? }` — picks a CD project's representative produced asset (finalVideoId → last rendered scene → last done plan video/image step → `musicBed` audio → startingImageFile) for the list cards + Overview tab (#2702, audio #2772). Pure, computed off the already-returned project payload (no fetch). Plus `previewAspectClass(aspectRatio)` (literal Tailwind classes — a computed `aspect-[w/h]` never lands in the build), `startingImageSrc()` (client mirror of `localImageFilename`), and the `videoSrcForJob`/`videoPosterForJob`/`imageSrcForJob`/`musicBedSrc` path builders — the one client-side definition of the `<jobId>`-named asset convention, shared with `ScenePreview.jsx`. |
| `editorialRoadmap.js` | `projectAnalyzedPoints` (aggregate roadmap → analyzed chart points with arc-position `frac`) + `dominant` (most-frequent string). Shared by EditorialRoadmapPanel and the Reader Map page. |
+| `grokVideoClip.js` | Mirror of `server/lib/grokVideoClip.js` — `GROK_VIDEO_DURATIONS` (`[6, 10]`) + `GROK_VIDEO_DEFAULT_DURATION`, the clip lengths grok's `image_to_video` actually delivers. |
| `imageCleaners.js` | Mirror of `resolveCleanersFromConfig` from `server/lib/imageClean.js`. Reads `{cleanC2PA, denoise}` off a per-mode settings record. `cleanC2PA` defaults are mode-aware (on for `codex` + `external` — the backends that emit C2PA chunks today — off otherwise, as an allow-list rather than a deny-list); `denoise` defaults off everywhere (lossy, opt-in only). |
| `runnerFamilies.js` | Mirror of `server/lib/runners.js`. |
| `issueLength.js` | Mirror of `server/lib/issueLength.js`. |
diff --git a/client/src/lib/grokVideoClip.js b/client/src/lib/grokVideoClip.js
index 97daf2c1f1..bff1508b87 100644
--- a/client/src/lib/grokVideoClip.js
+++ b/client/src/lib/grokVideoClip.js
@@ -1,13 +1,8 @@
// Client mirror of `server/lib/grokVideoClip.js` — the clip lengths grok's
-// `image_to_video` tool actually delivers. Enforced by the "client mirror"
-// suite in `server/lib/grokVideoClip.test.js`: if this drifts from the server
-// list, that test fails. Update the SERVER file first, then this one.
-//
-// The values are measured, not documented (#3022): three renders requesting
-// 2s / 3s / 6s all returned the same 6.04s clip, and grok's own agent reported
-// that image_to_video "only supports 6 or 10 second durations". So a shorter
-// request buys no render time — the picker offers exactly what grok delivers
-// rather than advertising a saving that doesn't exist.
+// `image_to_video` tool actually delivers (measured, #3022; see that file for
+// the evidence). Enforced by the "client mirror" suite in
+// `server/lib/grokVideoClip.test.js`: if this drifts from the server list, that
+// test fails. Update the SERVER file first, then this one.
/** Clip lengths (seconds) grok's image_to_video delivers, ascending. */
export const GROK_VIDEO_DURATIONS = [6, 10];
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index a9a4d68653..bb8b5c4b2b 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -21,11 +21,11 @@ export * from './universeStylePreset.js';
export * from './beatColors.js';
export * from './beatGrid.js';
export * from './bibleLimits.js';
-export * from './grokVideoClip.js';
export * from './catalogTypes.js';
export * from './creativeDirectorPlan.js';
export * from './creativeDirectorPreview.js';
export * from './editorialRoadmap.js';
+export * from './grokVideoClip.js';
export * from './imageCleaners.js';
export * from './imageGenBackends.js';
export * from './imageGenDefaults.js';
diff --git a/client/src/pages/Sprites.jsx b/client/src/pages/Sprites.jsx
index c62eefabce..74a52d6147 100644
--- a/client/src/pages/Sprites.jsx
+++ b/client/src/pages/Sprites.jsx
@@ -12,7 +12,8 @@ import { getSettings } from '../services/apiSystem.js';
import { deriveAvailableBackends } from '../lib/imageGenBackends.js';
import AppContextPicker from '../components/AppContextPicker.jsx';
import ReferenceWorkflow from '../components/sprites/ReferenceWorkflow.jsx';
-import WalkWorkflow, { WALK_DEFAULT_DURATION } from '../components/sprites/WalkWorkflow.jsx';
+import WalkWorkflow from '../components/sprites/WalkWorkflow.jsx';
+import { GROK_VIDEO_DEFAULT_DURATION } from '../lib/grokVideoClip.js';
import LoopTrimmer from '../components/sprites/LoopTrimmer.jsx';
import PublishWorkflow from '../components/sprites/PublishWorkflow.jsx';
import AssetCollection from '../components/sprites/AssetCollection.jsx';
@@ -472,7 +473,7 @@ export default function Sprites() {
// only add a staleness window — `detail` trails the server by one refetch, so
// a render fired right after a target change would 409 against a value the UI
// is no longer showing.
- const [duration, setDuration] = useState(WALK_DEFAULT_DURATION);
+ const [duration, setDuration] = useState(GROK_VIDEO_DEFAULT_DURATION);
// Image-backend availability + the selected backend `mode` are page-owned
// (#2938): both ReferenceWorkflow's picker and the asset collection's anchor
diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsx
index 4a4328eba2..512e49a3d2 100644
--- a/client/src/pages/VideoGen.jsx
+++ b/client/src/pages/VideoGen.jsx
@@ -74,6 +74,7 @@ import { videoLoraFamily, VIDEO_LORA_FAMILIES } from '../lib/runnerFamilies';
import { randomSeed } from '../lib/genUtils';
import { VIDEO_RESOLUTIONS, snapAspectToImage } from '../lib/videoGenResolutions';
import { clampImageEdge } from '../lib/imageGenResolutions';
+import { GROK_VIDEO_DURATIONS, GROK_VIDEO_DEFAULT_DURATION } from '../lib/grokVideoClip.js';
import ResolutionField from '../components/media/ResolutionField';
import { VIDEO_TILING_OPTIONS, VIDEO_TILING_ENUM_SET } from '../lib/videoTilingOptions';
import {
@@ -115,7 +116,7 @@ export default function VideoGen() {
// threaded into cancelVideoGen so cancellation is job-scoped.
const activeJobIdRef = useRef(null);
const [backend, setBackend] = useState('local');
- const [grokDuration, setGrokDuration] = useState(6);
+ const [grokDuration, setGrokDuration] = useState(GROK_VIDEO_DEFAULT_DURATION);
const [models, setModels] = useState([]);
const refreshGrokEnabled = useCallback(() => {
getSettings({ silent: true })
@@ -1574,8 +1575,7 @@ export default function VideoGen() {
onChange={(e) => setGrokDuration(Number(e.target.value))}
className="w-full bg-port-bg border border-port-border rounded-lg px-2 py-2 text-sm text-white focus:outline-none focus:border-port-accent disabled:opacity-50"
>
- <option value={6}>6 seconds</option>
- <option value={10}>10 seconds</option>
+ {GROK_VIDEO_DURATIONS.map((d) => <option key={d} value={d}>{d} seconds</option>)}
</select>
</FormField>
<ResolutionField
@@ -1878,7 +1878,7 @@ export default function VideoGen() {
summarize={(item) => (
<>
<span className="uppercase mr-2">{item.params.backend === 'grok' ? `grok ${item.params.mode}` : item.params.mode}</span>
- {item.params.width}×{item.params.height} · {item.params.backend === 'grok' ? `${item.params.grokDuration || 6}s` : `${item.params.numFrames}f`}
+ {item.params.width}×{item.params.height} · {item.params.backend === 'grok' ? `${item.params.grokDuration || GROK_VIDEO_DEFAULT_DURATION}s` : `${item.params.numFrames}f`}
</>
)}
/>
diff --git a/server/lib/grokVideoClip.js b/server/lib/grokVideoClip.js
index 82c9e19f8b..41fce9c050 100644
--- a/server/lib/grokVideoClip.js
+++ b/server/lib/grokVideoClip.js
@@ -20,16 +20,17 @@
* footage. Offering 1/2/3 in a picker would be advertising a saving that does
* not exist, which is why this list is exactly what grok delivers.
*
- * This module is deliberately **dependency-free** so `lib/validation.js` and
- * `routes/videoGen.js` can derive their Zod schemas from the same list the
- * services gate on, without pulling the videoGen graph (spawn, sseUtils,
- * imageGen) into every suite that imports validation.js. Same reasoning as
- * `walkBounds.js`: hand-copied literals in a schema are exactly how a schema
- * and its service drift apart.
+ * Its own module rather than `lib/grok.js` on cohesion grounds: that file is
+ * CLI-argv conventions (kept importable from the standalone autofixer), while
+ * this is capability data about the video tool. Being dependency-free is what
+ * lets `lib/validation.js` and `routes/videoGen.js` derive their Zod schemas
+ * from the same list the services gate on — the `walkBounds.js` reasoning, that
+ * hand-copied literals in a schema are how a schema and its service drift apart
+ * (as `[1,2,3,6,10]` here and `[6,10]` in the schema already had).
*
* If grok's tool ever gains shorter clips, change this list — the walk picker,
* both Zod schemas, and the service gates all follow from it. Confirm with a
- * probe (`run.sourceVideoSeconds` is stamped on every walk run for exactly this
+ * probe (every packaged walk run stamps `sourceVideoSeconds` for exactly this
* reason) rather than from a tool description.
*/
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 1d419bebd4..0115261f82 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -10,11 +10,11 @@ import { QUEUEABLE_IMAGE_MODES } from '../services/imageGen/modes.js';
import { GROK_VIDEO_DURATIONS } from './grokVideoClip.js';
// Clip lengths grok's image_to_video delivers, as a Zod union built from the
-// single shared list (grokVideoClip.js is dependency-free, so importing it here
-// adds nothing to the graph every route pulls in via this module). `z.literal`
-// per value rather than `z.number().refine()` keeps the "expected 6 | 10"
-// error message the hand-written union produced.
-const grokVideoDurationSchema = z.union(
+// single shared list (see grokVideoClip.js). `z.literal` per value rather than
+// `z.number().refine()` keeps the "expected 6 | 10" error message the
+// hand-written union produced. Exported so routes/videoGen.js validates
+// `grokDuration` against this same schema instead of rebuilding the union.
+export const grokVideoDurationSchema = z.union(
GROK_VIDEO_DURATIONS.map((d) => z.literal(d)),
);
@@ -1171,13 +1171,9 @@ const spriteWalkFpsSchema = spriteTrackFpsSchema(WALK_TRACK);
export const spriteWalkGenerateSchema = z.object({
direction: spriteWalkDirectionSchema,
- // Clip length in seconds — derived from the shared list rather than repeated
- // as literals, so the schema can't drift from what the service gates on
- // (grokVideoClip.js is dependency-free precisely so this import is safe here).
- // grok's image_to_video offers only 6s/10s and renders 6s for anything
- // shorter; the service defaults to 6s when omitted. Clip length only affects
- // how much source footage the packer can choose from — the cycle's look is set
- // by frameCount/fps below.
+ // Clip length in seconds; the service defaults to 6s when omitted. Only
+ // affects how much source footage the packer can choose from — the cycle's
+ // look is set by frameCount/fps below.
duration: grokVideoDurationSchema.optional(),
// Deterministic-postprocess knobs (not grok's): how many frames the packed
// cycle holds and how fast it plays back. Omitted → the set's pinned cycle
diff --git a/server/routes/videoGen.js b/server/routes/videoGen.js
index bb207ecd62..34a4c1dbef 100644
--- a/server/routes/videoGen.js
+++ b/server/routes/videoGen.js
@@ -18,7 +18,7 @@ import { asyncHandler, ServerError, failValidation } from '../lib/errorHandler.j
import { uploadFields } from '../lib/multipart.js';
import { PATHS, ensureDir, resolveGalleryImage } from '../lib/fileUtils.js';
import { safeUnder } from '../lib/ffmpeg.js';
-import { GROK_VIDEO_DURATIONS } from '../lib/grokVideoClip.js';
+import { grokVideoDurationSchema } from '../lib/validation.js';
import { IMAGE_GEN_MODE } from '../services/imageGen/modes.js';
import { getSettings } from '../services/settings.js';
import { checkPackages, isAllowedPython } from '../lib/pythonSetup.js';
@@ -115,13 +115,12 @@ const generateBodySchema = z.object({
// (mapped to an aspect ratio), sourceImageFile/sourceImage, and
// grokDuration.
backend: z.enum(['local', 'grok']).optional(),
- // Grok image_to_video clip length in seconds — the tool supports exactly
- // 6 or 10 (measured, #3022: a shorter request renders 6s anyway). Derived
- // from the shared list so this schema can't drift from the service gate.
- // Multipart bodies arrive as strings, so coerce first.
+ // Grok image_to_video clip length in seconds — the shared schema (see
+ // lib/grokVideoClip.js for which lengths grok actually delivers). Multipart
+ // bodies arrive as strings, so coerce first.
grokDuration: z.preprocess(
(v) => (v == null || v === '' ? undefined : Number(v)),
- z.union(GROK_VIDEO_DURATIONS.map((d) => z.literal(d))).optional(),
+ grokVideoDurationSchema.optional(),
),
prompt: z.string().min(1).max(8000),
negativePrompt: z.string().max(8000).optional(),
diff --git a/server/services/sprites/walk.js b/server/services/sprites/walk.js
index cefccd1d5c..2eb953a4f1 100644
--- a/server/services/sprites/walk.js
+++ b/server/services/sprites/walk.js
@@ -863,10 +863,8 @@ async function startWalkGenerationImpl(recordId, body) {
getSettings(),
]);
// Clip length grok will actually deliver — a request it doesn't offer falls
- // back to its shortest (6s). There is no shorter option to expose: a 2s/3s
- // request returns the same 6s clip at the same cost (measured, #3022 — see
- // lib/grokVideoClip.js). The walk's look comes from frameCount/fps below,
- // not from how much footage the packer had to choose from.
+ // back to its shortest (see lib/grokVideoClip.js). The walk's look comes from
+ // frameCount/fps below, not from how much footage the packer had to pick from.
const duration = resolveGrokDuration(body.duration);
// Frame count + playback fps are the deterministic-postprocess knobs, not the
// grok clip's — grok animates the same clip regardless, and the packer
@@ -1028,21 +1026,20 @@ async function packageRun(recordId, run, overrides = {}, location = {}) {
// failure is CAPTURED onto the run record — a throw escaping here would
// strand an attach at 'postprocessing' with no error text.
const videoAbs = resolveSpriteAssetPath(recordId, run.sourceVideoPath);
- // What grok DELIVERED, as opposed to what `run.duration` asked for. Stamped
- // here (shared by attach + rerun, so a reprocess backfills it onto an older
- // run) because the requested length is not a promise: grok's image_to_video
- // offers only 6s/10s and silently renders 6s for anything shorter (#3022).
- // Recording the probe is what keeps that fact honest — a code comment
- // asserting it drifted out of sync with a second comment asserting the
- // opposite, which is precisely what this field replaces.
+ // What grok DELIVERED, as opposed to what `run.duration` asked for — the
+ // requested length is not a promise (see lib/grokVideoClip.js). Stamped
+ // here, shared by attach + rerun, so a reprocess backfills it onto an older
+ // run. Overlap the probe with the (independent) manifest read.
//
// probeVideoDuration returns null when ffprobe is missing or the file has no
// parseable duration; leave the field ABSENT in that case rather than
// stamping 0, so "unknown" never reads as "a zero-length clip". A previously
// stamped value survives — a probe that can't run is not evidence of change.
- const probedSeconds = await probeVideoDuration(videoAbs);
+ const [probedSeconds, manifest] = await Promise.all([
+ probeVideoDuration(videoAbs),
+ loadManifest(recordId),
+ ]);
if (probedSeconds) run.sourceVideoSeconds = Math.round(probedSeconds * 100) / 100;
- const manifest = await loadManifest(recordId);
const anchor = manifest?.anchors?.find((a) => a.direction === run.direction);
if (!anchor?.path) throw new Error(`No locked ${run.direction} anchor in the reference manifest`);
const result = await runWalkPostprocess({
diff --git a/server/services/sprites/walk.test.js b/server/services/sprites/walk.test.js
index 16adc75002..f006977271 100644
--- a/server/services/sprites/walk.test.js
+++ b/server/services/sprites/walk.test.js
@@ -292,7 +292,7 @@ describe('startWalkGeneration', () => {
const id = await characterWithLockedAnchors(newId(), ['east']);
const result = await startWalkGeneration(id, { direction: 'east' });
expect(result.runId).toMatch(/^walk-east-[0-9a-f]{8}$/);
- expect(result.duration).toBe(6); // walk default (WALK_DEFAULT_DURATION — grok's real floor)
+ expect(result.duration).toBe(6); // GROK_VIDEO_DEFAULT_DURATION — grok's shortest deliverable clip
// The shell session id is the run id, so the card can deep-link to /shell/<id>.
expect(result.shellSession).toBe(result.runId);
@@ -328,19 +328,11 @@ describe('startWalkGeneration', () => {
expect(executeTuiRun.mock.calls[0][0].prompt).toContain('for 10 seconds');
});
- it('falls back to the default clip length for a duration grok does not offer', async () => {
- // Values outside GROK_VIDEO_DURATIONS fall back to WALK_DEFAULT_DURATION (6).
- const id = await characterWithLockedAnchors(newId(), ['east']);
- const result = await startWalkGeneration(id, { direction: 'east', duration: 5 });
- expect(result.duration).toBe(6);
- expect(executeTuiRun.mock.calls[0][0].prompt).toContain('for 6 seconds');
- });
-
- // The specific values a user would reach for to "save render time" (#3022).
- // grok renders 6s for these regardless, so asking for them must not put a
- // number in the prompt that the tool will silently ignore — the prompt has to
- // say 6, matching what actually comes back.
- it.each([1, 2, 3])('refuses the undeliverable %ss clip and asks grok for 6s', async (duration) => {
+ // 2s is the length a user reaches for to "save render time"; grok renders 6s
+ // for it regardless (#3022), so the prompt must ask for 6 — putting a number
+ // in it that the tool silently ignores is what made the old picker a lie.
+ // (The full fallback table is unit-tested in lib/grokVideoClip.test.js.)
+ it.each([2, 5])('asks grok for 6s when %ss is requested, since %ss is not deliverable', async (duration) => {
const id = await characterWithLockedAnchors(newId(), ['east']);
const result = await startWalkGeneration(id, { direction: 'east', duration });
expect(result.duration).toBe(6);
diff --git a/server/services/videoGen/grok.js b/server/services/videoGen/grok.js
index 728dfb7072..5a5357ba62 100644
--- a/server/services/videoGen/grok.js
+++ b/server/services/videoGen/grok.js
@@ -36,9 +36,7 @@ import { videoGenEvents } from './events.js';
import { finalizeGeneratedVideo } from './generateVideoHelpers.js';
import { mutateVideoHistory } from './history.js';
import { noImageReason, deriveAspectRatio, GROK_ASPECT_RATIOS } from '../imageGen/grok.js';
-import {
- GROK_VIDEO_DURATIONS, GROK_VIDEO_DEFAULT_DURATION, resolveGrokDuration,
-} from '../../lib/grokVideoClip.js';
+import { resolveGrokDuration } from '../../lib/grokVideoClip.js';
// 30 minutes — an image-first video turn is two sequential tool calls
// (image_gen then image_to_video render + download), so it runs meaningfully
@@ -53,14 +51,8 @@ const GROK_VIDEO_TIMEOUT_MS = (() => {
const DEFAULT_BIN = 'grok';
-// Clip lengths grok's image_to_video delivers. Re-exported from the
-// dependency-free lib leaf so the Zod schemas in lib/validation.js and
-// routes/videoGen.js derive from the same list this module gates on — see
-// lib/grokVideoClip.js for the measurement behind `[6, 10]` (#3022). This list
-// used to carry 1/2/3 on the theory that shorter clips "trade render time for
-// material"; they don't — grok returns a 6s clip for a 2s request, at the same
-// cost. Deep imports of these two names from this module keep working.
-export { GROK_VIDEO_DURATIONS, GROK_VIDEO_DEFAULT_DURATION };
+// The clip lengths this module gates on live in lib/grokVideoClip.js — the one
+// list the Zod schemas and the client picker also derive from (#3022).
// Per-job state — keyed by jobId (cloud lane allows parallel renders). Same
// client shape as videoGen/local.js so attachSseClient/broadcastSse work.