refactor(tui): clean up unused code and consolidate input handling

- Remove unused imports (Text, execSync, writeFileSync, React)
- Move n/r/q key handlers from App.tsx to StartScreen component
- Mark unused onClose prop in HelpOverlay with underscore prefix
- Consolidate keyboard handling in components that display the controls

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-21 06:46:11 +01:00
co-authored by Claude Opus 4.5
parent 1da51c38d8
commit 746cfb791c
5 changed files with 24 additions and 19 deletions
+4 -16
View File
@@ -24,8 +24,8 @@
*/
import React, { useState, useEffect, useCallback } from 'react';
import { Box, Text, useApp, useInput, useStdout } from 'ink';
import { execSync, spawnSync } from 'child_process';
import { Box, useApp, useInput, useStdout } from 'ink';
import { spawnSync } from 'child_process';
import { StartScreen } from './components/StartScreen.js';
import { TabBar } from './components/TabBar.js';
import { TerminalView } from './components/TerminalView.js';
@@ -118,21 +118,9 @@ export function App(): React.ReactElement {
return;
}
// Start screen specific inputs
// Start screen specific inputs - handled by StartScreen component
// Only number keys for quick session selection are handled here
if (viewMode === 'start') {
if (input === 'q') {
exit();
return;
}
if (input === 'n') {
handleCreateSession();
return;
}
if (input === 'r') {
refreshSessions();
return;
}
// Number keys to select session
const num = parseInt(input, 10);
if (!isNaN(num) && num >= 1 && num <= sessions.length) {
handleSelectSession(sessions[num - 1]);
+1 -1
View File
@@ -75,7 +75,7 @@ const SHORTCUT_GROUPS: ShortcutGroup[] = [
* @param props.onClose - Callback invoked when overlay should close
* @returns The help overlay element
*/
export function HelpOverlay({ onClose }: HelpOverlayProps): React.ReactElement {
export function HelpOverlay({ onClose: _onClose }: HelpOverlayProps): React.ReactElement {
return (
<Box flexDirection="column" padding={2}>
{/* Header */}
+18
View File
@@ -125,6 +125,24 @@ export function StartScreen({
onDeleteSession(sessions[selectedIndex]);
return;
}
// 'n' to create new session
if (input === 'n') {
onCreateSession();
return;
}
// 'r' to refresh session list
if (input === 'r') {
onRefresh();
return;
}
// 'q' to quit
if (input === 'q') {
onExit();
return;
}
});
return (
+1 -1
View File
@@ -24,7 +24,7 @@
*/
import { useState, useEffect, useCallback, useRef } from 'react';
import { existsSync, readFileSync, writeFileSync, watchFile, unwatchFile, unlinkSync } from 'fs';
import { existsSync, readFileSync, watchFile, unwatchFile, unlinkSync } from 'fs';
import { homedir } from 'os';
import { join } from 'path';
import { execSync } from 'child_process';
-1
View File
@@ -24,7 +24,6 @@
* @see {@link ./hooks/useSessionManager.ts} for state management
*/
import React from 'react';
import { render } from 'ink';
import { App } from './App.js';