Redesign session selector with multi-line layout

- Custom SessionList component with 2 lines per item
- First line: message text (bold when selected)
- Second line: metadata (time · message count) in dim
- Blue › cursor for selected item
- Added "Resume Session" header
- Handle Ctrl+C (‹x03›) in SelectList for consistency
- Improved date formatting (38 minutes ago, 8 hours ago, etc.)
This commit is contained in:
Mario Zechner 2025-11-12 09:25:40 +01:00
parent 6b48e73607
commit a6e300693d
3 changed files with 113 additions and 84 deletions

View file

@ -123,27 +123,13 @@ Current directory: ${process.cwd()}`;
async function selectSession(sessionManager: SessionManager): Promise<string | null> {
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) => {
if (!resolved) {
resolved = true;
selectedPath = path;
process.removeListener("SIGINT", handleSigint);
ui.stop();
resolve(path);
}
@ -151,7 +137,6 @@ async function selectSession(sessionManager: SessionManager): Promise<string | n
() => {
if (!resolved) {
resolved = true;
process.removeListener("SIGINT", handleSigint);
ui.stop();
resolve(null);
}
@ -159,7 +144,7 @@ async function selectSession(sessionManager: SessionManager): Promise<string | n
);
ui.addChild(selector);
ui.setFocus(selector.getSelectList());
ui.setFocus(selector.getSessionList());
ui.start();
});
}