anomalyco / anomalyco/opencode
[Web][WSL] Web UI switches from the correct launch directory to the WSL home directory
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
When OpenCode Web is started from a project directory inside WSL, the server initially recognizes the correct working directory, but the Web UI then creates or opens a second project rooted at the WSL user's home directory. The Web UI therefore does not stay on the project from which opencode web was launched. Repeating cd before starting the command does not fix it.
This does not appear to be a simple CWD propagation problem: the server log shows the intended directory being initialized first, followed shortly afterwards by a second instance for the home directory.
Plugins
None relevant
OpenCode version
1.18.31
Steps to reproduce
Environment
- OS: Windows 11 (build 10.0.26200.9457)
- Runtime: WSL2
- Shell: WSL launched from Windows Command Prompt
- OpenCode binary: /home//.opencode/bin/opencode
- Browser: Windows browser
- URL: http://127.0.0.1:4096/
Steps to reproduce
-
From Windows, open a project directory such as C:/Projects/01_dev/personal-dev/UI-MCP/.
-
Start WSL from that directory.
-
Confirm that pwd prints /mnt/c/Projects/01_dev/personal-dev/UI-MCP.
-
Run:
opencode web --print-logs -
Open the printed URL in a Windows browser.
-
Observe that the Web UI shows or switches to /home/ instead of the project directory.
Relevant log output
The intended directory is initialized first:
timestamp=2026-09-19T07:43:35.490Z level=INFO message="creating instance" directory=/mnt/c/Projects/01_dev/personal-dev/UI-MCP
timestamp=2026-09-19T07:43:35.492Z level=INFO message=fromDirectory directory=/mnt/c/Projects/01_dev/personal-dev/UI-MCP
timestamp=2026-09-19T07:43:35.817Z level=INFO message=bootstrapping directory=/mnt/c/Projects/01_dev/personal-dev/UI-MCP
There is also an instance for the OpenCode installation directory:
timestamp=2026-09-19T07:43:35.512Z level=INFO message="creating instance" directory=/home/<wsl-user>/.opencode
Shortly afterwards, the Web UI creates and boots an instance for the WSL home directory:
timestamp=2026-09-19T07:43:37.853Z level=INFO message="creating instance" directory=/home/<wsl-user>
timestamp=2026-09-19T07:43:37.854Z level=INFO message=fromDirectory directory=/home/<wsl-user>
timestamp=2026-09-19T07:43:37.858Z level=INFO message=bootstrapping directory=/home/<wsl-user>
timestamp=2026-09-19T07:43:38.592Z level=INFO message="watcher backend" directory=/home/<wsl-user> platform=linux backend=inotify
timestamp=2026-09-19T07:43:38.650Z level=INFO message="booting location services" directory=/home/<wsl-user> workspaceID=undefined
timestamp=2026-09-19T07:43:38.651Z level=INFO message="find file" query="" type=undefined directory=/home/<wsl-user> limit=50 results=0
Expected behavior
- The Web UI stays on /mnt/c/Projects/01_dev/personal-dev/UI-MCP/, the directory used to launch the server.
- The client does not automatically replace the initial project with /home/.
- If a project picker is needed, its initial location is the server start directory or current project, not the WSL home directory.
- WSL paths under /mnt/c remain valid project paths.
Actual behavior
- The server receives and bootstraps the correct WSL project path.
- The Web UI then creates or opens a separate project at the WSL home directory.
- The user is shown the wrong directory and cannot reliably select the intended project from the Web UI.
Requested investigation
Please identify which client request or initialization path causes the second creating instance directory=/home/ after the correct project is initialized. In particular, please check whether the Web UI initializes project/location state from path.home instead of the server's path.directory, or whether browser-local project state/global-project handling causes the home directory to be selected.
Related but not identical: #43173 (folder picker search anchored to the home directory) and #36902 (Windows paths sent to a WSL server).
Screenshot and/or share link
No screenshot. The full server log is included above.
Operating System
Windows 11 + WSL2 (WSL launched from Windows Command Prompt)
Terminal
Windows Command Prompt -> WSL shell
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Web UI initialization and client requests that follow the server's path.directory setup, using the logged creation of /mnt/c/Projects/01_dev/personal-dev/UI-MCP and /home/ as the sequence to reproduce. Check whether path.home or browser-local project state selects the second directory. Done means the UI remains on the launch directory and does not create or switch to the WSL home instance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100