feat(cli): add instance: false opt-out to effectCmd#25507
Merged
Conversation
For commands that don't read project state (e.g. serve, web, account, db, upgrade), the always-on InstanceStore.provide adds unnecessary work (InstanceBootstrap = config + plugin init + LSP/File/etc forks) and emits a server.instance.disposed IPC event the TUI then re-bootstraps on. Add `instance: false` to opt out: handler runs directly under AppRuntime with no instance load, no auto-dispose. Default stays true (no breaking change for existing converted commands). Convert serve.ts as the first user — server loads instances per-request via x-opencode-directory header, so it never needed an ambient one.
Effect.never is the idiomatic block-forever, replacing the
Effect.promise(() => new Promise<void>(() => {})) bridge. The
server.stop() call after it was unreachable in the legacy code too
(await new Promise(() => {}) never resolves), so dropping it.
6 tasks
4 tasks
66 tasks
oleksii-honchar
pushed a commit
to oleksii-honchar/better-opencode
that referenced
this pull request
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
For commands that don't read project state, the always-on `InstanceStore.provide` adds unnecessary work (`InstanceBootstrap` = config + plugin init + LSP/File/Snapshot/Vcs/Format/ShareNext init forks) and emits a `server.instance.disposed` IPC event the TUI re-bootstraps on.
Add `instance: false` to opt out: handler runs directly under `AppRuntime` with no instance load and no auto-dispose. Default stays `true` (no breaking change for existing converted commands).
```ts
effectCmd({
command: "serve",
instance: false, // ← skip InstanceStore.provide
handler: Effect.fn(...)(...)
})
```
First user: serve.ts
Converted as the demo. Server loads instances per-request via the `x-opencode-directory` header, so it never needed an ambient one — keeping the legacy "no instance load" semantics while still gaining `effectCmd`'s shape.
Future candidates (not in this PR)
`web`, `account` (login/logout/switch/orgs/open/console), `db` (path/query/migrate), `upgrade`, `uninstall` — all currently still on raw `cmd()` because the always-load behavior would add startup work they don't need.
Behavioral notes
Test plan