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, web search current results, voice live transcript + confirm flow
PurpleDoubleD428ebdd02a67
diff --git a/src/api/voice.ts b/src/api/voice.tsindex 523e3d44..e7022318 100644--- a/src/api/voice.ts+++ b/src/api/voice.ts@@ -134,13 +134,17 @@ export function stopSpeaking(): void {}}+export interface AudioRecorderOptions {+ onInterimTranscript?: (text: string) => void;+}+interface AudioRecorder {start: () => Promise<void>;stop: () => Promise<{ blob: Blob; transcript: string }>;isRecording: () => boolean;}-export function createAudioRecorder(): AudioRecorder {+export function createAudioRecorder(options?: AudioRecorderOptions): AudioRecorder {let mediaRecorder: MediaRecorder | null = null;let recognition: any = null;let audioChunks: Blob[] = [];@@ -190,7 +194,12 @@ export function createAudioRecorder(): AudioRecorder {interim += result[0].transcript;}}- currentTranscript = final || interim;+ currentTranscript = final + interim;++ // Fire interim transcript callback for live updates+ if (options?.onInterimTranscript) {+ options.onInterimTranscript(currentTranscript);+ }};recognition.onerror = (event: any) => {diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsxindex 6abf4bcd..29e4a083 100644--- a/src/components/chat/ChatInput.tsx+++ b/src/components/chat/ChatInput.tsx@@ -1,8 +1,7 @@-import { useState, useRef, useEffect } from 'react'+import { useState, useRef, useEffect, useCallback } from 'react'import { motion } from 'framer-motion'-import { Send, Square } from 'lucide-react'+import { Send, Square, Check } from 'lucide-react'import { VoiceButton } from './VoiceButton'-import { useVoiceStore } from '../../stores/voiceStore'interface Props {onSend: (content: string) => void@@ -12,7 +11,9 @@ interface Props {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)useEffect(() => {if (textareaRef.current) {@@ -34,22 +35,40 @@ export function ChatInput({ onSend, onStop, isGenerating }: Props) {const handleKeyDown = (e: React.KeyboardEvent) => {if (e.key === 'Enter' && !e.shiftKey) {e.preventDefault()+ if (isVoiceRecording) return // Don't send while recordinghandleSend()}}+ const handleInterimTranscript = useCallback((text: string) => {+ setInput(text)+ }, [])++ const handleRecordingChange = useCallback((recording: boolean) => {+ setIsVoiceRecording(recording)+ }, [])++ const handleVoiceTranscript = useCallback((text: string) => {+ // Final transcript received after recording stops+ 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()+ }+return (<div className="p-3 border-t border-gray-200 dark:border-white/5"><div className="flex items-end gap-2.5 glass-card rounded-xl px-3 py-2.5"><VoiceButton- onTranscript={(text) => {- const autoSend = useVoiceStore.getState().autoSendOnTranscribe- if (autoSend) {- onSend(text)- } else {- setInput(text)- }- }}+ onTranscript={handleVoiceTranscript}+ onInterimTranscript={handleInterimTranscript}+ onRecordingChange={handleRecordingChange}disabled={isGenerating}/><textarea@@ -57,7 +76,7 @@ export function ChatInput({ onSend, onStop, isGenerating }: Props) {value={input}onChange={(e) => setInput(e.target.value)}onKeyDown={handleKeyDown}- placeholder="Type a message..."+ placeholder={isVoiceRecording ? "Listening..." : "Type a message..."}rows={1}className="flex-1 bg-transparent resize-none text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none text-[0.8rem] leading-relaxed max-h-[200px]"/>@@ -69,6 +88,15 @@ export function ChatInput({ onSend, onStop, isGenerating }: Props) {><Square size={15} /></motion.button>+ ) : isVoiceRecording ? (+ <motion.button+ onClick={handleConfirmRecording}+ className="p-2 rounded-lg bg-green-100 dark:bg-green-500/20 border border-green-300 dark:border-green-500/40 text-green-600 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-500/30 transition-all shrink-0"+ whileTap={{ scale: 0.9 }}+ title="Confirm voice input"+ >+ <Check size={15} />+ </motion.button>) : (<motion.buttononClick={handleSend}@@ -81,7 +109,7 @@ export function ChatInput({ onSend, onStop, isGenerating }: Props) {)}</div><p className="text-[0.65rem] text-gray-400 dark:text-gray-600 mt-1.5 text-center">- Enter to send · Shift+Enter for new line+ {isVoiceRecording ? 'Speaking... click checkmark to confirm' : 'Enter to send \u00b7 Shift+Enter for new line'}</p></div>)diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsxindex acb109bf..35b42abc 100644--- a/src/components/chat/ChatView.tsx+++ b/src/components/chat/ChatView.tsx@@ -1,4 +1,5 @@import { useState } from 'react'+import { AnimatePresence } from 'framer-motion'import { useChat } from '../../hooks/useChat'import { useChatStore } from '../../stores/chatStore'import { useModelStore } from '../../stores/modelStore'@@ -73,7 +74,9 @@ export function ChatView() {<MessageList isGenerating={isGenerating} /><ChatInput onSend={sendMessage} onStop={stopGeneration} isGenerating={isGenerating} /></div>- {ragPanelOpen && <RAGPanel conversationId={activeConversationId} />}+ <AnimatePresence>+ {ragPanelOpen && <RAGPanel conversationId={activeConversationId} />}+ </AnimatePresence></div>)}diff --git a/src/components/chat/VoiceButton.tsx b/src/components/chat/VoiceButton.tsxindex 7335df18..da1ef5eb 100644--- a/src/components/chat/VoiceButton.tsx+++ b/src/components/chat/VoiceButton.tsx@@ -4,10 +4,12 @@ import { useVoice } from "../../hooks/useVoice"interface Props {onTranscript: (text: string) => void+ onInterimTranscript?: (text: string) => void+ onRecordingChange?: (isRecording: boolean) => voiddisabled?: boolean}-export function VoiceButton({ onTranscript, disabled }: Props) {+export function VoiceButton({ onTranscript, onInterimTranscript, onRecordingChange, disabled }: Props) {const { isRecording, sttSupported, startRecording, stopRecording } = useVoice()const handleClick = async () => {@@ -15,11 +17,13 @@ export function VoiceButton({ onTranscript, disabled }: Props) {if (isRecording) {const transcript = await stopRecording()+ onRecordingChange?.(false)if (transcript.trim()) {onTranscript(transcript.trim())}} else {- await startRecording()+ await startRecording(onInterimTranscript)+ onRecordingChange?.(true)}}@@ -48,6 +52,7 @@ export function VoiceButton({ onTranscript, disabled }: Props) {? "bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/40 text-red-600 dark:text-red-400": "hover:bg-gray-100 dark:hover:bg-white/10 text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"} disabled:opacity-30 disabled:cursor-not-allowed`}+ data-voice-buttonwhileTap={{ scale: 0.9 }}>{isRecording && (diff --git a/src/hooks/useVoice.ts b/src/hooks/useVoice.tsindex 05d2b819..06933912 100644--- a/src/hooks/useVoice.ts+++ b/src/hooks/useVoice.ts@@ -13,14 +13,23 @@ import {export function useVoice() {const store = useVoiceStore();const recorderRef = useRef<ReturnType<typeof createAudioRecorder> | null>(null);+ const onInterimRef = useRef<((text: string) => void) | null>(null);const sttSupported = isSpeechRecognitionSupported();const ttsSupported = isSpeechSynthesisSupported();- const startRecording = useCallback(async () => {+ const startRecording = useCallback(async (onInterimTranscript?: (text: string) => void) => {if (recorderRef.current?.isRecording()) return;- const recorder = createAudioRecorder();+ onInterimRef.current = onInterimTranscript || null;++ const recorder = createAudioRecorder({+ onInterimTranscript: (text: string) => {+ if (onInterimRef.current) {+ onInterimRef.current(text);+ }+ },+ });recorderRef.current = recorder;try {@@ -41,11 +50,13 @@ export function useVoice() {store.setRecording(false);store.setTranscript(transcript);recorderRef.current = null;+ onInterimRef.current = null;return transcript;} catch (err) {console.error("Failed to stop recording:", err);store.setRecording(false);recorderRef.current = null;+ onInterimRef.current = null;return "";}}, [store]);diff --git a/vite.config.ts b/vite.config.tsindex e00b38b1..b3b67099 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -858,51 +858,81 @@ function comfyLauncher(): Plugin {})}- // Tier 2: DuckDuckGo Instant Answer API (official, no CAPTCHA)- const tryDDGInstant = (): Promise<{ title: string; url: string; snippet: string }[]> => {- const ddgUrl = 'https://api.duckduckgo.com/?q=' + encodeURIComponent(query) + '&format=json&no_html=1&skip_disambig=1'- return fetchJSON(ddgUrl).then((data: any) => {- const results: { title: string; url: string; snippet: string }[] = []-- // Abstract (main answer)- if (data.AbstractText && data.AbstractURL) {- results.push({- title: data.Heading || query,- url: data.AbstractURL,- snippet: data.AbstractText,- })+ // Tier 2: DuckDuckGo HTML search (POST, returns current results)+ const tryDDGHTML = (): Promise<{ title: string; url: string; snippet: string }[]> => {+ return new Promise((resolve, reject) => {+ const postData = 'q=' + encodeURIComponent(query)+ const options = {+ hostname: 'html.duckduckgo.com',+ port: 443,+ path: '/html/',+ method: 'POST',+ headers: {+ 'Content-Type': 'application/x-www-form-urlencoded',+ 'Content-Length': Buffer.byteLength(postData),+ 'User-Agent': 'Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',+ 'Accept': 'text/html',+ 'Accept-Language': 'en-US,en;q=0.9',+ },+ timeout: 10000,}-- // Related topics- if (Array.isArray(data.RelatedTopics)) {- for (const topic of data.RelatedTopics) {- if (results.length >= maxResults) break- if (topic.Text && topic.FirstURL) {- results.push({- title: topic.Text.split(' - ')[0] || topic.Text.substring(0, 80),- url: topic.FirstURL,- snippet: topic.Text,- })- }- // Handle sub-topics (grouped results)- if (Array.isArray(topic.Topics)) {- for (const sub of topic.Topics) {- if (results.length >= maxResults) break- if (sub.Text && sub.FirstURL) {- results.push({- title: sub.Text.split(' - ')[0] || sub.Text.substring(0, 80),- url: sub.FirstURL,- snippet: sub.Text,- })+ const httpReq = https.request(options, (response) => {+ if (response.statusCode !== 200) {+ response.resume()+ reject(new Error('DDG HTML returned HTTP ' + response.statusCode))+ return+ }+ let html = ''+ response.on('data', (chunk: Buffer) => { html += chunk.toString() })+ response.on('end', () => {+ try {+ const results: { title: string; url: string; snippet: string }[] = []+ // Parse result links: <a class="result__a" href="...">title</a>+ const linkRegex = /<a[^>]+class="result__a"[^>]*href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi+ // Parse snippets: <a class="result__snippet" ...>snippet</a>+ const snippetRegex = /<a[^>]+class="result__snippet"[^>]*>([\s\S]*?)<\/a>/gi++ const links: { title: string; url: string }[] = []+ let linkMatch+ while ((linkMatch = linkRegex.exec(html)) !== null) {+ let url = linkMatch[1]+ // DDG wraps URLs in redirect: //duckduckgo.com/l/?uddg=ENCODED_URL+ if (url.includes('uddg=')) {+ const uddg = url.split('uddg=')[1]?.split('&')[0]+ if (uddg) url = decodeURIComponent(uddg)+ }+ const title = linkMatch[2].replace(/<[^>]*>/g, '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/'/g, "'").replace(/"/g, '"').trim()+ if (title && url && url.startsWith('http')) {+ links.push({ title, url })}}- }- }- }- if (results.length === 0) throw new Error('DDG Instant returned no results')- console.log('[WebSearch] DDG Instant Answer returned ' + results.length + ' results')- return results.slice(0, maxResults)+ const snippets: string[] = []+ let snippetMatch+ while ((snippetMatch = snippetRegex.exec(html)) !== null) {+ snippets.push(snippetMatch[1].replace(/<[^>]*>/g, '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/'/g, "'").replace(/"/g, '"').replace(/\s+/g, ' ').trim())+ }++ for (let i = 0; i < Math.min(links.length, maxResults); i++) {+ results.push({+ title: links[i].title,+ url: links[i].url,+ snippet: snippets[i] || '',+ })+ }++ if (results.length === 0) throw new Error('DDG HTML returned no parseable results')+ console.log('[WebSearch] DDG HTML returned ' + results.length + ' results')+ resolve(results)+ } catch (e) {+ reject(e)+ }+ })+ })+ httpReq.on('error', reject)+ httpReq.on('timeout', () => { httpReq.destroy(); reject(new Error('DDG HTML timeout')) })+ httpReq.write(postData)+ httpReq.end()})}@@ -924,7 +954,7 @@ function comfyLauncher(): Plugin {// Execute tiers in ordertrySearXNG()- .catch(() => tryDDGInstant())+ .catch(() => tryDDGHTML()).catch(() => tryWikipedia()).then((results) => {res.writeHead(200, { 'Content-Type': 'application/json' })