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
address review (claude): envelope per-chunk beats and round-trip them through Remix
[._.]/ Adam Eivydb3359678260
diff --git a/client/src/components/videoGen/AdvancedParamsPanel.jsx b/client/src/components/videoGen/AdvancedParamsPanel.jsxindex ea6aa00858..8e52909552 100644--- a/client/src/components/videoGen/AdvancedParamsPanel.jsx+++ b/client/src/components/videoGen/AdvancedParamsPanel.jsx@@ -20,11 +20,9 @@import { useState } from 'react';import { ChevronDown, Dice5 } from 'lucide-react';import { FormField } from '../ui/FormField';-import { frameOptionsForModel, fpsOptionsForModel } from '../../lib/videoGenParams.js';+import { frameOptionsForModel, fpsOptionsForModel, CHUNK_OPTIONS } from '../../lib/videoGenParams.js';import { VIDEO_TILING_OPTIONS } from '../../lib/videoTilingOptions';-const CHUNK_OPTIONS = [1, 2, 3, 4, 5, 6, 7, 8];-const inputCls = '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';export default function AdvancedParamsPanel({diff --git a/client/src/hooks/useVideoGenForm.js b/client/src/hooks/useVideoGenForm.jsindex 09561adef3..34879b9296 100644--- a/client/src/hooks/useVideoGenForm.js+++ b/client/src/hooks/useVideoGenForm.js@@ -10,7 +10,7 @@ import { clampImageEdge } from '../lib/imageGenResolutions';import { GROK_VIDEO_DEFAULT_DURATION } from '../lib/grokVideoClip.js';import { VIDEO_TILING_ENUM_SET } from '../lib/videoTilingOptions';import {- VIDEO_EDGE_BOUNDS,+ VIDEO_EDGE_BOUNDS, MAX_CHUNKS,videoModelMemoryGb, computeFflfSafeFrames, isModelAllowedForMode,normalizeFramesForModel, normalizeFpsForModel,icLoraSpecForMode, icResolutionIssue,@@ -791,6 +791,21 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })// toggle stuck ON when the user remixes a clip that had audio enabled.const remixDisableAudio = item.disableAudio ?? item.disable_audio;setDisableAudio(remixDisableAudio === true);+ // Per-chunk beats (#3695): ALWAYS set explicitly, like prompt/negativePrompt+ // above. A stitched chain entry carries the beats it rendered with; anything+ // else carries none, and leaving the form's beats behind would steer a+ // "faithful reproduction" remix with text from the render the user was+ // previously composing. `null` (an absent beat) maps back to the editor's ''.+ setChunkPrompts(Array.isArray(item.chunkPrompts)+ ? item.chunkPrompts.map((cp) => (typeof cp === 'string' ? cp : ''))+ : []);+ // Chunk count comes from the stitched entry's own chunk list — beats only+ // ride to the server while `chunks > 1`, so restoring the beats without the+ // count would leave them typed-but-inert. A non-chained entry resets to 1+ // rather than inheriting whatever the form last had.+ setChunks(Array.isArray(item.chainedFrom) && item.chainedFrom.length > 1+ ? Math.min(item.chainedFrom.length, MAX_CHUNKS)+ : 1);// Reset to text-to-video mode and clear any stale conditioning inputs from// image / fflf / extend / a2v / IC-remix modes. Without this, clicking Remix// while currently in (e.g.) image mode would carry the old source image into@@ -957,11 +972,27 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })const buildGeneratePayload = () => {const composed = composeStyledPrompt(prompt, negativePrompt, stylePreset);+ // The style preset and the no-music constraint are ENVELOPE, not content —+ // they have to wrap a per-chunk beat exactly as they wrap the main prompt.+ // Shipping a beat raw would render the chunks the user steered in a+ // different style (and with the soundtrack they disabled) than the chunks+ // that fall back to the main prompt — a visible change at every seam, which+ // is the artifact chaining exists to avoid.+ // Idempotent on "no music": if the text already says it, don't double-append.+ const withEnvelope = (text) => {+ const c = composeStyledPrompt(text, negativePrompt, stylePreset);+ return (noMusic && !disableAudio && !/no music/i.test(c.prompt))+ ? `${c.prompt}\n\nno music, no soundtrack`+ : c.prompt;+ };// Beats for the LIVE chunks only — the backing array is never truncated on// a chunk-count change, so slicing here is what keeps a stale tail off the// wire. A short list is fine: the server falls back to the main prompt for- // any chunk the list doesn't cover.- const beats = chainingActive ? chunkPrompts.slice(0, chunks) : [];+ // any chunk the list doesn't cover. A blank beat stays blank (NOT enveloped)+ // so it still reads as "absent" and triggers that same fallback.+ const beats = chainingActive+ ? chunkPrompts.slice(0, chunks).map((b) => (b?.trim() ? withEnvelope(b) : ''))+ : [];if (isGrok) {// Grok's image-first flow reads only these fields; width/height ride// along so the server maps them to the closest supported aspect ratio.@@ -981,9 +1012,7 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })// generation is itself active — there's no point steering audio output// when audio is disabled outright. Idempotent: if the user already// typed "no music" we avoid double-appending.- const promptOut = (noMusic && !disableAudio && !/no music/i.test(composed.prompt))- ? `${composed.prompt}\n\nno music, no soundtrack`- : composed.prompt;+ const promptOut = withEnvelope(prompt);// Legacy first/last-frame fflf: the two-image picker is mutually exclusive// with multi-keyframe mode on the server, so its image fields only ride// along when keyframes aren't active.diff --git a/client/src/hooks/useVideoGenForm.test.jsx b/client/src/hooks/useVideoGenForm.test.jsxindex 5bcf0a2690..65c56c1803 100644--- a/client/src/hooks/useVideoGenForm.test.jsx+++ b/client/src/hooks/useVideoGenForm.test.jsx@@ -248,6 +248,48 @@ describe('useVideoGenForm', () => {expect(result.current.buildGeneratePayload().chunkPrompts).toBe('');});+ it('wraps each beat in the same style/no-music envelope as the main prompt', async () => {+ // A raw beat would render its chunk without the style preset (and with the+ // soundtrack the user disabled) while the fallback chunks keep both — a+ // visible change at exactly the seams chaining exists to smooth over.+ const result = await chained(2);+ act(() => {+ result.current.setStylePreset({ prompt: 'film noir', negativePrompt: 'blurry' });+ result.current.setNoMusic(true);+ result.current.setChunkPromptAt(1, 'the storm breaks');+ });++ const payload = result.current.buildGeneratePayload();+ expect(payload.prompt).toBe('film noir. a long shot\n\nno music, no soundtrack');+ expect(JSON.parse(payload.chunkPrompts)).toEqual([+ '',+ 'film noir. the storm breaks\n\nno music, no soundtrack',+ ]);+ });++ it('restores the beats and the chunk count when remixing a chained clip', async () => {+ const { result } = render();+ await waitFor(() => expect(result.current.modelId).toBe(MLX.id));+ act(() => result.current.applyRemix({+ prompt: 'a long shot',+ chainedFrom: ['a', 'b', 'c'],+ chunkPrompts: ['she opens the door', null, 'the storm breaks'],+ }));+ expect(result.current.chunks).toBe(3);+ expect(result.current.chunkPrompts).toEqual(['she opens the door', '', 'the storm breaks']);+ });++ it('clears stale beats when remixing a clip that never chained', async () => {+ // Otherwise a "faithful reproduction" remix is steered by beats the user+ // typed for a render they never submitted.+ const result = await chained(3);+ act(() => result.current.setChunkPromptAt(0, 'a stale beat'));+ act(() => result.current.applyRemix({ prompt: 'an unrelated clip' }));+ expect(result.current.chunks).toBe(1);+ expect(result.current.chunkPrompts).toEqual([]);+ expect(result.current.buildGeneratePayload().chunkPrompts).toBe('');+ });+it('restores beats from a resumed job, mapping the server null back to blank', async () => {const { result } = render();await waitFor(() => expect(result.current.modelId).toBe(MLX.id));diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex dbb5f325c7..95d5dcc436 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -63,7 +63,7 @@ grep -i "what you want to do" client/src/lib/README.md| `imageTo3dReasons.js` | Client mirror of the image-to-3D unavailable-reason labels in `server/services/imageTo3d/targets.js`: `UNAVAILABLE_REASONS` (reason code → user-facing label), `UNAVAILABLE_REASON_FALLBACK`, and `unavailableReasonLabel(code, fallback?)`. Use this anywhere a target's `unavailableReason` is rendered — never re-declare the codes. Parity + code coverage enforced by `server/services/imageTo3d/unavailableReasons.parity.test.js`. || `importerDeepLink.js` | The Importer deep-link contract both ways: `buildImporterLink({ universeId, seriesId, seriesName })` builds the `/importer?…` URL a Series Pipeline page navigates to; `resolveImporterDeepLink(...)` reads those params back into the universe + series names the importer matches on. || `muscriptorModels.js` | `MUSCRIPTOR_MODELS` (audio → MIDI size tiers `small`/`medium`/`large`) + `DEFAULT_MUSCRIPTOR_MODEL`. Single source consumed by the transcribe `<select>`s in `MusicVideo.jsx` and `ReferenceAnalysis.jsx`. Mirrors the server's `MUSCRIPTOR_MODELS` in `server/services/audioMidiTranscription.js`. |-| `videoGenParams.js` | Pure VideoGen param helpers: `FRAME_OPTIONS`/`FPS_OPTIONS`/`VIDEO_EDGE_BOUNDS` constants, `videoModelMemoryGb()` (model memory footprint), `computeFflfSafeFrames()` (FFLF/ltx2 pixel-budget back-solve, mirrors `server/services/videoGen/local.js`), and `isModelAllowedForMode()` (a2v + IC-remix → ltx2 gate). Also mirrors the IC-LoRA remix registry (`IC_LORA_MODES`/`IC_LORA_MODE_VALUES`/`isIcLoraMode()`/`icLoraSpecForMode()`/`icResolutionIssue()`) from `server/lib/icLoraWeights.js` so the form validates a reference render pre-submit — pinned by `server/lib/icLoraWeights.parity.test.js`. |+| `videoGenParams.js` | Pure VideoGen param helpers: `FRAME_OPTIONS`/`FPS_OPTIONS`/`VIDEO_EDGE_BOUNDS`/`MAX_CHUNKS`/`CHUNK_OPTIONS` constants, `videoModelMemoryGb()` (model memory footprint), `computeFflfSafeFrames()` (FFLF/ltx2 pixel-budget back-solve, mirrors `server/services/videoGen/local.js`), and `isModelAllowedForMode()` (a2v + IC-remix → ltx2 gate). Also mirrors the IC-LoRA remix registry (`IC_LORA_MODES`/`IC_LORA_MODE_VALUES`/`isIcLoraMode()`/`icLoraSpecForMode()`/`icResolutionIssue()`) from `server/lib/icLoraWeights.js` so the form validates a reference render pre-submit — pinned by `server/lib/icLoraWeights.parity.test.js`. || `videoGenResolutions.js` | Shared resolution presets for video generation (companion to image side; LTX-2 latent-friendly sizes) + `snapAspectToImage()` to pick the closest-aspect preset for an I2V source. || `videoTilingOptions.js` | `VIDEO_TILING_OPTIONS` (the `<select>` rows) + `VIDEO_TILING_ENUM_SET` (the value-only Set). Single source consumed by `VideoGen.jsx` and the Remix URL builder in `useMediaPreviewActions`. Mirrors the server's `z.enum` in `server/routes/videoGen.js`. |diff --git a/client/src/lib/videoGenParams.js b/client/src/lib/videoGenParams.jsindex 5452512c27..68cf5495db 100644--- a/client/src/lib/videoGenParams.js+++ b/client/src/lib/videoGenParams.js@@ -12,6 +12,11 @@// see the hint under the Frames dropdown.export const FRAME_OPTIONS = [25, 49, 73, 97, 121, 145, 169, 193, 217, 241, 265, 313, 361, 481];export const FPS_OPTIONS = [16, 24, 30];+// Chain ceiling — mirrors the route's own 1..8 cap on `chunks` (and on the+// per-chunk prompt list), which bounds worst-case wall time at 8 × ~5min.+// Exported so the Chunks picker and the Remix restore can't drift from it.+export const MAX_CHUNKS = 8;+export const CHUNK_OPTIONS = Array.from({ length: MAX_CHUNKS }, (_, i) => i + 1);export const WAN_FRAME_OPTIONS = [...new Set([...FRAME_OPTIONS,41, 61, 81, 101, 161, 201, 321,