From 5172cf90699b486c0c01ac9b7b23f4507e4c3037 Mon Sep 17 00:00:00 2001 From: Edwin Jose Date: Mon, 8 Sep 2025 10:35:33 -0400 Subject: [PATCH] eslint fix --- frontend/src/app/chat/page.tsx | 34 +++++++++++-------- frontend/src/app/connectors/page.tsx | 9 ++++- frontend/src/app/settings/page.tsx | 2 +- frontend/src/app/upload/[provider]/page.tsx | 14 ++++++-- .../components/cloud-connectors-dialog.tsx | 11 +++--- .../components/cloud-connectors-dropdown.tsx | 2 +- frontend/src/components/onedrive-picker.tsx | 30 ++++++++-------- 7 files changed, 58 insertions(+), 44 deletions(-) diff --git a/frontend/src/app/chat/page.tsx b/frontend/src/app/chat/page.tsx index a38d8b32..c3fb39b0 100644 --- a/frontend/src/app/chat/page.tsx +++ b/frontend/src/app/chat/page.tsx @@ -127,7 +127,6 @@ function ChatPage() { const [dropdownDismissed, setDropdownDismissed] = useState(false); const [isUserInteracting, setIsUserInteracting] = useState(false); const [isForkingInProgress, setIsForkingInProgress] = useState(false); - const [lastForkTimestamp, setLastForkTimestamp] = useState(0); const dragCounterRef = useRef(0); const messagesEndRef = useRef(null); const inputRef = useRef(null); @@ -454,8 +453,15 @@ function ChatPage() { content: string; timestamp?: string; response_id?: string; - chunks?: any[]; - response_data?: any; + chunks?: Array<{ + item?: { type?: string; tool_name?: string; id?: string; inputs?: unknown; results?: unknown; status?: string }; + delta?: { tool_calls?: Array<{ id?: string; function?: { name?: string; arguments?: string }; type?: string }> }; + type?: string; + result?: unknown; + output?: unknown; + response?: unknown; + }>; + response_data?: unknown; }) => { const message: Message = { role: msg.role as "user" | "assistant", @@ -480,12 +486,12 @@ function ChatPage() { const toolCall = chunk.item; console.log("Found Langflow tool call:", toolCall); functionCalls.push({ - id: toolCall.id, - name: toolCall.tool_name, - arguments: toolCall.inputs || {}, + id: toolCall.id || "", + name: toolCall.tool_name || "unknown", + arguments: (toolCall.inputs as Record) || {}, argumentsString: JSON.stringify(toolCall.inputs || {}), - result: toolCall.results, - status: toolCall.status || "completed", + result: toolCall.results as Record | ToolCallResult[], + status: (toolCall.status as "pending" | "completed" | "error") || "completed", type: "tool_call", }); } @@ -494,10 +500,10 @@ function ChatPage() { for (const toolCall of chunk.delta.tool_calls) { if (toolCall.function) { functionCalls.push({ - id: toolCall.id, - name: toolCall.function.name, + id: toolCall.id || "", + name: toolCall.function.name || "unknown", arguments: toolCall.function.arguments ? JSON.parse(toolCall.function.arguments) : {}, - argumentsString: toolCall.function.arguments, + argumentsString: toolCall.function.arguments || "", status: "completed", type: toolCall.type || "function", }); @@ -508,7 +514,7 @@ function ChatPage() { if (chunk.type === "response.tool_call.result" || chunk.type === "tool_call_result") { const lastCall = functionCalls[functionCalls.length - 1]; if (lastCall) { - lastCall.result = chunk.result || chunk; + lastCall.result = (chunk.result as Record | ToolCallResult[]) || (chunk as Record); lastCall.status = "completed"; } } @@ -562,6 +568,7 @@ function ChatPage() { conversationData, isUserInteracting, isForkingInProgress, + setPreviousResponseIds, ]); // Handle new conversation creation - only reset messages when placeholderConversation is set @@ -1536,10 +1543,8 @@ function ChatPage() { } // Set interaction state to prevent auto-scroll interference - const forkTimestamp = Date.now(); setIsUserInteracting(true); setIsForkingInProgress(true); - setLastForkTimestamp(forkTimestamp); console.log("Fork conversation called for message index:", messageIndex); @@ -1552,7 +1557,6 @@ function ChatPage() { console.error("Fork button should only be on assistant messages"); setIsUserInteracting(false); setIsForkingInProgress(false); - setLastForkTimestamp(0); return; } diff --git a/frontend/src/app/connectors/page.tsx b/frontend/src/app/connectors/page.tsx index 8011d1bd..26e1a88a 100644 --- a/frontend/src/app/connectors/page.tsx +++ b/frontend/src/app/connectors/page.tsx @@ -16,7 +16,14 @@ export default function ConnectorsPage() { const { addTask } = useTask() const [selectedFiles, setSelectedFiles] = useState([]); const [isSyncing, setIsSyncing] = useState(false); - const [syncResult, setSyncResult] = useState(null); + const [syncResult, setSyncResult] = useState<{ + processed?: number; + total?: number; + status?: string; + error?: string; + added?: number; + errors?: number; + } | null>(null); const handleFileSelection = (files: GoogleDriveFile[]) => { setSelectedFiles(files); diff --git a/frontend/src/app/settings/page.tsx b/frontend/src/app/settings/page.tsx index 711f43e3..798f28ab 100644 --- a/frontend/src/app/settings/page.tsx +++ b/frontend/src/app/settings/page.tsx @@ -29,7 +29,7 @@ interface OneDriveFile { webUrl?: string driveItem?: { file?: { mimeType: string } - folder?: any + folder?: unknown } } diff --git a/frontend/src/app/upload/[provider]/page.tsx b/frontend/src/app/upload/[provider]/page.tsx index 000c9202..8d26de02 100644 --- a/frontend/src/app/upload/[provider]/page.tsx +++ b/frontend/src/app/upload/[provider]/page.tsx @@ -24,7 +24,7 @@ interface OneDriveFile { webUrl?: string driveItem?: { file?: { mimeType: string } - folder?: object + folder?: unknown } } @@ -157,6 +157,14 @@ export default function UploadProviderPage() { // You can add additional handling here like triggering sync, etc. } + const handleGoogleDriveFileSelected = (files: GoogleDriveFile[]) => { + handleFileSelected(files) + } + + const handleOneDriveFileSelected = (files: OneDriveFile[]) => { + handleFileSelected(files) + } + const handleSync = async (connector: CloudConnector) => { if (!connector.connectionId || selectedFiles.length === 0) return @@ -323,7 +331,7 @@ export default function UploadProviderPage() {
{connector.type === "google_drive" && ( ({}) const [connectorAccessTokens, setConnectorAccessTokens] = useState<{[connectorType: string]: string}>({}) const [activePickerType, setActivePickerType] = useState(null) - const [isGooglePickerOpen, setIsGooglePickerOpen] = useState(false) const getConnectorIcon = (iconName: string) => { const iconMap: { [key: string]: React.ReactElement } = { @@ -129,7 +127,7 @@ export function CloudConnectorsDialog({ if (response.ok) { const data = await response.json() const connections = data.connections || [] - const activeConnection = connections.find((conn: any) => conn.is_active) + const activeConnection = connections.find((conn: { connection_id: string; is_active: boolean }) => conn.is_active) const isConnected = activeConnection !== undefined let hasAccessToken = false @@ -152,7 +150,7 @@ export function CloudConnectorsDialog({ const errorData = await tokenResponse.json().catch(() => ({ error: 'Token unavailable' })) accessTokenError = errorData.error || 'Access token unavailable' } - } catch (e) { + } catch { accessTokenError = 'Failed to fetch access token' } } @@ -260,12 +258,11 @@ export function CloudConnectorsDialog({ onFileSelected={(files) => { handleFileSelection(connector.id, files) setActivePickerType(null) - setIsGooglePickerOpen(false) }} selectedFiles={selectedFiles[connector.id] as GoogleDriveFile[] || []} isAuthenticated={connector.status === "connected"} accessToken={connectorAccessTokens[connector.type]} - onPickerStateChange={setIsGooglePickerOpen} + onPickerStateChange={() => {}} />
) diff --git a/frontend/src/components/cloud-connectors-dropdown.tsx b/frontend/src/components/cloud-connectors-dropdown.tsx index 1989132a..f8be08cd 100644 --- a/frontend/src/components/cloud-connectors-dropdown.tsx +++ b/frontend/src/components/cloud-connectors-dropdown.tsx @@ -26,7 +26,7 @@ interface OneDriveFile { webUrl?: string driveItem?: { file?: { mimeType: string } - folder?: any + folder?: unknown } } diff --git a/frontend/src/components/onedrive-picker.tsx b/frontend/src/components/onedrive-picker.tsx index 6d4cfc78..739491c1 100644 --- a/frontend/src/components/onedrive-picker.tsx +++ b/frontend/src/components/onedrive-picker.tsx @@ -21,7 +21,7 @@ interface OneDriveFile { webUrl?: string driveItem?: { file?: { mimeType: string } - folder?: any + folder?: unknown } } @@ -32,8 +32,8 @@ interface GraphResponse { declare global { interface Window { mgt?: { - Providers: { - globalProvider: any + Providers?: { + globalProvider?: unknown } } } @@ -58,21 +58,19 @@ export function OneDrivePicker({ ]) useEffect(() => { - const loadMGT = async () => { - if (typeof window !== 'undefined' && !window.mgt) { - try { - const mgtModule = await import('@microsoft/mgt-components') - const mgtProvider = await import('@microsoft/mgt-msal2-provider') - - // Initialize provider if needed - if (!window.mgt?.Providers?.globalProvider && accessToken) { - // For simplicity, we'll use direct Graph API calls instead of MGT components - } - } catch (error) { - console.warn('MGT not available, falling back to direct API calls') - } + const loadMGT = async () => { + if (typeof window !== 'undefined' && !window.mgt) { + try { + await import('@microsoft/mgt-components') + await import('@microsoft/mgt-msal2-provider') + + // For simplicity, we'll use direct Graph API calls instead of MGT components + // MGT provider initialization would go here if needed + } catch { + console.warn('MGT not available, falling back to direct API calls') } } + } loadMGT() }, [accessToken])