GeezerVison is showing github.com — fix(core): wait for plugin activation before session entry points by kitlangton · Pull Request #46878 · anomalyco/opencode
Conversation
kitlangton
commented
Sep 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Why
A cold Location activates its plugins asynchronously: the supervisor's initial generation runs behind a 100 ms Stream.debounce, and builtins such as ConfigCommandPlugin, SkillPlugin, and every provider plugin register only when it completes. Session entry points used to wait on that before reading plugin-provided state. #46639 removed the waits from Session.command, SessionPrompt.prepare, and Session.shell and flipped the session-owned assertions from activationWaits == [source] to [], while its description says sessions wait on Plugin. Only SessionRunner.drain still does.
The consequence is deterministic on v2 for the first request after boot:
sessions.prompt({ text: "Original" }) → plugin prompt hooks never run; "Original" is durably admitted
sessions.command({ command: "ready" }) → Command.NotFoundError for a command a discovered plugin registers
The new session-activation.test.ts boots a real Location with a .opencode/plugins/prompt.ts and reproduces both. It fails on v2 and passes with this change. This is also the root of the ACP catalog race that #46682 worked around from the client side.
What Changes
SessionPrompt.prepare, SessionCommand.execute, SessionSkill.get, SessionShell.start, and SessionGenerate wait on Plugin.awaitActivation inside the Location they enter, before resolving hooks, commands, skills, the shell, or the model catalog. Revert is unchanged: it only touches Snapshot → Git, which no plugin provides.
Plugin.awaitActivation is a new accessor (Service.use((plugins) => plugins.awaitActivation)) so each site is one line instead of the old three-line Effect.gen block.
- The
Plugin.Service tag, Interface, Generation, and Failure move to plugin/service.ts, mirroring instance/service.ts. Session code importing plugin.ts directly creates the cycle plugin.ts → plugin/host.ts → session.ts → session/prompt.ts → plugin.ts, which the standalone server hits at boot (ReferenceError: Cannot access 'node' before initialization in plugin/host.ts). plugin.ts re-exports the same names, so no other import changes.
session-shell.test.ts gets a 15 s default timeout like the other real-Location suites: every test there boots a fresh Location, so shell start now includes cold activation before PowerShell spawns, and the Windows runner exceeded the 5 s default on the exit 7 case.
- Tests:
session-owned assertions restored to the pre-refactor(core): decouple plugins from config loading #46639 expectations ([source], [source, destination], …), with the skill and missing-session cases updated to match. The prompt-location fixture and the session-skill/session-generate mocks gain a Plugin.Service mock, since their hand-built Locations predate the wait.
Cost: one activation wait per cold Location on the first prompt/command/skill/shell/generate — about 250 ms locally for the builtins plus one file plugin (100 ms of it is the initial Stream.debounce), evidently longer on the Windows runner. Warm Locations pay nothing; the runner already waited before this change.
Not in scope, from the same audit: the catalog/VCS/shell server handlers also lost their bounded readiness wait in 5d73a5789f, and the initial generation still pays the 100 ms debounce. Both are separate decisions.
Verification
# packages/core
bun typecheck
bun run test test/session-activation.test.ts # fails on v2 (2/2), passes here (2/2, --rerun-each 5)
bun run test # 3,998 pass, 39 skip, 0 fail
# packages/server
bun run ../core/script/test.ts # 50 pass, 0 fail
# packages/cli
bun typecheck && bun run test test/acp # 96 pass, 0 fail
# manual: OPENCODE_* isolated env, `opencode serve --stdio --port 0` boots and prints its endpoint
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Session.command, SessionPrompt.prepare, and Session.shell stopped waiting on plugin activation in #46639, so the first request after a cold Location boot ran with an empty registry: prompt hooks were skipped and plugin commands were not found. Restore the waits (plus skill and generate) through a Plugin.awaitActivation accessor, and move the Plugin service tag to plugin/service.ts so session code can import it without the plugin.ts → host.ts → session.ts cycle.
Drop the inferred type annotation, keep Failure private as before, and replace the hand-spelled service-then-wait pairs in the location watcher and server handlers with the accessor. SessionRunner keeps its layer-time binding: the accessor inside drain would add Plugin.Service to the drain requirement.
Each Session.shell test boots a fresh Location, and shell start now waits for cold plugin activation before spawning PowerShell; on the Windows runner that exceeded the 5 s default.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|