Repository navigation
fix(discover): sanitize drive-letter colon so Windows discover finds sessions - #2952
Conversation
…sessions encode_project_path mirrors Claude Code's cwd -> ~/.claude/projects slug, but never replaced the drive-letter ':' with '-'. Every Windows cwd carries one, so the encoded slug (C:-Users-me) never matched Claude's real folder (C--Users-me) and the default `rtk discover` scanned 0 sessions on Windows. Add ':' to SANITIZED_CHARS; the shared encoder also fixes `rtk learn`. Refs rtk-ai#2919
There was a problem hiding this comment.
Pull request overview
Fixes Windows-only current-project discovery by aligning ClaudeProvider::encode_project_path with Claude Code’s project-folder slug sanitization (drive-letter : → -), so rtk discover (and shared users like rtk learn) can find sessions under ~/.claude/projects/.
Changes:
- Add
:to theSANITIZED_CHARSlist used byencode_project_path, preventingC:-...vsC--...mismatches on Windows. - Update the Rustdoc examples/comments to reflect the corrected Windows encoding output.
- Update/extend unit tests to assert the corrected Windows slug and add a full-path regression case.
fix(discover): sanitize drive-letter colon so Windows discover finds sessions (adopt upstream rtk-ai#2952)
|
A correction to my own description above, now that I've had the chance to pin it down. I wrote that a full Something I should have checked before opening this, and have now: instead of inferring the encoding from folder names, I read the slug function in the installed Claude Code binary (2.1.215). It replaces every non-alphanumeric character with It also means Thanks for your time, and no rush from my side. |
KuSh
left a comment
There was a problem hiding this comment.
LGTM!
Could you remove the duplicated test as it doesn't add anything except more maintenance surface. Thanks
rtk 0.46.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## [0.46.0](rtk-ai/rtk@v0.45.0...v0.46.0) (2026-08-26) ### Features - find: dispatch on find's grammar; compress find output for unmodeled predicates ([#3603](rtk-ai/rtk#3603)) - find: tee tail hint when rtk imposes the result cap ([#3603](rtk-ai/rtk#3603)) ### Bug Fixes - find: never-worse guard, recovery hint, and dispatch on find's grammar ([#3603](rtk-ai/rtk#3603)) - git: don't misdetect a value-taking option's argument as a patch flag ([#3575](rtk-ai/rtk#3575)) - cicd: stop benchmark.sh deleting the tracked scripts/benchmark harness ([#3595](rtk-ai/rtk#3595)) - tee: hash long recovery-file slugs to prevent collisions and shorten hints ([#3266](rtk-ai/rtk#3266)) - benchmark: avoid negative curl/cargo cases that fail the benchmark job ([#3430](rtk-ai/rtk#3430)) - test: accept both Ask and Allow verdicts in rewrite tests ([#3147](rtk-ai/rtk#3147)) — Closes [#3146](rtk-ai/rtk#3146) - core: decode process output using Windows console code page ([#2717](rtk-ai/rtk#2717)) — Closes [#2452](rtk-ai/rtk#2452) - git: preserve patch output from log commands ([#2951](rtk-ai/rtk#2951)) — Closes [#2944](rtk-ai/rtk#2944) - discover: sanitize drive-letter colon so Windows discover finds sessions ([#2952](rtk-ai/rtk#2952)) — Closes [#2919](rtk-ai/rtk#2919) - stream: decode lossily instead of dropping lines on invalid UTF-8 ([#2997](rtk-ai/rtk#2997)) — Closes [#2994](rtk-ai/rtk#2994) ### Other - test(find): use the platform temp dir instead of /tmp ([#3717](https://github.com/rtk-ai/rtk/pull/3717))</pre> <p>View the full release notes at <a href="https://github.com/rtk-ai/rtk/releases/tag/v0.46.0">https://github.com/rtk-ai/rtk/releases/tag/v0.46.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!17826
Problem
On Windows, the default
rtk discover(current-project mode) always reportsScanned: 0 sessions.--alland-p PROJECTwork, so history parsing is fine — only current-project resolution fails. (#2919)Root cause
ClaudeProvider::encode_project_pathmirrors Claude Code'scwd→~/.claude/projects/slug encoding, replacing separators with-. ItsSANITIZED_CHARSlist ('/', '.', '_', '\\', ' ', '[', ']') is missing the drive-letter colon:.Every Windows cwd carries one, so:
The
C:-vsC--mismatch means the encoded slug is never a substring of the real folder name, so the substring match indiscover_sessions_in_projects_dirfinds nothing → 0 sessions. This also lines up with @superjaff's note above that Claude's sanitizer maps:\/and spaces to-.Ground truth on a Windows box:
C:\Users\Administratorlands in~/.claude/projects/C--Users-Administrator— Claude replaces the colon with-.Fix
Add
':'toSANITIZED_CHARS(one char). The encoder is shared, so this also fixes the same 0-sessions symptom inrtk learn.Tests (TDD, red → green)
test_encode_project_path_windows— corrected expectation:C:\Users\foo\bar→C--Users-foo-bar(wasC:-Users-foo-bar, which had encoded the bug).test_encode_project_path_windows_full_path— regression for a full Windows cwd.Verified on Windows (rustc 1.96.0)
cargo fmt --all -- --check— cleancargo clippy --all-targets -- -D warnings— zero warningscargo test discover::provider::tests— 21/21 passScanned: 0 sessionsScanned: 1 sessions(A full
cargo test --allon my local Windows box has 16 pre-existingcore::streamfailures that spawncat/echo, absent from my PATH — the identical 16 fail on unmodifieddevelop, and they pass on CI'swindows-latest.)Scope
Colon sanitization is the deterministic root cause that breaks every Windows path. Drive-letter case-insensitivity (an uppercase
E:cwd vs a lowercasee--folder created by a different launch) is a separate, situational concern, left out of this focused PR.Closes #2919