From a3d1efeaa5dd463f9df828d6aaa520fb23f39402 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Tue, 4 Aug 2026 13:53:20 -0700 Subject: [PATCH] refactor(ui): drop unreferenced locals from dashboard route components @typescript-eslint/no-unused-vars is disabled in the dashboard eslint config, so unused locals accumulated with nothing to catch them. This is the first slice: symbols under src/app that no code reads. Every removal is an unused import, an unused interface or type alias, or a local const whose only mention was its own declaration. Nothing else on the touched lines changes, so no behavior moves with it. Part of LIT-5162. --- .../caching/_components/cache_dashboard.tsx | 25 ------------- .../_components/provider_margin_table.tsx | 8 ----- .../_components/GuardrailDetail.tsx | 2 +- .../_components/GuardrailTestResults.tsx | 3 -- .../content_filter/KeywordTable.tsx | 3 +- .../guardrails/_components/guardrail_info.tsx | 21 ----------- .../_components/CreateMCPServer.tsx | 1 - .../mcp-servers/_components/mcp_connect.tsx | 25 +------------ .../playground/components/chat_ui/ChatUI.tsx | 18 ++-------- .../components/chat_ui/RealtimePlayground.tsx | 2 -- .../prompts/_components/add_prompt_form.tsx | 6 ---- .../(dashboard)/prompts/_components/index.tsx | 2 +- .../_components/prompt_editor_view/index.tsx | 2 +- .../TransformRequestPanel.tsx | 6 ---- .../_components/components/UsagePageView.tsx | 35 ------------------- .../users/_components/edit_user.tsx | 3 +- .../_components/vector_store_info.tsx | 1 - ui/litellm-dashboard/src/app/chat/page.tsx | 1 - 18 files changed, 8 insertions(+), 156 deletions(-) diff --git a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_dashboard.tsx b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_dashboard.tsx index 47c266ceac0..5167ac16542 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_dashboard.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_dashboard.tsx @@ -65,32 +65,7 @@ interface CachePageProps { premiumUser: boolean; } -interface CacheHealthResponse { - status?: string; - cache_type?: string; - ping_response?: boolean; - set_cache_response?: string; - litellm_cache_params?: string; - error?: { - message: string; - type: string; - param: string; - code: string; - }; -} - // Helper function to deep-parse a JSON string if possible -const deepParse = (input: any) => { - let parsed = input; - if (typeof parsed === "string") { - try { - parsed = JSON.parse(parsed); - } catch { - return parsed; - } - } - return parsed; -}; const CacheDashboard: React.FC = ({ accessToken, token, userRole, userID, premiumUser }) => { const [selectedApiKeys, setSelectedApiKeys] = useState([]); diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/provider_margin_table.tsx b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/provider_margin_table.tsx index 9d11e13fb52..75939a23751 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/provider_margin_table.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/provider_margin_table.tsx @@ -69,14 +69,6 @@ const ProviderMarginTable: React.FC = ({ setEditFixedAmount(""); }; - const handleKeyDown = (e: React.KeyboardEvent, provider: string) => { - if (e.key === "Enter") { - handleSaveEdit(provider); - } else if (e.key === "Escape") { - handleCancelEdit(); - } - }; - const formatMargin = (margin: number | { percentage?: number; fixed_amount?: number }): string => { if (typeof margin === "number") { return `${(margin * 100).toFixed(1)}%`; diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailDetail.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailDetail.tsx index 1d959ccca95..2e007c06744 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailDetail.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailDetail.tsx @@ -25,7 +25,7 @@ const statusColors: Record = export function GuardrailDetail({ guardrailId, onBack, accessToken = null, startDate, endDate }: GuardrailDetailProps) { const [activeTab, setActiveTab] = useState("overview"); const [evaluationModalOpen, setEvaluationModalOpen] = useState(false); - const [logsPage, setLogsPage] = useState(1); + const [logsPage] = useState(1); const logsPageSize = 50; const { diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestResults.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestResults.tsx index 3c974de3632..10ce709244b 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestResults.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestResults.tsx @@ -1,11 +1,8 @@ import React, { useState } from "react"; import { Button, Card } from "@tremor/react"; -import { Typography } from "antd"; import { CopyOutlined, CheckCircleOutlined, ClockCircleOutlined, DownOutlined, RightOutlined } from "@ant-design/icons"; import NotificationsManager from "@/components/molecules/notifications_manager"; -const { Text } = Typography; - interface TestResult { guardrailName: string; response_text: string; diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/KeywordTable.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/KeywordTable.tsx index 57e59423aa5..eed2c8a5129 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/KeywordTable.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/KeywordTable.tsx @@ -1,8 +1,7 @@ import { DeleteOutlined } from "@ant-design/icons"; -import { Button, Select, Table, Typography } from "antd"; +import { Button, Select, Table } from "antd"; import React from "react"; -const { Text } = Typography; const { Option } = Select; interface BlockedWord { diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/guardrail_info.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/guardrail_info.tsx index 07df6ff15d9..54cac4bbe5c 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/guardrail_info.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/guardrail_info.tsx @@ -35,22 +35,6 @@ export interface GuardrailInfoProps { isAdmin: boolean; } -interface ProviderParam { - param: string; - description: string; - required: boolean; - default_value?: string; - options?: string[]; - type?: string; - fields?: { [key: string]: ProviderParam }; - dict_key_options?: string[]; - dict_value_type?: string; -} - -interface ProviderParamsResponse { - [provider: string]: { [key: string]: ProviderParam }; -} - const GuardrailInfoView: React.FC = ({ guardrailId, onClose, accessToken, isAdmin }) => { const [guardrailData, setGuardrailData] = useState(null); const [guardrailProviderSpecificParams, setGuardrailProviderSpecificParams] = useState(null); @@ -244,11 +228,6 @@ const GuardrailInfoView: React.FC = ({ guardrailId, onClose, resetToolPermissionEditor(); }, [resetToolPermissionEditor]); - const handleToolPermissionConfigChange = (config: ToolPermissionConfig) => { - setToolPermissionConfig(config); - setToolPermissionDirty(true); - }; - const handlePiiEntitySelect = (entity: string) => { setSelectedPiiEntities((prev) => { if (prev.includes(entity)) { diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/CreateMCPServer.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/CreateMCPServer.tsx index 0785dd142ff..d567c318743 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/CreateMCPServer.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/CreateMCPServer.tsx @@ -333,7 +333,6 @@ const CreateMCPServer: React.FC = ({ if (!pendingRestoredValues) { return; } - const transportReady = transportType || pendingRestoredValues.transport || ""; if (pendingRestoredValues.transport && !transportType) { // wait until transportType state catches up so the URL field is mounted return; diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_connect.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_connect.tsx index 7bdfd9c6b8f..74b77735377 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_connect.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_connect.tsx @@ -1,14 +1,13 @@ /* eslint-disable react/no-unescaped-entities */ import React, { useState } from "react"; -import { Card, Typography, Space, Alert, Button, Switch, Form, Collapse } from "antd"; +import { Card, Typography, Space, Alert, Button, Switch, Form } from "antd"; import { TabPanel, TabPanels, TabGroup, TabList, Tab, Title as TremorTitle, Text as TremorText } from "@tremor/react"; import { CopyIcon, Code, Terminal, Globe, CheckIcon, ExternalLinkIcon, KeyIcon, ServerIcon, Zap } from "lucide-react"; import { getProxyBaseUrl } from "@/components/networking"; import { copyToClipboard as utilCopyToClipboard } from "@/utils/dataUtils"; const { Title, Text } = Typography; -const { Panel } = Collapse; interface CodeBlockProps { code: string; @@ -117,12 +116,6 @@ interface MCPConnectProps { const MCPConnect: React.FC = ({ currentServerAccessGroups = [] }) => { const proxyBaseUrl = getProxyBaseUrl(); const [copiedStates, setCopiedStates] = useState>({}); - const [serverHeaders, setServerHeaders] = useState>({ - openai: [], - litellm: [], - cursor: [], - http: [], - }); const [currentServer] = useState("Zapier_MCP"); // This should match the current server being viewed const copyToClipboard = async (text: string, key: string) => { @@ -135,22 +128,6 @@ const MCPConnect: React.FC = ({ currentServerAccessGroups = [] } }; - const getHeadersConfig = (type: string) => { - const headers: Record = { - "x-litellm-api-key": "Bearer YOUR_LITELLM_API_KEY", - }; - - if (serverHeaders[type]?.length > 0) { - // Format server names (replace spaces with underscores) - const formattedServers = serverHeaders[type].map((s) => s.replace(/\s+/g, "_")); - - // Use comma-separated string (can include both servers and access groups) - headers["x-mcp-servers"] = formattedServers.join(","); - } - - return headers; - }; - const CodeBlock: React.FC<{ code: string; copyKey: string; diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx index e7261db6260..79368886c8b 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx @@ -7,7 +7,6 @@ import { CodeOutlined, DatabaseOutlined, DeleteOutlined, - FilePdfOutlined, InfoCircleOutlined, KeyOutlined, LinkOutlined, @@ -19,12 +18,10 @@ import { SoundOutlined, TagsOutlined, ToolOutlined, - UserOutlined, } from "@ant-design/icons"; import { Card, Text, TextInput, Title, Button as TremorButton } from "@tremor/react"; import { Button, Input, Modal, Popover, Select, Spin, Tooltip, Upload } from "antd"; import React, { useEffect, useRef, useState } from "react"; -import ReactMarkdown from "react-markdown"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { coy } from "react-syntax-highlighter/dist/esm/styles/prism"; import { v4 as uuidv4 } from "uuid"; @@ -50,14 +47,10 @@ import { makeOpenAIImageEditsRequest } from "../../llm_calls/image_edits"; import { makeOpenAIImageGenerationRequest } from "../../llm_calls/image_generation"; import { makeOpenAIResponsesRequest } from "@/components/llm_calls/responses_api"; import { makeInteractionsRequest } from "../../llm_calls/interactions_api"; -import A2AMetrics from "./A2AMetrics"; import AdditionalModelSettings from "./AdditionalModelSettings"; -import AudioRenderer from "./AudioRenderer"; import { OPEN_AI_VOICE_SELECT_OPTIONS, OpenAIVoice } from "./chatConstants"; -import ChatImageRenderer from "./ChatImageRenderer"; import ChatImageUpload from "./ChatImageUpload"; import { createChatDisplayMessage, createChatMultimodalMessage } from "./ChatImageUtils"; -import CodeInterpreterOutput from "./CodeInterpreterOutput"; import CodeInterpreterTool from "./CodeInterpreterTool"; import { generateCodeSnippet } from "@/components/chat_ui/CodeSnippets"; import EndpointSelector from "./EndpointSelector"; @@ -65,15 +58,11 @@ import FilePreviewCard from "./FilePreviewCard"; import ChatMessageBubble from "./ChatMessageBubble"; import MCPEventsDisplay from "@/components/chat_ui/MCPEventsDisplay"; import { EndpointType, getEndpointType } from "@/components/chat_ui/mode_endpoint_mapping"; -import ReasoningContent from "@/components/chat_ui/ReasoningContent"; -import ResponseMetrics, { TokenUsage } from "@/components/chat_ui/ResponseMetrics"; -import ResponsesImageRenderer from "./ResponsesImageRenderer"; import ResponsesImageUpload from "./ResponsesImageUpload"; import { createDisplayMessage, createMultimodalMessage } from "./ResponsesImageUtils"; -import { SearchResultsDisplay } from "./SearchResultsDisplay"; import SessionManagement from "./SessionManagement"; import RealtimePlayground from "./RealtimePlayground"; -import { A2ATaskMetadata, MessageType } from "@/components/chat_ui/types"; +import { MessageType } from "@/components/chat_ui/types"; import { useCodeInterpreter } from "../../hooks/useCodeInterpreter"; import { useChatHistory } from "../../hooks/useChatHistory"; import { getSecureItem, setSecureItem } from "@/utils/secureStorage"; @@ -147,13 +136,10 @@ const ChatUI: React.FC = ({ chatHistory, setChatHistory, mcpEvents, - setMCPEvents, messageTraceId, setMessageTraceId, responsesSessionId, - setResponsesSessionId, useApiSessionManagement, - setUseApiSessionManagement, updateTextUI, updateReasoningContent, updateTimingData, @@ -604,7 +590,7 @@ const ChatUI: React.FC = ({ return; } // Resolve the real server ID (toolsets use toolset: prefix) - const mcpServerId = rawSelected.startsWith("toolset:") ? rawSelected : rawSelected; + rawSelected.startsWith("toolset:") ? rawSelected : rawSelected; if (!selectedMCPDirectTool) { NotificationsManager.fromBackend("Please select an MCP tool to call"); return; diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/RealtimePlayground.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/RealtimePlayground.tsx index 68a150be8c0..2bf645fced2 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/RealtimePlayground.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/RealtimePlayground.tsx @@ -37,8 +37,6 @@ const RealtimePlayground: React.FC = ({ const audioContextRef = useRef(null); const mediaStreamRef = useRef(null); const processorRef = useRef(null); - const playbackQueueRef = useRef([]); - const isPlayingRef = useRef(false); const messagesEndRef = useRef(null); const nextPlayTimeRef = useRef(0); diff --git a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/add_prompt_form.tsx b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/add_prompt_form.tsx index 1bd831ca49d..c02efa82499 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/add_prompt_form.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/add_prompt_form.tsx @@ -15,12 +15,6 @@ interface AddPromptFormProps { onSuccess: () => void; } -interface PromptFormData { - prompt_id: string; - prompt_integration: string; - prompt_file?: File; -} - const AddPromptForm: React.FC = ({ visible, onClose, accessToken, onSuccess }) => { const [form] = Form.useForm(); const [loading, setLoading] = useState(false); diff --git a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/index.tsx b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/index.tsx index 9bebabb8cf2..c885fdcbf35 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/index.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/index.tsx @@ -47,7 +47,7 @@ const PromptsPanel: React.FC = ({ accessToken, userRole }) => { const [isDeleting, setIsDeleting] = useState(false); const [promptToDelete, setPromptToDelete] = useState<{ id: string; name: string } | null>(null); - const isAdmin = userRole ? isAdminRole(userRole) : false; + userRole ? isAdminRole(userRole) : false; // Admin Viewer follows the read-parity rule: see prompts, no writes. const canModify = userRole ? isProxyAdminRole(userRole) : false; diff --git a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/index.tsx b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/index.tsx index fa69a520145..e09ca787a69 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/index.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/index.tsx @@ -44,7 +44,7 @@ const PromptEditorView: React.FC = ({ onClose, onSuccess, }; const [prompt, setPrompt] = useState(getInitialPrompt()); - const [editMode, setEditMode] = useState(!!initialPromptData); + const [editMode] = useState(!!initialPromptData); const [showHistoryModal, setShowHistoryModal] = useState(false); // Construct versioned ID from prompt_id and version field diff --git a/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.tsx index 0c41547b9b7..0c7f10eab0e 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.tsx @@ -11,12 +11,6 @@ interface TransformRequestPanelProps { accessToken: string | null; } -interface TransformResponse { - raw_request_api_base: string; - raw_request_body: Record; - raw_request_headers: Record; -} - const TransformRequestPanel: React.FC = ({ accessToken }) => { const [originalRequestJSON, setOriginalRequestJSON] = useState(`{ "model": "openai/gpt-4o", diff --git a/ui/litellm-dashboard/src/app/(dashboard)/usage/_components/components/UsagePageView.tsx b/ui/litellm-dashboard/src/app/(dashboard)/usage/_components/components/UsagePageView.tsx index 46a17017d39..19f650386a6 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/usage/_components/components/UsagePageView.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/usage/_components/components/UsagePageView.tsx @@ -985,40 +985,5 @@ const UsagePage: React.FC = ({ teams, organizations }) => { }; // Add this helper function to process model-specific activity data -const getModelActivityData = (userSpendData: { results: DailyData[]; metadata: any }) => { - const modelData: { - [key: string]: { - total_requests: number; - total_tokens: number; - daily_data: Array<{ - date: string; - api_requests: number; - total_tokens: number; - }>; - }; - } = {}; - - userSpendData.results.forEach((day: DailyData) => { - Object.entries(day.breakdown.models || {}).forEach(([model, metrics]) => { - if (!modelData[model]) { - modelData[model] = { - total_requests: 0, - total_tokens: 0, - daily_data: [], - }; - } - - modelData[model].total_requests += metrics.metrics.api_requests; - modelData[model].total_tokens += metrics.metrics.total_tokens; - modelData[model].daily_data.push({ - date: day.date, - api_requests: metrics.metrics.api_requests, - total_tokens: metrics.metrics.total_tokens, - }); - }); - }); - - return modelData; -}; export default UsagePage; diff --git a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/edit_user.tsx b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/edit_user.tsx index de031984846..0f3e0dedb52 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/edit_user.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/edit_user.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect } from "react"; import { TextInput, SelectItem } from "@tremor/react"; import { Button as Button2, Modal, Form, Select as Select2, InputNumber } from "antd"; @@ -15,7 +15,6 @@ interface EditUserModalProps { } const EditUserModal: React.FC = ({ visible, possibleUIRoles, onCancel, user, onSubmit }) => { - const [editedUser, setEditedUser] = useState(user); const [form] = Form.useForm(); useEffect(() => { diff --git a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/vector_store_info.tsx b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/vector_store_info.tsx index ec20a3fd318..e5646037d14 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/vector_store_info.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/vector_store_info.tsx @@ -36,7 +36,6 @@ const VectorStoreInfoView: React.FC = ({ const [isEditing, setIsEditing] = useState(editVectorStore); const [metadataString, setMetadataString] = useState("{}"); const [credentials, setCredentials] = useState([]); - const [activeTab, setActiveTab] = useState(editVectorStore ? "details" : "details"); const fetchVectorStoreDetails = async () => { if (!accessToken) return; diff --git a/ui/litellm-dashboard/src/app/chat/page.tsx b/ui/litellm-dashboard/src/app/chat/page.tsx index b6dccef47c6..7b6b26c6436 100644 --- a/ui/litellm-dashboard/src/app/chat/page.tsx +++ b/ui/litellm-dashboard/src/app/chat/page.tsx @@ -65,7 +65,6 @@ export default function ChatConversationPage() { updateLastAssistantMessage, truncateFromMessage, } = useChatShell(); - const hadActiveConversationOnMountRef = useRef(activeConversationId !== null); const [selectedModel, setSelectedModel] = useState(null); const [models, setModels] = useState([]);