Skip to content

fix(models): force-refresh Cursor model catalog on every startup#65

Merged
justin-carper merged 1 commit into
mainfrom
update-cursor-models
Jul 8, 2026
Merged

fix(models): force-refresh Cursor model catalog on every startup#65
justin-carper merged 1 commit into
mainfrom
update-cursor-models

Conversation

@justin-carper

Copy link
Copy Markdown
Collaborator

Problem

New Cursor models weren't showing up locally. The auth loader warmed
the model cache with discoverModels({ apiKey }), which respects the
24h 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: true from the loader (src/plugin/index.ts). The
loader 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 config and provider.models hooks still read the existing cache
instantly — stale-while-revalidate.

Also tweaked the cursor_refresh_models tool description to note the
new auto-refresh-on-startup behavior (the manual tool remains useful
for picking up new models mid-session).

Testing

  • Added test/plugin-loader-refresh.test.ts: asserts the loader calls
    discoverModels with forceRefresh: true when a key resolves, and
    skips discovery entirely when no key is present. Confirmed it fails
    before the fix (forceRefresh undefined) and passes after.
  • Full suite: 302 tests passed (27 files).
  • npm run typecheck: clean.

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).
@justin-carper justin-carper merged commit e9fcb26 into main Jul 8, 2026
6 checks passed
@justin-carper justin-carper deleted the update-cursor-models branch July 8, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant