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 33ff5216cc
commit 928a535aec
5 changed files with 27 additions and 25 deletions

View File

@ -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) {

View File

@ -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<IImageGen> {
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<IImageGen> {
}
} 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]

View File

@ -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 }) => (
<svg
width="20"
height="20"
@ -364,7 +364,7 @@ export function MycelialIntelligenceBar() {
}}
title={isRecording ? "Stop recording" : "Voice input"}
>
<MicrophoneIcon isListening={isRecording} isDark={isDark} />
<MicrophoneIcon isListening={isRecording} />
</button>
)}
@ -638,7 +638,7 @@ export function MycelialIntelligenceBar() {
}}
title={isRecording ? "Stop recording" : "Start voice input"}
>
<MicrophoneIcon isListening={isRecording} isDark={isDark} />
<MicrophoneIcon isListening={isRecording} />
</button>
)}

View File

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

View File

@ -570,7 +570,7 @@ async function callProviderAPI(
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));
// 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<string, any>;
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<string, any>;
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<string, any>;
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<string, any>;
console.log('📥 RunPod API: Stream endpoint response:', JSON.stringify(streamData, null, 2));
if (streamData.output) {
// Use stream endpoint output
data.output = streamData.output;