Skip to content

Discover models without blocking plugin activation - #5

Merged
moutansos merged 1 commit into
mainfrom
fix/background-catalog-cache
Oct 22, 2026
Merged

moutansos merged 1 commit into
mainfrom
fix/background-catalog-cache

Conversation

@moutansos

Copy link
Copy Markdown
Owner

Summary

  • Register the CLIProxyAPI provider before either network request, then load the model catalog and optional models.dev metadata in the background. A disk cache supplies the last successful catalogs immediately when OpenCode activates the plugin once per location.
  • Share the catalog cache by server URL, not API key. A failed catalog fetch keeps the previous cache and its timestamp, and unloading the plugin stops further provider reloads.
  • Let one process download metadata while the others wait for its cache. A stale lock can be recovered without deleting a lock another process has taken over.

Test plan

  • bun test ./src
  • bun run typecheck
  • bun run build
  • Load the plugin against a slow CLIProxyAPI server and confirm activation succeeds before /v1/models returns
  • Confirm a second OpenCode location reuses the cached catalog and does not start a second models.dev download

OpenCode can load this plugin in a separate process for every location, so
waiting on CLIProxyAPI or models.dev can exceed the activation budget. Register
the provider first and fill models from a shared disk cache and background
refresh. A failed fetch no longer refreshes the cache timestamp, and a process
that loses the metadata lock waits for the winner's cache.
@moutansos
moutansos merged commit 9e2c5e2 into main Oct 22, 2026
1 check passed
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