fix(models): force-refresh Cursor model catalog on every startup#65
Merged
Conversation
The auth loader warmed the model cache with discoverModels({apiKey}),
which respects the 24h on-disk TTL and no-ops when the cache is still
fresh. New Cursor models never surfaced locally until the cache
happened to expire or a user manually ran cursor_refresh_models.
Pass forceRefresh: true from the loader instead. It already runs once
per opencode startup with the resolved key and is fire-and-forget, so
this triggers a live Cursor.models.list() on every launch without
adding startup latency. The config and provider.models hooks still
read the existing cache instantly (stale-while-revalidate).
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.
Problem
New Cursor models weren't showing up locally. The auth loader warmed
the model cache with
discoverModels({ apiKey }), which respects the24h on-disk TTL and no-ops if the cache is still fresh. New models
only surfaced once the cache happened to expire, or a user manually
ran
cursor_refresh_models.Fix
Pass
forceRefresh: truefrom the loader (src/plugin/index.ts). Theloader already runs once per opencode startup with the resolved key
and is fire-and-forget, so this now triggers a live
Cursor.models.list()on every launch with no added startup latency.The
configandprovider.modelshooks still read the existing cacheinstantly — stale-while-revalidate.
Also tweaked the
cursor_refresh_modelstool description to note thenew auto-refresh-on-startup behavior (the manual tool remains useful
for picking up new models mid-session).
Testing
test/plugin-loader-refresh.test.ts: asserts the loader callsdiscoverModelswithforceRefresh: truewhen a key resolves, andskips discovery entirely when no key is present. Confirmed it fails
before the fix (
forceRefreshundefined) and passes after.npm run typecheck: clean.