refactor(podcasts): drop chat podcast polling state

This commit is contained in:
CREDO23 2026-06-11 10:04:51 +02:00
parent 1f9fd61c9e
commit ccd8209d12
2 changed files with 0 additions and 105 deletions

View file

@ -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;

View file

@ -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<PodcastStateListener> = 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));
}