Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion ui/src/stores/studioConfigurationSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,18 @@ export function createStudioConfigurationSlice(
setDurationSeconds: requestedSeconds => {
const options = get().modelOptions
const fps = options?.fps ?? 16
const minimum = Math.max(1, (options?.frames_minimum || fps) / fps)
// DramaBox (and similar TTS models) declare duration_slider.min=0 so
// that 0 means "auto-derive from the prompt". The video floor of 1s
// must not rewrite that sentinel — Wizard prepare and the Advanced
// slider both call this setter with 0.
const autoDurationAllowed = Boolean(
options?.audio_only
&& options.duration_slider
&& options.duration_slider.min === 0,
)
const minimum = autoDurationAllowed
? 0
: Math.max(1, (options?.frames_minimum || fps) / fps)
const nativeMaximum = options?.frames_maximum ? options.frames_maximum / fps : null
const maximum = options?.sliding_window || nativeMaximum == null
? Number.POSITIVE_INFINITY
Expand Down
42 changes: 42 additions & 0 deletions ui/tests/architectureSlices.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,48 @@ test('Studio configuration slice owns form state without owning generation execu
assert.equal('runTool' in studio, false)
})

test('Studio duration setter keeps TTS auto sentinel at zero', async () => {
const { createStudioConfigurationSlice } = await import('../src/stores/studioConfigurationSlice.ts')
let state = {
params: { prompt: 'Speaker 1: hello', image_mode: 0 },
modelOptions: {
fps: 16,
audio_only: true,
duration_slider: { label: 'Target Duration (seconds, 0 = auto)', min: 0, max: 120, increment: 0.5, default: 0 },
},
h3WindowPlan: null,
generationMode: 'audio',
savedParamsPerMode: {},
}
const set = update => {
const partial = typeof update === 'function' ? update(state) : update
state = { ...state, ...partial }
}
const studio = createStudioConfigurationSlice({
alignFrameCount: frames => frames,
resolveResolution: (_options, preset, ratio) => `${preset}:${ratio}`,
})(set, () => state)
state = { ...state, ...studio }

state.setDurationSeconds(0)
assert.equal(state.durationSeconds, 0)
assert.equal(state.params.video_length, 0)

state.setDurationSeconds(12)
assert.equal(state.durationSeconds, 12)

state.modelOptions = {
fps: 24,
frames_minimum: 24,
frames_maximum: 120,
sliding_window: true,
audio_only: false,
duration_slider: null,
}
state.setDurationSeconds(0)
assert.equal(state.durationSeconds, 1)
})

test('composed slices bind without as-never casts at the useStore call site', async () => {
const fs = await import('node:fs/promises')
const source = await fs.readFile(new URL('../src/stores/useStore.ts', import.meta.url), 'utf8')
Expand Down
Loading