Fix session selector: handle Ctrl+C and viewport width

- Add SIGINT handler to allow Ctrl+C to exit during session selection
- Remove hardcoded 60-char truncation, let SelectList handle dynamic truncation
- Simplify date format (5m, 2h, 3d instead of "5m ago")
- Make metadata more compact (5msg instead of "5 msgs")
This commit is contained in:
Mario Zechner 2025-11-12 09:21:17 +01:00
parent 458702b3a7
commit 6b48e73607
2 changed files with 37 additions and 17 deletions

View file

@ -124,17 +124,37 @@ async function selectSession(sessionManager: SessionManager): Promise<string | n
return new Promise((resolve) => {
const ui = new TUI(new ProcessTerminal());
let selectedPath: string | null = null;
let resolved = false;
// Handle Ctrl+C
const handleSigint = () => {
if (!resolved) {
resolved = true;
ui.stop();
process.exit(0);
}
};
process.on("SIGINT", handleSigint);
const selector = new SessionSelectorComponent(
sessionManager,
(path: string) => {
selectedPath = path;
ui.stop();
resolve(path);
if (!resolved) {
resolved = true;
selectedPath = path;
process.removeListener("SIGINT", handleSigint);
ui.stop();
resolve(path);
}
},
() => {
ui.stop();
resolve(null);
if (!resolved) {
resolved = true;
process.removeListener("SIGINT", handleSigint);
ui.stop();
resolve(null);
}
},
);