fix(opencode): strip directory query when proxying to remote workspace#26076
Open
MichielMAnalytics wants to merge 1 commit intoanomalyco:devfrom
Open
Conversation
The SDK rewrites x-opencode-directory header to a ?directory= query for GET/HEAD requests. When proxied to a remote workspace, the local path leaks through, the remote can't resolve it, falls back to worktree="/", and corrupts sessionListQuery's path.relative() — which empties the TUI's session list and renders a black screen. Add the directory strip alongside the existing workspace strip so the adapter's target.headers["x-opencode-directory"] wins. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #26075
Type of change
What does this PR do?
workspaceProxyURLstrips?workspace=before forwarding a request to a remote workspace, but it doesn't strip?directory=. The SDK rewrites the client'sx-opencode-directoryheader into a?directory=query for GET/HEAD (packages/sdk/js/src/v2/client.ts), so when a request flows through the workspace-routing middleware, the local client's directory leaks to the remote.The remote then tries to resolve a path that doesn't exist on its filesystem, falls back to
worktree: "/", and that broken path corrupts downstreampath.relative()callers — most visiblysessionListQueryin the TUI sync context, which then returns no sessions and the session route renders empty.Adding
proxyURL.searchParams.delete("directory")next to the existingworkspacestrip lets the adapter'starget.headers["x-opencode-directory"](the workspace's own directory on the remote) win, which is the intended contract.How did you verify your code works?
packages/opencode/test/server/workspace-routing.test.tsasserting bothworkspaceanddirectoryare stripped. Full file: 16/16 pass viabun --cwd packages/opencode test test/server/workspace-routing.test.ts.curl 'https://<remote>/path?directory=<some-local-path-not-on-remote>'returns{"worktree": "/", ...}. Removing thedirectoryparam returns the correct workspace path. Confirms why the proxied request was triggering the wrong fallback.WorkspaceAdapter: before the fix,/warpsucceeded but the TUI showed a blank session view. After the fix, the session view renders correctly.Screenshots / recordings
Not a UI change.
Checklist