[PR #13844] fix(attach): default working directory to invoker's cwd #14835

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

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

State: closed
Merged: No


Adding support for server attachments linking to local TUI spawn directory

When running opencode attach without --dir, the TUI session previously fell back to the server's process.cwd() as its working directory. This changes the default to use the attaching client's process.cwd() so the session operates in the directory where the attach command was invoked.

Change

One-line change in packages/opencode/src/cli/cmd/tui/attach.ts:

- if (!args.dir) return undefined
+ if (!args.dir) return process.cwd()

When directory was undefined, the SDK client skipped sending the x-opencode-directory header, causing the server middleware to fall back to its own process.cwd(). Now it always sends the client's cwd, matching the behavior users would expect.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13844 **State:** closed **Merged:** No --- ## Adding support for server attachments linking to local TUI spawn directory When running `opencode attach` without `--dir`, the TUI session previously fell back to the server's `process.cwd()` as its working directory. This changes the default to use the attaching client's `process.cwd()` so the session operates in the directory where the attach command was invoked. ## Change One-line change in `packages/opencode/src/cli/cmd/tui/attach.ts`: ```diff - if (!args.dir) return undefined + if (!args.dir) return process.cwd() ``` When `directory` was `undefined`, the SDK client skipped sending the `x-opencode-directory` header, causing the server middleware to fall back to its own `process.cwd()`. Now it always sends the client's cwd, matching the behavior users would expect.
yindo added the pull-request label 2026-02-16 18:19:35 -05:00
yindo closed this issue 2026-02-16 18:19:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14835