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:
Jamie Pine
2026-04-25 02:12:00 -07:00
parent d526a9e337
commit 935efedae0
@@ -587,7 +587,10 @@ export function StoryTrackEditor({ storyId, items }: StoryTrackEditorProps) {
const item = items.find((i) => i.id === selectedClipId);
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);
if (splitTimeMs <= 0 || splitTimeMs >= effectiveDuration) {