Skip to content

fix(server): don't forward host directory to remote workspace - #40136

Open
jamesmurdza wants to merge 1 commit into
anomalyco:devfrom
jamesmurdza:fix/workspace-proxy-strip-directory-param
Open

fix(server): don't forward host directory to remote workspace#40136
jamesmurdza wants to merge 1 commit into
anomalyco:devfrom
jamesmurdza:fix/workspace-proxy-strip-directory-param

Conversation

@jamesmurdza

@jamesmurdza jamesmurdza commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Related to #36902

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When a request is proxied to a remote workspace, workspaceProxyURL copied the whole query string and only deleted workspace. That left the directory param in place — but directory is the host's cwd. From a Windows host it's a path like F:\proj, which is meaningless on the remote Linux sandbox.

On the remote, that value flows into defaultDirectory() and gets path.resolved against the sandbox cwd, producing something like /home/daytona/workspace/repo/F:\proj. The session is created against that
non-existent dir, and the first prompt blows up in SystemPrompt.environment (realPath -> ENOENT). The prompt handler turns that into a defect -> opaque 500, which the TUI shows as a bare "Failed to send prompt" toast.

The fix is one line: strip directory before forwarding, so the remote falls back to its own project root. This mirrors what ProxyUtil.headers already does for the x-opencode-directory header — the query param was just the one path that slipped through.

How did you verify your code works?

  • Added a unit test in workspace-routing.test.ts asserting directory is dropped (and an unrelated param like keep is preserved) by workspaceProxyURL.
  • Reproduced the original crash by driving a remote workspace from a Windows host: before the change the first prompt 500s; after it, the session boots on the remote's own project root and the prompt succeeds.

Screenshots / recordings

N/A — not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

When proxying a request to a remote workspace, workspaceProxyURL kept
the `directory` query param — the *host's* working directory (e.g. a
Windows path `F:\proj`). The Linux sandbox then `path.resolve`d it
against its own cwd, yielding a bogus dir like
`/home/daytona/workspace/repo/F:\proj` that doesn't exist. Sessions
were created against that path, and the first prompt crashed in
SystemPrompt.environment (realPath -> ENOENT), which the prompt handler
converts to a defect -> opaque 500 -> 'Failed to send prompt' toast.

Strip the `directory` param when forwarding so the remote falls back to
its own project root, mirroring ProxyUtil.headers already stripping the
`x-opencode-directory` header.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
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.

jamesmurdza added a commit to jamesmurdza/integrations that referenced this pull request Aug 2, 2026
… symlink

Reference opencode PR anomalyco/opencode#40136, which strips the host
`directory` query param before proxying to the remote — the upstream fix for
the bug the worktree->REPO_PATH symlink works around. Once it ships in a
release and OPENCODE_VERSION is bumped to include it, the symlink can be
removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant