Skip to content

fix(provider): reorder plugin initialization before config snapshot#20777

Closed
luanweslley77 wants to merge 1 commit intoanomalyco:devfrom
luanweslley77:fix/provider-persist-20026
Closed

fix(provider): reorder plugin initialization before config snapshot#20777
luanweslley77 wants to merge 1 commit intoanomalyco:devfrom
luanweslley77:fix/provider-persist-20026

Conversation

@luanweslley77
Copy link
Copy Markdown
Contributor

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 the provider list after /instance/dispose. Root cause: configProviders was captured as a stale snapshot of cfg.provider BEFORE plugin.list() ran and called the config() hook. When plugins modified cfg.provider to add their providers, it was already too late — the snapshot didn't include them.
Fix: Move plugin.list() to run BEFORE reading configProviders, ensuring the plugin config() hook executes first. This way, any providers registered by plugins are visible when cfg.provider is captured.
New execution order:

  1. plugins = yield* plugin.list() — plugin config() hook runs, modifies cfg.provider
  2. configProviders = Object.entries(cfg.provider ?? {}) — now sees plugin modifications
  3. Rest of initialization (extend database, load env, load apikeys, etc.)
    This is a minimal reordering fix (8 lines added, 4 removed) that preserves the existing merge priority chain while fixing the timing issue.

How did you verify your code works?

  • Unit tests: 70 provider tests pass
  • Typecheck: clean
  • Manual test: /connect in TUI — plugin providers persist after instance dispose/reload

Screenshots / recordings

N/A - no UI changes

Checklist

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

Moves plugin.list() before reading configProviders to ensure the
plugin config() hook runs first, so any providers registered by plugins
are visible when cfg.provider is captured. Previously, configProviders
was read as a stale snapshot before plugins had a chance to modify it,
causing plugin-registered providers to disappear after /instance/dispose.

Closes anomalyco#20026
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