fix(coding-agent): shorten invalid session error

Follow-up to #6002
This commit is contained in:
Mario Zechner
2026-06-25 15:20:08 +02:00
parent 774288587f
commit 0d145e895c
3 changed files with 4 additions and 6 deletions
@@ -800,7 +800,7 @@ export class SessionManager {
if (this.fileEntries.length === 0) {
const explicitPath = this.sessionFile;
if (statSync(explicitPath).size > 0) {
throw new Error(`Session file is not a valid pi session and was not modified: ${explicitPath}`);
throw new Error(`Session file is not a valid pi session: ${explicitPath}`);
}
this.newSession();
this.sessionFile = explicitPath;
@@ -57,9 +57,7 @@ describe("--session invalid file handling", () => {
const result = await runCli(["--session", sessionFile, "-p", "hi"], projectDir, agentDir);
expect(result.code).toBe(1);
expect(result.stderr).toContain(
`Error: Session file is not a valid pi session and was not modified: ${sessionFile}`,
);
expect(result.stderr).toContain(`Error: Session file is not a valid pi session: ${sessionFile}`);
expect(result.stderr).not.toContain("SessionManager.open");
expect(result.stderr).not.toContain("at ");
expect(readFileSync(sessionFile, "utf8")).toBe(originalContent);
@@ -275,7 +275,7 @@ describe("SessionManager.setSessionFile with corrupted files", () => {
writeFileSync(noHeaderFile, originalContent);
expect(() => SessionManager.open(noHeaderFile, tempDir)).toThrow(
`Session file is not a valid pi session and was not modified: ${noHeaderFile}`,
`Session file is not a valid pi session: ${noHeaderFile}`,
);
expect(readFileSync(noHeaderFile, "utf-8")).toBe(originalContent);
});
@@ -286,7 +286,7 @@ describe("SessionManager.setSessionFile with corrupted files", () => {
writeFileSync(nonSessionFile, originalContent);
expect(() => SessionManager.open(nonSessionFile, tempDir)).toThrow(
`Session file is not a valid pi session and was not modified: ${nonSessionFile}`,
`Session file is not a valid pi session: ${nonSessionFile}`,
);
expect(readFileSync(nonSessionFile, "utf-8")).toBe(originalContent);
});