Repository navigation
Wait for OpenCode plugin activation before integration calls - #486
chriswritescode-dev wants to merge 1 commit into
Conversation
| export async function awaitOpenCodePlugins(api: Pick<OpenCodeApi, 'provider'>): Promise<void> { | ||
| await api.provider.list() | ||
| } |
There was a problem hiding this comment.
Heavy readiness probe
awaitOpenCodePlugins calls provider.list() and discards the result, so it is used only for its wait-for-plugins side effect. That call returns the whole provider and model catalogue, which is large. It now runs before every credential status check, credential delete, key connect, auth-methods request, authorize request, and frontend getIntegrations. A UI that checks status for each provider downloads the catalogue N times. Consider waiting once per OpenCode instance or directory and caching the result, or using a lighter readiness signal if one exists.
| await awaitOpenCodePlugins(openCodeClient.api) | ||
| await openCodeClient.api.integration.connect.key(connectInput) |
There was a problem hiding this comment.
Status code mapping
A plugin-activation timeout (ServiceUnavailableError) goes through handleOpenCodeError and comes out as a 502. The new test asserts this. The condition is temporary and safe to retry, so a 503 would be more accurate and would let clients retry. This is minor and only matters if a client treats 502 and 503 differently.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
User description
Summary
OpenCode 2.3.0 no longer waits for plugin activation in its
integration.listhandler. On a directory instance that has just started, the integration endpoints therefore act on a half-loaded registry for about 100ms:integration.listreturns an empty or partial catalogue, without plugin-provided forms such as GitHub Copilot'sdeploymentType/enterpriseUrl.integration.connect.keyfor Azure succeeds without the requiredresourceNamefield and stores an invalid credential.OpenCode's
provider.listhandler still waits for plugin activation (awaitPlugins, failing withServiceUnavailableErrorafter 5s) in both 2.2.5 and 2.3.0. A new shared helper,awaitOpenCodePlugins, calls it first. The provider credential routes, the OAuthauth-methodsandauthorizeroutes, and the frontend'sgetIntegrationsnow await it before touching integrations.This replaces
runWhenIntegrationReady, which retried only onIntegrationNotFoundErrorand could not catch the partial state, so it and its tests are removed.Validation
mainnow pass: "connects an azure key together with its required resourceName form field" (its manual warm-up call is removed, so it proves the route waits) and "maps the real integration catalogue and starts and cancels an OAuth attempt".provider.listruns beforeconnect.keyandintegration.list, and that a failed activation wait does not connect the key.vitest run --coverage: 4,281 passed, none skipped. Statements 90.18%, branches 85.3%.pnpm lintandpnpm typecheckare clean.PR Type
Bug fix, Enhancement
Description
Add shared
awaitOpenCodePluginshelper callingprovider.listAwait plugin activation before credential and OAuth integration calls
Remove retry-based
runWhenIntegrationReadyhelper and its testsStub
provider.list; add activation-wait and failure testsDiagram Walkthrough
File Walkthrough
3 files
Await plugin activation before OAuth integration callsGate credential routes on plugin activationAwait plugins before listing integrations1 files
Add awaitOpenCodePlugins, drop not-found error export4 files
Test activation wait, remove retry testAdd activation-wait tests, drop retry coverageStub provider namespace list methodDelete obsolete integration-ready helper tests1 files
Delete retry-based integration readiness helper