Skip to content

fix(project): use case-insensitive path comparison for global session migration on Windows#17514

Open
NamedIdentity wants to merge 1 commit intoanomalyco:devfrom
NamedIdentity:fix/windows-path-case
Open

fix(project): use case-insensitive path comparison for global session migration on Windows#17514
NamedIdentity wants to merge 1 commit intoanomalyco:devfrom
NamedIdentity:fix/windows-path-case

Conversation

@NamedIdentity
Copy link

@NamedIdentity NamedIdentity commented Mar 14, 2026

Issue for this PR

Closes #17518

Type of change

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

What does this PR do?

The global session migration (inlined in #16814) uses eq(SessionTable.directory, data.worktree) — SQLite strict equality. On Windows, paths are case-insensitive but this comparison is case-sensitive, so sessions stored under C:\ai-work\dtd\project never match C:\ai-work\DTD\project after a parent directory rename.

Fix: on Windows, use LOWER() in the SQL comparison and path.normalize() to handle mixed slash directions. Non-Windows platforms keep the exact comparison since their filesystems are case-sensitive.

How did you verify your code works?

  • Confirmed 23 sessions orphaned under global after a parent directory was renamed from dtd to DTD
  • Applied SQL migration with LOWER() matching — all sessions correctly reassigned
  • Typecheck passes (zero errors in project.ts)

Screenshots / recordings

N/A — not a UI change.

Checklist

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

… migration on Windows

On Windows, directory paths are case-insensitive but migrateFromGlobal
compared stored session directories against the current worktree using
strict equality. When a parent directory was renamed with different
casing (e.g. dtd -> DTD), sessions created under the old casing were
never migrated to the correct project.

Use SQL LOWER() on Windows to match directories case-insensitively,
and path.normalize() to handle mixed slash directions. Preserves
exact comparison on case-sensitive platforms.

Relates to anomalyco#17183
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 14, 2026
@github-actions
Copy link
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-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 14, 2026
@github-actions
Copy link
Contributor

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.

BUG - migrateFromGlobal skips sessions after directory case change on Windows

1 participant