fix(coding-agent): reject invalid session files

closes #6002
This commit is contained in:
Mario Zechner
2026-06-25 15:16:18 +02:00
parent f14b3594c1
commit 543710f643
5 changed files with 106 additions and 28 deletions
+11 -1
View File
@@ -241,6 +241,16 @@ function validateSessionIdFlags(parsed: Args): void {
}
}
function openSessionOrExit(path: string, sessionDir?: string): SessionManager {
try {
return SessionManager.open(path, sessionDir);
} catch (error: unknown) {
const message = error instanceof Error ? error.message : String(error);
console.error(chalk.red(`Error: ${message}`));
process.exit(1);
}
}
function forkSessionOrExit(sourcePath: string, cwd: string, sessionDir?: string, sessionId?: string): SessionManager {
try {
return SessionManager.forkFrom(sourcePath, cwd, sessionDir, { id: sessionId });
@@ -290,7 +300,7 @@ async function createSessionManager(
switch (resolved.type) {
case "path":
case "local":
return SessionManager.open(resolved.path, sessionDir);
return openSessionOrExit(resolved.path, sessionDir);
case "global": {
console.log(chalk.yellow(`Session found in different project: ${resolved.cwd}`));