mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 16:39:42 +02:00
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:
@@ -204,6 +204,11 @@ export function App(): React.ReactElement {
|
|||||||
return <HelpOverlay onClose={() => setShowHelp(false)} />;
|
return <HelpOverlay onClose={() => setShowHelp(false)} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle delete session from start screen
|
||||||
|
const handleDeleteSession = useCallback((session: ScreenSession) => {
|
||||||
|
killSession(session.sessionId);
|
||||||
|
}, [killSession]);
|
||||||
|
|
||||||
// Render start screen
|
// Render start screen
|
||||||
if (viewMode === 'start') {
|
if (viewMode === 'start') {
|
||||||
return (
|
return (
|
||||||
@@ -211,6 +216,7 @@ export function App(): React.ReactElement {
|
|||||||
sessions={sessions}
|
sessions={sessions}
|
||||||
onSelectSession={handleSelectSession}
|
onSelectSession={handleSelectSession}
|
||||||
onAttachSession={handleAttachSession}
|
onAttachSession={handleAttachSession}
|
||||||
|
onDeleteSession={handleDeleteSession}
|
||||||
onCreateSession={handleCreateSession}
|
onCreateSession={handleCreateSession}
|
||||||
onRefresh={refreshSessions}
|
onRefresh={refreshSessions}
|
||||||
onExit={exit}
|
onExit={exit}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const SHORTCUT_GROUPS: ShortcutGroup[] = [
|
|||||||
{ key: '\u2191/\u2193', description: 'Navigate session list' },
|
{ key: '\u2191/\u2193', description: 'Navigate session list' },
|
||||||
{ key: 'Enter', description: 'View session in TUI' },
|
{ key: 'Enter', description: 'View session in TUI' },
|
||||||
{ key: 'a', description: 'Attach to screen (full terminal)' },
|
{ key: 'a', description: 'Attach to screen (full terminal)' },
|
||||||
|
{ key: 'd', description: 'Delete/kill selected session' },
|
||||||
{ key: 'n', description: 'Create new session' },
|
{ key: 'n', description: 'Create new session' },
|
||||||
{ key: 'r', description: 'Refresh session list' },
|
{ key: 'r', description: 'Refresh session list' },
|
||||||
{ key: 'q', description: 'Quit' },
|
{ key: 'q', description: 'Quit' },
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ interface StartScreenProps {
|
|||||||
sessions: ScreenSession[];
|
sessions: ScreenSession[];
|
||||||
onSelectSession: (session: ScreenSession) => void;
|
onSelectSession: (session: ScreenSession) => void;
|
||||||
onAttachSession: (session: ScreenSession) => void;
|
onAttachSession: (session: ScreenSession) => void;
|
||||||
|
onDeleteSession: (session: ScreenSession) => void;
|
||||||
onCreateSession: () => void;
|
onCreateSession: () => void;
|
||||||
onRefresh: () => void;
|
onRefresh: () => void;
|
||||||
onExit: () => void;
|
onExit: () => void;
|
||||||
@@ -49,6 +50,7 @@ export function StartScreen({
|
|||||||
sessions,
|
sessions,
|
||||||
onSelectSession,
|
onSelectSession,
|
||||||
onAttachSession,
|
onAttachSession,
|
||||||
|
onDeleteSession,
|
||||||
onCreateSession,
|
onCreateSession,
|
||||||
onRefresh,
|
onRefresh,
|
||||||
onExit,
|
onExit,
|
||||||
@@ -56,6 +58,13 @@ export function StartScreen({
|
|||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
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
|
// Handle keyboard input for navigation
|
||||||
useInput((input, key) => {
|
useInput((input, key) => {
|
||||||
// Arrow key navigation
|
// Arrow key navigation
|
||||||
@@ -79,6 +88,12 @@ export function StartScreen({
|
|||||||
onAttachSession(sessions[selectedIndex]);
|
onAttachSession(sessions[selectedIndex]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'd' or 'x' to delete/kill session
|
||||||
|
if ((input === 'd' || input === 'x') && sessions.length > 0) {
|
||||||
|
onDeleteSession(sessions[selectedIndex]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -169,6 +184,8 @@ export function StartScreen({
|
|||||||
<Text> View </Text>
|
<Text> View </Text>
|
||||||
<Text color="green">[a]</Text>
|
<Text color="green">[a]</Text>
|
||||||
<Text> Attach </Text>
|
<Text> Attach </Text>
|
||||||
|
<Text color="red">[d]</Text>
|
||||||
|
<Text> Delete </Text>
|
||||||
<Text color="green">[r]</Text>
|
<Text color="green">[r]</Text>
|
||||||
<Text> Refresh </Text>
|
<Text> Refresh </Text>
|
||||||
<Text color="yellow">[q]</Text>
|
<Text color="yellow">[q]</Text>
|
||||||
|
|||||||
Reference in New Issue
Block a user