Skip to content

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

@myagizmaktav

Description

@myagizmaktav

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pilotPilot AI will work on thispilot-donePilot completed this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions