mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 15:01:26 +00:00
Fixes #933
This commit is contained in:
parent
349c6420c7
commit
6b4188fa0b
1 changed files with 12 additions and 0 deletions
|
|
@ -648,6 +648,18 @@ export class SessionManager {
|
||||||
this.sessionFile = resolve(sessionFile);
|
this.sessionFile = resolve(sessionFile);
|
||||||
if (existsSync(this.sessionFile)) {
|
if (existsSync(this.sessionFile)) {
|
||||||
this.fileEntries = loadEntriesFromFile(this.sessionFile);
|
this.fileEntries = loadEntriesFromFile(this.sessionFile);
|
||||||
|
|
||||||
|
// If file was empty or corrupted (no valid header), truncate and start fresh
|
||||||
|
// to avoid appending messages without a session header (which breaks the session)
|
||||||
|
if (this.fileEntries.length === 0) {
|
||||||
|
const explicitPath = this.sessionFile;
|
||||||
|
this.newSession();
|
||||||
|
this.sessionFile = explicitPath;
|
||||||
|
this._rewriteFile();
|
||||||
|
this.flushed = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const header = this.fileEntries.find((e) => e.type === "session") as SessionHeader | undefined;
|
const header = this.fileEntries.find((e) => e.type === "session") as SessionHeader | undefined;
|
||||||
this.sessionId = header?.id ?? randomUUID();
|
this.sessionId = header?.id ?? randomUUID();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue