Skip to content

fix(discover): match the project folder case-insensitively on Windows - #4143

Closed
Wilson421 wants to merge 1 commit into
rtk-ai:developfrom
ewc3labs:fix/discover-windows-drive-letter-case
Closed

Wilson421 wants to merge 1 commit into
rtk-ai:developfrom
ewc3labs:fix/discover-windows-drive-letter-case

Conversation

@Wilson421

Copy link
Copy Markdown

Summary

  • On Windows, rtk discover (and rtk learn, same filter) scans zero sessions and prints No missed savings found. RTK usage looks good!
  • Claude Code's history folder for C:\DEV\proj is c--DEV-proj — lowercased drive letter. encode_project_path receives C:\DEV\proj from current_dir() and produces C--DEV-proj, and the filter match is case-sensitive, so no project directory is ever selected.
  • Same silent zero as the drive-letter colon already fixed in discover: 0 sessions scanned on Windows - drive-letter case mismatch when resolving current project #2919, one character along. Fixed where both callers share the comparison; off Windows the match stays exact.
  • Second change, same defect class: zero sessions scanned no longer prints the clean-bill line.

Measured, Windows 11, two machines

run result
rtk discover (bare) 0 sessions, 0 commands, "RTK usage looks good!"
rtk discover --project <folder name> 3 sessions, 3,872 commands, ~24.5K tokens of missed savings
second machine, bare 0 sessions
second machine, --project 325 sessions, 69,910 commands

With this patch, bare rtk discover on the first machine: 3 sessions, 3,887 commands.

The failure direction is what makes it worth fixing rather than documenting: a user who has never routed a single command through rtk is told their usage looks good. Both people who hit it here assumed the tool had measured something.

The second change

format_text already guards one false "looks good" — the RTK_DISABLED bypass, with a comment saying exactly why. An empty scan reaches the same line by a different road, so zero sessions now says nothing was analysed and points at --project / --all.

Test plan

  • cargo fmt --check clean, cargo clippy --all-targets clean
  • cargo test --bin rtk discover:: — 634 passed, 0 failed
  • New tests: the matcher ignores drive-letter case on Windows (and still discriminates between different projects); stays exact off Windows; a session in c--DEV-… is found through the directory walk when the filter says C--DEV-…; and zero sessions never renders the clean-bill line.
  • Negative controls: with the Windows branch disabled, both new provider tests fail (assertion failed: project_dir_matches(...)). The report test fails against the old formatter for the same reason.
  • End to end: rebuilt binary, bare rtk discover in a project that previously reported 0.
  • Full suite cargo test --bin rtk: the only failures are 17 pre-existing core::stream cases ("program not found") that reproduce identically on a stock develop checkout on this machine.

I kept this separate from #4141, which touches hooks::init — different area, different defect, though both are "reported success over nothing done".

`rtk discover` scans zero sessions on Windows and reports
"No missed savings found. RTK usage looks good!"

Claude Code's history folder for `C:\DEV\proj` is `c--DEV-proj`, with a
lowercased drive letter. `encode_project_path` gets `C:\DEV\proj` from
`current_dir()` and produces `C--DEV-proj`, and the filter match is
case-sensitive, so no project directory is ever selected. Same silent
zero as the drive-letter colon in rtk-ai#2919, one character along.

MEASURED, Windows 11, two machines:

    bare                      0 sessions,     0 commands   "looks good!"
    --project <folder name>   3 sessions, 3,872 commands
    second machine, bare      0 sessions
    second machine, filtered  325 sessions, 69,910 commands

Both callers (discover and learn) build the filter the same way, so the
comparison is fixed where they share it. Off Windows paths are
case-sensitive and the match stays exact.

Also: zero sessions scanned no longer prints the clean-bill line. The
report already guards one false "looks good" (the RTK_DISABLED bypass);
this is the same defect reached through an empty scan, and the absence of
evidence was reading as evidence of absence.

Co-Authored-By: Claude Opus 5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 20, 2026 09:48

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The changes are focused, tested, and no unresolved correctness issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Fixes Windows project discovery by matching encoded project directories case-insensitively and prevents zero-session scans from reporting a clean bill of health.

Changes:

  • Added Windows-specific case-insensitive project matching.
  • Added a clear zero-session report message.
  • Added platform-specific and regression tests.
File Description
src/​discover/​provider.rs Updates project matching and adds discovery tests.
src/​discover/​report.rs Handles empty scans without claiming RTK usage is healthy.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes rtk discover/learn silently scanning zero sessions on Windows because the project-folder filter compared drive-letter case exactly (e.g. 'c--DEV-proj' vs 'C--DEV-proj'), causing a false 'RTK usage looks good!' message. Also changes the report formatter so that zero scanned sessions no longer renders as a clean-bill-of-health message, instead prompting the user to check the filter or use --all.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

@KuSh

KuSh commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

Closing this as a duplicate of two older PRs that together carry both of its changes. #2931 has matched the project folder case-insensitively on Windows since July, with the same helper shape and a before/after measured on a Windows machine, and its tests run on every platform. #3374 handles the zero-sessions report line, and also tells a current-project scan from an all-projects one so it only suggests --all when that can help. Both are the place to follow up; #3374 needs a small rebase onto develop, and a review or a comment there would help it along. If a case here is not covered by those two, reply and this can be reopened. Thanks for measuring this on two machines.

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

Labels

bug Something isn't working discover windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants