Skip to content

fix(provider): persist plugin providers after instance dispose#20254

Open
luanweslley77 wants to merge 2 commits intoanomalyco:devfrom
luanweslley77:fix/provider-persist-20026
Open

fix(provider): persist plugin providers after instance dispose#20254
luanweslley77 wants to merge 2 commits intoanomalyco:devfrom
luanweslley77:fix/provider-persist-20026

Conversation

@luanweslley77
Copy link
Copy Markdown

@luanweslley77 luanweslley77 commented Mar 31, 2026

Issue for this PR

Closes #20026

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Plugin providers registered via config() hook disappear from TUI provider list after /instance/dispose.
Root cause: mergeProvider() only checks database (models.dev), but plugin providers aren't persisted there after reload.
Fix: Add fromConfigProvider() function and register plugin providers in database before mergeProvider() is called.

Changes:

packages/opencode/src/provider/provider.ts (+87 lines) - Provider persistence fix
packages/opencode/test/provider/plugin-reload.test.ts (+153 lines) - Test coverage

How did you verify your code works?

Unit tests: cd packages/opencode && bun test test/provider/plugin-reload.test.ts ✅ (1 pass, 41 expects)
Manual test: Plugin with custom provider (not from models.dev)

/connect → Select plugin provider → Complete OAuth
/connect again after instance dispose
Provider persists in list ✅ (before fix: disappeared ❌)

Screenshots / recordings

N/A - no UI changes

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

- Add fromConfigProvider() to convert config providers to database format
- Register plugin providers in database before mergeProvider() is called
- Remove unused type assertion (code quality)
- Fixes issue where plugin providers disappeared after /instance/dispose

Fixes anomalyco#20026
- Add robust test for provider persistence after instance dispose/reload
- Tests fix for issue anomalyco#20026 (plugin providers disappearing)
- Verifies provider config, models, capabilities, and options persist correctly
- Two instance lifecycle test: load → dispose → reload → verify

Test coverage:
- Provider registration and metadata
- Multiple models with full capability specs
- Options (baseURL, headers) persistence
- Model limits, costs, and modalities
- Complete data integrity after reload

Test plan: bun test test/provider/plugin-reload.test.ts
Result: ✅ 1 pass, 41 expect() calls

Related to: anomalyco#20026
@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title fix(provider): persist plugin providers after instance dispose doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@luanweslley77 luanweslley77 changed the title fix(provider): persist plugin providers after instance dispose fix(provider): persist plugin providers after instance dispose Mar 31, 2026
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.

/connect in TUI does not persist plugin providers after instance dispose

1 participant