Merge branch 'tmp-2025-01-11' - resume scope toggle with async loading (#620)

This commit is contained in:
Mario Zechner 2026-01-12 00:00:28 +01:00
commit 9d49b4d4ed
9 changed files with 382 additions and 125 deletions

View file

@ -61,14 +61,14 @@ async function prepareInitialMessage(
* Resolve a session argument to a file path.
* If it looks like a path, use as-is. Otherwise try to match as session ID prefix.
*/
function resolveSessionPath(sessionArg: string, cwd: string, sessionDir?: string): string {
async function resolveSessionPath(sessionArg: string, cwd: string, sessionDir?: string): Promise<string> {
// If it looks like a file path, use as-is
if (sessionArg.includes("/") || sessionArg.includes("\\") || sessionArg.endsWith(".jsonl")) {
return sessionArg;
}
// Try to match as session ID (full or partial UUID)
const sessions = SessionManager.list(cwd, sessionDir);
const sessions = await SessionManager.list(cwd, sessionDir);
const matches = sessions.filter((s) => s.id.startsWith(sessionArg));
if (matches.length >= 1) {
@ -79,12 +79,12 @@ function resolveSessionPath(sessionArg: string, cwd: string, sessionDir?: string
return sessionArg;
}
function createSessionManager(parsed: Args, cwd: string): SessionManager | undefined {
async function createSessionManager(parsed: Args, cwd: string): Promise<SessionManager | undefined> {
if (parsed.noSession) {
return SessionManager.inMemory();
}
if (parsed.session) {
const resolvedPath = resolveSessionPath(parsed.session, cwd, parsed.sessionDir);
const resolvedPath = await resolveSessionPath(parsed.session, cwd, parsed.sessionDir);
return SessionManager.open(resolvedPath, parsed.sessionDir);
}
if (parsed.continue) {
@ -314,7 +314,7 @@ export async function main(args: string[]) {
}
// Create session manager based on CLI flags
let sessionManager = createSessionManager(parsed, cwd);
let sessionManager = await createSessionManager(parsed, cwd);
time("createSessionManager");
// Handle --resume: show session picker
@ -322,13 +322,10 @@ export async function main(args: string[]) {
// Initialize keybindings so session picker respects user config
KeybindingsManager.create();
const sessions = SessionManager.list(cwd, parsed.sessionDir);
time("SessionManager.list");
if (sessions.length === 0) {
console.log(chalk.dim("No sessions found"));
return;
}
const selectedPath = await selectSession(sessions);
const selectedPath = await selectSession(
(onProgress) => SessionManager.list(cwd, parsed.sessionDir, onProgress),
SessionManager.listAll,
);
time("selectSession");
if (!selectedPath) {
console.log(chalk.dim("No session selected"));