({ tab, isActive })
| 29 | } |
| 30 | |
| 31 | const TabPanel: React.FC<TabPanelProps> = ({ tab, isActive }) => { |
| 32 | const { updateTab } = useTabState(); |
| 33 | const [projects, setProjects] = React.useState<Project[]>([]); |
| 34 | const [selectedProject, setSelectedProject] = React.useState<Project | null>(null); |
| 35 | const [sessions, setSessions] = React.useState<Session[]>([]); |
| 36 | const [loading, setLoading] = React.useState(false); |
| 37 | |
| 38 | // Track screen when tab becomes active |
| 39 | useScreenTracking(isActive ? tab.type : undefined, isActive ? tab.id : undefined); |
| 40 | const [error, setError] = React.useState<string | null>(null); |
| 41 | |
| 42 | // Load projects when tab becomes active and is of type 'projects' |
| 43 | useEffect(() => { |
| 44 | if (isActive && tab.type === 'projects') { |
| 45 | loadProjects(); |
| 46 | } |
| 47 | }, [isActive, tab.type]); |
| 48 | |
| 49 | const loadProjects = async () => { |
| 50 | try { |
| 51 | setLoading(true); |
| 52 | setError(null); |
| 53 | const projectList = await api.listProjects(); |
| 54 | setProjects(projectList); |
| 55 | } catch (err) { |
| 56 | console.error("Failed to load projects:", err); |
| 57 | setError("Failed to load projects. Please ensure ~/.claude directory exists."); |
| 58 | } finally { |
| 59 | setLoading(false); |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | const handleProjectClick = async (project: Project) => { |
| 64 | try { |
| 65 | setLoading(true); |
| 66 | setError(null); |
| 67 | const sessionList = await api.getProjectSessions(project.id); |
| 68 | setSessions(sessionList); |
| 69 | setSelectedProject(project); |
| 70 | |
| 71 | // Update tab title to show project name |
| 72 | const projectName = project.path.split('/').pop() || 'Project'; |
| 73 | updateTab(tab.id, { |
| 74 | title: projectName |
| 75 | }); |
| 76 | } catch (err) { |
| 77 | console.error("Failed to load sessions:", err); |
| 78 | setError("Failed to load sessions for this project."); |
| 79 | } finally { |
| 80 | setLoading(false); |
| 81 | } |
| 82 | }; |
| 83 | |
| 84 | const handleOpenProject = async () => { |
| 85 | console.log('handleOpenProject called'); |
| 86 | try { |
| 87 | // Use native dialog to pick folder |
| 88 | const { open } = await import('@tauri-apps/plugin-dialog'); |
nothing calls this directly
no test coverage detected