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

Merge a partial composition patch instead of resetting mode and cutting (#11193)

[._.]/af92cf47b2e2
diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.js
index ed8e857435..1fe9071863 100644
--- a/server/services/musicVideo/projectsLogic.js
+++ b/server/services/musicVideo/projectsLogic.js
@@ -362,10 +362,15 @@ export function applyProjectPatch(project, patch) {
}) } : {}),
...(Array.isArray(patch.lyricMarkers) ? { lyricMarkers: normalizeLyricMarkers(patch.lyricMarkers) } : {}),
...(Array.isArray(patch.phrases) ? { phrases: normalizePhrases(patch.phrases) } : {}),
- // #8984 — the composition manifest is replaced whole; null clears it.
+ // #8984 — a manifest carrying its `mode` replaces the stored one whole
+ // (the editors send the full manifest, so an omitted key clears it); null
+ // clears it all. One without `mode` is a partial patch and merges over the
+ // stored manifest, so `{ style }` cannot silently reset mode and cutting.
// The composition document pointer is owned by the import routes: a PATCH
// that echoes (or omits, or forges) it keeps the stored one.
- ...('composition' in patch ? { composition: withStoredCompositionDocument(normalizeComposition(patch.composition), project.composition) } : {}),
+ ...('composition' in patch ? { composition: withStoredCompositionDocument(normalizeComposition(
+ patch.composition && typeof patch.composition === 'object' && !('mode' in patch.composition) && project.composition
+ ? { ...project.composition, ...patch.composition } : patch.composition), project.composition) } : {}),
// #8988 — an explicitly chosen sound-design bed; null clears it.
...('soundBed' in patch ? { soundBed: normalizeSoundBed(patch.soundBed) } : {}),
// The film look is replaced whole (one bounded record); null clears it.
diff --git a/server/services/musicVideo/projectsLogic.test.js b/server/services/musicVideo/projectsLogic.test.js
index ab416c50aa..ddb9ef0ca1 100644
--- a/server/services/musicVideo/projectsLogic.test.js
+++ b/server/services/musicVideo/projectsLogic.test.js
@@ -870,6 +870,15 @@ describe('composition document (render style `document`)', () => {
expect(applyProjectPatch(project, { composition: null }).composition).toBeNull();
});
+ // Uniquely catches a style-only PATCH resetting mode to concat and dropping cutting (staling the approvals).
+ it('merges a composition patch without a mode over the stored manifest, and replaces one that carries it', () => {
+ const project = { ...withDocument(), composition: { ...withDocument().composition, mode: 'composed', cutting: 'intercut' } };
+ const styled = applyProjectPatch(project, { composition: { style: { color: '#ff0000', font: 'serif' } } }).composition;
+ expect(styled).toMatchObject({ mode: 'composed', cutting: 'intercut', overlay: { titleLines: ['EXAMPLE'] }, style: { color: '#ff0000', font: 'serif' } });
+ const { cutting: _drop, ...full } = project.composition;
+ expect(applyProjectPatch(project, { composition: full }).composition).not.toHaveProperty('cutting');
+ });
+
it('carries the pointer to a clone (versions are immutable folders)', () => {
const clone = cloneProjectRecord(withDocument(), { id: 'mv-2', now: '2026-01-03T00:00:00.000Z' });
expect(clone.composition.document).toEqual(pointer);