refactor: introduce OpenCodeSupervisor for server lifecycle management (#200)

Replace direct opencodeServerManager calls with a supervisor that
provides health polling, operation locking, and a 4-step recovery
pipeline (restart, debug capture, rollback, seed default config).

Add archiveBrokenConfig to SettingsService for backup before rollback.
Wire supervisor into all route factories with graceful fallback to
direct manager calls. Add health watch configuration defaults and
env vars.
This commit is contained in:
Chris Scott authored and GitHub committed 2026-04-25 19:02:47 -04:00
1 parent 1212e6c6fb
commit 3dd8e34f98
13 files changed
+915 -111

No files matched your search

+26
View File
@@ -523,6 +523,32 @@ export class SettingsService {
}
}
archiveBrokenConfig(userId: string = 'default'): string | null {
const current = this.getDefaultOpenCodeConfig(userId)
if (!current) {
return null
}
const ts = new Date().toISOString().replace(/[:.]/g, '-')
const backupName = `${current.name}-broken-${ts}`
try {
this.createOpenCodeConfig(
{
name: backupName,
content: current.rawContent,
isDefault: false,
},
userId,
{ suppressAutoDefault: true },
)
logger.warn(`Archived broken OpenCode config as '${backupName}'`)
return backupName
} catch (error) {
logger.error('Failed to archive broken config:', error)
return null
}
}
restoreToLastKnownGoodConfig(userId: string = 'default'): { configName: string; content: string } | null {
if (!SettingsService.lastKnownGoodConfigContent) {
logger.warn('No last known good config available for rollback')