Repository navigation
feat(server): report plugin readiness on plugin.list - #64029
Conversation
There was a problem hiding this comment.
I found no blocking problems. The new endpoint works as described. On a live opencode serve, a cold Location returned ready: false and then ready: true within a few seconds, and opencode models --server … gave the same output as the base. The new server test, the core plugin tests and typecheck:tsc for core, server, cli and client all pass. The CLI suite has 5 server/service lifecycle failures, and the base has the same 5.
The settle announcement fires only when the last hold is released and not after close. The supervisor doesn't re-activate on plugin.updated, so the extra event can't cause a reload loop. The existing listeners in the TUI, desktop app and app only re-read the plugin list.
Public API (all additive and backwards compatible):
- New
GET /api/experimental/plugin/ready(operationexperimental.plugin.ready). - New SDK method
client.experimental.plugin.ready()with typesExperimentalPluginReadyInputandExperimentalPluginReadyOutput. The code generator also addsclient.plugin.readyand thePluginReady*types, already marked deprecated. - New
readyon the corePlugin.Interface. plugin.updatednow fires once more each time an activation settles.
One inline note: when the CLI talks to an older server, it no longer waits for plugins at all.
Related: #63221
| // reports its plugins have finished loading, npm installs included. | ||
| export const waitForPlugins = (client: OpenCodeClient, directory: string) => | ||
| Effect.tryPromise((signal) => client.plugin.list({ location: { directory } }, { signal })).pipe( | ||
| Effect.tryPromise((signal) => client.experimental.plugin.ready({ location: { directory } }, { signal })).pipe( |
There was a problem hiding this comment.
Against a server that doesn't have this endpoint yet (for example an older server passed with --server), this call gets a 404. Effect.repeat stops on that error and Effect.ignore swallows it, so models, debug agents and auth don't wait at all. Before, they waited for a non-empty plugin list. Falling back to the old plugin.list check when ready fails would keep that case working.
There was a problem hiding this comment.
My earlier point is addressed: if the readiness route fails, waitForPlugins now falls back to waiting for a non-empty plugin.list. I pointed this PR's CLI at a base server, where the route returns 404, and models --server … printed the full model list on a cold location. Against this PR's server, the route returned ready: false and then true. The route now lives in server.experimental, so the deprecated client.plugin.ready alias is gone. The server, client and core tests I ran pass, typecheck:tsc passes for server, cli, client and protocol, and check:generated is clean.
Public API (all additions, all backwards compatible):
GET /api/experimental/plugin/readyclient.experimental.plugin.ready()readyon the corePlugin.Interface- one more
plugin.updatedevent each time plugin loading settles
I found nothing new that needs changing.
There was a problem hiding this comment.
The new commit puts waitForPlugins back to the base version, so the CLI no longer calls the readiness route and the problem with older servers from my earlier comment no longer applies. I checked that packages/cli now has no diff from the base, the server readiness test passes, and typecheck:tsc passes for the CLI.
Public API (all additions, all backwards compatible):
GET /api/experimental/plugin/readyclient.experimental.plugin.ready()readyon the corePlugin.Interface- one more
plugin.updatedevent each time plugin loading settles
The CLI's behaviour is unchanged. I have no new concerns.
98e811c to
813eaf5
Compare
There was a problem hiding this comment.
Moving readiness onto plugin.list works as described, and I have no blocking concerns. My earlier point about older servers no longer applies, because this version doesn't touch the CLI.
On a live serve, GET /api/plugin on a cold location returned ready: false with an empty list, then ready: true with the full list. The base CLI's models --server … against this server printed the full list, so older clients still read the new response. The server handler reads ready before the list, so a response can't combine a partial list with ready: true. The server, core plugin and packages/plugin tests pass, typecheck:tsc passes for core, server, client, protocol, plugin and cli, and check:generated is clean.
Public API (backwards compatible):
GET /api/plugin(plugin.list) gains an optionalreadyfield, in the OpenAPI spec and in the SDK'sPluginListOutput. Servers from before this change leave it out.- Plugins see the same
readythroughctx.plugin.list(). plugin.updatednow also fires when readiness flips, which adds two events per activation.- The core
Plugin.Interfacegainsready. - The experimental
/api/experimental/plugin/readyroute from the earlier version is gone.
There was a problem hiding this comment.
The new commits look sound and I have no new concerns. A failing plugin.updated listener is now logged and can't leave a hold pending. The supervisor gives back the extra hold when two sources ask for one at the same time. ctx.plugin.list() for plugins now reads ready before the list, matching the HTTP handler. ready is now an optional boolean with no null option.
On a live serve, GET /api/plugin on a cold location returned ready: false and then true. The core plugin tests (630, including the new overlapping-holds test) and the server readiness test pass, typecheck:tsc passes for core, server, client, protocol and plugin, and check:generated is clean.
Public API (same as my last review, backwards compatible):
GET /api/plugin(plugin.list) gains an optional booleanready, in the HTTP API, the SDK andctx.plugin.list().plugin.updatedalso fires when readiness flips.- The core
Plugin.Interfacegainsready.
Issue for this PR
Follow-up to #62796. Implements the readiness part of Kit's proposal in the #core thread on async plugins.
Type of change
What does this PR do?
The server never waits for plugins, so catalog reads can be partial on a cold Location, and clients couldn't tell when loading was done.
plugin.listnow says so, andplugin.updatedfires when it changes:Clients already re-read
plugin.listonplugin.updated, so one read tells them both what's loaded and whether that's everything.readyis the signalPlugin.awaitActivationwaits on (no holds pending), read without waiting. It covers the whole activation, including npm installs and later reloads.plugin.list.readythroughctx.plugin.list().plugin.updatedlistener is logged and can't leave a hold pending.plugin.updatedevents (ready flipping to false and back). Listeners only re-readplugin.list, which is in memory, and the plugin supervisor doesn't react to it, so there's no reload loop.Not in this PR, from the same proposal: a client helper that waits for
ready, and flippingreadyto false before config and credential changes respond.How did you verify your code works?
plugin.listreportsready: false; once it finishes, re-readingplugin.liston eachplugin.updatedends atready: true. It fails without the announcement when activation settles.readyto false once and back to true once, announcing each flip.packages/coreplugin tests (630),packages/server(128),packages/cli(399),packages/client(262),packages/sdk(40),packages/protocol(14),packages/plugin(37) andpackages/tui(1,675) pass.bun run check,check:generated, andtypecheck:tscfor core, server, client, protocol and cli pass.Checklist
Added by the opencode bot (AI-generated).
Related: #63221
Public API: adds optional
readyto plugin.list (HTTP, SDK, plugin ctx); plugin.updated also fires when readiness flips (backwards compatible)