fix(opencode): prevent idle starts and orphaned serve - #1763
Merged
Merged
Conversation
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.
What
Startup model refresh skips OpenCode even when it is enabled. Its model list loads when a user requests it. Other disabled providers are also skipped.
The OpenCode provider now awaits pool shutdown. On Windows, the pool owns each spawned process tree in a Job Object and verifies that the listener port closes before it forgets the server. Shutdown also waits for starts already in progress.
Why
Startup model refresh previously called every registered provider. OpenCode shutdown returned before its pool finished, and the pool tracked the shell wrapper PID even when
opencode.exesurvived that wrapper.Evidence
Before the change, a controlled Mcode process exit left its captured OpenCode listener alive on port 49680. The exact captured listener was stopped after the check.
With this change, awaited pool shutdown removed the captured wrapper and OpenCode listener and closed port 64138. A separate abrupt-exit check removed both captured processes and closed port 54066 through Job Object ownership.
The full worktree Mcode startup check did not reach its health endpoint within
agent:ready's wait. Its server stayed in startup after the copied database loaded, so that check does not prove the model warmup path in the full app. The runtime was stopped withagent:down.Review Notes
The six focused test files passed, with 59 tests total. Server typecheck and targeted oxlint passed. No schema, setting, or migration changed.