Skip to content

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

Closed
neriousy wants to merge 1 commit into
devfrom
reuse-console-config
Closed

neriousy wants to merge 1 commit into
devfrom
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

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant