From 65efda3278f2b448ed3c23161e7d7f7e5ca9b95d Mon Sep 17 00:00:00 2001 From: Haileyesus Date: Thu, 5 Mar 2026 17:14:17 +0300 Subject: [PATCH] fix: remove unused imports, functions, and types after discovering using `npm run lint` --- .../chat/hooks/useChatProviderState.ts | 2 +- .../components/ContentRenderers/TextContent.tsx | 1 + .../chat/tools/configs/toolConfigs.ts | 3 +++ src/components/chat/view/ChatInterface.tsx | 1 - .../AssistantThinkingIndicator.tsx | 1 - .../view/subcomponents/ChatMessagesPane.tsx | 1 - .../view/subcomponents/MessageComponent.tsx | 3 +-- .../git-panel/hooks/useGitPanelController.ts | 7 ------- .../sidebar/hooks/useSidebarController.ts | 17 ----------------- src/components/sidebar/types/types.ts | 5 ----- src/components/sidebar/view/Sidebar.tsx | 2 -- .../view/subcomponents/SidebarProjectItem.tsx | 5 +---- .../view/subcomponents/SidebarProjectList.tsx | 4 ---- .../subcomponents/SidebarProjectSessions.tsx | 5 +---- .../view/subcomponents/SidebarSessionItem.tsx | 4 +--- 15 files changed, 9 insertions(+), 52 deletions(-) diff --git a/src/components/chat/hooks/useChatProviderState.ts b/src/components/chat/hooks/useChatProviderState.ts index 8bd1151b..9d48ce3d 100644 --- a/src/components/chat/hooks/useChatProviderState.ts +++ b/src/components/chat/hooks/useChatProviderState.ts @@ -1,7 +1,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'; import { authenticatedFetch } from '../../../utils/api'; import { CLAUDE_MODELS, CODEX_MODELS, CURSOR_MODELS, GEMINI_MODELS } from '../../../../shared/modelConstants'; -import type { PendingPermissionRequest, PermissionMode, Provider } from '../types/types'; +import type { PendingPermissionRequest, PermissionMode } from '../types/types'; import type { ProjectSession, SessionProvider } from '../../../types/app'; interface UseChatProviderStateArgs { diff --git a/src/components/chat/tools/components/ContentRenderers/TextContent.tsx b/src/components/chat/tools/components/ContentRenderers/TextContent.tsx index 811165aa..2a5702f1 100644 --- a/src/components/chat/tools/components/ContentRenderers/TextContent.tsx +++ b/src/components/chat/tools/components/ContentRenderers/TextContent.tsx @@ -22,6 +22,7 @@ export const TextContent: React.FC = ({ formattedJson = JSON.stringify(parsed, null, 2); } catch (e) { // If parsing fails, use original content + console.warn('Failed to parse JSON content:', e); } return ( diff --git a/src/components/chat/tools/configs/toolConfigs.ts b/src/components/chat/tools/configs/toolConfigs.ts index 556334a3..40dd3dbc 100644 --- a/src/components/chat/tools/configs/toolConfigs.ts +++ b/src/components/chat/tools/configs/toolConfigs.ts @@ -274,6 +274,7 @@ export const TOOL_CONFIGS: Record = { } return { todos, isResult: true }; } catch (e) { + console.warn('Failed to parse todo list content:', e); return { todos: [], isResult: true }; } } @@ -514,6 +515,7 @@ export const TOOL_CONFIGS: Record = { content: parsed.plan?.replace(/\\n/g, '\n') || parsed.plan }; } catch (e) { + console.warn('Failed to parse plan content:', e); return { content: '' }; } } @@ -544,6 +546,7 @@ export const TOOL_CONFIGS: Record = { content: parsed.plan?.replace(/\\n/g, '\n') || parsed.plan }; } catch (e) { + console.warn('Failed to parse plan content:', e); return { content: '' }; } } diff --git a/src/components/chat/view/ChatInterface.tsx b/src/components/chat/view/ChatInterface.tsx index 36ce5a8e..eb888be9 100644 --- a/src/components/chat/view/ChatInterface.tsx +++ b/src/components/chat/view/ChatInterface.tsx @@ -88,7 +88,6 @@ function ChatInterface({ isLoadingMoreMessages, hasMoreMessages, totalMessages, - isSystemSessionChange, setIsSystemSessionChange, canAbortSession, setCanAbortSession, diff --git a/src/components/chat/view/subcomponents/AssistantThinkingIndicator.tsx b/src/components/chat/view/subcomponents/AssistantThinkingIndicator.tsx index 3fc8ca83..6fe096df 100644 --- a/src/components/chat/view/subcomponents/AssistantThinkingIndicator.tsx +++ b/src/components/chat/view/subcomponents/AssistantThinkingIndicator.tsx @@ -1,6 +1,5 @@ import { SessionProvider } from '../../../../types/app'; import SessionProviderLogo from '../../../llm-logo-provider/SessionProviderLogo'; -import type { Provider } from '../../types/types'; type AssistantThinkingIndicatorProps = { selectedProvider: SessionProvider; diff --git a/src/components/chat/view/subcomponents/ChatMessagesPane.tsx b/src/components/chat/view/subcomponents/ChatMessagesPane.tsx index 4ca67bd9..30a617f9 100644 --- a/src/components/chat/view/subcomponents/ChatMessagesPane.tsx +++ b/src/components/chat/view/subcomponents/ChatMessagesPane.tsx @@ -247,7 +247,6 @@ export default function ChatMessagesPane({ DiffLine[]; onFileOpen?: (filePath: string, diffInfo?: unknown) => void; @@ -43,7 +42,7 @@ type InteractiveOption = { type PermissionGrantState = 'idle' | 'granted' | 'error'; -const MessageComponent = memo(({ message, index, prevMessage, createDiff, onFileOpen, onShowSettings, onGrantToolPermission, autoExpandTools, showRawParameters, showThinking, selectedProject, provider }: MessageComponentProps) => { +const MessageComponent = memo(({ message, prevMessage, createDiff, onFileOpen, onShowSettings, onGrantToolPermission, autoExpandTools, showRawParameters, showThinking, selectedProject, provider }: MessageComponentProps) => { const { t } = useTranslation('chat'); const isGrouped = prevMessage && prevMessage.type === message.type && ((prevMessage.type === 'assistant') || diff --git a/src/components/git-panel/hooks/useGitPanelController.ts b/src/components/git-panel/hooks/useGitPanelController.ts index 36868671..7fe86358 100644 --- a/src/components/git-panel/hooks/useGitPanelController.ts +++ b/src/components/git-panel/hooks/useGitPanelController.ts @@ -154,13 +154,6 @@ export function useGitPanelController({ setGitStatus({ error: 'Git operation failed', details: String(error) }); setCurrentBranch(''); } finally { - if ( - signal?.aborted || - selectedProjectNameRef.current !== projectName - ) { - return; - } - setIsLoading(false); } }, [fetchFileDiff, selectedProject]); diff --git a/src/components/sidebar/hooks/useSidebarController.ts b/src/components/sidebar/hooks/useSidebarController.ts index e1a7a167..600057d8 100644 --- a/src/components/sidebar/hooks/useSidebarController.ts +++ b/src/components/sidebar/hooks/useSidebarController.ts @@ -1,5 +1,4 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; -import type React from 'react'; import type { TFunction } from 'i18next'; import { api } from '../../../utils/api'; import type { Project, ProjectSession, SessionProvider } from '../../../types/app'; @@ -141,21 +140,6 @@ export function useSidebarController({ }; }, []); - const handleTouchClick = useCallback( - (callback: () => void) => - (event: React.TouchEvent) => { - const target = event.target as HTMLElement; - if (target.closest('.overflow-y-auto') || target.closest('[data-scroll-container]')) { - return; - } - - event.preventDefault(); - event.stopPropagation(); - callback(); - }, - [], - ); - const toggleProject = useCallback((projectName: string) => { setExpandedProjects((prev) => { const next = new Set(); @@ -460,7 +444,6 @@ export function useSidebarController({ showVersionModal, starredProjects, filteredProjects, - handleTouchClick, toggleProject, handleSessionClick, toggleStarProject, diff --git a/src/components/sidebar/types/types.ts b/src/components/sidebar/types/types.ts index e9f2ce64..bab1b665 100644 --- a/src/components/sidebar/types/types.ts +++ b/src/components/sidebar/types/types.ts @@ -1,4 +1,3 @@ -import type React from 'react'; import type { LoadingProgress, Project, ProjectSession, SessionProvider } from '../../../types/app'; export type ProjectSortOrder = 'name' | 'date'; @@ -56,8 +55,4 @@ export type MCPServerStatus = { isConfigured?: boolean; } | null; -export type TouchHandlerFactory = ( - callback: () => void, -) => (event: React.TouchEvent) => void; - export type SettingsProject = Pick; diff --git a/src/components/sidebar/view/Sidebar.tsx b/src/components/sidebar/view/Sidebar.tsx index 3658880d..59ff84e1 100644 --- a/src/components/sidebar/view/Sidebar.tsx +++ b/src/components/sidebar/view/Sidebar.tsx @@ -65,7 +65,6 @@ function Sidebar({ sessionDeleteConfirmation, showVersionModal, filteredProjects, - handleTouchClick, toggleProject, handleSessionClick, toggleStarProject, @@ -175,7 +174,6 @@ function Sidebar({ onSaveEditingSession: (projectName: string, sessionId: string, summary: string, provider: SessionProvider) => { void updateSessionSummary(projectName, sessionId, summary, provider); }, - touchHandlerFactory: handleTouchClick, t, }; diff --git a/src/components/sidebar/view/subcomponents/SidebarProjectItem.tsx b/src/components/sidebar/view/subcomponents/SidebarProjectItem.tsx index 82b85a0f..b0113357 100644 --- a/src/components/sidebar/view/subcomponents/SidebarProjectItem.tsx +++ b/src/components/sidebar/view/subcomponents/SidebarProjectItem.tsx @@ -4,7 +4,7 @@ import type { TFunction } from 'i18next'; import { cn } from '../../../../lib/utils'; import TaskIndicator from './TaskIndicator'; import type { Project, ProjectSession, SessionProvider } from '../../../../types/app'; -import type { MCPServerStatus, SessionWithProvider, TouchHandlerFactory } from '../../types/types'; +import type { MCPServerStatus, SessionWithProvider } from '../../types/types'; import { getTaskIndicatorStatus } from '../../utils/utils'; import SidebarProjectSessions from './SidebarProjectSessions'; @@ -46,7 +46,6 @@ type SidebarProjectItemProps = { onStartEditingSession: (sessionId: string, initialName: string) => void; onCancelEditingSession: () => void; onSaveEditingSession: (projectName: string, sessionId: string, summary: string, provider: SessionProvider) => void; - touchHandlerFactory: TouchHandlerFactory; t: TFunction; }; @@ -92,7 +91,6 @@ export default function SidebarProjectItem({ onStartEditingSession, onCancelEditingSession, onSaveEditingSession, - touchHandlerFactory, t, }: SidebarProjectItemProps) { const isSelected = selectedProject?.name === project.name; @@ -424,7 +422,6 @@ export default function SidebarProjectItem({ onDeleteSession={onDeleteSession} onLoadMoreSessions={onLoadMoreSessions} onNewSession={onNewSession} - touchHandlerFactory={touchHandlerFactory} t={t} /> diff --git a/src/components/sidebar/view/subcomponents/SidebarProjectList.tsx b/src/components/sidebar/view/subcomponents/SidebarProjectList.tsx index 2ec0a4ca..52714ebe 100644 --- a/src/components/sidebar/view/subcomponents/SidebarProjectList.tsx +++ b/src/components/sidebar/view/subcomponents/SidebarProjectList.tsx @@ -5,7 +5,6 @@ import type { LoadingSessionsByProject, MCPServerStatus, SessionWithProvider, - TouchHandlerFactory, } from '../../types/types'; import SidebarProjectItem from './SidebarProjectItem'; import SidebarProjectsState from './SidebarProjectsState'; @@ -51,7 +50,6 @@ export type SidebarProjectListProps = { onStartEditingSession: (sessionId: string, initialName: string) => void; onCancelEditingSession: () => void; onSaveEditingSession: (projectName: string, sessionId: string, summary: string, provider: SessionProvider) => void; - touchHandlerFactory: TouchHandlerFactory; t: TFunction; }; @@ -91,7 +89,6 @@ export default function SidebarProjectList({ onStartEditingSession, onCancelEditingSession, onSaveEditingSession, - touchHandlerFactory, t, }: SidebarProjectListProps) { const state = ( @@ -154,7 +151,6 @@ export default function SidebarProjectList({ onStartEditingSession={onStartEditingSession} onCancelEditingSession={onCancelEditingSession} onSaveEditingSession={onSaveEditingSession} - touchHandlerFactory={touchHandlerFactory} t={t} /> ))} diff --git a/src/components/sidebar/view/subcomponents/SidebarProjectSessions.tsx b/src/components/sidebar/view/subcomponents/SidebarProjectSessions.tsx index 3249e862..33506e31 100644 --- a/src/components/sidebar/view/subcomponents/SidebarProjectSessions.tsx +++ b/src/components/sidebar/view/subcomponents/SidebarProjectSessions.tsx @@ -2,7 +2,7 @@ import { ChevronDown, Plus } from 'lucide-react'; import type { TFunction } from 'i18next'; import { Button } from '../../../../shared/view/ui'; import type { Project, ProjectSession, SessionProvider } from '../../../../types/app'; -import type { SessionWithProvider, TouchHandlerFactory } from '../../types/types'; +import type { SessionWithProvider } from '../../types/types'; import SidebarSessionItem from './SidebarSessionItem'; type SidebarProjectSessionsProps = { @@ -29,7 +29,6 @@ type SidebarProjectSessionsProps = { ) => void; onLoadMoreSessions: (project: Project) => void; onNewSession: (project: Project) => void; - touchHandlerFactory: TouchHandlerFactory; t: TFunction; }; @@ -70,7 +69,6 @@ export default function SidebarProjectSessions({ onDeleteSession, onLoadMoreSessions, onNewSession, - touchHandlerFactory, t, }: SidebarProjectSessionsProps) { if (!isExpanded) { @@ -105,7 +103,6 @@ export default function SidebarProjectSessions({ onProjectSelect={onProjectSelect} onSessionSelect={onSessionSelect} onDeleteSession={onDeleteSession} - touchHandlerFactory={touchHandlerFactory} t={t} /> )) diff --git a/src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx b/src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx index 30008d51..4d4951d0 100644 --- a/src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx +++ b/src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx @@ -4,7 +4,7 @@ import type { TFunction } from 'i18next'; import { cn } from '../../../../lib/utils'; import { formatTimeAgo } from '../../../../utils/dateUtils'; import type { Project, ProjectSession, SessionProvider } from '../../../../types/app'; -import type { SessionWithProvider, TouchHandlerFactory } from '../../types/types'; +import type { SessionWithProvider } from '../../types/types'; import { createSessionViewModel } from '../../utils/utils'; import SessionProviderLogo from '../../../llm-logo-provider/SessionProviderLogo'; @@ -27,7 +27,6 @@ type SidebarSessionItemProps = { sessionTitle: string, provider: SessionProvider, ) => void; - touchHandlerFactory: TouchHandlerFactory; t: TFunction; }; @@ -45,7 +44,6 @@ export default function SidebarSessionItem({ onProjectSelect, onSessionSelect, onDeleteSession, - touchHandlerFactory, t, }: SidebarSessionItemProps) { const sessionView = createSessionViewModel(session, currentTime, t);