GH-2415: fix(executor): send X-OpenCode-Directory header in attached mode#2438
Merged
alekspetrov merged 1 commit intomainfrom Apr 29, 2026
Merged
GH-2415: fix(executor): send X-OpenCode-Directory header in attached mode#2438alekspetrov merged 1 commit intomainfrom
alekspetrov merged 1 commit intomainfrom
Conversation
…2415) OpenCode v1.4.x attached mode resolves the project directory from the `x-opencode-directory` header, not from the legacy JSON `path` field on POST /session. Without it, sessions are created in the server's cwd rather than ExecuteOptions.ProjectPath. Set the header (URL-encoded) on both POST /session and POST /session/:id/message, with a regression test asserting both requests carry it.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Automated PR created by Pilot for task GH-2415.
Closes #2415
Changes
GitHub Issue #2415: fix(executor): send X-OpenCode-Directory header in attached mode
Problem
When Pilot talks to an attached OpenCode server over HTTP, it creates sessions in the server process cwd instead of the target project path.
Root Cause
OpenCode attached mode resolves the project directory from the
x-opencode-directoryheader ordirectoryquery parameter, not from the legacy JSONpathfield in thePOST /sessionbody.Verified against upstream OpenCode source:
packages/sdk/js/src/v2/client.tspackages/opencode/src/server/routes/instance/middleware.tsImpact
Pilot can execute tasks against the wrong repository even though
ExecuteOptions.ProjectPathis set correctly.Proposed Fix
Send
X-OpenCode-Directory: <urlencoded project path>on both:POST /sessionPOST /session/:id/messageAdd regression coverage to assert the header is present on both requests.