Skip to content

[Web][WSL] Web UI switches from the correct launch directory to the WSL home directory #49947

Closed as not planned

Description

@itiwoja

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

Steps to reproduce

  1. From Windows, open a project directory such as C:/Projects/01_dev/personal-dev/UI-MCP/.

  2. Start WSL from that directory.

  3. Confirm that pwd prints /mnt/c/Projects/01_dev/personal-dev/UI-MCP.

  4. Run:

    opencode web --print-logs
  5. Open the printed URL in a Windows browser.

  6. 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

Activity

  1. MykolaBiron commented on Sep 19, 2026

    @MykolaBiron

    I'd like to work on this one. Traced it down: the autoselecting resource in packages/app/src/pages/layout.tsx auto-navigates on load using server.projects.last(), which is a browser localStorage value keyed only by server host:port, not by launch directory. Since opencode web reuses the same default port across separate invocations, a stale "last project" for that port gets reused even when launched from a different project. It is self-reinforcing since navigating persists it as the new "last". Planning to make the autoselect prefer the server's actual current launch directory over the stale last value when one exists.
    Will open a PR referencing this issue.

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions