fix(server): stop restoring stale OpenCode models#4095
Conversation
- Treat successful OpenCode provider snapshots as authoritative for removed models. - Keep retaining cached models only for pending or failed OpenCode refreshes. - Add ProviderRegistry tests for successful and failed OpenCode refresh merges.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This PR changes runtime behavior for OpenCode provider model merging, determining whether stale models are retained or dropped after refresh. While well-tested and small in scope, the change affects user-visible model availability and warrants human review. You can customize Macroscope's approvability policy. Learn more. |
Closes #4056.
Summary
Verification
corepack pnpm exec vp test run apps/server/src/provider/Layers/ProviderRegistry.test.tscorepack pnpm exec vp run typecheckcorepack pnpm exec vp check(passes with existing warnings outside this change)Note
Low Risk
Scoped to provider snapshot merge logic with targeted tests; non-OpenCode merge behavior is preserved.
Overview
OpenCode model lists no longer keep models that disappear after a successful refresh.
mergeProviderModelsnow takes the refreshed provider snapshot and only re-attaches missing slugs from the previous cache for non-OpenCode drivers, or for OpenCode when the instance is not installed or the refresh ended inerror(including empty model lists on failure).Other providers (e.g. Cursor) still merge in previously discovered models when a refresh returns none, and capability backfill from the prior snapshot is unchanged.
Tests cover OpenCode dropping removed-plugin models on success and keeping the last good list when refresh fails.
Reviewed by Cursor Bugbot for commit 39b459d. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
mergeProviderModelsto drop stale models on successful OpenCode provider refreshmergeProviderModelsin ProviderRegistry.ts now checks if the provider is an installed OpenCode provider with a non-error status; if so, models absent from the refresh result are dropped instead of kept.error) or for non-OpenCode providers, the prior behavior of retaining missing models is unchanged.Macroscope summarized 39b459d.