Skip to content

fix(server): stop restoring stale OpenCode models#4095

Open
nateEc wants to merge 1 commit into
pingdotgg:mainfrom
nateEc:codex/fix-opencode-model-cache
Open

fix(server): stop restoring stale OpenCode models#4095
nateEc wants to merge 1 commit into
pingdotgg:mainfrom
nateEc:codex/fix-opencode-model-cache

Conversation

@nateEc

@nateEc nateEc commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Closes #4056.

Summary

  • Treat successful OpenCode provider snapshots as authoritative for removed models.
  • Preserve cached OpenCode models only while a refresh is pending or failed.
  • Add ProviderRegistry coverage for successful and failed OpenCode model refreshes.

Verification

  • corepack pnpm exec vp test run apps/server/src/provider/Layers/ProviderRegistry.test.ts
  • corepack pnpm exec vp run typecheck
  • corepack 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. mergeProviderModels now 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 in error (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 mergeProviderModels to drop stale models on successful OpenCode provider refresh

  • Previously, models missing from a refreshed OpenCode provider snapshot were retained even when the refresh succeeded, causing stale models to persist.
  • mergeProviderModels in 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.
  • On a failed refresh (status error) or for non-OpenCode providers, the prior behavior of retaining missing models is unchanged.
  • Behavioral Change: installed OpenCode providers will lose previously retained models after any successful refresh that omits them.

Macroscope summarized 39b459d.

- 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.
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1a11e3dc-ff1a-4055-a66b-1b8d2665fb79

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@macroscopeapp

macroscopeapp Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenCode models remain cached after logout or plugin removal

1 participant