The open-source AI voice studio. Clone, dictate, create.
feat(generate): restore instruct toggle in floating generate box (Qwen CustomVoice)
James Pine106aec46a887
diff --git a/app/src/components/Generation/FloatingGenerateBox.tsx b/app/src/components/Generation/FloatingGenerateBox.tsxindex 956c6547..d977cc1a 100644--- a/app/src/components/Generation/FloatingGenerateBox.tsx+++ b/app/src/components/Generation/FloatingGenerateBox.tsx@@ -1,7 +1,7 @@import { useQuery } from '@tanstack/react-query';import { useMatchRoute } from '@tanstack/react-router';import { AnimatePresence, motion } from 'framer-motion';-import { Loader2, Sparkles } from 'lucide-react';+import { Loader2, SlidersHorizontal, Sparkles } from 'lucide-react';import { useEffect, useRef, useState } from 'react';import { Button } from '@/components/ui/button';import { Form, FormControl, FormField, FormItem, FormMessage } from '@/components/ui/form';@@ -40,6 +40,7 @@ export function FloatingGenerateBox({const { data: selectedProfile } = useProfile(selectedProfileId || '');const { data: profiles } = useProfiles();const [isExpanded, setIsExpanded] = useState(false);+ const [isInstructExpanded, setIsInstructExpanded] = useState(false);const [selectedPresetId, setSelectedPresetId] = useState<string | null>(null);const containerRef = useRef<HTMLDivElement>(null);const textareaRef = useRef<HTMLTextAreaElement | null>(null);@@ -125,7 +126,14 @@ export function FloatingGenerateBox({}, [watchedEngine, setSelectedEngine]);// Sync generation form language, engine, and effects with selected profile- type EngineValue = 'qwen' | 'luxtts' | 'chatterbox' | 'chatterbox_turbo' | 'tada' | 'kokoro' | 'qwen_custom_voice';+ type EngineValue =+ | 'qwen'+ | 'luxtts'+ | 'chatterbox'+ | 'chatterbox_turbo'+ | 'tada'+ | 'kokoro'+ | 'qwen_custom_voice';useEffect(() => {if (selectedProfile?.language) {form.setValue('language', selectedProfile.language as LanguageCode);@@ -346,9 +354,80 @@ export function FloatingGenerateBox({: 'Generate speech'}</span></div>++ {/* Instruct toggle — only for Qwen CustomVoice, which actually honors the kwarg */}+ <AnimatePresence>+ {isExpanded && form.watch('engine') === 'qwen_custom_voice' && (+ <motion.div+ initial={{ opacity: 0, scale: 0.8 }}+ animate={{ opacity: 1, scale: 1 }}+ exit={{ opacity: 0, scale: 0.8 }}+ transition={{ duration: 0.2 }}+ className="absolute top-0 right-[calc(100%+0.5rem)]"+ >+ <div className="group relative">+ <Button+ type="button"+ variant="ghost"+ size="icon"+ onClick={() => setIsInstructExpanded((prev) => !prev)}+ className={cn(+ 'h-10 w-10 rounded-full transition-all duration-200',+ isInstructExpanded+ ? 'bg-accent text-accent-foreground border border-accent hover:bg-accent/90'+ : 'bg-card border border-border hover:bg-background/50',+ )}+ aria-label={+ isInstructExpanded+ ? 'Hide delivery instructions'+ : 'Show delivery instructions'+ }+ aria-pressed={isInstructExpanded}+ >+ <SlidersHorizontal className="h-4 w-4" />+ </Button>+ <span className="pointer-events-none absolute bottom-full left-1/2 -translate-x-1/2 mb-2 whitespace-nowrap rounded-md bg-popover px-3 py-1.5 text-xs text-popover-foreground border border-border opacity-0 transition-opacity group-hover:opacity-100 z-[9999]">+ Delivery instructions (tone, emotion, pace)+ </span>+ </div>+ </motion.div>+ )}+ </AnimatePresence></div></div>+ {/* Additive instruct textarea — shown below main text when toggle is on and engine supports it */}+ <AnimatePresence>+ {isInstructExpanded && form.watch('engine') === 'qwen_custom_voice' && (+ <motion.div+ initial={{ opacity: 0, height: 0 }}+ animate={{ opacity: 1, height: 'auto' }}+ exit={{ opacity: 0, height: 0 }}+ transition={{ duration: 0.2, ease: 'easeOut' }}+ className="overflow-hidden"+ >+ <FormField+ control={form.control}+ name="instruct"+ render={({ field }) => (+ <FormItem className="mt-2">+ <FormControl>+ <Textarea+ {...field}+ placeholder="Delivery instructions — e.g. Speak slowly with warmth, Authoritative and clear..."+ className="resize-none bg-transparent border border-accent/20 focus-visible:ring-1 focus-visible:ring-accent/40 rounded-2xl text-sm placeholder:text-muted-foreground/60 w-full px-3 py-2"+ style={{ minHeight: '60px', maxHeight: '160px' }}+ maxLength={500}+ />+ </FormControl>+ <FormMessage className="text-xs" />+ </FormItem>+ )}+ />+ </motion.div>+ )}+ </AnimatePresence>+<AnimatePresence><motion.divinitial={{ height: 0, opacity: 0 }}diff --git a/app/src/components/Generation/GenerationForm.tsx b/app/src/components/Generation/GenerationForm.tsxindex ef3ff2c0..b31d908c 100644--- a/app/src/components/Generation/GenerationForm.tsx+++ b/app/src/components/Generation/GenerationForm.tsx@@ -1,5 +1,5 @@-import { useEffect } from 'react';import { Loader2, Mic } from 'lucide-react';+import { useEffect } from 'react';import { Button } from '@/components/ui/button';import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';import {@@ -24,7 +24,11 @@ import { getLanguageOptionsForEngine, type LanguageCode } from '@/lib/constants/import { useGenerationForm } from '@/lib/hooks/useGenerationForm';import { useProfile } from '@/lib/hooks/useProfiles';import { useUIStore } from '@/stores/uiStore';-import { EngineModelSelector, applyEngineSelection, getEngineDescription } from './EngineModelSelector';+import {+ applyEngineSelection,+ EngineModelSelector,+ getEngineDescription,+} from './EngineModelSelector';import { ParalinguisticInput } from './ParalinguisticInput';function getEngineSelectValue(engine: string): string {@@ -114,7 +118,7 @@ export function GenerationForm() {)}/>- {(form.watch('engine') === 'qwen' || form.watch('engine') === 'qwen_custom_voice') && (+ {form.watch('engine') === 'qwen_custom_voice' && (<FormFieldcontrol={form.control}name="instruct"diff --git a/app/src/lib/hooks/useGenerationForm.ts b/app/src/lib/hooks/useGenerationForm.tsindex d6a44bfc..06ec7242 100644--- a/app/src/lib/hooks/useGenerationForm.ts+++ b/app/src/lib/hooks/useGenerationForm.ts@@ -136,7 +136,9 @@ export function useGenerationForm(options: UseGenerationFormOptions = {}) {const hasModelSizes =engine === 'qwen' || engine === 'qwen_custom_voice' || engine === 'tada';- const supportsInstruct = engine === 'qwen' || engine === 'qwen_custom_voice';+ // Only Qwen CustomVoice actually honors the instruct kwarg at model level.+ // Base Qwen3-TTS accepts the kwarg but ignores it.+ const supportsInstruct = engine === 'qwen_custom_voice';const effectsChain = options.getEffectsChain?.();// This now returns immediately with status="generating"const result = await generation.mutateAsync({