Repository navigation
fix(opencode): list file commands without blocking on MCP connections - #48630
Closed
luochen1990 wants to merge 1 commit into
Closed
luochen1990 wants to merge 1 commit into
luochen1990 wants to merge 1 commit into
Conversation
command.list now returns config/skill commands immediately; MCP prompts merge into the state from a background fiber and publish command.updated so clients re-fetch. ACP directory snapshots await Command.ready() to keep their previous blocking capture semantics.
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Member
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
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.
Issue for this PR
Closes #36288
Closes #48629
Type of change
What does this PR do?
/commandcurrently waits for all MCP servers to connect before returning file-based commands (measured 5.6s with 9 servers, 0.65s with MCP disabled — see issue). This PR makes the initial listing immediate and merges MCP prompts asynchronously:Command.initnow loads defaults + config commands + skills synchronously;mcp.prompts()is forked into a background fiber (scoped to the cache entry) that merges prompts in-place once servers settle, preserving the existingmcp > config > skillprecedencecommand.updatedevent (same shape/pattern aslsp.updated) is published when the merge lands; the TUI sync store re-fetchescommand.liston receipt, so prompts appear in the/menu as soon as they existcommand.ready()lets callers opt back into the old wait-for-prompts semantics; the ACP directory loader uses it (its snapshot is cached per-directory forever, so it must capture the merged state — behavior there is unchanged)Known trade-off (stated in the issue): a one-shot API consumer that neither subscribes to events nor re-fetches will see prompts missing from its first response during the connection window. The web app's bootstrap fetch is currently one-shot too; I'm happy to wire
command.updatedinto it as a follow-up for consistency.How did you verify your code works?
packages/opencode/test/command/index.test.ts): a stdio MCP server fixture with a 1.5s handshake delay —command.list()returns file commands within a 1s budget without the prompt, the prompt appears afterready(), andcommand.updatedis received viaEventV2Bridge; a second test covers the no-MCP-servers case (ready()resolves without hanging). Verified that both fail on the old implementation (the first behaviorally, the second at the missingready()API).packages/opencodesuite: 3276 pass / 2 fail, both failures reproduce on the base commit (umask-dependent file mode assert + audio decode, unrelated)/commandreturns in 0.52s at t≈2s with file commands only; after settle, prompt is listed (8ms)Screenshots / recordings
N/A (no visual change; behavior is timing-only)
Checklist