diff --git a/src/tui/App.tsx b/src/tui/App.tsx index 308a4fe9..48b7a0e3 100644 --- a/src/tui/App.tsx +++ b/src/tui/App.tsx @@ -204,6 +204,11 @@ export function App(): React.ReactElement { return setShowHelp(false)} />; } + // Handle delete session from start screen + const handleDeleteSession = useCallback((session: ScreenSession) => { + killSession(session.sessionId); + }, [killSession]); + // Render start screen if (viewMode === 'start') { return ( @@ -211,6 +216,7 @@ export function App(): React.ReactElement { sessions={sessions} onSelectSession={handleSelectSession} onAttachSession={handleAttachSession} + onDeleteSession={handleDeleteSession} onCreateSession={handleCreateSession} onRefresh={refreshSessions} onExit={exit} diff --git a/src/tui/components/HelpOverlay.tsx b/src/tui/components/HelpOverlay.tsx index 9641a021..d529ef10 100644 --- a/src/tui/components/HelpOverlay.tsx +++ b/src/tui/components/HelpOverlay.tsx @@ -24,6 +24,7 @@ const SHORTCUT_GROUPS: ShortcutGroup[] = [ { key: '\u2191/\u2193', description: 'Navigate session list' }, { key: 'Enter', description: 'View session in TUI' }, { key: 'a', description: 'Attach to screen (full terminal)' }, + { key: 'd', description: 'Delete/kill selected session' }, { key: 'n', description: 'Create new session' }, { key: 'r', description: 'Refresh session list' }, { key: 'q', description: 'Quit' }, diff --git a/src/tui/components/StartScreen.tsx b/src/tui/components/StartScreen.tsx index 8653776d..e0b37839 100644 --- a/src/tui/components/StartScreen.tsx +++ b/src/tui/components/StartScreen.tsx @@ -16,6 +16,7 @@ interface StartScreenProps { sessions: ScreenSession[]; onSelectSession: (session: ScreenSession) => void; onAttachSession: (session: ScreenSession) => void; + onDeleteSession: (session: ScreenSession) => void; onCreateSession: () => void; onRefresh: () => void; onExit: () => void; @@ -49,6 +50,7 @@ export function StartScreen({ sessions, onSelectSession, onAttachSession, + onDeleteSession, onCreateSession, onRefresh, onExit, @@ -56,6 +58,13 @@ export function StartScreen({ const now = Date.now(); const [selectedIndex, setSelectedIndex] = useState(0); + // Ensure selectedIndex is valid when sessions change + React.useEffect(() => { + if (selectedIndex >= sessions.length && sessions.length > 0) { + setSelectedIndex(sessions.length - 1); + } + }, [sessions.length, selectedIndex]); + // Handle keyboard input for navigation useInput((input, key) => { // Arrow key navigation @@ -79,6 +88,12 @@ export function StartScreen({ onAttachSession(sessions[selectedIndex]); return; } + + // 'd' or 'x' to delete/kill session + if ((input === 'd' || input === 'x') && sessions.length > 0) { + onDeleteSession(sessions[selectedIndex]); + return; + } }); return ( @@ -169,6 +184,8 @@ export function StartScreen({ View [a] Attach + [d] + Delete [r] Refresh [q]