Skip to content

Commit b55986c

Browse files
committed
fix: ignore sqlite markers in session migration warnings
1 parent 142f446 commit b55986c

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

src/commands/doctor-session-sqlite.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,60 @@ describe("runDoctorSessionSqlite", () => {
213213
).toHaveLength(2);
214214
});
215215

216+
it("does not report SQLite markers as missing transcript files", async () => {
217+
const store = createLegacyStore();
218+
fs.rmSync(store.transcriptPath);
219+
fs.rmSync(store.trajectoryPath);
220+
fs.writeFileSync(
221+
store.storePath,
222+
JSON.stringify(
223+
{
224+
"agent:main:main": {
225+
channel: "cli",
226+
chatType: "direct",
227+
sessionFile: `sqlite:main:session-1:${store.storePath}`,
228+
sessionId: "session-1",
229+
sessionStartedAt: 1000,
230+
updatedAt: 2000,
231+
},
232+
},
233+
null,
234+
2,
235+
),
236+
{ mode: 0o600 },
237+
);
238+
239+
const report = await runDoctorSessionSqlite({
240+
env: store.env,
241+
mode: "import",
242+
store: store.storePath,
243+
});
244+
const validation = await runDoctorSessionSqlite({
245+
env: store.env,
246+
mode: "validate",
247+
store: store.storePath,
248+
});
249+
250+
expect(report.totals).toMatchObject({
251+
importedEntries: 1,
252+
importedTranscriptEvents: 0,
253+
issues: 0,
254+
sqliteEntries: 1,
255+
});
256+
expect(validation.totals).toMatchObject({
257+
issues: 0,
258+
validatedEntries: 1,
259+
validatedTranscriptEvents: 0,
260+
});
261+
expect(
262+
loadExactSqliteSessionEntry({
263+
agentId: "main",
264+
sessionKey: "agent:main:main",
265+
storePath: store.storePath,
266+
})?.entry.sessionFile,
267+
).toContain("sqlite:main:session-1:");
268+
});
269+
216270
it("validates missing SQLite rows without creating the agent database", async () => {
217271
const store = createLegacyStore();
218272

src/commands/doctor-session-sqlite.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
loadSqliteTranscriptEventsSync,
1111
} from "../config/sessions/session-accessor.sqlite.js";
1212
import { resolveSqliteTargetFromSessionStorePath } from "../config/sessions/session-sqlite-target.js";
13+
import { parseSqliteSessionFileMarker } from "../config/sessions/sqlite-marker.js";
1314
import { normalizeStoreSessionKey } from "../config/sessions/store-entry.js";
1415
import {
1516
resolveAgentSessionStoreTargetsSync,
@@ -336,6 +337,9 @@ function resolveLegacyTranscriptPath(
336337
target: SessionStoreTarget,
337338
entry: SessionEntry,
338339
): string | undefined {
340+
if (parseSqliteSessionFileMarker(entry.sessionFile)) {
341+
return undefined;
342+
}
339343
const defaultPath = resolveSessionFilePath(entry.sessionId, entry, {
340344
agentId: target.agentId,
341345
sessionsDir: path.dirname(target.storePath),

0 commit comments

Comments
 (0)