Repository navigation
Description
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 sessionsWSL (~/.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 sessionsKey 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", whoseworktreeis/. This prevents the Web UI from matching the current directory to any project. - New directories never get registered: Starting
opencode webin a new directory (e.g.,C:/Users/hundeor/home/hunde) does not create a newprojectrecord, even aftergit 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 webin a directory should automatically create or update theprojecttable entry for that directory. - The Web UI should display all sessions whose
directorymatches the current working directory, regardless ofproject_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 hasworktree = "/". - The Web UI filters sessions by
project_id, but the current directory has no matchingproject.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)
- Sessions list is empty on page load in web UI #30166 — Page loading race condition (ruled out: F5/refresh does not fix)
- /undo and /timeline undo does not revert file edits #4704 —
opencode webmulti-project path filtering (ruled out: single directory also fails) - [WEB-UI] No new session can be started #12627 — Root workspace cannot create sessions (possibly related)
- Web terminal fails when CSP blocks Ghostty WASM data URL #26001 / Embedded web UI CSP blocks the inline theme preload script #21088 — CSP compatibility (Firefox console warnings, but not the root cause)
Suggested Fix
- Project auto-registration: Ensure
opencode web/serveautomatically creates aprojectrecord 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
directoryprefix match rather than strictproject_idequality. - Migration for orphaned sessions: Provide a one-time migration to reassign
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
- Open a terminal in any directory without an existing OpenCode project (e.g.,
C:/Users/hundeor/home/hundeon 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
Activity
github-actions commentedon Jul 15, 2026
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 webstartup rather than a client-side race), please note that in the issue. Otherwise, adding a+1or additional repro details to one of the above may help the maintainers prioritize a fix.nickmimic commentedon Jul 25, 2026
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.
richter-p commentedon Aug 3, 2026
Confirmed today on
opencode 1.18.11(npm install, Windows 11,opencode webwithOPENCODE_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_idanalysis: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):It expects
v2.session.listto return a paginated{ data, cursor }wrapper. That SDK method issuesGET /session, but the server answers with a bareSession[]array (verified live:/sessionand/session?limit=5000both return[...]). Soo.dataisundefined,r.push(...undefined)throws, the query rejects, andsessions = []. Sessions are never shown even when they exist and match the directory.The home project list is a browser-local registry, not the server's
/project.createServerProjects(packages/app/src/context/server.tsx) persists opened projects tolocalStorage(keyopencode.global.dat:server, scope"local"). It starts empty in a fresh browser and only fills via the "Add Project" flow. The server's/projectlist — which correctly returns theglobalproject plus sandboxes — is not what the home page reads. So even with correctprojectDB rows, the UI shows nothing until projects are added manually, and adding is broken (see 3).The "Add Project" directory picker can't list folders.
createDirectorySearch(packages/app/src/components/directory-picker-domain.ts) callssdk.api.file.list({ location: { directory } })→GET /file?directory=<abs>. The server'sFileHttpApi.listhandler (packages/opencode/src/server/routes/instance/httpapi/handlers/file.ts) only acceptsGET /file?path=<relative-to-cwd>and 400s ondirectory(any value; verified). So the picker always shows "no folders found". Itsfindsearch also returns paths relative to the server cwd, which the picker then joins againsthome, producing wrong absolute paths.So in 1.18.11 the home page is broken independently of
project_idhandling. The session page itself works fine (GET /session/:id,/session/:id/messagereturn correctly), so only the home listing + picker paths are affected..
Mattheinrichs commentedon Sep 21, 2026
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
globalproject (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.
thdxr commentedon Oct 11, 2026
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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊