The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix: RAG panel visibility, voice recording flow with live transcript
PurpleDoubleD0604ce886544
diff --git a/src/api/voice.ts b/src/api/voice.tsindex e7022318..cafdf783 100644--- a/src/api/voice.ts+++ b/src/api/voice.ts@@ -181,13 +181,26 @@ export function createAudioRecorder(options?: AudioRecorderOptions): AudioRecordrecognition = new SpeechRecognition();recognition.continuous = true;recognition.interimResults = true;- recognition.lang = "en-US";+ // Auto-detect user language instead of hardcoding en-US+ recognition.lang = navigator.language || "en-US";+ console.log("[Voice] SpeechRecognition starting with lang:", recognition.lang);++ recognition.onstart = () => {+ console.log("[Voice] SpeechRecognition started successfully");+ };recognition.onresult = (event: any) => {+ console.log("[Voice] onresult fired, results count:", event.results?.length);+ if (!event.results) {+ console.warn("[Voice] onresult: event.results is undefined");+ return;+ }+let interim = "";let final = "";for (let i = 0; i < event.results.length; i++) {const result = event.results[i];+ if (!result || !result[0]) continue;if (result.isFinal) {final += result[0].transcript;} else {@@ -195,6 +208,7 @@ export function createAudioRecorder(options?: AudioRecorderOptions): AudioRecord}}currentTranscript = final + interim;+ console.log("[Voice] Transcript update:", currentTranscript.slice(0, 80));// Fire interim transcript callback for live updatesif (options?.onInterimTranscript) {@@ -203,11 +217,22 @@ export function createAudioRecorder(options?: AudioRecorderOptions): AudioRecord};recognition.onerror = (event: any) => {- // Silently handle recognition errors — audio blob still captures- console.warn("SpeechRecognition error:", event.error);+ console.error("[Voice] SpeechRecognition error:", event.error, event.message);+ // If offline or network error, the transcript will just be empty+ // but audio blob still captures};- recognition.start();+ recognition.onend = () => {+ console.log("[Voice] SpeechRecognition ended");+ };++ try {+ recognition.start();+ } catch (err) {+ console.error("[Voice] Failed to start SpeechRecognition:", err);+ }+ } else {+ console.warn("[Voice] SpeechRecognition API not available in this browser");}recording = true;diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsxindex 29e4a083..7515433d 100644--- a/src/components/chat/ChatInput.tsx+++ b/src/components/chat/ChatInput.tsx@@ -13,7 +13,7 @@ export function ChatInput({ onSend, onStop, isGenerating }: Props) {const [input, setInput] = useState('')const [isVoiceRecording, setIsVoiceRecording] = useState(false)const textareaRef = useRef<HTMLTextAreaElement>(null)- const voiceButtonRef = useRef<{ stopRecording: () => void } | null>(null)+ const stopVoiceRef = useRef<(() => Promise<string>) | null>(null)useEffect(() => {if (textareaRef.current) {@@ -41,7 +41,15 @@ export function ChatInput({ onSend, onStop, isGenerating }: Props) {}const handleInterimTranscript = useCallback((text: string) => {+ console.log('[Voice] Interim:', text)setInput(text)+ // Force textarea height recalculation after interim update+ requestAnimationFrame(() => {+ if (textareaRef.current) {+ textareaRef.current.style.height = 'auto'+ textareaRef.current.style.height = Math.min(textareaRef.current.scrollHeight, 200) + 'px'+ }+ })}, [])const handleRecordingChange = useCallback((recording: boolean) => {@@ -53,13 +61,16 @@ export function ChatInput({ onSend, onStop, isGenerating }: Props) {setInput(text)}, [])- // When the checkmark is clicked, we need to trigger the VoiceButton to stop- // We do this by simulating a click on the VoiceButton- const handleConfirmRecording = () => {- // The VoiceButton click handler will stop recording and call onTranscript- // which sets the final text. We just need to trigger it.- const voiceBtn = document.querySelector('[data-voice-button]') as HTMLElement- if (voiceBtn) voiceBtn.click()+ const handleStopRegistered = useCallback((stopFn: () => Promise<string>) => {+ stopVoiceRef.current = stopFn+ }, [])++ // When the checkmark is clicked, stop voice recording via the registered stop function+ const handleConfirmRecording = async () => {+ if (stopVoiceRef.current) {+ await stopVoiceRef.current()+ stopVoiceRef.current = null+ }}return (@@ -69,6 +80,7 @@ export function ChatInput({ onSend, onStop, isGenerating }: Props) {onTranscript={handleVoiceTranscript}onInterimTranscript={handleInterimTranscript}onRecordingChange={handleRecordingChange}+ onStopRegistered={handleStopRegistered}disabled={isGenerating}/><textareadiff --git a/src/components/chat/RAGPanel.tsx b/src/components/chat/RAGPanel.tsxindex 769ea301..fad2ccf7 100644--- a/src/components/chat/RAGPanel.tsx+++ b/src/components/chat/RAGPanel.tsx@@ -13,6 +13,7 @@ import {ChevronRight,AlertTriangle,Download,+ MessageSquarePlus,} from 'lucide-react'import { useRAG } from '../../hooks/useRAG'import { useRAGStore } from '../../stores/ragStore'@@ -41,20 +42,45 @@ function ScoreBadge({ score }: { score: number }) {}export function RAGPanel({ conversationId }: Props) {- const {- documents,- isEnabled,- isIndexing,- indexingProgress,- contextWarning,- pullingEmbeddingModel,- uploadDocument,- removeDocument,- toggleRAG,- } = useRAG(conversationId)+ // Show placeholder when no conversation is active+ if (!conversationId) {+ return (+ <motion.div+ className="w-[280px] shrink-0 h-full border-l border-gray-200 dark:border-white/5 bg-white dark:bg-[#2a2a2a] flex flex-col items-center justify-center"+ initial={{ width: 0, opacity: 0 }}+ animate={{ width: 280, opacity: 1 }}+ exit={{ width: 0, opacity: 0 }}+ transition={{ duration: 0.2 }}+ >+ <MessageSquarePlus size={32} className="text-gray-300 dark:text-gray-600 mb-3" />+ <p className="text-sm text-gray-400 dark:text-gray-500 text-center px-6">+ Start a conversation first+ </p>+ <p className="text-[0.6rem] text-gray-300 dark:text-gray-600 text-center px-6 mt-1">+ Document chat will be available once a conversation is active.+ </p>+ </motion.div>+ )+ }++ return <RAGPanelInner conversationId={conversationId} />+}++function RAGPanelInner({ conversationId }: { conversationId: string }) {+ const rag = useRAG(conversationId)+ const documents = rag.documents ?? []+ const isEnabled = rag.isEnabled ?? false+ const isIndexing = rag.isIndexing ?? false+ const indexingProgress = rag.indexingProgress ?? null+ const contextWarning = rag.contextWarning ?? null+ const pullingEmbeddingModel = rag.pullingEmbeddingModel ?? false+ const uploadDocument = rag.uploadDocument+ const removeDocument = rag.removeDocument+ const toggleRAG = rag.toggleRAG++ const embeddingModelReactive = useRAGStore((s) => s.embeddingModel)+ const lastRetrievedChunksReactive = useRAGStore((s) => s.lastRetrievedChunks)- const embeddingModel = useRAGStore((s) => s.embeddingModel)- const lastRetrievedChunks = useRAGStore((s) => s.lastRetrievedChunks)const [isDragging, setIsDragging] = useState(false)const [error, setError] = useState<string | null>(null)const [chunksExpanded, setChunksExpanded] = useState(false)@@ -127,7 +153,7 @@ export function RAGPanel({ conversationId }: Props) {return 'Unknown'}- if (!conversationId) return null+ const safeChunks = Array.isArray(lastRetrievedChunksReactive) ? lastRetrievedChunksReactive : []const progressPercent = indexingProgress? String((indexingProgress.current / indexingProgress.total) * 100) + '%'@@ -310,7 +336,7 @@ export function RAGPanel({ conversationId }: Props) {</div>{/* Retrieved Chunks section */}- {lastRetrievedChunks.length > 0 && isEnabled && (+ {safeChunks.length > 0 && isEnabled && (<div className="border-t border-gray-200 dark:border-white/5"><buttononClick={() => setChunksExpanded(!chunksExpanded)}@@ -322,7 +348,7 @@ export function RAGPanel({ conversationId }: Props) {<ChevronRight size={12} className="text-gray-400" />)}<span className="text-[0.6rem] font-medium text-gray-600 dark:text-gray-300">- Retrieved Chunks ({lastRetrievedChunks.length})+ Retrieved Chunks ({safeChunks.length})</span></button>@@ -334,20 +360,20 @@ export function RAGPanel({ conversationId }: Props) {animate={{ opacity: 1, height: 'auto' }}exit={{ opacity: 0, height: 0 }}>- {lastRetrievedChunks.map((result, idx) => (+ {safeChunks.map((result, idx) => (<div- key={result.chunk.id + '-' + idx}+ key={(result?.chunk?.id ?? idx) + '-' + idx}className="p-2 rounded-lg bg-gray-50 dark:bg-white/5 space-y-1"><div className="flex items-center gap-1.5">- <ScoreBadge score={result.score} />+ <ScoreBadge score={result?.score ?? 0} /><span className="text-[0.55rem] text-gray-500 dark:text-gray-400 truncate">- {getDocName(result.chunk.documentId)}+ {getDocName(result?.chunk?.documentId ?? '')}</span></div><p className="text-[0.55rem] text-gray-600 dark:text-gray-300 leading-relaxed">- {result.chunk.content.slice(0, 80)}- {result.chunk.content.length > 80 ? '...' : ''}+ {(result?.chunk?.content ?? '').slice(0, 80)}+ {(result?.chunk?.content ?? '').length > 80 ? '...' : ''}</p></div>))}@@ -360,7 +386,7 @@ export function RAGPanel({ conversationId }: Props) {{/* Footer: embedding model */}<div className="px-3 py-2 border-t border-gray-200 dark:border-white/5"><p className="text-[0.55rem] text-gray-400 dark:text-gray-500 truncate">- Embedding: {embeddingModel}+ Embedding: {embeddingModelReactive ?? 'nomic-embed-text'}</p></div></motion.div>diff --git a/src/components/chat/VoiceButton.tsx b/src/components/chat/VoiceButton.tsxindex da1ef5eb..69e8a699 100644--- a/src/components/chat/VoiceButton.tsx+++ b/src/components/chat/VoiceButton.tsx@@ -1,3 +1,4 @@+import { useEffect } from "react"import { motion } from "framer-motion"import { Mic, MicOff } from "lucide-react"import { useVoice } from "../../hooks/useVoice"@@ -6,12 +7,27 @@ interface Props {onTranscript: (text: string) => voidonInterimTranscript?: (text: string) => voidonRecordingChange?: (isRecording: boolean) => void+ onStopRegistered?: (stopFn: () => Promise<string>) => voiddisabled?: boolean}-export function VoiceButton({ onTranscript, onInterimTranscript, onRecordingChange, disabled }: Props) {+export function VoiceButton({ onTranscript, onInterimTranscript, onRecordingChange, onStopRegistered, disabled }: Props) {const { isRecording, sttSupported, startRecording, stopRecording } = useVoice()+ // Register stop function whenever recording state changes+ useEffect(() => {+ if (isRecording && onStopRegistered) {+ onStopRegistered(async () => {+ const transcript = await stopRecording()+ onRecordingChange?.(false)+ if (transcript.trim()) {+ onTranscript(transcript.trim())+ }+ return transcript+ })+ }+ }, [isRecording, onStopRegistered, stopRecording, onRecordingChange, onTranscript])+const handleClick = async () => {if (disabled) return@@ -22,8 +38,9 @@ export function VoiceButton({ onTranscript, onInterimTranscript, onRecordingChanonTranscript(transcript.trim())}} else {- await startRecording(onInterimTranscript)+ // Notify parent BEFORE starting (so UI updates immediately)onRecordingChange?.(true)+ await startRecording(onInterimTranscript)}}