fix: resolve #3124 #3125 #3127 session tools, cache priming, and compaction loop

- #3124: Session tools now merge SDK and file-backed sessions for SQLite backend
- #3125: Cache priming fixed for OpenCode >=1.3.14 empty workspace
- #3127: Activity-based progress detection prevents infinite compaction on Kimi/Minimax

All 29 new tests pass, 4885 total tests passing.
This commit is contained in:
YeonGyu-Kim
2026-04-05 09:30:19 +09:00
parent aeb9c97c30
commit 130f4ac080
22 changed files with 538 additions and 114 deletions
@@ -33,6 +33,10 @@ type BackgroundUpdateCheckRunner = (
getToastMessage: (isUpdate: boolean, latestVersion?: string) => string,
) => Promise<void>
function getCacheWorkspaceDir(deps: BackgroundUpdateCheckDeps): string {
return deps.join(deps.getOpenCodeCacheDir(), "packages")
}
const defaultDeps: BackgroundUpdateCheckDeps = {
existsSync,
join,
@@ -60,7 +64,7 @@ function getPinnedVersionToastMessage(latestVersion: string): string {
*/
function resolveActiveInstallWorkspace(deps: BackgroundUpdateCheckDeps): string {
const configPaths = deps.getOpenCodeConfigPaths({ binary: "opencode" })
const cacheDir = deps.getOpenCodeCacheDir()
const cacheDir = getCacheWorkspaceDir(deps)
const configInstallPath = deps.join(configPaths.configDir, "node_modules", PACKAGE_NAME, "package.json")
const cacheInstallPath = deps.join(cacheDir, "node_modules", PACKAGE_NAME, "package.json")
@@ -76,6 +80,12 @@ function resolveActiveInstallWorkspace(deps: BackgroundUpdateCheckDeps): string
return cacheDir
}
const cachePackageJsonPath = deps.join(cacheDir, "package.json")
if (deps.existsSync(cachePackageJsonPath)) {
deps.log(`[auto-update-checker] Active workspace: cache-dir (${cacheDir}, package.json present)`)
return cacheDir
}
// Default to config-dir if neither exists (matches doctor behavior)
deps.log(`[auto-update-checker] Active workspace: config-dir (default, no install detected)`)
return configPaths.configDir
@@ -95,6 +105,19 @@ async function runBunInstallSafe(workspaceDir: string, deps: BackgroundUpdateChe
}
}
async function primeCacheWorkspace(
activeWorkspace: string,
deps: BackgroundUpdateCheckDeps,
): Promise<boolean> {
const cacheWorkspace = getCacheWorkspaceDir(deps)
if (activeWorkspace === cacheWorkspace) {
return true
}
deps.log(`[auto-update-checker] Priming cache workspace after install: ${cacheWorkspace}`)
return runBunInstallSafe(cacheWorkspace, deps)
}
export function createBackgroundUpdateCheckRunner(
overrides: Partial<BackgroundUpdateCheckDeps> = {},
): BackgroundUpdateCheckRunner {
@@ -156,6 +179,13 @@ export function createBackgroundUpdateCheckRunner(
const installSuccess = await runBunInstallSafe(activeWorkspace, deps)
if (installSuccess) {
const cachePrimed = await primeCacheWorkspace(activeWorkspace, deps)
if (!cachePrimed) {
await deps.showUpdateAvailableToast(ctx, latestVersion, getToastMessage)
deps.log("[auto-update-checker] cache workspace priming failed after install")
return
}
await deps.showAutoUpdatedToast(ctx, currentVersion, latestVersion)
deps.log(`[auto-update-checker] Update installed: ${currentVersion}${latestVersion}`)
return