Skip to content

fix(server): await models before listing - #41783

Merged
kitlangton merged 1 commit into
v2from
model-list-ready
Aug 11, 2026
Merged

kitlangton merged 1 commit into
v2from
model-list-ready

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Make the first model.list request against a newly started server wait for model-providing plugins to finish initializing. This restores opencode models --standalone output on cold start instead of silently returning no models.

Closes #41071

Before / After

Before: A standalone server became HTTP-ready while PluginSupervisor was still activating the initial plugin generation. An immediate model.list request read the empty Catalog, returned HTTP 200 with data: [], and the CLI printed nothing before exiting 0.

After: model.list waits for PluginSupervisor.flush before reading the catalog, matching the existing model.default readiness boundary. If initialization does not settle within five seconds, the endpoint returns the existing model-catalog service-unavailable error rather than a successful empty response.

How

  • packages/server/src/handlers/model.ts applies the existing bounded model-catalog initialization wait to model.list.
  • packages/server/test/model.test.ts starts a fresh server with a configured custom model and immediately requests /api/model, asserting that the cold-start response includes that model.

Scope

  • No CLI output or exit-code behavior changes are needed; the fix is at the server model-list consistency boundary.
  • No protocol or generated-client surfaces change.
  • Provider loading and plugin supervision behavior are unchanged.

Testing

  • bun run test test/model.test.ts --rerun-each 3 from packages/server (3 passes)
  • bun run test from packages/server (18 passes, 11 skips)
  • bun typecheck from packages/server
  • Push hook: bun turbo typecheck --concurrency=3 (33 successful tasks)
  • bunx prettier --check src/handlers/model.ts test/model.test.ts from packages/server

The regression test was also run before the handler change and reproduced the bug as HTTP 200 with { "data": [] }.

@kitlangton
kitlangton marked this pull request as ready for review August 11, 2026 16:17
@kitlangton
kitlangton merged commit 23b0688 into v2 Aug 11, 2026
9 of 10 checks passed
@kitlangton
kitlangton deleted the model-list-ready branch August 11, 2026 16:18
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
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