Skip to content

GH-2415: fix(executor): send X-OpenCode-Directory header in attached mode#2438

Merged
alekspetrov merged 1 commit intomainfrom
pilot/GH-2415
Apr 29, 2026
Merged

GH-2415: fix(executor): send X-OpenCode-Directory header in attached mode#2438
alekspetrov merged 1 commit intomainfrom
pilot/GH-2415

Conversation

@alekspetrov
Copy link
Copy Markdown
Collaborator

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-directory header or directory query parameter, not from the legacy JSON path field in the POST /session body.

Verified against upstream OpenCode source:

  • packages/sdk/js/src/v2/client.ts
  • packages/opencode/src/server/routes/instance/middleware.ts

Impact

Pilot can execute tasks against the wrong repository even though ExecuteOptions.ProjectPath is set correctly.

Proposed Fix

Send X-OpenCode-Directory: <urlencoded project path> on both:

  • POST /session
  • POST /session/:id/message

Add regression coverage to assert the header is present on both requests.

…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-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@alekspetrov alekspetrov merged commit 12ffe0e into main Apr 29, 2026
4 checks passed
@alekspetrov alekspetrov deleted the pilot/GH-2415 branch April 29, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(executor): send X-OpenCode-Directory header in attached mode

2 participants