Skip to content
Open
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
58 changes: 51 additions & 7 deletions app/src/components/Generation/FloatingGenerateBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ import { useMatchRoute } from '@tanstack/react-router';
import { AnimatePresence, motion } from 'framer-motion';
import { Loader2, SlidersHorizontal, Sparkles } from 'lucide-react';
import { useEffect, useRef, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { Button } from '@/components/ui/button';
import { Form, FormControl, FormField, FormItem, FormMessage } from '@/components/ui/form';
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { Textarea } from '@/components/ui/textarea';
import { useToast } from '@/components/ui/use-toast';
import { LANGUAGE_OPTIONS } from '@/lib/constants/languages';
import { apiClient } from '@/lib/api/client';
import { useGenerationForm } from '@/lib/hooks/useGenerationForm';
import { useProfile, useProfiles } from '@/lib/hooks/useProfiles';
import { useAddStoryItem, useStory } from '@/lib/hooks/useStories';
Expand Down Expand Up @@ -46,6 +50,20 @@ export function FloatingGenerateBox({
const addStoryItem = useAddStoryItem();
const { toast } = useToast();

// Fetch model status to dynamically populate the model selector dropdown.
// Models are split into "Built-in" (qwen-tts-*) and "Custom" (is_custom flag)
// groups, keeping the same structure as GenerationForm.tsx.
// @modified AJ - Kamyab (Ankit Jain) — Added custom model grouping in selector
const { data: modelStatus } = useQuery({
queryKey: ['modelStatus'],
queryFn: () => apiClient.getModelStatus(),
refetchInterval: 10000,
});

// Separate built-in TTS models from user-added custom models
const builtInModels = modelStatus?.models.filter((m) => m.model_name.startsWith('qwen-tts')) || [];
const customModels = modelStatus?.models.filter((m) => m.is_custom) || [];

// Calculate if track editor is visible (on stories route with items)
const hasTrackEditor = isStoriesRoute && currentStory && currentStory.items.length > 0;

Expand Down Expand Up @@ -173,7 +191,7 @@ export function FloatingGenerateBox({
'fixed right-auto',
isStoriesRoute
? // Position aligned with story list: after sidebar + padding, width 360px
'left-[calc(5rem+2rem)] w-[360px]'
'left-[calc(5rem+2rem)] w-[360px]'
: 'left-[calc(5rem+2rem)] w-[calc((100%-5rem-4rem)/2-1rem)]',
)}
style={{
Expand Down Expand Up @@ -414,12 +432,38 @@ export function FloatingGenerateBox({
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem value="1.7B" className="text-xs text-muted-foreground">
Qwen3-TTS 1.7B
</SelectItem>
<SelectItem value="0.6B" className="text-xs text-muted-foreground">
Qwen3-TTS 0.6B
</SelectItem>
<SelectGroup>
<SelectLabel className="text-xs">Built-in</SelectLabel>
{builtInModels.length > 0 ? (
builtInModels.map((model) => {
const sizeValue = model.model_name.replace('qwen-tts-', '');
return (
<SelectItem key={model.model_name} value={sizeValue} className="text-xs text-muted-foreground">
{model.display_name}
</SelectItem>
);
})
) : (
<>
<SelectItem value="1.7B" className="text-xs text-muted-foreground">
Qwen3-TTS 1.7B
</SelectItem>
<SelectItem value="0.6B" className="text-xs text-muted-foreground">
Qwen3-TTS 0.6B
</SelectItem>
</>
)}
</SelectGroup>
{customModels.length > 0 && (
<SelectGroup>
<SelectLabel className="text-xs">Custom</SelectLabel>
{customModels.map((model) => (
<SelectItem key={model.model_name} value={model.model_name} className="text-xs text-muted-foreground">
{model.display_name}
</SelectItem>
))}
</SelectGroup>
)}
</SelectContent>
</Select>
<FormMessage className="text-xs" />
Expand Down
53 changes: 49 additions & 4 deletions app/src/components/Generation/GenerationForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Loader2, Mic } from 'lucide-react';
import { useQuery } from '@tanstack/react-query';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import {
Expand All @@ -14,12 +15,15 @@ import { Input } from '@/components/ui/input';
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { Textarea } from '@/components/ui/textarea';
import { LANGUAGE_OPTIONS } from '@/lib/constants/languages';
import { apiClient } from '@/lib/api/client';
import { useGenerationForm } from '@/lib/hooks/useGenerationForm';
import { useProfile } from '@/lib/hooks/useProfiles';
import { useUIStore } from '@/stores/uiStore';
Expand All @@ -30,6 +34,20 @@ export function GenerationForm() {

const { form, handleSubmit, isPending } = useGenerationForm();

// Fetch model status to dynamically populate the model selector dropdown.
// Models are split into "Built-in" (qwen-tts-*) and "Custom" (is_custom flag)
// groups so users can easily distinguish between them.
// @modified AJ - Kamyab (Ankit Jain) — Added custom model grouping in selector
const { data: modelStatus } = useQuery({
queryKey: ['modelStatus'],
queryFn: () => apiClient.getModelStatus(),
refetchInterval: 10000,
});

// Separate built-in TTS models from user-added custom models
const builtInModels = modelStatus?.models.filter((m) => m.model_name.startsWith('qwen-tts')) || [];
const customModels = modelStatus?.models.filter((m) => m.is_custom) || [];

async function onSubmit(data: Parameters<typeof handleSubmit>[0]) {
await handleSubmit(data, selectedProfileId);
}
Expand Down Expand Up @@ -129,19 +147,46 @@ export function GenerationForm() {
name="modelSize"
render={({ field }) => (
<FormItem>
<FormLabel>Model Size</FormLabel>
<FormLabel>Model</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem value="1.7B">Qwen TTS 1.7B (Higher Quality)</SelectItem>
<SelectItem value="0.6B">Qwen TTS 0.6B (Faster)</SelectItem>
<SelectGroup>
<SelectLabel>Built-in</SelectLabel>
{builtInModels.length > 0 ? (
builtInModels.map((model) => {
// Map model_name (qwen-tts-1.7B) back to model_size value (1.7B)
const sizeValue = model.model_name.replace('qwen-tts-', '');
return (
<SelectItem key={model.model_name} value={sizeValue}>
{model.display_name}
</SelectItem>
);
})
) : (
<>
<SelectItem value="1.7B">Qwen TTS 1.7B (Higher Quality)</SelectItem>
<SelectItem value="0.6B">Qwen TTS 0.6B (Faster)</SelectItem>
</>
)}
</SelectGroup>
{customModels.length > 0 && (
<SelectGroup>
<SelectLabel>Custom</SelectLabel>
{customModels.map((model) => (
<SelectItem key={model.model_name} value={model.model_name}>
{model.display_name}
</SelectItem>
))}
</SelectGroup>
)}
</SelectContent>
</Select>
<FormDescription>Larger models produce better quality</FormDescription>
<FormDescription>Select voice generation model</FormDescription>
<FormMessage />
</FormItem>
)}
Expand Down
Loading