Skip to content

fix: keep sessions discoverable for non-git projects on Windows - #40503

Open
BB-84C wants to merge 1 commit into
anomalyco:devfrom
BB-84C:fix/session-path-non-git-windows
Open

fix: keep sessions discoverable for non-git projects on Windows#40503
BB-84C wants to merge 1 commit into
anomalyco:devfrom
BB-84C:fix/session-path-non-git-windows

Conversation

@BB-84C

@BB-84CBB-84C commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes#35750

Type of change

  • Bug fix

What does this PR do?

Sessions created in non-git projects on Windows can disappear from the session picker.

Non-git projects use worktree "/" (set in Project.fromDirectory). On Windows, path.resolve("/") resolves to the drive root of the current process, so sessionPath() produced a machine-dependent absolute path like D:/repo and stored it in session.path. The session list query matches paths relative to the worktree, so those rows never matched and the sessions vanished from the picker. Which sessions were visible depended on which drive root the server process happened to be rooted at. Related reports: #37041, #37353, #38780.

Changes:

  • sessionPath() returns undefined when the worktree-relative result is absolute (cross-volume, which is what happens for non-git worktrees on Windows). Sessions without a usable path fall back to the existing directory-based scoping in listByProject (path IS NULL AND directory = ?).
  • The TUI session list query now passes directory alongside path, which is what makes the directory fallback reachable for project instances. POSIX behavior and git-project behavior are unchanged (the path condition still matches first).
  • Migration 20260804120000_normalize_session_path NULLs out legacy absolute/empty paths so existing sessions become visible again after upgrade.

How did you verify your code works?

  • New unit tests for sessionPath (win32 cross-volume returns undefined, same-volume keeps relative, posix unchanged) in packages/opencode/test/session/session-path.test.ts.
  • New server test in packages/opencode/test/server/session-list.test.ts: a NULL-path session is listed when directory is provided and stays hidden without it. 12/12 pass in that file.
  • tsgo --noEmit passes for opencode, tui, and core; oxlint clean on changed files.
  • Real-machine check on Windows (non-git directory D:\BB84.ai): built the fork binary, pointed it at a snapshot copy of a real production DB (16,873 sessions, including rows with stored absolute paths like D:/BB84.ai and empty paths), enabled session directory filtering in the TUI, and confirmed sessions remain visible instead of being lost. The migration was exercised on the snapshot only; the production DB was not modified.

Screenshots / recordings

No screenshots - verification was done interactively in the TUI.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Non-git projects use worktree "/", and on Windows path.resolve("/")
resolves to the drive root of the current process. sessionPath() therefore
stored a machine-dependent absolute path (e.g. "D:/repo") that the session
list query's worktree-relative match can never find, hiding those sessions
from the picker.
- sessionPath(): return undefined when the worktree-relative result is
absolute (cross-volume / non-git Windows), so sessions fall back to the
existing directory-based scoping in the list query.
- TUI session list: pass directory alongside path so the server can match
pathless rows.
- Migration: NULL out legacy absolute/empty paths so existing sessions
become visible again.
@github-actionsgithub-actionsBot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Aug 4, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actionsgithub-actionsBot added contributor and removed needs:compliance This means the issue will auto-close after 2 hours. labels Aug 4, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to 1.17.x hides pre-existing sessions — new path column not back-filled during migration

1 participant

@BB-84C