[PR #6413] fix: pass --dir parameter from attach command to server #11889

Closed
opened 2026-02-16 18:16:49 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6413

State: closed
Merged: No


Summary

Fixes the --dir parameter in opencode attach command not being passed to the server, causing sessions to use the client's current directory instead of the specified path.

Changes:

  • Parse and resolve --dir argument in attach command
  • Pass directory through TUI app to SDKProvider
  • SDK client sends directory via existing x-opencode-directory header

Context

When running opencode attach <url> --dir /path/to/project, the parameter was being ignored. This particularly affected users running the server remotely and attaching from a different machine.

The SDK already supported the x-opencode-directory header; it just wasn't being wired through from the attach command.

Fixes #5380

Testing

Verified with:

  • Local server: opencode attach http://localhost:4096 --dir ~/project
  • Remote server: opencode attach http://remote:4096 --dir /remote/path
  • Relative paths correctly resolved to absolute paths
  • Without --dir: Falls back to current directory (backwards compatible)

Session API confirms correct directory is set on server.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6413 **State:** closed **Merged:** No --- ## Summary Fixes the `--dir` parameter in `opencode attach` command not being passed to the server, causing sessions to use the client's current directory instead of the specified path. Changes: - Parse and resolve `--dir` argument in attach command - Pass directory through TUI app to SDKProvider - SDK client sends directory via existing `x-opencode-directory` header ## Context When running `opencode attach <url> --dir /path/to/project`, the parameter was being ignored. This particularly affected users running the server remotely and attaching from a different machine. The SDK already supported the `x-opencode-directory` header; it just wasn't being wired through from the attach command. Fixes #5380 ## Testing Verified with: - Local server: `opencode attach http://localhost:4096 --dir ~/project` - Remote server: `opencode attach http://remote:4096 --dir /remote/path` - Relative paths correctly resolved to absolute paths - Without `--dir`: Falls back to current directory (backwards compatible) Session API confirms correct directory is set on server.
yindo added the pull-request label 2026-02-16 18:16:49 -05:00
yindo closed this issue 2026-02-16 18:16:49 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11889