Skip to content

fix(discover): encode Windows drive-colon so project auto-detect matches#3007

Open
Izymiro wants to merge 1 commit into
rtk-ai:developfrom
Izymiro:fix/windows-drive-colon-discover
Open

fix(discover): encode Windows drive-colon so project auto-detect matches#3007
Izymiro wants to merge 1 commit into
rtk-ai:developfrom
Izymiro:fix/windows-drive-colon-discover

Conversation

@Izymiro

@Izymiro Izymiro commented Jul 15, 2026

Copy link
Copy Markdown

Problem

On Windows, rtk discover (and rtk learn) with no -p/--all report
Scanned: 0 sessions even when the current project has plenty of history.
rtk discover --all and rtk discover -p <name> both work correctly, which
isolates the fault to current-project auto-detection.

Root cause

ClaudeProvider::encode_project_path (src/discover/provider.rs) reproduces
Claude Code's cwd→slug encoding to build the --project filter, but its
SANITIZED_CHARS set is missing the colon :. Claude Code replaces the
drive-letter colon with -, so a cwd of C:\Users\foo\bar maps to the
projects directory C--Users-foo-bar. rtk instead produces
C:-Users-foo-bar, and the substring match in
discover_sessions_in_projects_dir (dir_name.contains(filter)) then fails,
so no sessions are found. Unix paths have no C:, so the bug is Windows-only.

Fix

  • Add ':' to SANITIZED_CHARS.
  • Update the docstring example and test_encode_project_path_windows to expect
    C--Users-foo-bar.
  • Add test_encode_project_path_unix_colon documenting that the encoding is
    platform-independent (a colon in a POSIX path collapses to - the same way),
    so this is not a Windows-only drive-letter special case.

Verification

Reproduced on Windows 11: for a real project directory
C--Users-<user>-Desktop-Projects-<proj>, rtk discover returned 0 sessions
before the change and the correct session count after — matching the output of
rtk discover -p <proj>.

Claude Code replaces the drive-letter colon with `-` when building the
project directory name under ~/.claude/projects (e.g. `C:\Users\foo\bar`
becomes `C--Users-foo-bar`). encode_project_path omitted `:` from its
sanitized-character set and produced `C:-Users-foo-bar`, so the
auto-detected --project filter never matched and `rtk discover` / `rtk learn`
reported "0 sessions" on Windows.

Add `:` to SANITIZED_CHARS, fix the docstring example, update the Windows
test, and add a POSIX test documenting that the encoding is platform-independent.
@CLAassistant

CLAassistant commented Jul 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@tapheret2 tapheret2 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: fix(discover): encode Windows drive-colon so project auto-detect matches

Files: src/discover/provider.rs
Size: +20 / -5

Notes

  • Static pass on the patch: no obvious blockers from the diff alone.

Thanks @Izymiro — independent review on the patch.

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.

3 participants