mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-10-03 00:55:14 -07:00
fix(stories): round split_time_ms before posting
handleSplit was sending currentTimeMs - item.start_time_ms straight to the backend, which rejects it because StoryItemSplit.split_time_ms is typed as int and the playhead's currentTimeMs is a float (it's driven from HTMLAudioElement.currentTime, which carries sub-millisecond precision). Pydantic surfaced the mismatch as "Input should be a valid integer, got a number with a fractional part" and the toast read "Failed to split clip". Math.round at the call site, matching what the trim and move handlers already do.
This commit is contained in:
@@ -587,7 +587,10 @@ export function StoryTrackEditor({ storyId, items }: StoryTrackEditorProps) {
|
|||||||
const item = items.find((i) => i.id === selectedClipId);
|
const item = items.find((i) => i.id === selectedClipId);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
const splitTimeMs = currentTimeMs - item.start_time_ms;
|
// currentTimeMs is driven by audio playback and arrives as a float;
|
||||||
|
// the backend's StoryItemSplit.split_time_ms is `int`, so round before
|
||||||
|
// sending or pydantic rejects the request.
|
||||||
|
const splitTimeMs = Math.round(currentTimeMs - item.start_time_ms);
|
||||||
const effectiveDuration = getEffectiveDuration(item);
|
const effectiveDuration = getEffectiveDuration(item);
|
||||||
|
|
||||||
if (splitTimeMs <= 0 || splitTimeMs >= effectiveDuration) {
|
if (splitTimeMs <= 0 || splitTimeMs >= effectiveDuration) {
|
||||||
|
|||||||
Reference in New Issue
Block a user