Skip to content

Conversation

@gricha
Copy link
Contributor

@gricha gricha commented Jan 16, 2026

What does this PR do?

I spawn OpenCode directly on my dev servers in $HOME. I then try to attach to them from any of my machine, and because projects may be scattered and not at $HOME, I want to be able to use --dir parameter. In these examples docs is my hostname in Tailnet.

If I ran opencode attach docs:4096 --dir ./perry from my machine earlier, it would consider it a local path and try to push that in. Absolute paths would also be caught with issues like:

ENOENT: no such file or directory, chdir '/home/gricha/personal/opencode-gricha' -> '/home/workspace/perry'

I didn't want to break local-validation functionality you have, so I added gating for local vs. remote attach, and let remote pass through the dir to the upstream server.

How did you verify your code works?

opencode attach docs:4096 --dir ./perry
opencode attach docs:4096 --dir /home/workspace/perry
both work properly now - I also tested for whether they are able to load up skills/subagents from those directories after that change and it works fine.

Fixes #8981

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

@gricha
Copy link
Contributor Author

gricha commented Jan 16, 2026

I'd not consider this a duplicate, I think this is a much simpler fix of existing functionality that just makes sure that intended behavior works properly.

@gricha gricha requested a review from rekram1-node January 21, 2026 16:43
@gricha
Copy link
Contributor Author

gricha commented Jan 22, 2026

@rekram1-node @thdxr could I get a quick look at this? i spin up one server remotely on my docker containers right now, and having this validation disabled would let me start them in the right repositories, with proper skills/agents loaded up. I have to do a bit of a dance right now without it. sorry to bug multiple times about that

@rekram1-node rekram1-node merged commit 8ebb766 into anomalyco:dev Jan 22, 2026
4 checks passed
shuv1337 added a commit to Latitudes-Dev/shuvcode that referenced this pull request Jan 24, 2026
The attach command now always passes client's cwd to the server via
the directory parameter. This fork-specific enhancement regressed
during upstream merge (PR anomalyco#8969, commit 8ebb766).

Ensures file autocomplete, theme discovery, and exports use the client's
directory when attaching to a remote server, not the server's launch dir.

Preserves upstream's remote --dir path support by early-returning when
the directory doesn't exist locally.
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.

Bug: attach --dir works incorrectly when using with remote server

2 participants