oh-my-opencode/src/tools/lsp/lsp-manager-temp-directory-cleanup.ts
YeonGyu-Kim f3f6ba47fe merge: integrate origin/dev into modular-enforcement branch
Resolves all merge conflicts, preserving our split module structure
while integrating all dev changes:
- Custom agent summaries support (parseRegisteredAgentSummaries)
- Background notification queue (enqueueNotificationForParent)
- Atlas shared git-worktree module (collectGitDiffStats, formatFileChanges)
- Ralph-loop withTimeout + DEFAULT_API_TIMEOUT=5000
- Session recovery assistant_prefill_unsupported error type
- Atlas agentOverrides forwarding
- Config handler plan model demotion (buildPlanDemoteConfig)
- Delegate-task agentOverrides, promptSyncWithModelSuggestionRetry, variant
- LSP init timeout + stale init detection
- isPlanFamily function + task-continuation-enforcer hook
- Handoff command
2026-02-08 17:34:47 +09:00

30 lines
725 B
TypeScript

type ManagedClientForTempDirectoryCleanup = {
refCount: number
client: {
stop: () => Promise<void>
}
}
export async function cleanupTempDirectoryLspClients(
clients: Map<string, ManagedClientForTempDirectoryCleanup>
): Promise<void> {
const keysToRemove: string[] = []
for (const [key, managed] of clients.entries()) {
const isTempDir = key.startsWith("/tmp/") || key.startsWith("/var/folders/")
const isIdle = managed.refCount === 0
if (isTempDir && isIdle) {
keysToRemove.push(key)
}
}
for (const key of keysToRemove) {
const managed = clients.get(key)
if (managed) {
clients.delete(key)
try {
await managed.client.stop()
} catch {}
}
}
}