Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Summary

Adds explicit runtime type distinction between Local (project-directory) and Worktree (isolated git worktrees):

  • Local runtime: Uses project directory directly, no isolation. Creation is a no-op (just "use this directory"), delete is a no-op (won't delete user's project). Good for existing repos where user wants to work in-place.

  • Worktree runtime: Creates isolated git worktrees under ~/.mux/src/<project>/<branch>. Existing behavior, now made explicit.

  • SSH runtime: Unchanged, remote execution.

Changes

  • RuntimeMode now includes "local" | "worktree" | "ssh"
  • Extracted LocalBaseRuntime for shared exec/file operations between Local and Worktree
  • LocalRuntime uses project path directly (no-op create/delete)
  • WorktreeRuntime manages git worktrees (renamed from old LocalRuntime)
  • UI shows Local/Worktree/SSH options in creation controls
  • Updated VS Code extension to handle all runtime types with appropriate icons
  • Runtime badges: SSH (server icon), Worktree (git branch icon), Local (no badge)

Backward Compatibility

  • type: "local" with srcBaseDir = legacy worktree config (still works)
  • type: "local" without srcBaseDir = new project-dir runtime
  • type: "worktree" = explicit worktree (new workspaces)

Users can upgrade/downgrade without breaking existing workspaces.

Generated with mux

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ 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".

@ammar-agent ammar-agent force-pushed the runtime-local-worktree-refactor branch 2 times, most recently from 4c481c4 to cc384a9 Compare December 1, 2025 17:38
ammar-agent added a commit that referenced this pull request Dec 1, 2025
When users upgrade to a version with new runtime types (like 'local' without
srcBaseDir for project-dir mode, or new 'worktree' type) and then downgrade,
the old version should show a clear error instead of crashing.

Changes:
- Add IncompatibleRuntimeError for workspaces from newer mux versions
- Add isIncompatibleRuntimeConfig helper to detect future configs
- Add 'incompatible_workspace' SendMessageError type
- Handle error in sendMessage/resumeStream handlers
- Show helpful toast with 'upgrade mux' suggestion
- Mark incompatible_workspace as non-retryable

This prepares for #824 (Local/Worktree runtime distinction) by ensuring
users can safely downgrade without losing access to their other workspaces.
ammar-agent added a commit that referenced this pull request Dec 1, 2025
When users upgrade to a version with new runtime types (like 'local' without
srcBaseDir for project-dir mode, or new 'worktree' type) and then downgrade,
the old version shows a clear error instead of crashing.

Changes:
- Add IncompatibleRuntimeError for workspaces from newer mux versions
- Add isIncompatibleRuntimeConfig helper to detect future configs
- Add incompatibleRuntime field to FrontendWorkspaceMetadata
- Show error in AIView when workspace is incompatible
- Add 'incompatible_workspace' SendMessageError type as fallback
- Mark incompatible_workspace as non-retryable

This prepares for #824 (Local/Worktree runtime distinction) by ensuring
users can safely downgrade without losing access to their other workspaces.
ammar-agent added a commit that referenced this pull request Dec 1, 2025
When users upgrade to a version with new runtime types (like 'local' without
srcBaseDir for project-dir mode, or new 'worktree' type) and then downgrade,
the old version shows a clear error instead of crashing.

Changes:
- Add IncompatibleRuntimeError for workspaces from newer mux versions
- Add isIncompatibleRuntimeConfig helper to detect future configs
- Add incompatibleRuntime field to FrontendWorkspaceMetadata
- Show error in AIView when workspace is incompatible
- Add 'incompatible_workspace' SendMessageError type as fallback
- Mark incompatible_workspace as non-retryable

This prepares for #824 (Local/Worktree runtime distinction) by ensuring
users can safely downgrade without losing access to their other workspaces.
ammario pushed a commit that referenced this pull request Dec 1, 2025
…827)

## Summary

Prepares for #824 by ensuring users can safely upgrade→downgrade without
losing access to their other workspaces.

When users upgrade to a version with new runtime types (like `type:
"local"` without `srcBaseDir` for project-dir mode, or new `type:
"worktree"`) and then downgrade, the old version now shows a clear error
instead of crashing.

## Changes

| File | Change |
|------|--------|
| `src/common/utils/runtimeCompatibility.ts` | New:
`isIncompatibleRuntimeConfig()` helper (in common/ to avoid circular
deps) |
| `src/common/types/workspace.ts` | Added `incompatibleRuntime` field to
`FrontendWorkspaceMetadata` |
| `src/node/config.ts` | Set `incompatibleRuntime` when loading
workspace metadata |
| `src/browser/components/AIView.tsx` | Display error view for
incompatible workspaces |
| `src/browser/App.tsx` | Pass `incompatibleRuntime` to AIView |
| `src/node/runtime/runtimeFactory.ts` | Re-export helper + throw
`IncompatibleRuntimeError` as safety net |
| `src/node/services/ipcMain.ts` | Handle `IncompatibleRuntimeError` in
sendMessage (fallback) |
| `src/common/types/errors.ts` | Added `incompatible_workspace`
SendMessageError type |

## User Experience

When clicking into an incompatible workspace, users see a centered error
view:

> ⚠️ **Incompatible Workspace**  
> This workspace was created with a newer version of mux.  
> Please upgrade mux to use this workspace.  
>  
> You can delete this workspace and create a new one, or upgrade mux to
use it.

## Testing

- Added unit tests for `isIncompatibleRuntimeConfig()`
- Added unit tests for `createRuntime()` throwing on incompatible
configs
- Added tests for error toast display (fallback path)
- Added tests for non-retryable error classification

_Generated with `mux`_
@ammar-agent ammar-agent force-pushed the runtime-local-worktree-refactor branch 2 times, most recently from eaa56ed to c9168b7 Compare December 1, 2025 20:15
- Add explicit 'worktree' RuntimeMode alongside 'local' and 'ssh'
- Local runtime uses project directory directly (no isolation)
- Worktree runtime creates isolated git worktrees (existing behavior)
- Extract LocalBaseRuntime for shared exec/file operations
- Update UI to show Local/Worktree/SSH options in creation controls
- Maintain backward compatibility: legacy local+srcBaseDir treated as worktree

_Generated with mux_
@ammar-agent ammar-agent force-pushed the runtime-local-worktree-refactor branch from c9168b7 to 56094dc Compare December 1, 2025 20:16
Add comprehensive test coverage for LocalRuntime:
- Constructor and getWorkspacePath behavior (ignores args, returns project path)
- createWorkspace success/failure cases
- deleteWorkspace no-op behavior (doesn't delete anything)
- renameWorkspace/forkWorkspace unsupported operation errors
- Inherited LocalBaseRuntime methods (exec, stat, resolvePath, normalizePath)

12 new tests covering the project-dir runtime behavior.
Add ConcurrentLocalWarning component that displays a dismissible warning
when:
1. Current workspace uses local project-dir runtime (no isolation)
2. Another workspace for the same project is actively streaming

The warning helps users understand that agents may interfere with each
other when working on the same directory without worktree isolation.

Also adds projectPath prop to AIView to enable this check.
@ammar-agent ammar-agent force-pushed the runtime-local-worktree-refactor branch from e2ee558 to f09ce19 Compare December 1, 2025 20:29
- Reduce icon size from 12x12 to 10x10 (~15% smaller)
- Redesign worktree icon to be vertically oriented like SSH icon
- Improve SSH icon with visible indicator dots
- Both icons now have similar visual weight and shape
@ammar-agent ammar-agent force-pushed the runtime-local-worktree-refactor branch 13 times, most recently from 9df61c3 to d85230d Compare December 1, 2025 21:10
@ammar-agent ammar-agent force-pushed the runtime-local-worktree-refactor branch from d85230d to 1a9f8c2 Compare December 1, 2025 21:11
@ammar-agent ammar-agent force-pushed the runtime-local-worktree-refactor branch from 1a9f8c2 to 1eb3e2a Compare December 1, 2025 21:14
Bug fixes:
- Delete workspace filters by ID instead of path. For local project-dir
  runtimes, all workspaces share the same path (project dir), so filtering
  by path was deleting ALL local workspaces when one was deleted.
- WorkspaceHeader now uses metadata.name for display, fixing 'project/project'
  title issue for local runtimes where namedWorkspacePath is the project path.

Docs:
- Split runtime docs into docs/runtime/{local,worktree,ssh}.md
- Add docs/runtime/index.md overview with comparison table
- Update cross-references in workspaces.md and vscode-extension.md

Tests:
- Add integration tests for local project-dir workspace deletion
- Verify only specified workspace is deleted, not all with same path
- Verify project directory is not deleted
@ammar-agent ammar-agent force-pushed the runtime-local-worktree-refactor branch from 1eb3e2a to e3a12fe Compare December 1, 2025 21:16
@ammario ammario merged commit 7087ef4 into main Dec 1, 2025
15 checks passed
@ammario ammario deleted the runtime-local-worktree-refactor branch December 1, 2025 21:20
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.

3 participants