feat(session-manager): add version-gated SDK read path for OpenCode beta

- Add SDK client injection via setStorageClient()

- Version-gate getMainSessions(), getAllSessions(), readSessionMessages(), readSessionTodos()

- Add comprehensive tests for SDK path (beta mode)

- Maintain backward compatibility with JSON fallback
This commit is contained in:
YeonGyu-Kim
2026-02-14 18:16:18 +09:00
parent 5eebef953b
commit b0944b7fd1
8 changed files with 720 additions and 10 deletions
+23
View File
@@ -19,6 +19,12 @@ beforeAll(async () => {
join: mock((...args: string[]) => args.join("/")),
}))
// Mock storage detection to return false (stable mode)
mock.module("./opencode-storage-detection", () => ({
isSqliteBackend: () => false,
resetSqliteBackendCache: () => {},
}))
;({ getMessageDir } = await import("./opencode-message-dir"))
})
@@ -110,4 +116,21 @@ describe("getMessageDir", () => {
// then
expect(result).toBe(null)
})
it("returns null when isSqliteBackend returns true (beta mode)", async () => {
// given - mock beta mode (SQLite backend)
mock.module("./opencode-storage-detection", () => ({
isSqliteBackend: () => true,
resetSqliteBackendCache: () => {},
}))
// Re-import to get fresh module with mocked isSqliteBackend
const { getMessageDir: getMessageDirBeta } = await import("./opencode-message-dir")
// when
const result = getMessageDirBeta("ses_123")
// then
expect(result).toBe(null)
})
})