Skip to content

Windows: Sessions not showing in opencode desktop UI due to inconsistent path separator (/ vs \) #31597

Closed

Description

@IntronsYanh

Description

On Windows, sessions created at different times store the directory field in the SQLite DB with inconsistent path separators — some use forward slashes (D:/Workspace/my-project), others use backslashes (D:\Workspace\my-project). The project.worktree field uses backslashes (D:\Workspace\my-project).

When opencode loads sessions for the current project, it appears to match session.directory against the current working directory (or project.worktree) using exact string comparison. Because of the slash mismatch, sessions stored with / are not displayed in the opencode desktop UI session list.

opencode does not normalize path separators when persisting session.directory. On Windows, path.resolve() or equivalent can return either / or \ depending on the calling context (e.g. Git integration may return /, Node.js process.cwd() returns ).

Suggested Fix
Normalize all file paths to use the OS-native separator (or consistently use /) before writing to the database. For example, call path.normalize() or replace / with \ on Windows before any DB write.

Workaround
Manually update the SQLite database:

sqlite3 ~/.local/share/opencode/opencode.db
"UPDATE session SET directory = REPLACE(directory, '/', '') WHERE directory LIKE '%:/%';"

Plugins

No response

OpenCode version

v1.14.22

Steps to reproduce

-- project table
SELECT worktree FROM project WHERE id='abc123...';
-- Result: D:\Workspace\my-project

-- session table (before fix)
SELECT directory, COUNT(*) FROM session WHERE project_id='abc123...' GROUP BY directory;
-- Result:
-- D:/Workspace/my-project | 17
-- D:\Workspace\my-project | 1

17 sessions were invisible in the TUI because their directory used / while the project used .

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

opencode desktop

Activity

  1. github-actions commented on Jun 10, 2026

    @github-actions
    Contributor

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

    If your issue is distinct, please clarify how it differs from the above.

  2. Hona commented on Jul 2, 2026

    @Hona
    Member

    Fixed in v1.16.0 by #29666 — you reported this on v1.14.22, which predates the fix.

    Since v1.16.0 the canonical storage form is forward slashes: session/project path columns are Drizzle custom types (packages/core/src/database/path.ts) that normalize writes and query parameters, and the one-time migration 20260601010001_normalize_storage_paths rewrites existing backslash rows on upgrade, so your mixed D:/... / D:\... rows converge automatically.

    One important note: the manual workaround in this issue goes in the opposite direction of the storage invariant (REPLACE(directory, '/', '\')). If you applied it after upgrading to >= v1.16.0, the migration will not re-run and those rows will stop matching — reverse it with:

    UPDATE session SET directory = REPLACE(directory, char(92), '/') WHERE directory GLOB '[A-Za-z]:' || char(92) || '*';

    Please upgrade and remove the workaround. If sessions are still missing on a current release, comment with opencode --version and a sample directory value and we will reopen.

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