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

fix: preserve authored whitespace in queued video chunk prompts (#12481)

[._.]/ Adam Eivy99466f24a0e4
diff --git a/server/services/videoGen/prepareParams.js b/server/services/videoGen/prepareParams.js
index 2610ef34e7..d6e1d53c71 100644
--- a/server/services/videoGen/prepareParams.js
+++ b/server/services/videoGen/prepareParams.js
@@ -1125,7 +1125,7 @@ async function resolvePreparedParams({
// identically instead of storing a useless array of nulls.
const normalizedChunkPrompts = effectiveChunks > 1 && Array.isArray(body.chunkPrompts)
? body.chunkPrompts.slice(0, effectiveChunks)
- .map((p) => (typeof p === 'string' && p.trim() !== '' ? p.trim() : null))
+ .map((p) => (typeof p === 'string' && p.trim() !== '' ? p : null))
: undefined;
const effectiveChunkPrompts = normalizedChunkPrompts?.some(Boolean)
? normalizedChunkPrompts
diff --git a/server/services/videoGen/prepareParams.test.js b/server/services/videoGen/prepareParams.test.js
index f48413a734..7b92999de4 100644
--- a/server/services/videoGen/prepareParams.test.js
+++ b/server/services/videoGen/prepareParams.test.js
@@ -348,9 +348,9 @@ describe('prepareVideoGenParams', () => {
});
describe('per-chunk prompt beats (#3695)', () => {
- it('normalizes beats and keeps a blank entry in position as a fallback marker', async () => {
- const prepared = await prepare({ mode: 'image', chunks: 3, chunkPrompts: [' opens the door ', '', 'the storm breaks'] });
- expect(prepared.effectiveChunkPrompts).toEqual(['opens the door', null, 'the storm breaks']);
+ it('preserves nonblank beats as authored and keeps a blank entry in position as a fallback marker', async () => {
+ const prepared = await prepare({ mode: 'image', chunks: 3, chunkPrompts: [' opens the door\n\t', '', 'the storm breaks'] });
+ expect(prepared.effectiveChunkPrompts).toEqual([' opens the door\n\t', null, 'the storm breaks']);
});
it('truncates a stale overlong list to the resolved chunk count', async () => {
diff --git a/server/services/videoGen/submitJob.test.js b/server/services/videoGen/submitJob.test.js
index 9ceb5f1f94..2866a2f2c2 100644
--- a/server/services/videoGen/submitJob.test.js
+++ b/server/services/videoGen/submitJob.test.js
@@ -175,6 +175,14 @@ describe('submitVideoGenJob', () => {
}
});
+ it('persists prepared chunk beats byte-for-byte into queued params', async () => {
+ const chunkPrompts = [' \topening beat\n ', null, 'closing beat '];
+ mocks.prepareVideoGenParams.mockResolvedValue(localPrepared({ effectiveChunkPrompts: chunkPrompts }));
+
+ await submitVideoGenJob({ prompt: 'Example shot', width: 1280, height: 720 }, {});
+ expect(mocks.enqueueJob.mock.calls[0][0].params.chunkPrompts).toEqual(chunkPrompts);
+ });
+
it('cleans multipart uploads exactly once when submission fails', async () => {
const failure = new Error('staging failed');
const uploads = { sourceImage: { path: '/tmp/example-upload' } };