-
Notifications
You must be signed in to change notification settings - Fork 84
feat: support "/" character in workspace/branch names #2795
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| /** | ||
| * Validates workspace name format | ||
| * - Must be 1-64 characters long | ||
| * - Can only contain: lowercase letters, digits, underscore, hyphen | ||
| * - Pattern: [a-z0-9_-]{1,64} | ||
| * - Can only contain: lowercase letters, digits, underscore, hyphen, forward slash | ||
| * - No leading, trailing, or consecutive slashes | ||
| * - Pattern: [a-z0-9_-]+(?:\/[a-z0-9_-]+)* (1-64 characters) | ||
| */ | ||
| export function validateWorkspaceName(name: string): { valid: boolean; error?: string } { | ||
| if (!name || name.length === 0) { | ||
|
|
@@ -13,16 +14,25 @@ export function validateWorkspaceName(name: string): { valid: boolean; error?: s | |
| return { valid: false, error: "Workspace name cannot exceed 64 characters" }; | ||
| } | ||
|
|
||
| const validPattern = /^[a-z0-9_-]+$/; | ||
| const validPattern = /^[a-z0-9_-]+(?:\/[a-z0-9_-]+)*$/; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
By permitting Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Allowing Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Allowing Useful? React with 👍 / 👎. |
||
| if (!validPattern.test(name)) { | ||
| return { | ||
| valid: false, | ||
| // Workspace names become folder names, git branches, and session directories, | ||
| // so they need to be filesystem-safe across platforms. | ||
| error: | ||
| "Workspace names can only contain lowercase letters, numbers, hyphens, and underscores", | ||
| "Workspace names can only contain lowercase letters, numbers, hyphens, underscores, and forward slashes (no leading, trailing, or consecutive slashes)", | ||
| }; | ||
| } | ||
|
|
||
| return { valid: true }; | ||
| } | ||
|
|
||
| /** | ||
| * Convert a workspace name to a filesystem-safe path component by replacing | ||
| * forward slashes with hyphens. | ||
| * | ||
| * This allows git-style branch names like "feature/my-branch" to be used as | ||
| * workspace names while remaining safe for directory names and session paths. | ||
| */ | ||
| export function sanitizeWorkspaceNameForPath(name: string): string { | ||
| return name.replace(/\//g, "-"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| } | ||
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.
Allowing
/in workspace names here makes plan paths become nested (getPlanFilePathbuilds.../{workspaceName}.mdinsrc/common/utils/planStorage.ts:25-31), butmovePlanFilestill runs a baremvand neither creates the destination parent directory nor checksexecBufferedexit status (src/node/utils/runtime/helpers.ts:246-253). Renaming a workspace with an existing plan from something likefootofeature/foowill therefore silently fail to move the file, and later reads target only the new path, so the plan appears to disappear after rename.Useful? React with 👍 / 👎.