I need to understand how presets work in the SegmentSettingsForm and trace why selecting a preset might not pass the preset id or phase config to the task.
Explore:
The SegmentSettingsForm directory structure and main components
How presets are selected and what happens when one is chosen
How the form values (including preset) flow to task creation
Look for any disconnect where the preset ID or phase config might be lost
Focus on:
How preset selection updates form state
How form state is consumed when creating a task
Whether preset_id or phase_config is actually included in the task params
Search broadly in src/shared/components/SegmentSettingsForm/ and trace to task creation hooks.
Assistant
I'll conduct a thorough exploration of how presets work in SegmentSettingsForm and trace the flow to task creation. Let me start by understanding the directory structure and then trace the data flow.
Assistant
Let me get a complete view of the directory structure and read the key files.
Assistant
Now let me read the key files to understand the structure and preset handling.
Assistant
Good! Now let me search for where this form is used and how the task is created. Let me also check the segmentSettingsUtils to understand SegmentSettings better.
Assistant
Excellent! I can see the key function buildTaskParams at line 508. Now let me search for where SegmentSettingsForm is used and how the task is created.
Assistant
Let me check the two most important files: the hook that manages form state and the view components that use the form.
Assistant
Perfect! Now let me check the SegmentRegenerateForm as well to see another use case, and look at the useSegmentSettings hook.
Assistant
Let me read the main useSegmentSettings hook to understand the full data flow.
Assistant
Let me continue reading this file to see the getSettingsForTaskCreation function:
Assistant
Perfect! Now let me search for where buildTaskParams is actually being used to verify the preset_id and phase_config flow:
Assistant
Excellent! Now let me check how the preset is actually being selected in the MotionPresetSelector:
Assistant
Now let me look at the signature of onPresetSelect to see what parameters are passed:
Assistant
Perfect! Now I have a complete picture. Let me create a comprehensive summary document with my findings.
Summary: Preset Data Flow in SegmentSettingsForm
Based on my thorough exploration of the codebase, I've traced how presets work and identified the complete data flow from form selection to task creation. Here's my analysis:
Architecture Overview
Data Flow Chain:
User selects preset in MotionPresetSelector
Preset ID and phase config stored in SegmentSettings
Form state updated via onChange callback
Settings saved to DB (optional)
At task submission, settings merged with shot defaults
Both preset ID and phase config are saved to shot_generations.metadata.segmentOverrides
Migration utility handles the new format storage
Potential Issues / Observations
No Loss in Standard Flow: The preset ID and phase config are properly passed through the entire chain from SegmentSettingsForm → useSegmentSettingsForm → useSegmentSettings → buildTaskParams → task creation.
Verification Point: If preset values aren't reaching the task, the issue would be in:
The onChange callback not being called (check if handlePhasePresetSelect is properly passed to MotionPresetSelector)
getSettingsForTaskCreation() returning undefined values (check if form.data has the values)
buildTaskParams() not receiving the settings (check if effectiveSettings includes selectedPhasePresetId)
Save vs Display: The form displays settings from form.data immediately, but only persists to DB when:
saveSettings() is called explicitly
Auto-save triggers (500ms debounce in useSegmentSettings)
This is intentional - display is immediate, but DB writes are async
Shot Defaults Resolution: Shot defaults are only used in getSettingsForTaskCreation(), not in buildTaskParams(). The caller must merge with shot defaults before passing to buildTaskParams() if they want to include them.
Files to Review if Debugging
For Display Issues: Check if preset selection updates form.settings in SegmentSettingsForm
For DB Save Issues: Check useSegmentSettings mutations and buildMetadataUpdate()
For Task Creation Issues: Verify buildTaskParams() receives correct effectiveSettings
For Mode Logic: Check stripModeFromPhaseConfig() and the conditional on line 568