Skip to content

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

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions