fix: open web UI to cwd-encoded URL so initial directory is correct#16577
Open
Jrc356 wants to merge 3 commits intoanomalyco:devfrom
Open
fix: open web UI to cwd-encoded URL so initial directory is correct#16577Jrc356 wants to merge 3 commits intoanomalyco:devfrom
Jrc356 wants to merge 3 commits intoanomalyco:devfrom
Conversation
The web command was opening the browser to a bare URL (e.g. http://localhost:4096/) with no directory context. The server middleware falls back to process.cwd() when neither the x-opencode-directory header nor the directory query param are present, but that only works correctly for the server process itself — the browser-side frontend had no way to know which directory was intended, and on some setups cwd resolves to /. Fix: encode process.cwd() as a URL-safe base64 segment and append it to the initial URL that is opened in the browser (e.g. http://localhost:4096/<base64dir>). The frontend router already parses this segment via DirectoryLayout and includes the directory in all subsequent API calls via the x-opencode-directory header, so the server now receives the correct context from the very first request.
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 #6336
Type of change
What does this PR do?
Updates the
WebCommandin the CLI to open at cwdHow did you verify your code works?
I have opencode 1.2.21 installed in my path, opening a project using
opencode web --hostname 0.0.0.0appears to open at rootwithout
--hostnameit does open to cwdwith this PR's changes I used
which opened at cwd and then tried
which also opened at cwd!
Checklist
If you do not follow this template your PR will be automatically rejected.