From 405a694f35b7265a6f0a0e7053fd943ed160f304 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 15 Apr 2026 06:19:30 +0200 Subject: [PATCH] Add function to handle creation of attached sequence for routine --- src/app/App.tsx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/app/App.tsx b/src/app/App.tsx index 568b592b..fb0a28c0 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -4543,6 +4543,52 @@ export function App({ store, initialStatusMessage }: AppProps) { } }; + const handleCreateAttachedSequenceForRoutine = (routineId: string) => { + const routine = editorState.projectDocument.scheduler.routines[routineId] ?? null; + + if (routine === null) { + setStatusMessage("Selected sequence placement no longer exists."); + return; + } + + const targetOption = resolveProjectScheduleTargetOption( + getControlTargetRefKey(routine.target) + ); + + if (targetOption === null) { + setStatusMessage("Selected sequencer target no longer exists."); + return; + } + + try { + const nextSequence = createAttachedSequenceForRoutine({ + title: routine.title, + targetOption, + routine + }); + + updateProjectSequencerState( + "Create attached sequence", + "Created an attached sequence from this placement.", + (scheduler, sequences) => { + sequences.sequences[nextSequence.id] = nextSequence; + const draftRoutine = scheduler.routines[routineId]; + + if (draftRoutine === undefined) { + throw new Error("Selected sequence placement no longer exists."); + } + + draftRoutine.sequenceId = nextSequence.id; + draftRoutine.effects = []; + } + ); + setSelectedSequenceId(nextSequence.id); + setSequencerMode("timeline"); + } catch (error) { + setStatusMessage(getErrorMessage(error)); + } + }; + const handleAddProjectDialogue = () => { const nextDialogue = createProjectDialogue();