Skip to content

Web UI Session List Empty — Project Auto-Registration Fails on Windows/WSL #37096

Closed as not planned

Description

@RayySummers

Description

THIS ISSUE IS CREATED WITH THE HELP OF KIMI AGENT. I am a human and I copied everything related to this issue. Thanks!

Environment

  • OpenCode Version: 1.18.1
  • OS: Windows 11 + WSL2 (Ubuntu)
  • Browser: Chrome, Firefox (including Private Window)
  • Installation: npm (npm i -g opencode-ai) and official install script

Problem Summary

When running opencode web (or opencode serve) in any directory, the Web UI sidebar shows "Nothing here yet" / "Create a session to get started" instead of the existing session history. Clicking "New Session" either does nothing or creates an empty placeholder. CLI mode (opencode run) works correctly — it can create and continue sessions without issues.

Root Cause Analysis

After extensive database investigation, the issue is identified as the project table failing to auto-register new working directories, causing a mismatch between session.project_id and project.id.

Database Evidence

Windows (~/.local/share/opencode/opencode.db):

SELECT id, worktree, vcs FROM project;
-- Returns only 3 rows:
-- global | / | null
-- 46d9d6de... | E:/Creative/Projects/Wendo/obsidian-vault-wendo/Wendo | git
-- 59e85b02... | E:/Creative/Projects/wikipedia | git

SELECT COUNT(*) FROM session;
-- Returns 195 sessions

SELECT project_id, COUNT(*) FROM session GROUP BY project_id;
-- global: 109 sessions (orphaned)
-- 59e85b02...: 78 sessions
-- 46d9d6de...: 8 sessions

WSL (~/.local/share/opencode/opencode.db):

SELECT id, worktree, vcs FROM project;
-- Returns only 2 rows:
-- global | / | null
-- 456ebf0f... | /home/hunde/.openclaw/workspace | git

SELECT COUNT(*) FROM session;
-- Returns 279 sessions

SELECT project_id, COUNT(*) FROM session GROUP BY project_id;
-- global: 273 sessions (97.8% orphaned)
-- 456ebf0f...: 6 sessions

Key Observations

  1. Project table is severely underpopulated: Windows has 3 projects for 195 sessions; WSL has 2 projects for 279 sessions.
  2. "global" acts as a catch-all: Sessions created in directories without a registered project are assigned project_id = "global", whose worktree is /. This prevents the Web UI from matching the current directory to any project.
  3. New directories never get registered: Starting opencode web in a new directory (e.g., C:/Users/hunde or /home/hunde) does not create a new project record, even after git init.
  4. WAL mode complicates manual fixes: Directly modifying the SQLite database file is ineffective because OpenCode uses WAL (Write-Ahead Logging), and the running process overwrites changes on checkpoint.

Expected Behavior

  • Starting opencode web in a directory should automatically create or update the project table entry for that directory.
  • The Web UI should display all sessions whose directory matches the current working directory, regardless of project_id.
  • If no project exists, sessions should still be visible under a default/local context.

Actual Behavior

  • Web UI sidebar is permanently blank.
  • Sessions are created with project_id = "global", which has worktree = "/".
  • The Web UI filters sessions by project_id, but the current directory has no matching project.id, so nothing is displayed.

What Has Been Tried

Attempt Result
Firefox Private Window (no extensions) ❌ Same issue
Chrome (different browser) ❌ Same issue
opencode serve (project directory) ❌ Same issue
git init + git commit in current directory ❌ No new project record created
Manual SQLite INSERT into project table ❌ Overwritten by WAL checkpoint
Clearing ~/.cache/opencode ❌ No effect
Reinstalling OpenCode ❌ No effect

Related Issues (Partial Matches)

Suggested Fix

  1. Project auto-registration: Ensure opencode web/serve automatically creates a project record for the current working directory on startup if one does not exist.
  2. Graceful fallback: If no project matches the current directory, the Web UI should fall back to displaying sessions by directory prefix match rather than strict project_id equality.
  3. Migration for orphaned sessions: Provide a one-time migration to reassign global sessions to their correct project_id based on session.directory matching.

Workaround

Use CLI mode for now:

opencode run "your prompt here"

Plugins

None.

OpenCode version

1.18.1

Steps to reproduce

  1. Open a terminal in any directory without an existing OpenCode project (e.g., C:/Users/hunde or /home/hunde on WSL).
  2. Run opencode web.
  3. Open the browser URL (e.g., http://localhost:4096).
  4. Observe the sidebar shows "Nothing here yet" even if historical sessions exist in that directory.
  5. Run opencode run "test" — CLI works and creates a session.
  6. Refresh the Web UI — the new session still does not appear.

Screenshot and/or share link

No response

Operating System

Windows 11 and WSL2 (Ubuntu)

Terminal

Windows Terminal

Activity

  1. github-actions commented on Jul 15, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is distinct from these (e.g., specific to the project table not being auto-populated on opencode web startup rather than a client-side race), please note that in the issue. Otherwise, adding a +1 or additional repro details to one of the above may help the maintainers prioritize a fix.

  2. nickmimic commented on Jul 25, 2026

    @nickmimic

    Confirming this also reproduces on Ubuntu in a UTM VM (not WSL): opencode 1.18.5, fresh install via the curl script, fresh project directory. TUI works fine in the same directory; only opencode web is affected. Session creation via direct /api/session fetch does succeed (session ID appears in URL), but the UI doesn't render it, so it's not just project auto-registration, the V2 frontend itself doesn't reflect a valid, successfully-created session.

  3. richter-p commented on Aug 3, 2026

    @richter-p

    Confirmed today on opencode 1.18.11 (npm install, Windows 11, opencode web with OPENCODE_SERVER_PASSWORD). Home page shows no sessions; "Add Project" shows "no folders found".

    I traced the actual API traffic and the shipped web bundle. In 1.18.11 the empty home is caused by three concrete failures (V1/V2 contract drift between the bundled web app and the server), which refine the original project_id analysis:

    1. Home session list crashes on an API contract mismatch. The home page loads sessions via loadHomeSessionIndex (packages/app/src/context/global-sync/home-session-index.ts):

      const page = response.data!
      data.push(...page.data)
      if (page.data.length < HOME_V2_SESSION_PAGE_LIMIT || !page.cursor.next) return ...

      It expects v2.session.list to return a paginated { data, cursor } wrapper. That SDK method issues GET /session, but the server answers with a bare Session[] array (verified live: /session and /session?limit=5000 both return [...]). So o.data is undefined, r.push(...undefined) throws, the query rejects, and sessions = []. Sessions are never shown even when they exist and match the directory.

    2. The home project list is a browser-local registry, not the server's /project. createServerProjects (packages/app/src/context/server.tsx) persists opened projects to localStorage (key opencode.global.dat:server, scope "local"). It starts empty in a fresh browser and only fills via the "Add Project" flow. The server's /project list — which correctly returns the global project plus sandboxes — is not what the home page reads. So even with correct project DB rows, the UI shows nothing until projects are added manually, and adding is broken (see 3).

    3. The "Add Project" directory picker can't list folders. createDirectorySearch (packages/app/src/components/directory-picker-domain.ts) calls sdk.api.file.list({ location: { directory } }) → GET /file?directory=<abs>. The server's FileHttpApi.list handler (packages/opencode/src/server/routes/instance/httpapi/handlers/file.ts) only accepts GET /file?path=<relative-to-cwd> and 400s on directory (any value; verified). So the picker always shows "no folders found". Its find search also returns paths relative to the server cwd, which the picker then joins against home, producing wrong absolute paths.

    So in 1.18.11 the home page is broken independently of project_id handling. The session page itself works fine (GET /session/:id, /session/:id/message return correctly), so only the home listing + picker paths are affected.
    .

  4. Mattheinrichs commented on Sep 21, 2026

    @Mattheinrichs

    Same empty-list symptom here. One fix that's relevant: #46520 — a 1-file change to the Home session filter, for sessions belonging to the global project (created outside a git repo), which were being dropped because their directory never matches the global worktree /.

    Worth knowing: opencode's cleanup bot closes PRs older than a month with fewer than 2 positive reactions, so if you're still hitting the empty list, a 👍 on #46520 is what actually keeps it alive.

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

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