fix(discover): sanitize absolute -p paths before matching project dirs#2889
Open
AZERDSQ131 wants to merge 1 commit into
Open
fix(discover): sanitize absolute -p paths before matching project dirs#2889AZERDSQ131 wants to merge 1 commit into
AZERDSQ131 wants to merge 1 commit into
Conversation
`rtk discover -p <absolute path>` always reported 0 sessions and printed the success message "No missed savings found. RTK usage looks good!" -- a false all-clear -- while the same project filtered by a name substring reported many sessions. Claude Code stores transcripts under sanitized project directory names where path separators (and other non-alphanumeric characters) become dashes (~/.claude/projects/-home-user-projects-my-app/). The default (no -p) branch already ran the cwd through ClaudeProvider::encode_project_path before matching, but the -p branch passed the raw value straight through. A -p value containing a path separator can therefore never substring-match the sanitized directory name, so the filter silently matched zero projects instead of erroring or falling back. Extracted the filter resolution into `resolve_project_filter`: a -p value containing '/' or '\\' is now treated as a filesystem path and sanitized the same way as the default cwd; a -p value with no separator is still treated as a plain name substring, unchanged from today's already-working behavior. Adds five unit tests covering: --all overrides everything, an absolute Unix path resolves to the exact same filter as the equivalent default cwd, a Windows backslash path is sanitized, a plain name substring is passed through untouched, and the no-project default still encodes the cwd.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2834
rtk discover -p <absolute path>always reports 0 sessions and prints the success message "No missed savings found. RTK usage looks good!" — a false all-clear — while the same project filtered by a name substring reports many sessions with substantial missed savings.Repro (from the issue):
Root cause: Claude Code stores transcripts under sanitized project directory names where path separators become dashes (
~/.claude/projects/-home-user-projects-my-app/, viaClaudeProvider::encode_project_path).src/discover/mod.rs'srun()already ran the default (no-p) cwd throughencode_project_pathbefore matching, but the-pbranch passed the raw value straight through:A
-pvalue containing/can therefore never substring-match the sanitized directory name (src/discover/provider.rs'sdiscover_sessions_in_projects_dirdoes a plaindir_name.contains(filter)).Fix: extracted the filter resolution into
resolve_project_filter(project, all, cwd). A-pvalue containing/or\is now treated as a filesystem path and sanitized the same way as the default cwd; a-pvalue with no separator is still treated as a plain name substring, unchanged from today's already-working "name substring" mode.Adds five unit tests:
--alloverrides everything regardless of-pSome("/home/user/projects/my-app")== default cwd"/home/user/projects/my-app")Ran the mandatory gate locally:
cargo fmt --all— applied (reformatted a few wrapped lines)cargo clippy --all-targets— cleancargo test --all— 2398 passed (+ 6/11/11/14/5/11 in the other suites), 0 failed