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
- Project table is severely underpopulated: Windows has 3 projects for 195 sessions; WSL has 2 projects for 279 sessions.
- "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.
- 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.
- 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
- Project auto-registration: Ensure
opencode web/serve automatically creates a project record for the current working directory on startup if one does not exist.
- 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.
- 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
- Open a terminal in any directory without an existing OpenCode project (e.g.,
C:/Users/hunde or /home/hunde on WSL).
- Run
opencode web.
- Open the browser URL (e.g.,
http://localhost:4096).
- Observe the sidebar shows "Nothing here yet" even if historical sessions exist in that directory.
- Run
opencode run "test" — CLI works and creates a session.
- 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
Description
Environment
npm i -g opencode-ai) and official install scriptProblem Summary
When running
opencode web(oropencode 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
projecttable failing to auto-register new working directories, causing a mismatch betweensession.project_idandproject.id.Database Evidence
Windows (
~/.local/share/opencode/opencode.db):WSL (
~/.local/share/opencode/opencode.db):Key Observations
project_id = "global", whoseworktreeis/. This prevents the Web UI from matching the current directory to any project.opencode webin a new directory (e.g.,C:/Users/hundeor/home/hunde) does not create a newprojectrecord, even aftergit init.Expected Behavior
opencode webin a directory should automatically create or update theprojecttable entry for that directory.directorymatches the current working directory, regardless ofproject_id.Actual Behavior
project_id = "global", which hasworktree = "/".project_id, but the current directory has no matchingproject.id, so nothing is displayed.What Has Been Tried
opencode serve(project directory)git init+git commitin current directoryprojecttable~/.cache/opencodeRelated Issues (Partial Matches)
opencode webmulti-project path filtering (ruled out: single directory also fails)Suggested Fix
opencode web/serveautomatically creates aprojectrecord for the current working directory on startup if one does not exist.directoryprefix match rather than strictproject_idequality.globalsessions to their correctproject_idbased onsession.directorymatching.Workaround
Use CLI mode for now:
opencode run "your prompt here"Plugins
None.
OpenCode version
1.18.1
Steps to reproduce
C:/Users/hundeor/home/hundeon WSL).opencode web.http://localhost:4096).opencode run "test"— CLI works and creates a session.Screenshot and/or share link
No response
Operating System
Windows 11 and WSL2 (Ubuntu)
Terminal
Windows Terminal