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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: keep music-video shot-plan helpers module-private and reuse trimTo (#8964)
[._.]/ Adam Eivyc7d41e30d087
diff --git a/server/services/musicVideo/planner.js b/server/services/musicVideo/planner.jsindex 1665633dfa..5e66b1889e 100644--- a/server/services/musicVideo/planner.js+++ b/server/services/musicVideo/planner.js@@ -82,7 +82,7 @@ export function validSections(sections) {* director to trim, continue, replace, or explicitly loop it (render.js).* The label keeps the section name and numbers the shots inside it.*/-export function sceneInputsFromShots(shots) {+function sceneInputsFromShots(shots) {return shots.map((shot) => {const base = shot.sectionLabel || `Section ${shot.sectionIndex + 1}`;const label = (shot.shotCount > 1 ? `${base} · ${shot.shotIndex + 1}/${shot.shotCount}` : base).slice(0, SCENE_LABEL_MAX);diff --git a/server/services/musicVideo/render.js b/server/services/musicVideo/render.jsindex baa78a255f..0c0cd4fe18 100644--- a/server/services/musicVideo/render.js+++ b/server/services/musicVideo/render.js@@ -64,20 +64,20 @@ export const attachRenderSseClient = (jobId, res) => attachSse(jobs, jobId, res)// `loop` key and keeps the legacy behavior — its clip repeats to fill the// authored span — so existing projects render exactly as they did. A scene// created since carries an explicit boolean, and only `loop: true` repeats.-export const sceneLoops = (scene) => scene?.loop !== false;+const sceneLoops = (scene) => scene?.loop !== false;// A non-looping shot may run this much past its source clip; the gap holds the// final frame (tpad) rather than repeating footage. Longer shortfalls block the// render until the director resolves them.-export const COVERAGE_TOLERANCE_SEC = 0.25;-export const COVERAGE_RESOLUTIONS = Object.freeze(['trim', 'continue', 'replace', 'loop']);+const COVERAGE_TOLERANCE_SEC = 0.25;+const COVERAGE_RESOLUTIONS = Object.freeze(['trim', 'continue', 'replace', 'loop']);/*** Pure: the snapped clips whose authored span needs more footage than their* non-looping source clip provides. Returns* `[{ sceneId, spanSec, clipSec, shortBySec }]` (empty when every shot is covered).*/-export function findCoverageShortfalls(clips, { toleranceSec = COVERAGE_TOLERANCE_SEC } = {}) {+function findCoverageShortfalls(clips, { toleranceSec = COVERAGE_TOLERANCE_SEC } = {}) {const out = [];for (const clip of Array.isArray(clips) ? clips : []) {if (clip.loop !== false) continue;diff --git a/server/services/musicVideo/shotPlan.js b/server/services/musicVideo/shotPlan.jsindex 4d2059cdd6..13446a4dbc 100644--- a/server/services/musicVideo/shotPlan.js+++ b/server/services/musicVideo/shotPlan.js@@ -35,7 +35,7 @@ const BOUNDARY_SNAP_SEC = 0.2;const OPEN_CUE_MAX_SEC = 8;// Grok renders fixed 6s/10s clips; a local model's default render is ~5s// (121 frames at 24fps). A project pacing ceiling overrides either.-export const DEFAULT_LOCAL_CLIP_CAPACITY_SEC = 5;+const DEFAULT_LOCAL_CLIP_CAPACITY_SEC = 5;const DEFAULT_MIN_SHOT_SEC = 2;const DEFAULT_HOOK_SEC = 3;@@ -55,7 +55,7 @@ export function resolveClipCapacitySec(videoSettings) {* ceiling so any span longer than the ceiling can always be tiled within* [floor, ceiling]; the hook is clamped into the same range.*/-export function resolvePacing(pacing, clipCapacitySec) {+function resolvePacing(pacing, clipCapacitySec) {const maxShotSec = Math.max(1, pacing?.maxShotSec ?? clipCapacitySec);const minShotSec = Math.min(pacing?.minShotSec ?? DEFAULT_MIN_SHOT_SEC, maxShotSec / 2);const hookSec = Math.min(maxShotSec, Math.max(minShotSec, pacing?.hookSec ?? DEFAULT_HOOK_SEC));@@ -63,7 +63,7 @@ export function resolvePacing(pacing, clipCapacitySec) {}/** Timed cues sorted by start, each with a resolved end (explicit, next cue, or capped open end). */-export function timedCues(cues) {+function timedCues(cues) {const timed = (Array.isArray(cues) ? cues : []).filter((c) => c && typeof c.text === 'string' && c.text.trim() && typeof c.startSec === 'number').slice()diff --git a/server/services/musicVideo/timedText.js b/server/services/musicVideo/timedText.jsindex c06024b48e..7ad6825bed 100644--- a/server/services/musicVideo/timedText.js+++ b/server/services/musicVideo/timedText.js@@ -16,6 +16,7 @@*/import { randomUUID } from 'crypto';+import { trimTo } from '../../lib/textUtils.js';const MAX_CUE_TEXT = 500;const MAX_SEC = 36000;@@ -55,18 +56,16 @@ function normalizeList(list, prefix, shape) {return out;}-const trimmed = (value, max) => (typeof value === 'string' ? value.trim().slice(0, max) : '');-/** Normalize an edited cue list: keep ids, trim text, drop empty lines. Order is kept (lyric order). */export const normalizeLyricCues = (cues) => normalizeList(cues, 'lc', (cue) => {- const text = trimmed(cue.text, MAX_CUE_TEXT);+ const text = trimTo(cue.text, MAX_CUE_TEXT);return text ? { text } : null;});/** Normalize an edited phrase list: keep ids, trim label/intent. */export const normalizePhrases = (phrases) => normalizeList(phrases, 'mp', (phrase) => ({- label: trimmed(phrase.label, 120),- intent: trimmed(phrase.intent, 2000),+ label: trimTo(phrase.label, 120),+ intent: trimTo(phrase.intent, 2000),}));/** Clear the audio-derived timings on every cue/phrase, keeping the authored text. */@@ -148,7 +147,7 @@ function parsePlain(text) {.map((line) => ({ text: line, startSec: null, endSec: null }));}-export function detectLyricsFormat(text) {+function detectLyricsFormat(text) {if (/-->/.test(text)) return 'srt';if (/^\s*\[\d{1,3}:\d{1,2}/m.test(text)) return 'lrc';return 'text';