🤖 feat: auto-increment fork names with /fork command#1875
🤖 feat: auto-increment fork names with /fork command#1875ammar-agent wants to merge 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9fe17d7003
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Auto-generate name and title if not provided | ||
| const forkIdentity = newName | ||
| ? { name: newName, title: undefined } | ||
| : generateForkIdentity(sourceMetadata.name, sourceMetadata.title); | ||
| const resolvedName = forkIdentity.name; |
There was a problem hiding this comment.
Resolved - Fixed in c2ae6dd. Auto-generation now checks existing workspace names and skips to next available suffix.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2ae6dd2d3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| export function generateForkNameWithSuffix(sourceName: string, suffix: number): string { | ||
| const { base } = parseWorkspaceName(sourceName); | ||
| return `${base}-${suffix}`; | ||
| } |
There was a problem hiding this comment.
Resolved - Centralized name resolution now truncates base names to fit the 64-char limit and checks collisions via resolveWorkspaceName (commit 3f51f81).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f51f81c5d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| export function parseWorkspaceName(name: string): { base: string; suffix: number } { | ||
| const match = /^(.+)-(\d+)$/.exec(name); | ||
| if (match) { | ||
| const [, base, numStr] = match; | ||
| const num = parseInt(numStr, 10); | ||
| // Only treat as fork suffix if it's >= 2 (fork numbering starts at 2) | ||
| if (num >= 2) { | ||
| return { base, suffix: num }; |
There was a problem hiding this comment.
Avoid treating any trailing digits as fork suffixes
Because parseWorkspaceName treats any trailing -<digits> (>=2) as an existing fork suffix, auto-forking a workspace whose name naturally ends in numbers (e.g., release-2024) will produce release-2025 instead of release-2024-2. The same logic exists for titles, so Release 2024 becomes Release 2025. This changes the semantic meaning of names/titles and can produce surprising or incorrect results whenever the original name/title legitimately ends with a number. Consider only interpreting numeric suffixes as fork counters when the base name/title exists without the number, or persist a fork counter separately.
Useful? React with 👍 / 👎.
Simplify the fork UX so '/fork' without arguments works by auto-generating incremented names and titles: - Original: name 'bugs-asd23', title 'Fixing bugs' - First fork: name 'bugs-asd23-2', title 'Fixing bugs 2' - Second fork: name 'bugs-asd23-3', title 'Fixing bugs 3' Changes: - Add forkNameGenerator.ts with parsing and generation logic - Update fork API to make newName optional - Update /fork slash command to work without arguments - Remove fork-help toast (no longer needed) - Fix config.addWorkspace to persist title field - Add integration tests for auto-increment behavior Tests: 15 unit tests + 11 integration tests pass
Address Codex review feedback - when forking the same workspace multiple times without specifying a name, the auto-generation now checks existing workspace names and skips to the next available suffix. Example: forking 'bugs-asd23' three times now produces: - bugs-asd23-2 (first fork) - bugs-asd23-3 (second fork, skips -2) - bugs-asd23-4 (third fork, skips -2 and -3) Added: - findNextForkSuffix() to scan existing names for collisions - 6 new unit tests for collision avoidance - 1 integration test for multiple forks from same source
Move workspace name length/collision rules into shared helpers so create/rename/fork paths consistently enforce the same constraints: - Add WORKSPACE_NAME_MAX_LENGTH constant and use in validation + task names - Add buildWorkspaceNameWithSuffix() for length-safe suffixing - Add resolveWorkspaceName() with collision strategies (error/random/numeric) - Update create/rename/fork flows to use resolver and avoid name collisions - Ensure auto-fork truncates base names to keep within 64-char limit Tests: - Added workspaceNaming + workspaceNameResolver unit tests - Updated forkNameGenerator tests for length handling - Updated workspaceValidation tests to use shared constant
3f51f81 to
4c3fd67
Compare
Summary
Simplify the fork UX so
/forkworks without arguments by auto-generating incremented names and titles.Background
Previously,
/forkrequired specifying a new name, which interrupted workflow when users just wanted to branch off quickly. This change allows/forkto auto-generate an incremented name and title based on the source workspace.Implementation
Given a workspace with:
bugs-asd23Fixing bugsRunning
/forkproduces:bugs-asd23-2Fixing bugs 2Subsequent forks continue the sequence (
-3,-4, etc.).Changes:
forkNameGenerator.tswith parsing and generation logicWORKSPACE_NAME_MAX_LENGTH,buildWorkspaceNameWithSuffix,resolveWorkspaceName) so create/fork/rename enforce length + collision rules in one placenewNameoptional/forkslash command to work without argumentsfork-helptoast type (no longer needed - empty args triggers auto-generate)config.addWorkspaceto persist thetitlefield (was missing, prevented titles from persisting through reload)Validation
make static-checkRisks
Generated with
mux• Model:anthropic:claude-opus-4-5• Thinking:high• Cost:$15.08