From bb23b6b5ca802a6df9c32b792c94c9cfa9060a56 Mon Sep 17 00:00:00 2001
From: licheer-zte
Date: Sun, 9 Aug 2026 04:24:02 +0800
Subject: [PATCH] fix(doctor): skip legacy main transcript check for
SQLite-owned sessions (#119940)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix(doctor): skip legacy main transcript check for SQLite-owned sessions
After the SQLite session import, the main session's legacy .jsonl is
archived and 'sessions cleanup' prunes it as unreferenced, but doctor
still warned 'Main session transcript missing' because the main-session
check required the legacy file. The sibling recent-session check already
skips SQLite-owned keys; apply the same ownership guard to the main
session so doctor and cleanup agree. (#119926)
* style(doctor): condense SQLite ownership comment
Co-authored-by: 李琪0668001400
---------
Co-authored-by: Peter Steinberger
---
src/commands/doctor-state-integrity.test.ts | 5 +++++
src/commands/doctor-state-integrity.ts | 4 +++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/commands/doctor-state-integrity.test.ts b/src/commands/doctor-state-integrity.test.ts
index fddd53ebd72a..d9ae4b0f05ab 100644
--- a/src/commands/doctor-state-integrity.test.ts
+++ b/src/commands/doctor-state-integrity.test.ts
@@ -617,6 +617,10 @@ describe("doctor state integrity oauth dir checks", () => {
const cfg: OpenClawConfig = {};
setupSessionState(cfg, process.env, process.env.HOME ?? "");
const storePath = resolveStorePath(cfg.session?.store, { agentId: "main" });
+ await upsertSessionEntry(
+ { agentId: "main", sessionKey: "agent:main:main", storePath },
+ { sessionId: "sqlite-main-session", updatedAt: Date.now() },
+ );
await upsertSessionEntry(
{ agentId: "main", sessionKey: "agent:main:sqlite-only", storePath },
{ sessionId: "sqlite-only-session", updatedAt: Date.now() },
@@ -628,6 +632,7 @@ describe("doctor state integrity oauth dir checks", () => {
});
expect(stateIntegrityText()).not.toContain("recent sessions are missing transcripts");
+ expect(stateIntegrityText()).not.toContain("Main session transcript missing");
});
it("does not auto-archive orphan transcripts from non-interactive repair mode", async () => {
diff --git a/src/commands/doctor-state-integrity.ts b/src/commands/doctor-state-integrity.ts
index 46421882a6a3..45d9f42051ca 100644
--- a/src/commands/doctor-state-integrity.ts
+++ b/src/commands/doctor-state-integrity.ts
@@ -1474,7 +1474,9 @@ export async function noteStateIntegrity(
const mainKey = resolveMainSessionKey(cfg);
const mainEntry = store[mainKey];
- if (mainEntry?.sessionId) {
+ // SQLite-owned transcripts live in the agent DB after import.
+ // Do not require the archived legacy JSONL for those sessions.
+ if (mainEntry?.sessionId && !sqliteSessionKeys.has(mainKey)) {
const transcriptPath = resolveSessionFilePath(
mainEntry.sessionId,
mainEntry,