Vendor all 4 Pi packages (tui, ai, agent-core, coding-agent) from pi-mono v0.57.1 as @gsd/* workspace packages under packages/. This replaces the compiled npm dependency (@mariozechner/pi-coding-agent) and patch-package workflow, giving direct source access for modifications. - Copy Pi source from pi-mono v0.57.1 into packages/ - Create workspace package.json + tsconfig.json for each package - Rename ~240 imports from @mariozechner/pi-* to @gsd/pi-* - Apply existing patches as source edits (setModel persist, VT input) - Remove @mariozechner/pi-coding-agent dep and patch-package - Update build pipeline to build packages in dependency order - Add pi-upstream git remote for future selective syncing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
/**
|
|
* TUI session selector for --resume flag
|
|
*/
|
|
|
|
import { ProcessTerminal, TUI } from "@gsd/pi-tui";
|
|
import { KeybindingsManager } from "../core/keybindings.js";
|
|
import type { SessionInfo, SessionListProgress } from "../core/session-manager.js";
|
|
import { SessionSelectorComponent } from "../modes/interactive/components/session-selector.js";
|
|
|
|
type SessionsLoader = (onProgress?: SessionListProgress) => Promise<SessionInfo[]>;
|
|
|
|
/** Show TUI session selector and return selected session path or null if cancelled */
|
|
export async function selectSession(
|
|
currentSessionsLoader: SessionsLoader,
|
|
allSessionsLoader: SessionsLoader,
|
|
): Promise<string | null> {
|
|
return new Promise((resolve) => {
|
|
const ui = new TUI(new ProcessTerminal());
|
|
const keybindings = KeybindingsManager.create();
|
|
let resolved = false;
|
|
|
|
const selector = new SessionSelectorComponent(
|
|
currentSessionsLoader,
|
|
allSessionsLoader,
|
|
(path: string) => {
|
|
if (!resolved) {
|
|
resolved = true;
|
|
ui.stop();
|
|
resolve(path);
|
|
}
|
|
},
|
|
() => {
|
|
if (!resolved) {
|
|
resolved = true;
|
|
ui.stop();
|
|
resolve(null);
|
|
}
|
|
},
|
|
() => {
|
|
ui.stop();
|
|
process.exit(0);
|
|
},
|
|
() => ui.requestRender(),
|
|
{ showRenameHint: false, keybindings },
|
|
);
|
|
|
|
ui.addChild(selector);
|
|
ui.setFocus(selector.getSessionList());
|
|
ui.start();
|
|
});
|
|
}
|