diff --git a/surfsense_web/components/tool-ui/podcast/brief-review.tsx b/surfsense_web/components/tool-ui/podcast/brief-review.tsx index 3473b64d6..d3962374a 100644 --- a/surfsense_web/components/tool-ui/podcast/brief-review.tsx +++ b/surfsense_web/components/tool-ui/podcast/brief-review.tsx @@ -15,7 +15,9 @@ import { } from "@/components/ui/select"; import { Textarea } from "@/components/ui/textarea"; import { + MAX_DURATION_SECONDS, MAX_SPEAKERS, + MIN_DURATION_SECONDS, type PodcastSpec, type PodcastStyle, podcastStyle, @@ -55,6 +57,9 @@ interface BriefReviewProps { */ export function BriefReview({ podcast, spec }: BriefReviewProps) { const [draft, setDraft] = useState(spec); + const [durationUnit, setDurationUnit] = useState(() => + defaultDurationUnit(spec.duration.max_seconds), + ); const [voices, setVoices] = useState(null); const [isSubmitting, setIsSubmitting] = useState(false); @@ -63,6 +68,7 @@ export function BriefReview({ podcast, spec }: BriefReviewProps) { // biome-ignore lint/correctness/useExhaustiveDependencies: reset only when the server version moves useEffect(() => { setDraft(spec); + setDurationUnit(defaultDurationUnit(spec.duration.max_seconds)); }, [podcast.specVersion]); useEffect(() => { @@ -304,39 +310,72 @@ export function BriefReview({ podcast, spec }: BriefReviewProps) { ))} -
-
- - - setDraft((current) => ({ - ...current, - duration: { ...current.duration, min_minutes: Number(e.target.value) || 1 }, - })) - } - /> +
+
+ +
-
- - - setDraft((current) => ({ - ...current, - duration: { - ...current.duration, - max_minutes: Number(e.target.value) || current.duration.min_minutes, - }, - })) - } - /> +
+
+ + { + const seconds = clampDurationSeconds( + fromUnitValue(Number(e.target.value), durationUnit), + ); + setDraft((current) => ({ + ...current, + duration: { ...current.duration, min_seconds: seconds }, + })); + }} + /> +
+
+ + { + const parsed = Number(e.target.value); + const fallback = secondsToUnitValue( + draft.duration.min_seconds, + durationUnit, + ); + const seconds = clampDurationSeconds( + fromUnitValue( + Number.isFinite(parsed) ? parsed : fallback, + durationUnit, + ), + ); + setDraft((current) => ({ + ...current, + duration: { ...current.duration, max_seconds: seconds }, + })); + }} + /> +
@@ -365,7 +404,9 @@ export function BriefReview({ podcast, spec }: BriefReviewProps) {