Skip to content

fix(core): reuse Console config across startup activations - #53817

Draft
neriousy wants to merge 1 commit into
v2from
reuse-console-config
Draft

neriousy wants to merge 1 commit into
v2from
reuse-console-config

Conversation

@neriousy

@neriousy neriousy commented Oct 7, 2026

Copy link
Copy Markdown
Member

Issue for this PR

Regression from #53775. Follow-up to #53813.

Type of change

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

What does this PR do?

Since #53775, startup with a connected OpenCode Console fetches the Console config (GET /api/v2/config) twice, one after the other, before plugin activation finishes. Models, /connect and anything else behind Plugin.awaitActivation wait for both.

Cause: the supervisor first activates the guarded plugins on their own, then activates the full plugin list. Plugin.activate keeps a running plugin only if it is in the unchanged prefix of the new list. In the full list, OpencodePlugin comes after models.dev, Azure and other plugins, so the plugin from the early pass is torn down and set up again, and its initial load() fetches the Console config a second time. Each fetch took ~0.9–1.25s here.

Fix: the plugin saves each successful Console config fetch with the connection key and the time it was fetched. On plugin startup only, a fetch for the same connection from the last 30s is reused instead of fetched again. The saved value is keyed by the ManagedPolicy service instance, so it is shared within a server process and does not leak between tests.

What stays the same:

  • Credential switches, the one-minute refresh, and the 401/403 re-checks still always fetch.
  • Failed fetches are not saved, so if the early pass fails, the full pass retries.

I kept the plugin order unchanged. Moving OpencodePlugin earlier would avoid the restart, but its provider transform reads catalog providers that models.dev registers first.

How did you verify your code works?

  • Timed the first GET /api/integration on a fresh serve with a connected Console:
  • New test reuses a just-fetched Console config when the plugin starts again: it fails without the reuse (2 requests instead of 1) and passes with it.
  • bun typecheck in packages/core.
  • bun test test/plugin/ test/plugin.test.ts test/mcp.test.ts test/config/policy.test.ts: 493 pass. Some supervisor tests fail on v2 too when the Azure CLI is signed in, because the Azure plugin makes real requests; I ran with an empty AZURE_CONFIG_DIR.

Screenshots / recordings

N/A

Checklist

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

@neriousy
neriousy marked this pull request as draft October 7, 2026 22:27

This branch has not been deployed

No deployments
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