feat(tui): add delete session from start screen

- Press 'd' or 'x' to delete/kill selected session
- Auto-adjust selection index when sessions are removed
- Update footer controls with delete shortcut
- Update help overlay with delete shortcut

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-21 06:27:06 +01:00
co-authored by Claude Opus 4.5
parent 71373f80d4
commit 7bd5260b7d
3 changed files with 24 additions and 0 deletions
+6
View File
@@ -204,6 +204,11 @@ export function App(): React.ReactElement {
return <HelpOverlay onClose={() => 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}
+1
View File
@@ -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' },
+17
View File
@@ -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({
<Text> View </Text>
<Text color="green">[a]</Text>
<Text> Attach </Text>
<Text color="red">[d]</Text>
<Text> Delete </Text>
<Text color="green">[r]</Text>
<Text> Refresh </Text>
<Text color="yellow">[q]</Text>