From ef3b5e7d0a4f773dd6fa168cc6d1b2dbc28beaa7 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Sat, 29 Nov 2025 21:51:54 -0800 Subject: [PATCH] fix: resolve TypeScript errors for Cloudflare Pages build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix undefined 'result' variable reference in useWhisperTranscriptionSimple.ts - Add type guards for array checks in ImageGenShapeUtil.tsx output handling - Add Record type assertions for response.json() calls in llmUtils.ts - Remove unused 'isDark' parameter from MicrophoneIcon component - Remove unused 'index' parameter in components.tsx map callback 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/hooks/useWhisperTranscriptionSimple.ts | 1 - src/shapes/ImageGenShapeUtil.tsx | 29 ++++++++++++---------- src/ui/MycelialIntelligenceBar.tsx | 6 ++--- src/ui/components.tsx | 2 +- src/utils/llmUtils.ts | 14 +++++------ 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/hooks/useWhisperTranscriptionSimple.ts b/src/hooks/useWhisperTranscriptionSimple.ts index 17bee76..3865d53 100644 --- a/src/hooks/useWhisperTranscriptionSimple.ts +++ b/src/hooks/useWhisperTranscriptionSimple.ts @@ -714,7 +714,6 @@ export const useWhisperTranscription = ({ } } else { console.log('⚠️ No transcription text produced') - console.log('🔍 Full transcription result object:', result) // Try alternative transcription parameters (only for local model) if (!shouldUseRunPod && transcriberRef.current) { diff --git a/src/shapes/ImageGenShapeUtil.tsx b/src/shapes/ImageGenShapeUtil.tsx index 9882a26..2397397 100644 --- a/src/shapes/ImageGenShapeUtil.tsx +++ b/src/shapes/ImageGenShapeUtil.tsx @@ -194,18 +194,20 @@ async function pollRunPodJob( } else if (firstItem.url) { imageUrl = firstItem.url } - } else if (data.output?.result) { + } else if (!Array.isArray(data.output) && data.output?.result) { // Some formats nest result inside output - if (typeof data.output.result === 'string') { - imageUrl = data.output.result - } else if (data.output.result?.image) { - imageUrl = data.output.result.image - } else if (data.output.result?.url) { - imageUrl = data.output.result.url + const outputObj = data.output as { result?: string | { image?: string; url?: string } } + if (typeof outputObj.result === 'string') { + imageUrl = outputObj.result + } else if (outputObj.result?.image) { + imageUrl = outputObj.result.image + } else if (outputObj.result?.url) { + imageUrl = outputObj.result.url } - } else if (Array.isArray(data.output?.images) && data.output.images.length > 0) { + } else if (!Array.isArray(data.output) && data.output?.images && Array.isArray(data.output.images) && data.output.images.length > 0) { // ComfyUI worker format: { output: { images: [{ filename, type, data }] } } - const firstImage = data.output.images[0] + const outputObj = data.output as { images: Array<{ data?: string; url?: string; type?: string; filename?: string }> } + const firstImage = outputObj.images[0] if (firstImage.data) { // Base64 encoded image if (firstImage.data.startsWith('data:image')) { @@ -386,8 +388,9 @@ export class ImageGenShape extends BaseBoxShapeUtil { let imageUrl = '' // Handle output.images array format (Automatic1111 endpoint format) - if (Array.isArray(data.output.images) && data.output.images.length > 0) { - const firstImage = data.output.images[0] + if (typeof data.output === 'object' && !Array.isArray(data.output) && data.output.images && Array.isArray(data.output.images) && data.output.images.length > 0) { + const outputObj = data.output as { images: Array<{ data?: string; url?: string } | string> } + const firstImage = outputObj.images[0] // Base64 encoded image string if (typeof firstImage === 'string') { imageUrl = firstImage.startsWith('data:') ? firstImage : `data:image/png;base64,${firstImage}` @@ -399,9 +402,9 @@ export class ImageGenShape extends BaseBoxShapeUtil { } } else if (typeof data.output === 'string') { imageUrl = data.output - } else if (data.output.image) { + } else if (!Array.isArray(data.output) && data.output.image) { imageUrl = data.output.image - } else if (data.output.url) { + } else if (!Array.isArray(data.output) && data.output.url) { imageUrl = data.output.url } else if (Array.isArray(data.output) && data.output.length > 0) { const firstItem = data.output[0] diff --git a/src/ui/MycelialIntelligenceBar.tsx b/src/ui/MycelialIntelligenceBar.tsx index 3a0f804..29e39f7 100644 --- a/src/ui/MycelialIntelligenceBar.tsx +++ b/src/ui/MycelialIntelligenceBar.tsx @@ -4,7 +4,7 @@ import { canvasAI, useCanvasAI } from "@/lib/canvasAI" import { useWebSpeechTranscription } from "@/hooks/useWebSpeechTranscription" // Microphone icon component -const MicrophoneIcon = ({ isListening, isDark }: { isListening: boolean; isDark: boolean }) => ( +const MicrophoneIcon = ({ isListening }: { isListening: boolean }) => ( - + )} @@ -638,7 +638,7 @@ export function MycelialIntelligenceBar() { }} title={isRecording ? "Stop recording" : "Start voice input"} > - + )} diff --git a/src/ui/components.tsx b/src/ui/components.tsx index 3e800de..e280c55 100644 --- a/src/ui/components.tsx +++ b/src/ui/components.tsx @@ -68,7 +68,7 @@ function CustomPeopleMenu() { {/* Other users (stacked) */} - {collaborators.slice(0, 3).map((presence, index) => ( + {collaborators.slice(0, 3).map((presence) => (
; console.log('📥 Ollama API: Response received:', JSON.stringify(data, null, 2).substring(0, 500)); // Extract response from AI Orchestrator format @@ -657,7 +657,7 @@ async function callProviderAPI( }); if (syncResponse.ok) { - const syncData = await syncResponse.json(); + const syncData = await syncResponse.json() as Record; console.log('📥 RunPod API: Synchronous response:', JSON.stringify(syncData, null, 2)); // Check if we got output directly @@ -722,9 +722,9 @@ async function callProviderAPI( throw new Error(`RunPod API error: ${response.status} - ${errorText}`); } - const data = await response.json(); + const data = await response.json() as Record; console.log('📥 RunPod API: Response data:', JSON.stringify(data, null, 2)); - + // Handle async job pattern (RunPod often returns job IDs) if (data.id && (data.status === 'IN_QUEUE' || data.status === 'IN_PROGRESS')) { console.log('⏳ RunPod API: Job queued/in progress, polling job ID:', data.id); @@ -921,7 +921,7 @@ async function pollRunPodJob( throw new Error(`Failed to check job status: ${response.status} - ${errorText}`); } - const data = await response.json(); + const data = await response.json() as Record; console.log(`🔄 RunPod API: Poll attempt ${attempt + 1}/${maxAttempts}, status:`, data.status); console.log(`📥 RunPod API: Full poll response:`, JSON.stringify(data, null, 2)); @@ -951,9 +951,9 @@ async function pollRunPodJob( }); if (streamResponse.ok) { - const streamData = await streamResponse.json(); + const streamData = await streamResponse.json() as Record; console.log('📥 RunPod API: Stream endpoint response:', JSON.stringify(streamData, null, 2)); - + if (streamData.output) { // Use stream endpoint output data.output = streamData.output;