Skip to content

fix(core): match session directory case by filesystem identity - #49530

Closed
pascalandr wants to merge 1 commit into
anomalyco:v2from
pascalandr:session-directory-case
Closed

pascalandr wants to merge 1 commit into
anomalyco:v2from
pascalandr:session-directory-case

Conversation

@pascalandr

Copy link
Copy Markdown

Summary

Fix directory-scoped session discovery when a stored session location and the requested directory differ only by a spelling that the filesystem considers equivalent.

On a normal Windows filesystem, a session stored or moved to D:\codenomad was omitted from GET /api/session?directory=D%3A%5CCodeNomad, despite both paths referring to the same directory and project. SessionStore.list used an exact SQL string comparison. This was observed through CodeNomad and reproduced directly against the native API.

Implementation

  • Discover distinct stored directory spellings under the existing search, workspace, parent and paging-anchor predicates.
  • Use Unicode case folding only to identify candidates; require filesystem resolution to confirm directory identity. This preserves genuinely distinct case-sensitive directories instead of applying a blanket NOCASE comparison.
  • Reuse FSUtil.normalizePath for native Windows resolution: Bun's callback-based realPath can preserve the caller's case even when the disk contains only one directory.
  • Apply the confirmed directory set before SQL LIMIT, retaining ordering and forward/backward page boundaries.
  • Preserve exact-spelling access to unavailable historical directories. Read-time recovery does not rewrite session locations or durable history.

Directory-scoped lists gain one distinct-directory query. Filesystem work is limited to candidate case variants with bounded concurrency and no persistent alias cache. Project-wide lists keep their existing query path. There is no public API/schema change.

Validation

  • Regression check: restoring the old exact predicate fails three Windows tests (ASCII aliases, accented aliases and pagination); the fix passes.
  • Core store + native move tests: 23 passed, 1 existing skip, including a repeat with repository-required Bun 1.4.2.
  • Store suite under an explicitly case-sensitive Windows temporary directory: 7 passed. A separate filesystem probe confirmed Checkout and checkout are two distinct entries there.
  • Server instance/import integration: 4 passed.
  • Native filesystem fixtures cover Checkout/checkout, ÉQUIPE/équipe, Σ/ς, search/parent/workspace isolation, both paging directions and missing directories. The test oracle uses directory enumeration rather than the resolution implementation under test.
  • Full pre-push checks with Bun 1.4.2: lint and all 35 typecheck tasks passed.
  • Prettier validation against LF-normalized sources and git diff --check passed.

Related discovery: NeuralNomadsAI/CodeNomad#649. This is a separate native-runtime fix, independent of that PR's worktree conversation-placement instruction.

Directory-scoped session lists currently compare stored paths as exact SQL strings. A session moved to D:\codenomad disappears from a D:\CodeNomad listing even though both names refer to the same Windows directory. Resolve existing case variants at read time so historical sessions remain discoverable without rewriting their location or durable events.

Use case folding only to identify candidate spellings among distinct directories matching the other selectors, then require filesystem resolution to establish identity. Reuse native Windows normalization because Bun's callback realPath can preserve caller spelling. Keep exact missing-directory histories readable, preserve workspace/search/parent and anchor filters, and apply the accepted directory set before LIMIT in both paging directions. This adds one distinct-directory query to directory-scoped lists and performs bounded filesystem resolution only for candidate aliases; project-wide lists keep their existing path.

Add real-filesystem regressions for ASCII, accented and Greek names, pagination, selector isolation and missing directories. Determine the expected filesystem behavior by directory enumeration rather than reusing the resolution logic under test. Restoring the old exact predicate makes three tests fail on default Windows; the fix passes seven store tests on default and explicitly case-sensitive Windows directories. Core move/store tests pass (23 passed, one existing skip), four server instance/import tests pass, core typecheck and LF-normalized Prettier validation pass.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@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-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 17, 2026
@github-actions github-actions Bot closed this Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant