diff --git a/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx index 75cfa4184..4bd07a9d1 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx @@ -77,11 +77,6 @@ import { convertToThreadMessage, reconcileInterruptedAssistantMessages, } from "@/lib/chat/message-utils"; -import { - isPodcastGenerating, - looksLikePodcastRequest, - setActivePodcastTaskId, -} from "@/lib/chat/podcast-state"; import { createStreamFlushHelpers } from "@/lib/chat/stream-flush"; import { consumeSseEvents, processSharedStreamEvent } from "@/lib/chat/stream-pipeline"; import { @@ -954,11 +949,6 @@ export default function NewChatPage() { if (!userQuery.trim() && userImages.length === 0) return; - if (userQuery.trim() && isPodcastGenerating() && looksLikePodcastRequest(userQuery)) { - toast.warning("A podcast is already being generated."); - return; - } - const token = getBearerToken(); if (!token) { toast.error("Not authenticated. Please log in again."); @@ -1218,17 +1208,6 @@ export default function NewChatPage() { recentCancelRequestedAtRef.current = Date.now(); } }, - onToolOutputAvailable: (event, sharedCtx) => { - if (event.output?.status === "pending" && event.output?.podcast_id) { - const idx = sharedCtx.toolCallIndices.get(event.toolCallId); - if (idx !== undefined) { - const part = sharedCtx.contentPartsState.contentParts[idx]; - if (part?.type === "tool-call" && part.toolName === "generate_podcast") { - setActivePodcastTaskId(String(event.output.podcast_id)); - } - } - } - }, }) ) { return; @@ -2187,17 +2166,6 @@ export default function NewChatPage() { recentCancelRequestedAtRef.current = Date.now(); } }, - onToolOutputAvailable: (event, sharedCtx) => { - if (event.output?.status === "pending" && event.output?.podcast_id) { - const idx = sharedCtx.toolCallIndices.get(event.toolCallId); - if (idx !== undefined) { - const part = sharedCtx.contentPartsState.contentParts[idx]; - if (part?.type === "tool-call" && part.toolName === "generate_podcast") { - setActivePodcastTaskId(String(event.output.podcast_id)); - } - } - } - }, }) ) { return; diff --git a/surfsense_web/lib/chat/podcast-state.ts b/surfsense_web/lib/chat/podcast-state.ts deleted file mode 100644 index 061a89b63..000000000 --- a/surfsense_web/lib/chat/podcast-state.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Module-level state for tracking active podcast generation. - * Used by the new-chat adapter to prevent duplicate podcast requests. - */ - -type PodcastStateListener = (isGenerating: boolean) => void; - -let _activePodcastTaskId: string | null = null; -const _listeners: Set = new Set(); - -/** - * Check if a podcast is currently being generated - */ -export function isPodcastGenerating(): boolean { - return _activePodcastTaskId !== null; -} - -/** - * Get the active podcast task ID - */ -export function getActivePodcastTaskId(): string | null { - return _activePodcastTaskId; -} - -/** - * Set the active podcast task ID (when podcast generation starts) - */ -export function setActivePodcastTaskId(taskId: string): void { - _activePodcastTaskId = taskId; - notifyListeners(); -} - -/** - * Clear the active podcast task ID (when podcast generation completes or errors) - */ -export function clearActivePodcastTaskId(): void { - _activePodcastTaskId = null; - notifyListeners(); -} - -/** - * Subscribe to podcast state changes - */ -export function subscribeToPodcastState(listener: PodcastStateListener): () => void { - _listeners.add(listener); - return () => { - _listeners.delete(listener); - }; -} - -function notifyListeners(): void { - const isGenerating = _activePodcastTaskId !== null; - for (const listener of _listeners) { - listener(isGenerating); - } -} - -/** - * Check if a message looks like a podcast request - */ -export function looksLikePodcastRequest(message: string): boolean { - const podcastPatterns = [ - /\bpodcast\b/i, - /\bcreate.*podcast\b/i, - /\bgenerate.*podcast\b/i, - /\bmake.*podcast\b/i, - /\bturn.*into.*podcast\b/i, - /\bpodcast.*about\b/i, - /\bgive.*podcast\b/i, - ]; - - return podcastPatterns.some((pattern) => pattern.test(message)); -}