From 37e15ac78616f51cc6e464f0b6176889595b540e Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 22 Sep 2025 22:28:01 +0700 Subject: [PATCH] lint / text fixes --- src/components/Shakespeare/ChatPane.tsx | 27 +++---------------------- src/hooks/useConsoleMessages.ts | 2 +- src/hooks/useErrorDetection.ts | 3 ++- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index f9af956c..9a1b372b 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -41,33 +41,14 @@ import { assistantContentEmpty } from '@/lib/ai-messages'; import { saveFileToTmp } from '@/lib/fileUtils'; import { useGit } from '@/hooks/useGit'; import { useConsoleErrorAlert, useAIModelErrorAlert } from '@/hooks/useErrorDetection'; -import { Alert, AlertDescription } from '@/components/ui/alert'; import { QuillySVG } from '@/components/ui/QuillySVG'; -const ALERT_TYPE = { - WARN: 'warn', - ERROR: 'error', - CONSOLE_ERROR: 'console_error' -} as const; - -type AlertType = typeof ALERT_TYPE[keyof typeof ALERT_TYPE]; - -interface ChatAlert { - type: AlertType; - message: string; - action?: { - label: string; - onClick: () => void; - }; -} function ChatIntervention({ - type, message, onDismiss, action }: { - type: string; message: string; onDismiss: () => void; action?: { label: string; onClick: () => void }; @@ -281,11 +262,11 @@ export const ChatPane = forwardRef(({ }, [internalIsLoading, onLoadingChange]); // Function to scroll to bottom - const scrollToBottom = () => { + const scrollToBottom = useCallback(() => { if (scrollAreaRef.current) { scrollAreaRef.current.scrollTop = scrollAreaRef.current.scrollHeight; } - }; + }, []); // Function to open model selector dropdown const openModelSelector = useCallback(() => { @@ -388,7 +369,7 @@ export const ChatPane = forwardRef(({ return () => clearTimeout(timer); } - }, [projectId, scrolledProjects]); + }, [projectId, scrolledProjects, scrollToBottom]); const handleFileSelect = (file: File) => { setAttachedFiles(prev => [...prev, file]); @@ -660,7 +641,6 @@ export const ChatPane = forwardRef(({ {/* AI Model Alert */} {aiModelAlert.hasError && ( (({ {/* Console Error Alert */} {consoleAlert.hasError && ( void> = new Set(); +const listeners: Set<(messages: ConsoleMessage[]) => void> = new Set(); const notifyListeners = () => { listeners.forEach(listener => listener([...globalConsoleMessages])); diff --git a/src/hooks/useErrorDetection.ts b/src/hooks/useErrorDetection.ts index c64c4417..209d12d6 100644 --- a/src/hooks/useErrorDetection.ts +++ b/src/hooks/useErrorDetection.ts @@ -1,4 +1,5 @@ import { useState, useCallback, useMemo } from 'react'; +import OpenAI from 'openai'; import { useConsoleMessages } from './useConsoleMessages'; export interface ConsoleErrorAlert { @@ -52,7 +53,7 @@ export interface AIModelErrorAlert { } export const useAIModelErrorAlert = ( - messages: any[], + messages: OpenAI.Chat.Completions.ChatCompletionMessage[], onNewChat?: () => void, onChangeModel?: () => void ): AIModelErrorAlert => {