Skip to content

Conversation

@ThomasK33
Copy link
Member

Summary

This PR enables opening existing git branches as workspaces, including branches with forward slashes in their names (e.g., feature/foo, bugfix/issue-123).

Features

  1. Open Branch as Workspace - Two entry points:

    • Creation Controls UI: Toggle between 'New branch' and 'Existing branch' modes
    • Command Palette: 'Open Branch as Workspace...' command with searchable branch selector
  2. Slash Support in Branch Names - Properly handles common branch naming conventions:

    • feature/foo → stored as feature%2Ffoo on disk (not nested directories)
    • Displayed correctly as feature/foo in the UI

Technical Changes

  • Add encodeWorkspaceNameForDir() helper using encodeURIComponent() for safe filesystem names
  • Add validateGitBranchName() validator allowing slashes (plus a-z, 0-9, _, -)
  • Update WorktreeRuntime, SSHRuntime, and Config to encode workspace directory names
  • Backend validation now chooses validator based on runtime type (git vs local)
  • UI uses metadata.name for display instead of deriving from encoded paths

Backward Compatibility

  • Existing workspaces continue to work without migration
  • Legacy workspace paths handled correctly
  • Local runtime still uses strict validation (no slashes)

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high

Two entry points for opening existing branches as workspaces:

1. **Creation Controls UI** - Toggle between 'New branch' and 'Existing branch'
   modes in the workspace creation flow. When in existing branch mode,
   shows a searchable dropdown of local + remote branches.

2. **Command Palette** - 'Open Branch as Workspace...' command (Cmd+Shift+P)
   with a searchable branch selector.

Backend changes:
- Add listRemoteBranches() to git.ts
- Update BranchListResult schema to include remoteBranches
- Fetch remotes before listing branches (best-effort, ensures newly
  pushed PR branches are visible)

This enables the workflow: someone opens a PR on GitHub → you fetch → select
their branch → experiment with it in an isolated workspace.

Future: GitHub PR integration can layer on top - just needs to resolve
PR → branch name, then feed into this existing flow.

Signed-off-by: Thomas Kosiewski <[email protected]>

---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking: `high`_
Change-Id: Icd3157070795b352712304a8b56417ba74f28364
Signed-off-by: Thomas Kosiewski <[email protected]>
Enable creating and opening workspaces on existing git branches that contain
forward slashes, a common naming convention like `feature/foo` or
`bugfix/issue-123`.

- Add `encodeWorkspaceNameForDir()` helper that uses `encodeURIComponent()`
- `feature/foo` → directory `feature%2Ffoo` (not nested directories)
- Simple names like `main` remain unchanged
- Applied in WorktreeRuntime, SSHRuntime, and Config.addWorkspace()

- Add `validateGitBranchName()` for worktree/SSH runtimes
- Allows forward slashes (plus existing charset: a-z, 0-9, _, -)
- Rejects: leading/trailing slashes, consecutive slashes, 64+ chars
- Original `validateWorkspaceName()` still used for local runtime

- workspaceService.create/rename/fork now choose validator based on runtime type
- Git runtimes (worktree/SSH) use slash-permitting validation
- Local runtime uses strict validation

- Command palette now uses `metadata.name` for display (not path derivation)
- Correctly displays `feature/foo` instead of `foo` or `feature%2Ffoo`

- Existing workspaces continue to work (no migration needed)
- Old workspace paths without encoding are handled correctly
- Legacy fallback paths in config.ts unchanged

Signed-off-by: Thomas Kosiewski <[email protected]>

---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking: `high`_

Change-Id: I650cebc612b2111cff8ae75a94a6a50fe7217165
Replace separate 'New branch' / 'Existing branch' toggle with a single
combobox-style input that:

- Shows matching existing branches as user types (autocomplete dropdown)
- Selecting a branch from dropdown → uses existing branch, hides 'from main'
- Typing a non-matching name and pressing Enter → creates new branch
- Auto-generation via magic wand still works when input is empty

Benefits:
- Simpler, more intuitive UX - no mode switching required
- Natural discovery of existing branches while typing
- Consistent behavior whether creating or reusing branches

Technical:
- New BranchNameInput component with Popover-based autocomplete
- CreationControls simplified (removed mode toggle, branch picker integration)
- Trunk branch selector hidden when existing branch is selected

Signed-off-by: Thomas Kosiewski <[email protected]>

---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking: `high`_

Change-Id: I1dd55befbd7c2902fc2ae7e095925776e6534504
- Show dropdown immediately when input is focused (not just when typing)
- Add 'Create new branch' option at top when input doesn't match existing
- Keep dropdown open while focused with existing branches visible
- Remove 'Press Enter' hint since the create option makes it clear

Change-Id: Id6c23e41008a9623762b0c6ec929038c775f140b
Signed-off-by: Thomas Kosiewski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant