fix: trigger auto-update check on headless `serve` startup
Merged
RA
5mo ago+150+150+012345678901234567890123456789-3-3-0123456789
PINEAPPLE
Summary
Triggers a best-effort auto-update check when headless altimate serve starts, so extension-launched servers follow the same upgrade path as TUI.
Updated implementation details to match the final code:
- Schedules a one-time startup check (~1s after server listen) via a dedicated helper.
- Runs the check in
Instance.provide({ directory: process.cwd(), init: InstanceBootstrap, fn: ... })(nobootstrap()wrapper), avoiding unintendedInstance.dispose()teardown during in-process server runtime. - Keeps all update policy inside
upgrade()(autoupdate gating, install method handling, downgrade guard, telemetry). - Uses explicit error handling/logging for both upgrade execution failures and outer orchestration failures.
- Extracts logic into
packages/opencode/src/cli/cmd/serve-upgrade-check.ts. - Adds dependency injection for collaborators in the helper to avoid process-global module mocking in tests.
Test Plan
- Ran targeted tests for startup upgrade check behavior:
- delayed scheduling
process.cwd()instance usage- non-throwing behavior when upgrade/provide fail
- Verified combined CLI test coverage after mock isolation fix:
packages/opencode/test/clisuite passing (512 pass, 0 fail).
- Verified CI TypeScript failure caused by leaked
mock.modulestate is resolved by DI-based test rewrite.
Checklist
- Tests added/updated
- Documentation updated (if needed)
- CHANGELOG updated (if user-facing)