refactor: introduce OpenCodeSupervisor for server lifecycle management#200
Merged
chriswritescode-dev merged 1 commit intomainfrom Apr 25, 2026
Merged
refactor: introduce OpenCodeSupervisor for server lifecycle management#200chriswritescode-dev merged 1 commit intomainfrom
chriswritescode-dev merged 1 commit intomainfrom
Conversation
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OpenCodeSupervisorwith lifecycle state machine (idle → starting → healthy/unhealthy → recovering → failed)opencodeServerManagerto prevent concurrent start/stop/restart/reload racesarchiveBrokenConfigmethod toSettingsServicefor backup before rollbackHEALTH_POLL_MS,HEALTH_FAILURE_THRESHOLD,HEALTH_WATCH_ENABLED)Changes
backend/src/services/opencode-supervisor.ts- New supervisor class with lifecycle managementbackend/src/services/opencode-single-server.ts- Operation locking andallowNestedparameterbackend/src/services/settings.ts- NewarchiveBrokenConfigmethodbackend/src/index.ts- Wire up supervisor, update shutdown logicbackend/src/routes/health.ts- Use supervisor lifecycle state for health checksbackend/src/routes/oauth.ts- Delegate config reload to supervisorbackend/src/routes/providers.ts- Delegate config reload to supervisorbackend/src/routes/repos.ts- Delegate restart to supervisorbackend/src/routes/settings.ts- Delegate reload/restart to supervisor (~20 call sites)shared/src/config/defaults.ts- Health watch config defaultsshared/src/config/env.ts- Health watch env varsType of Change
Checklist
pnpm lintpasses locallypnpm typecheckpasses locally