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
+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>