Skip to content

fix: normalize Windows desktop session paths#26580

Open
Blueteemo wants to merge 5 commits into
anomalyco:devfrom
Blueteemo:fix/issue-17765-windows-desktop-session-paths
Open

fix: normalize Windows desktop session paths#26580
Blueteemo wants to merge 5 commits into
anomalyco:devfrom
Blueteemo:fix/issue-17765-windows-desktop-session-paths

Conversation

@Blueteemo
Copy link
Copy Markdown

@Blueteemo Blueteemo commented May 9, 2026

Issue for this PR

Closes #17765

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On Windows Desktop, all session history disappears every time the client is closed and reopened. The sessions still exist in the SQLite database but the UI shows an empty list.

Root cause: Path normalization was inconsistent across different parts of the system:

  • project.worktree stored as "/" (Unix-style root)
  • session.directory stored as "C:\" (Windows path format)
  • lastProjectSession key stored as "/"

This path mismatch prevented the Desktop UI from matching/loading existing sessions after restart.

Solution: Added consistent path normalization in two places:

  1. packages/app/src/utils/path-key.ts - Simplified pathKey() to properly handle Windows root paths (e.g., C:\ or /) -> normalize to /
  2. packages/opencode/src/session/session.ts - Added normalizeDirectory() helper to normalize directory paths before storing sessions

How did you verify your code works?

  1. Manually edited the Desktop's opencode.global.dat file to fix path mismatches (changing "/" to "C:\" for worktree and lastProject)
  2. Confirmed sessions reappeared in the sidebar after the path fix
  3. The fix ensures new sessions are created with normalized paths, preventing future mismatches

Screenshots / recordings

N/A - This is a backend fix, not a UI change.

Checklist

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

@Blueteemo Blueteemo requested a review from adamdotdevin as a code owner May 9, 2026 20:35
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found several related PRs that address similar path normalization issues on Windows:

  1. PR fix: normalize Windows session directory filters #26463 - "fix: normalize Windows session directory filters"

  2. PR fix: sessions missing from sidebar on Windows due to path separator mismatch #23862 - "fix: sessions missing from sidebar on Windows due to path separator mismatch"

  3. PR fix: normalize windows path separators in session queries #20215 - "fix: normalize windows path separators in session queries"

  4. PR fix/windows path normalization(#21441) #21852 - "fix/windows path normalization(SortableWorkspace session list empty due to store.path.directory not bootstrapped #21441)"

  5. PR fix: normalize WSL desktop session paths #22049 - "fix: normalize WSL desktop session paths"

These PRs suggest there's been an ongoing issue with path normalization across different environments. PR #23862 appears most closely related as it addresses the same symptom of sessions disappearing from the sidebar on Windows due to path mismatches.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Desktop loses all session history after restart, but sessions still exist in opencode.db

2 participants