import type { Session } from "../api/sessions"; import { SessionCard } from "./session-card"; import type { InstanceHealth } from "../api/sessions"; export interface SessionListProps { sessions: Session[]; onOpen?: (session: Session) => void; onStart?: (session: Session) => void; onStop?: (session: Session) => void; onDelete?: (session: Session) => void; onRecreateTunnel?: (session: Session) => void; actionBusyId?: string | null; tunnelHealth?: Record; showGrouping?: boolean; activeTitle?: string; recentTitle?: string; maxRecent?: number; emptyMessage?: string; } const activeStatuses = ["running", "building", "starting", "probing", "pending", "unhealthy"]; const recentStatuses = ["stopped", "error"]; export function SessionList({ sessions, onOpen, onStart, onStop, onDelete, onRecreateTunnel, actionBusyId = null, tunnelHealth = {}, showGrouping = true, activeTitle = "Active Sessions", recentTitle = "Recent Sessions", maxRecent = 5, emptyMessage = "No sessions", }: SessionListProps) { const activeSessions = sessions.filter((s) => activeStatuses.includes(s.status)); const recentSessions = sessions .filter((s) => recentStatuses.includes(s.status)) .slice(0, maxRecent); if (!showGrouping) { return (
{sessions.length === 0 ? (

{emptyMessage}

) : ( sessions.map((session) => ( )) )}
); } return (
{/* Active Sessions */}

{activeTitle}

{activeSessions.length > 0 && ( {activeSessions.length} )}
{activeSessions.length === 0 ? (

No active sessions

) : (
{activeSessions.map((session) => ( ))}
)}
{/* Recent Sessions */} {recentSessions.length > 0 && (

{recentTitle}

{recentSessions.length}
{recentSessions.map((session) => ( ))}
)}
); }