Skip to content

fix(opencode2): refresh expired model catalog in place - #200

Merged
oakimov merged 3 commits into
oakimov:mainfrom
adonm:fix/opencode2-stale-catalog-refresh
Nov 20, 2026
Merged

oakimov merged 3 commits into
oakimov:mainfrom
adonm:fix/opencode2-stale-catalog-refresh

Conversation

@adonm

@adonm adonm commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Scope: OpenCode 2.x refreshes its Cursor picker in place after the published catalog expires. src/models.ts adds discoverModelCache; OpenCode 1.x still uses discoverModels during config load and has no daemon catalog latch.

Start with ensureModels in src/plugin-opencode2.ts. Session activity checks the published snapshot’s original timestamp. A successful refresh reloads the provider, not the Location; failed, empty, or timed-out refreshes leave the picker alone and back off. A credential switch clears that backoff. The existing alias hook reads the updated catalog.

Verified: Frozen install, typecheck, build, and 299 targeted tests passed. Bun LCOV covered all 66 changed executable lines. Re-ran #194’s stub A/B on stock OpenCode 2.3.0 with external networking blocked: f1c38d2 kept only Argon with zero discovery calls; this branch made one call, emitted provider.updated and model.updated, and added Carbon. A stubbed 503 kept Argon. No live 24-hour wait or prompts; no prompt-cache code changed.

Fixes #194

Track the age of the published catalog and retry expired discovery on existing host activity. Keep the current inventory on failure and preserve config-load discovery in OpenCode 1.x.

Fixes oakimov#194
@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@caeliq-reviewer caeliq-reviewer Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found. The earlier empty-catalog issue is fixed.

Tests pass (3652). Live test passed on OpenCode 2.3.2 and 1.19.6.

Comment thread src/plugin-opencode2.ts Resolved
Reject empty discovery responses before persisting a replacement. Refresh legacy empty snapshots on demand and use the turn context hook to recheck expiry when host events are unavailable.
@oakimov
oakimov merged commit 3dc9202 into oakimov:main Nov 20, 2026
6 checks passed
adonm added a commit to adonm/cursor-opencode-provider that referenced this pull request Nov 24, 2026
Adopt upstream's oakimov#199 pricing table, oakimov#200 in-place catalog refresh,
oakimov#201 CURSOR_PROGRESS_CONTINUATION opt-out, and oakimov#202 local AI SDK entry.
The fork's earlier ports (deb1787, 2bbab84, 9bf27b0 gate) are dropped
where upstream now covers the same ground.

Keep the fork-only pieces upstream still lacks: the seven-day conversation
snapshot default with fixed 24 h .tmp cleanup and resolver-derived test
ages, scripts/build-atomic.sh, scripts/sync-upstream.sh, the stale-dist
gate, and test/updater-build.test.ts.

Retire the last topic branch: nothing on perf/cache-ttl-and-lean-runtime
remains that upstream or this merge does not already cover, so TOPICS is
empty and the updater tests seed a synthetic topic into the copied script.
@adonm
adonm deleted the fix/opencode2-stale-catalog-refresh branch November 24, 2026 04:04
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.

opencode2: Cursor model picker stays stale after the 24-hour cache expires

2 participants