mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-24 21:38:09 +02:00
feat(podcasts): constrain monologue briefs to a single speaker
This commit is contained in:
parent
eb56acc407
commit
f0fc660d70
4 changed files with 55 additions and 14 deletions
|
|
@ -110,6 +110,16 @@ export function BriefReview({ podcast, spec }: BriefReviewProps) {
|
|||
});
|
||||
};
|
||||
|
||||
const setStyle = (style: PodcastStyle) => {
|
||||
setDraft((current) => ({
|
||||
...current,
|
||||
style,
|
||||
// A monologue has exactly one speaker, so extra speakers are dropped
|
||||
// rather than letting approval fail validation.
|
||||
speakers: style === "monologue" ? current.speakers.slice(0, 1) : current.speakers,
|
||||
}));
|
||||
};
|
||||
|
||||
const updateSpeaker = (slot: number, change: Partial<PodcastSpec["speakers"][number]>) => {
|
||||
setDraft((current) => ({
|
||||
...current,
|
||||
|
|
@ -198,12 +208,7 @@ export function BriefReview({ podcast, spec }: BriefReviewProps) {
|
|||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label htmlFor="podcast-style">Style</Label>
|
||||
<Select
|
||||
value={draft.style}
|
||||
onValueChange={(value) =>
|
||||
setDraft((current) => ({ ...current, style: value as PodcastStyle }))
|
||||
}
|
||||
>
|
||||
<Select value={draft.style} onValueChange={(value) => setStyle(value as PodcastStyle)}>
|
||||
<SelectTrigger id="podcast-style">
|
||||
<SelectValue placeholder="Style" />
|
||||
</SelectTrigger>
|
||||
|
|
@ -226,7 +231,7 @@ export function BriefReview({ podcast, spec }: BriefReviewProps) {
|
|||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={addSpeaker}
|
||||
disabled={draft.speakers.length >= MAX_SPEAKERS}
|
||||
disabled={draft.style === "monologue" || draft.speakers.length >= MAX_SPEAKERS}
|
||||
>
|
||||
<Plus className="size-4" /> Add speaker
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -61,13 +61,19 @@ export const durationTarget = z.object({
|
|||
});
|
||||
export type DurationTarget = z.infer<typeof durationTarget>;
|
||||
|
||||
export const podcastSpec = z.object({
|
||||
language: z.string().min(2),
|
||||
style: podcastStyle,
|
||||
speakers: z.array(speakerSpec).min(1).max(MAX_SPEAKERS),
|
||||
duration: durationTarget,
|
||||
focus: z.string().max(2000).nullable().optional(),
|
||||
});
|
||||
export const podcastSpec = z
|
||||
.object({
|
||||
language: z.string().min(2),
|
||||
style: podcastStyle,
|
||||
speakers: z.array(speakerSpec).min(1).max(MAX_SPEAKERS),
|
||||
duration: durationTarget,
|
||||
focus: z.string().max(2000).nullable().optional(),
|
||||
})
|
||||
// Mirrors the backend invariant: one voice is what "monologue" means.
|
||||
.refine((spec) => spec.style !== "monologue" || spec.speakers.length === 1, {
|
||||
message: "A monologue has exactly one speaker",
|
||||
path: ["speakers"],
|
||||
});
|
||||
export type PodcastSpec = z.infer<typeof podcastSpec>;
|
||||
|
||||
// =============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue