Skip to content

Windows: global-project session path depends on server process drive, hides API-created sessions from desktop picker #51258

Description

@1624318455

Problem

Sessions created through opencode web (or any API client) on Windows are invisible in the desktop TUI /sessions picker when the target directory is on a different drive than the server process's cwd — as long as the directory has no git repo (so the session lands in the global project).

Concrete case (v1.18.32, single shared opencode.db):

  • opencode web runs with cwd on C:.
  • Phone app creates a session with directory=D:\Work\ForAI\dsh-plugin-TTS, sends messages. The session is fully readable via GET /session and GET /session?directory=....
  • Desktop TUI opened in D:\Work\ForAI\dsh-plugin-TTS shows only an older session in its picker, never the new ones.

Root cause

packages/opencode/src/session/session.ts:

  1. sessionPath(worktree, cwd) = relative(resolve(worktree), cwd). For global-project sessions the worktree is /, and on Windows resolve("/") is the server process's drive root. Same directory string therefore stores a different path depending on who created it:
    • web on C: → path = "D:/Work/ForAI/dsh-plugin-TTS" (absolute, cross-drive fallback)
    • TUI on D: → path = "Work/ForAI/dsh-plugin-TTS" (relative)
  2. The TUI picker (packages/tui/src/context/sync.tsx → sessionListQuery()) queries session.list({ path }) with its own drive-relative spelling, and listByProject matches path verbatim (eq / LIKE path/%). The two spellings never match, so each side only ever sees sessions minted on its own drive.

Verified locally: GET /session?path=Work/ForAI/dsh-plugin-TTS&roots=true returns exactly the 1 old session; the same query with the absolute spelling returns exactly the 2 missing ones.

Side note explaining a related asymmetry: a phone app that lists sessions globally (no project_id/path filter) sees desktop-created sessions fine — the filtering only bites in the desktop picker direction. Also note git init does NOT help here: it moves the TUI query to a new project id while existing sessions stay global, hiding even more.

Suggested fix

In sessionPath, when the worktree is the global root ("/") and the session directory is a Windows drive-absolute path, anchor the relative computation at the session directory's own drive root (D:/) instead of the server process drive. That makes the stored path identical no matter which drive the server runs on, and identical to what a same-drive TUI queries. It is a no-op for same-drive sessions and for real (git) worktrees.

I can put up a PR for this if the approach sounds right.

Activity

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

No one assigned

    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