fix: resolve TypeScript errors for Cloudflare Pages build

- Fix undefined 'result' variable reference in useWhisperTranscriptionSimple.ts
- Add type guards for array checks in ImageGenShapeUtil.tsx output handling
- Add Record<string, any> 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 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2025-11-29 21:51:54 -08:00
parent 3738b9c56b
commit ef3b5e7d0a
5 changed files with 27 additions and 25 deletions

View File

@ -714,7 +714,6 @@ export const useWhisperTranscription = ({
} }
} else { } else {
console.log('⚠️ No transcription text produced') console.log('⚠️ No transcription text produced')
console.log('🔍 Full transcription result object:', result)
// Try alternative transcription parameters (only for local model) // Try alternative transcription parameters (only for local model)
if (!shouldUseRunPod && transcriberRef.current) { if (!shouldUseRunPod && transcriberRef.current) {

View File

@ -194,18 +194,20 @@ async function pollRunPodJob(
} else if (firstItem.url) { } else if (firstItem.url) {
imageUrl = 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 // Some formats nest result inside output
if (typeof data.output.result === 'string') { const outputObj = data.output as { result?: string | { image?: string; url?: string } }
imageUrl = data.output.result if (typeof outputObj.result === 'string') {
} else if (data.output.result?.image) { imageUrl = outputObj.result
imageUrl = data.output.result.image } else if (outputObj.result?.image) {
} else if (data.output.result?.url) { imageUrl = outputObj.result.image
imageUrl = data.output.result.url } 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 }] } } // 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) { if (firstImage.data) {
// Base64 encoded image // Base64 encoded image
if (firstImage.data.startsWith('data:image')) { if (firstImage.data.startsWith('data:image')) {
@ -386,8 +388,9 @@ export class ImageGenShape extends BaseBoxShapeUtil<IImageGen> {
let imageUrl = '' let imageUrl = ''
// Handle output.images array format (Automatic1111 endpoint format) // Handle output.images array format (Automatic1111 endpoint format)
if (Array.isArray(data.output.images) && data.output.images.length > 0) { if (typeof data.output === 'object' && !Array.isArray(data.output) && data.output.images && Array.isArray(data.output.images) && data.output.images.length > 0) {
const firstImage = data.output.images[0] const outputObj = data.output as { images: Array<{ data?: string; url?: string } | string> }
const firstImage = outputObj.images[0]
// Base64 encoded image string // Base64 encoded image string
if (typeof firstImage === 'string') { if (typeof firstImage === 'string') {
imageUrl = firstImage.startsWith('data:') ? firstImage : `data:image/png;base64,${firstImage}` imageUrl = firstImage.startsWith('data:') ? firstImage : `data:image/png;base64,${firstImage}`
@ -399,9 +402,9 @@ export class ImageGenShape extends BaseBoxShapeUtil<IImageGen> {
} }
} else if (typeof data.output === 'string') { } else if (typeof data.output === 'string') {
imageUrl = data.output imageUrl = data.output
} else if (data.output.image) { } else if (!Array.isArray(data.output) && data.output.image) {
imageUrl = 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 imageUrl = data.output.url
} else if (Array.isArray(data.output) && data.output.length > 0) { } else if (Array.isArray(data.output) && data.output.length > 0) {
const firstItem = data.output[0] const firstItem = data.output[0]

View File

@ -4,7 +4,7 @@ import { canvasAI, useCanvasAI } from "@/lib/canvasAI"
import { useWebSpeechTranscription } from "@/hooks/useWebSpeechTranscription" import { useWebSpeechTranscription } from "@/hooks/useWebSpeechTranscription"
// Microphone icon component // Microphone icon component
const MicrophoneIcon = ({ isListening, isDark }: { isListening: boolean; isDark: boolean }) => ( const MicrophoneIcon = ({ isListening }: { isListening: boolean }) => (
<svg <svg
width="20" width="20"
height="20" height="20"
@ -364,7 +364,7 @@ export function MycelialIntelligenceBar() {
}} }}
title={isRecording ? "Stop recording" : "Voice input"} title={isRecording ? "Stop recording" : "Voice input"}
> >
<MicrophoneIcon isListening={isRecording} isDark={isDark} /> <MicrophoneIcon isListening={isRecording} />
</button> </button>
)} )}
@ -638,7 +638,7 @@ export function MycelialIntelligenceBar() {
}} }}
title={isRecording ? "Stop recording" : "Start voice input"} title={isRecording ? "Stop recording" : "Start voice input"}
> >
<MicrophoneIcon isListening={isRecording} isDark={isDark} /> <MicrophoneIcon isListening={isRecording} />
</button> </button>
)} )}

View File

@ -68,7 +68,7 @@ function CustomPeopleMenu() {
</div> </div>
{/* Other users (stacked) */} {/* Other users (stacked) */}
{collaborators.slice(0, 3).map((presence, index) => ( {collaborators.slice(0, 3).map((presence) => (
<div <div
key={presence.id} key={presence.id}
style={{ style={{

View File

@ -570,7 +570,7 @@ async function callProviderAPI(
throw new Error(`Ollama API error: ${response.status} - ${errorText}`); throw new Error(`Ollama API error: ${response.status} - ${errorText}`);
} }
const data = await response.json(); const data = await response.json() as Record<string, any>;
console.log('📥 Ollama API: Response received:', JSON.stringify(data, null, 2).substring(0, 500)); console.log('📥 Ollama API: Response received:', JSON.stringify(data, null, 2).substring(0, 500));
// Extract response from AI Orchestrator format // Extract response from AI Orchestrator format
@ -657,7 +657,7 @@ async function callProviderAPI(
}); });
if (syncResponse.ok) { if (syncResponse.ok) {
const syncData = await syncResponse.json(); const syncData = await syncResponse.json() as Record<string, any>;
console.log('📥 RunPod API: Synchronous response:', JSON.stringify(syncData, null, 2)); console.log('📥 RunPod API: Synchronous response:', JSON.stringify(syncData, null, 2));
// Check if we got output directly // Check if we got output directly
@ -722,9 +722,9 @@ async function callProviderAPI(
throw new Error(`RunPod API error: ${response.status} - ${errorText}`); throw new Error(`RunPod API error: ${response.status} - ${errorText}`);
} }
const data = await response.json(); const data = await response.json() as Record<string, any>;
console.log('📥 RunPod API: Response data:', JSON.stringify(data, null, 2)); console.log('📥 RunPod API: Response data:', JSON.stringify(data, null, 2));
// Handle async job pattern (RunPod often returns job IDs) // Handle async job pattern (RunPod often returns job IDs)
if (data.id && (data.status === 'IN_QUEUE' || data.status === 'IN_PROGRESS')) { if (data.id && (data.status === 'IN_QUEUE' || data.status === 'IN_PROGRESS')) {
console.log('⏳ RunPod API: Job queued/in progress, polling job ID:', data.id); 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}`); throw new Error(`Failed to check job status: ${response.status} - ${errorText}`);
} }
const data = await response.json(); const data = await response.json() as Record<string, any>;
console.log(`🔄 RunPod API: Poll attempt ${attempt + 1}/${maxAttempts}, status:`, data.status); console.log(`🔄 RunPod API: Poll attempt ${attempt + 1}/${maxAttempts}, status:`, data.status);
console.log(`📥 RunPod API: Full poll response:`, JSON.stringify(data, null, 2)); console.log(`📥 RunPod API: Full poll response:`, JSON.stringify(data, null, 2));
@ -951,9 +951,9 @@ async function pollRunPodJob(
}); });
if (streamResponse.ok) { if (streamResponse.ok) {
const streamData = await streamResponse.json(); const streamData = await streamResponse.json() as Record<string, any>;
console.log('📥 RunPod API: Stream endpoint response:', JSON.stringify(streamData, null, 2)); console.log('📥 RunPod API: Stream endpoint response:', JSON.stringify(streamData, null, 2));
if (streamData.output) { if (streamData.output) {
// Use stream endpoint output // Use stream endpoint output
data.output = streamData.output; data.output = streamData.output;