Skip to content

fix(discover): encode '.' as '-' in project path slug#1472

Merged
KuSh merged 3 commits intortk-ai:developfrom
niklasmarderx:fix/discover-dot-in-cwd
Apr 26, 2026
Merged

fix(discover): encode '.' as '-' in project path slug#1472
KuSh merged 3 commits intortk-ai:developfrom
niklasmarderx:fix/discover-dot-in-cwd

Conversation

@niklasmarderx
Copy link
Copy Markdown
Contributor

Claude Code replaces both / and . with - when computing a project directory name from the working directory path. rtk only replaced /, so for users with a dot in their path (e.g. /Users/first.last) the computed slug didn't match Claude's directory name and rtk discover returned zero sessions.

The fix is a one-character change in encode_project_path: replace ['/', '.'] instead of just '/'.

Two tests added to cover the dot case and multiple consecutive dots.

Closes #1457

Claude Code replaces both '/' and '.' with '-' when deriving a
projects-directory name from the working-directory path. rtk only
replaced '/'. For users whose path contains a dot (e.g. /Users/first.last)
the computed slug didn't match Claude's directory name, so rtk discover
found zero sessions.

Fixes rtk-ai#1457
@pszymkowiak pszymkowiak added bug Something isn't working effort-small Quelques heures, 1 fichier good first issue Good for newcomers labels Apr 23, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes project path encoding in the discover module to replace '.' characters with '-', matching Claude Code's directory naming convention. Without this fix, users with dots in their filesystem path (e.g., /Users/first.last) would get zero sessions from rtk discover because the computed slug didn't match Claude's actual directory name.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #1457


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

Comment thread src/discover/provider.rs Outdated
…ath slug

Per claude-code#24067, underscore is replaced with '-'.
Per claude-code#40946, non-ASCII characters are each replaced with '-'.
Windows backslashes follow the same rule.

Refactored encode_project_path to use chars().map() instead of
chained replace() calls for clarity.

Closes rtk-ai#1457
@niklasmarderx
Copy link
Copy Markdown
Contributor Author

Good catch — pushed a follow-up commit that extends the encoding to cover _, \, and non-ASCII characters. Used chars().map() instead of chained replace() calls since we now handle four cases plus the Unicode check. Added three tests referencing the upstream issues.

@KuSh KuSh self-assigned this Apr 25, 2026
Comment thread src/discover/provider.rs
@niklasmarderx
Copy link
Copy Markdown
Contributor Author

Done — extracted SANITIZED_CHARS constant and flipped the condition to !c.is_ascii() || SANITIZED_CHARS.contains(&c) as suggested.

Copy link
Copy Markdown
Collaborator

@KuSh KuSh left a comment

Choose a reason for hiding this comment

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

Thanks!

@KuSh KuSh merged commit 323cc3d into rtk-ai:develop Apr 26, 2026
11 checks passed
@aeppling aeppling mentioned this pull request Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working effort-small Quelques heures, 1 fichier good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants