779ca4872b
- Removed Prettier configuration files (.prettierignore and .prettierrc) and migrated formatting to Biome. - Updated Biome configuration from version 2.3.11 to 2.3.12 and changed arrowParentheses rule from 'always' to 'asNeeded'. - Pinned @biomejs/biome dependency to exact version 2.3.12 in package.json and bun.lock. - Applied consistent arrow function formatting across 489 files by removing unnecessary parentheses around single parameters. - Removed blank lines after comment blocks and reorganized imports for consistency across the codebase.
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
/**
|
|
* TUI session selector for --resume flag
|
|
*/
|
|
import { ProcessTerminal, TUI } from "@oh-my-pi/pi-tui";
|
|
import { SessionSelectorComponent } from "../modes/components/session-selector";
|
|
import type { SessionInfo } from "../session/session-manager";
|
|
|
|
/** Show TUI session selector and return selected session path or null if cancelled */
|
|
export async function selectSession(sessions: SessionInfo[]): Promise<string | null> {
|
|
const { promise, resolve } = Promise.withResolvers<string | null>();
|
|
const ui = new TUI(new ProcessTerminal());
|
|
let resolved = false;
|
|
const selector = new SessionSelectorComponent(
|
|
sessions,
|
|
(path: string) => {
|
|
if (!resolved) {
|
|
resolved = true;
|
|
ui.stop();
|
|
resolve(path);
|
|
}
|
|
},
|
|
() => {
|
|
if (!resolved) {
|
|
resolved = true;
|
|
ui.stop();
|
|
resolve(null);
|
|
}
|
|
},
|
|
() => {
|
|
if (!resolved) {
|
|
resolved = true;
|
|
ui.stop();
|
|
process.exit(0);
|
|
}
|
|
},
|
|
);
|
|
|
|
ui.addChild(selector);
|
|
ui.setFocus(selector.getSessionList());
|
|
ui.start();
|
|
return promise;
|
|
}
|