-
Notifications
You must be signed in to change notification settings - Fork 632
fix(projects): Convert special characters other than English letters and numbers to - #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LeoZheng1738
wants to merge
1
commit into
siteboon:main
Choose a base branch
from
LeoZheng1738:fix_project
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Name collision risk and broken decoding logic.
This change introduces two critical issues:
Name collisions: Different project paths can now map to the same
projectName, causing conflicts. For example:/workspace/my_project→-workspace-my-project/workspace/my-project→-workspace-my-projectThe collision check at line 1001 would incorrectly reject the second (legitimately different) project.
Broken fallback decoding: Multiple locations in the codebase decode
projectNameback to paths usingreplace(/-/g, '/'), assuming the old encoding scheme where only slashes were replaced:generateDisplayNameextractProjectDirectorygetProjectsWith the new encoding, this decoding produces incorrect paths. For example, if
projectNameis-workspace-my-project-version-1-0, decoding yields/workspace/my/project/version/1/0instead of the original path.While
originalPathis stored for newly added manual projects (line 1011), the fallback logic will fail whenoriginalPathis unavailable or for projects encoded with the old scheme.Recommended solutions:
Maintain bidirectional mapping: Store a mapping of encoded names to original paths in the config, or use a reversible encoding scheme (e.g., URL encoding or base64).
Update all decoding sites: Replace all instances of
projectName.replace(/-/g, '/')with logic that retrieves the path from config'soriginalPathfield.Prevent collisions: Before adding a project, check if any existing config entry has a different
originalPathbut the same encodedprojectName.Migration strategy: Consider how existing projects with the old encoding will coexist with new ones, or implement a one-time migration to re-encode all existing projects.
Example diff for collision prevention:
// Check if project already exists in config const config = await loadProjectConfig(); const projectDir = path.join(process.env.HOME, '.claude', 'projects', projectName); if (config[projectName]) { - throw new Error(`Project already configured for path: ${absolutePath}`); + // Check if it's truly the same project or a collision + if (config[projectName].originalPath !== absolutePath) { + throw new Error(`Project name collision: A different project at '${config[projectName].originalPath}' already uses the encoded name '${projectName}'`); + } + throw new Error(`Project already configured for path: ${absolutePath}`); }🤖 Prompt for AI Agents