fix: add directory parameter to plugin client for multi-project support#11344
Merged
rekram1-node merged 1 commit intoanomalyco:devfrom Feb 6, 2026
Merged
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
da6f2fd to
d933b6a
Compare
When OpenCode Server serves multiple projects, plugin's internal client needs to specify the target directory. Without this, API calls from plugins (e.g., delegate_task calling session.get) would fallback to process.cwd(), causing NotFoundError when accessing sessions from different projects. This fix ensures each Instance's plugin client includes the correct directory parameter, enabling proper cross-project session access in multi-project environments like oh-my-opencodeui.
d933b6a to
c00f3dc
Compare
kyashrathore
pushed a commit
to kyashrathore/Claxedo
that referenced
this pull request
Feb 7, 2026
…rt (anomalyco#11344) Co-authored-by: cooooooooooode <187372691+cooooooooooode@users.noreply.github.com>
fanjia1024
pushed a commit
to fanjia1024/opencode
that referenced
this pull request
Feb 10, 2026
…rt (anomalyco#11344) Co-authored-by: cooooooooooode <187372691+cooooooooooode@users.noreply.github.com>
BryceRyan
pushed a commit
to BryceRyan/opencode
that referenced
this pull request
Feb 10, 2026
…rt (anomalyco#11344) Co-authored-by: cooooooooooode <187372691+cooooooooooode@users.noreply.github.com>
avion23
pushed a commit
to avion23/opencode
that referenced
this pull request
Feb 13, 2026
…rt (anomalyco#11344) Co-authored-by: cooooooooooode <187372691+cooooooooooode@users.noreply.github.com>
3 tasks
schneiderlo
pushed a commit
to schneiderlo/opencode
that referenced
this pull request
Feb 17, 2026
…rt (anomalyco#11344) Co-authored-by: cooooooooooode <187372691+cooooooooooode@users.noreply.github.com>
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.
Fixes #11342
Problem
When OpenCode Desktop App connects to an external OpenCode Server, calling
delegate_taskfails withNotFoundError. The error occurs because the plugin system's internal client doesn't pass thedirectoryparameter when making API calls.Without the
directoryparameter, the server middleware falls back toprocess.cwd()(the server's startup directory) instead of using the actual project directory where the session was created. This causes session files to be searched in the wrong location.Solution
Add the
directoryparameter when creating the plugin client inpackages/opencode/src/plugin/index.ts:This ensures the client includes the
x-opencode-directoryheader in all API requests, allowing the server to correctly resolve the project context.How to Verify
Setup
Start OpenCode Server from project A:
cd /path/to/projectA opencode serveOpen OpenCode Desktop App and connect to http://localhost:4096
In the Desktop App, open project B (different from project A)
Test
Create a session in project B
Execute an action that calls
delegate_task(e.g., ask AI to perform a complex task that requires delegation)Expected Result
NotFoundError: Resource not found: .../session/{projectA-hash}/ses_xxx.jsondelegate_taskexecutes successfully, session files are found in the correct project directoryChanges
packages/opencode/src/plugin/index.ts(1 line added)