Skip to content

Commit 11c24e7

Browse files
committed
refactor(ui): remove unused props/imports and delegate project path selection to tabs\n\n- Remove unused icons/components and dead handlers (e.g., directory selection) across UI components\n- Drop unused callbacks from props (onBack, onMCPClick, onUsageClick, etc.)\n- Fix createAgentsTab reference in App.tsx\n- Silence TypeScript lints by renaming unused vars (e.g., _error, _className)\n- Centralize project path selection in tab controls
1 parent 9a692fe commit 11c24e7

14 files changed

Lines changed: 22 additions & 109 deletions

src/App.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import { useState, useEffect } from "react";
2-
import { motion, AnimatePresence } from "framer-motion";
3-
import { Loader2, Bot, FolderCode } from "lucide-react";
2+
import { motion } from "framer-motion";
3+
import { Bot, FolderCode } from "lucide-react";
44
import { api, type Project, type Session, type ClaudeMdFile } from "@/lib/api";
55
import { OutputCacheProvider } from "@/lib/outputCache";
66
import { TabProvider } from "@/contexts/TabContext";
77
import { ThemeProvider } from "@/contexts/ThemeContext";
8-
import { Button } from "@/components/ui/button";
98
import { Card } from "@/components/ui/card";
109
import { ProjectList } from "@/components/ProjectList";
1110
import { FilePicker } from "@/components/FilePicker";
1211
import { SessionList } from "@/components/SessionList";
13-
import { RunningClaudeSessions } from "@/components/RunningClaudeSessions";
14-
import { Topbar } from "@/components/Topbar";
1512
import { CustomTitlebar } from "@/components/CustomTitlebar";
1613
import { MarkdownEditor } from "@/components/MarkdownEditor";
1714
import { ClaudeFileEditor } from "@/components/ClaudeFileEditor";
@@ -50,13 +47,13 @@ type View =
5047
*/
5148
function AppContent() {
5249
const [view, setView] = useState<View>("tabs");
53-
const { createClaudeMdTab, createSettingsTab, createUsageTab, createMCPTab, createProjectsTab, createAgentsTab } = useTabState();
50+
const { createClaudeMdTab, createSettingsTab, createUsageTab, createMCPTab, createAgentsTab } = useTabState();
5451
const [projects, setProjects] = useState<Project[]>([]);
5552
const [selectedProject, setSelectedProject] = useState<Project | null>(null);
5653
const [sessions, setSessions] = useState<Session[]>([]);
5754
const [editingClaudeFile, setEditingClaudeFile] = useState<ClaudeMdFile | null>(null);
5855
const [loading, setLoading] = useState(true);
59-
const [error, setError] = useState<string | null>(null);
56+
const [_error, setError] = useState<string | null>(null);
6057
const [showNFO, setShowNFO] = useState(false);
6158
const [showClaudeBinaryDialog, setShowClaudeBinaryDialog] = useState(false);
6259
const [showProjectPicker, setShowProjectPicker] = useState(false);
@@ -197,10 +194,7 @@ function AppContent() {
197194
/**
198195
* Opens a new Claude Code session in the interactive UI
199196
*/
200-
const handleNewSession = async () => {
201-
handleViewChange("tabs");
202-
// The tab system will handle creating a new chat tab
203-
};
197+
// New session creation is handled by the tab system via titlebar actions
204198

205199
/**
206200
* Handles editing a CLAUDE.md file from a project
@@ -229,10 +223,7 @@ function AppContent() {
229223
/**
230224
* Handles navigating to hooks configuration
231225
*/
232-
const handleProjectSettings = (project: Project) => {
233-
setProjectForSettings(project);
234-
handleViewChange("project-settings");
235-
};
226+
// Project settings navigation handled via `projectForSettings` state when needed
236227

237228

238229
const renderContent = () => {

src/components/AgentExecution.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
ArrowLeft,
55
Play,
66
StopCircle,
7-
FolderOpen,
87
Terminal,
98
AlertCircle,
109
Loader2,
@@ -22,13 +21,11 @@ import {
2221
Dialog,
2322
DialogContent,
2423
DialogDescription,
25-
DialogHeader,
2624
DialogTitle,
2725
} from "@/components/ui/dialog";
2826
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
2927
import { api, type Agent } from "@/lib/api";
3028
import { cn } from "@/lib/utils";
31-
import { open } from "@tauri-apps/plugin-dialog";
3229
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
3330
import { StreamMessage } from "./StreamMessage";
3431
import { ExecutionControlBar } from "./ExecutionControlBar";
@@ -91,7 +88,7 @@ export const AgentExecution: React.FC<AgentExecutionProps> = ({
9188
onBack,
9289
className,
9390
}) => {
94-
const [projectPath, setProjectPath] = useState(initialProjectPath || "");
91+
const [projectPath] = useState(initialProjectPath || "");
9592
const [task, setTask] = useState(agent.default_task || "");
9693
const [model, setModel] = useState(agent.model || "sonnet");
9794
const [isRunning, setIsRunning] = useState(false);
@@ -280,25 +277,7 @@ export const AgentExecution: React.FC<AgentExecutionProps> = ({
280277
}, [messages]);
281278

282279

283-
const handleSelectPath = async () => {
284-
try {
285-
const selected = await open({
286-
directory: true,
287-
multiple: false,
288-
title: "Select Project Directory"
289-
});
290-
291-
if (selected) {
292-
setProjectPath(selected as string);
293-
setError(null); // Clear any previous errors
294-
}
295-
} catch (err) {
296-
console.error("Failed to select directory:", err);
297-
// More detailed error logging
298-
const errorMessage = err instanceof Error ? err.message : String(err);
299-
setError(`Failed to select directory: ${errorMessage}`);
300-
}
301-
};
280+
// Project path selection is handled upstream when opening an execution tab
302281

303282
const handleOpenHooksDialog = async () => {
304283
setIsHooksDialogOpen(true);

src/components/Agents.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { Badge } from '@/components/ui/badge';
1313
import { Card } from '@/components/ui/card';
1414
import { Toast } from '@/components/ui/toast';
1515
import { api, type Agent, type AgentRunWithMetrics } from '@/lib/api';
16-
import { formatISOTimestamp } from '@/lib/date-utils';
1716
import { open as openDialog, save } from '@tauri-apps/plugin-dialog';
1817
import { invoke } from '@tauri-apps/api/core';
1918
import { GitHubAgentBrowser } from '@/components/GitHubAgentBrowser';

src/components/CheckpointSettings.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export const CheckpointSettings: React.FC<CheckpointSettingsProps> = ({
3939
sessionId,
4040
projectId,
4141
projectPath,
42-
onClose,
4342
className,
4443
}) => {
4544
const [autoCheckpointEnabled, setAutoCheckpointEnabled] = useState(true);

src/components/ClaudeCodeSession.tsx

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import React, { useState, useEffect, useRef, useMemo } from "react";
22
import { motion, AnimatePresence } from "framer-motion";
33
import {
4-
ArrowLeft,
5-
Terminal,
6-
FolderOpen,
74
Copy,
85
ChevronDown,
96
GitBranch,
10-
Settings,
117
ChevronUp,
128
X,
139
Hash,
14-
Command,
1510
Wrench
1611
} from "lucide-react";
1712
import { Button } from "@/components/ui/button";
@@ -20,7 +15,6 @@ import { Label } from "@/components/ui/label";
2015
import { Popover } from "@/components/ui/popover";
2116
import { api, type Session } from "@/lib/api";
2217
import { cn } from "@/lib/utils";
23-
import { open } from "@tauri-apps/plugin-dialog";
2418
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
2519
import { StreamMessage } from "./StreamMessage";
2620
import { FloatingPromptInput, type FloatingPromptInputRef } from "./FloatingPromptInput";
@@ -77,14 +71,11 @@ interface ClaudeCodeSessionProps {
7771
export const ClaudeCodeSession: React.FC<ClaudeCodeSessionProps> = ({
7872
session,
7973
initialProjectPath = "",
80-
onBack,
81-
onProjectSettings,
8274
className,
8375
onStreamingChange,
8476
onProjectPathChange,
8577
}) => {
86-
const [projectPath, setProjectPath] = useState(initialProjectPath || session?.project_path || "");
87-
const [sessionRestoreData, setSessionRestoreData] = useState<{ projectId: string } | null>(null);
78+
const [projectPath] = useState(initialProjectPath || session?.project_path || "");
8879
const [messages, setMessages] = useState<ClaudeStreamMessage[]>([]);
8980
const [isLoading, setIsLoading] = useState(false);
9081
const [error, setError] = useState<string | null>(null);
@@ -437,29 +428,7 @@ export const ClaudeCodeSession: React.FC<ClaudeCodeSessionProps> = ({
437428
}
438429
};
439430

440-
const handleSelectPath = async () => {
441-
try {
442-
const selected = await open({
443-
directory: true,
444-
multiple: false,
445-
title: "Select Project Directory"
446-
});
447-
448-
if (selected) {
449-
const selectedPath = selected as string;
450-
setProjectPath(selectedPath);
451-
setError(null);
452-
// Call the callback to update tab title
453-
if (onProjectPathChange) {
454-
onProjectPathChange(selectedPath);
455-
}
456-
}
457-
} catch (err) {
458-
console.error("Failed to select directory:", err);
459-
const errorMessage = err instanceof Error ? err.message : String(err);
460-
setError(`Failed to select directory: ${errorMessage}`);
461-
}
462-
};
431+
// Project path selection handled by parent tab controls
463432

464433
const handleSendPrompt = async (prompt: string, model: "sonnet" | "opus") => {
465434
console.log('[ClaudeCodeSession] handleSendPrompt called with:', { prompt, model, projectPath, claudeSessionId, effectiveSession });

src/components/FloatingPromptInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
Lightbulb,
1313
Cpu,
1414
Rocket,
15-
Zap as Lightning
15+
1616
} from "lucide-react";
1717
import { cn } from "@/lib/utils";
1818
import { Button } from "@/components/ui/button";
@@ -138,7 +138,7 @@ const THINKING_MODES: ThinkingModeConfig[] = [
138138
/**
139139
* ThinkingModeIndicator component - Shows visual indicator bars for thinking level
140140
*/
141-
const ThinkingModeIndicator: React.FC<{ level: number; color?: string }> = ({ level, color }) => {
141+
const ThinkingModeIndicator: React.FC<{ level: number; color?: string }> = ({ level, color: _color }) => {
142142
const getBarColor = (barIndex: number) => {
143143
if (barIndex > level) return "bg-muted";
144144
return "bg-primary";

src/components/MCPManager.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useState, useEffect } from "react";
22
import { motion, AnimatePresence } from "framer-motion";
3-
import { Download, AlertCircle, Loader2 } from "lucide-react";
4-
import { Button } from "@/components/ui/button";
3+
import { AlertCircle, Loader2 } from "lucide-react";
54
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
65
import { Card } from "@/components/ui/card";
76
import { Toast, ToastContainer } from "@/components/ui/toast";
@@ -26,7 +25,7 @@ interface MCPManagerProps {
2625
* Provides a comprehensive UI for adding, configuring, and managing MCP servers
2726
*/
2827
export const MCPManager: React.FC<MCPManagerProps> = ({
29-
className,
28+
className: _className,
3029
}) => {
3130
const [activeTab, setActiveTab] = useState("servers");
3231
const [servers, setServers] = useState<MCPServer[]>([]);

src/components/ProjectList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const getDisplayPath = (path: string, maxLength: number = 30): string => {
5252
for (const indicator of homeIndicators) {
5353
if (path.includes(indicator)) {
5454
const parts = path.split('/');
55-
const userIndex = parts.findIndex((p, i) =>
55+
const userIndex = parts.findIndex((_part, i) =>
5656
i > 0 && parts[i - 1] === indicator.split('/')[1]
5757
);
5858
if (userIndex > 0) {

src/components/SessionList.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import React, { useState } from "react";
22
import { motion, AnimatePresence } from "framer-motion";
3-
import { FileText, Calendar, Clock, MessageSquare, Info } from "lucide-react";
4-
import { Card, CardContent } from "@/components/ui/card";
3+
import { Clock, MessageSquare } from "lucide-react";
4+
import { Card } from "@/components/ui/card";
55
import { Pagination } from "@/components/ui/pagination";
66
import { ClaudeMemoriesDropdown } from "@/components/ClaudeMemoriesDropdown";
7-
import {
8-
Tooltip,
9-
TooltipContent,
10-
TooltipProvider,
11-
TooltipTrigger,
12-
} from "@/components/ui/tooltip";
7+
import { TooltipProvider } from "@/components/ui/tooltip";
138
import { cn } from "@/lib/utils";
14-
import { formatUnixTimestamp, formatISOTimestamp, truncateText, getFirstLine } from "@/lib/date-utils";
9+
import { truncateText, getFirstLine } from "@/lib/date-utils";
1510
import type { Session, ClaudeMdFile } from "@/lib/api";
1611

1712
interface SessionListProps {
@@ -57,7 +52,6 @@ const ITEMS_PER_PAGE = 12;
5752
export const SessionList: React.FC<SessionListProps> = ({
5853
sessions,
5954
projectPath,
60-
onBack,
6155
onSessionClick,
6256
onEditClaudeFile,
6357
className,

src/components/Settings.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import React, { useState, useEffect } from "react";
22
import { motion, AnimatePresence } from "framer-motion";
33
import {
4-
ArrowLeft,
54
Plus,
65
Trash2,
76
Save,
87
AlertCircle,
98
Loader2,
10-
BarChart3,
119
Shield,
12-
Trash,
1310
Check,
1411
} from "lucide-react";
1512
import { Button } from "@/components/ui/button";
@@ -18,7 +15,6 @@ import { Label } from "@/components/ui/label";
1815
import { Switch } from "@/components/ui/switch";
1916
import { Card } from "@/components/ui/card";
2017
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
21-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
2218
import {
2319
api,
2420
type ClaudeSettings,
@@ -63,7 +59,6 @@ interface EnvironmentVariable {
6359
* Provides a no-code interface for editing the settings.json file
6460
*/
6561
export const Settings: React.FC<SettingsProps> = ({
66-
onBack,
6762
className,
6863
}) => {
6964
const [settings, setSettings] = useState<ClaudeSettings | null>(null);

0 commit comments

Comments
 (0)