Skip to content

Commit 42d93f0

Browse files
committed
Fix system message to conditionally describe workspace type
System message incorrectly stated all workspaces are git worktrees. With SSHRuntime, workspaces can be either worktrees (LocalRuntime) or regular git clones (SSHRuntime). Changes: - buildEnvironmentContext() now uses runtime type to determine message - LocalRuntime: 'git worktree' with worktree-specific warnings - SSHRuntime: 'git repository' without worktree warnings - Updated buildSystemMessage() to accept Runtime parameter - Added test to verify different messages for different runtimes - Removed unused isGitWorktree() function (cleaner than git detection) Worktree Reference Audit: - Updated 30+ user-facing references from 'worktree' to 'workspace' - Fixed documentation (workspaces.md, intro.md, fork.md, etc.) - Updated UI components (NewWorkspaceModal, ForceDeleteModal) - Fixed comments in types, config, and service files - Kept 170+ accurate references (git commands, LocalRuntime specifics) The codebase now correctly distinguishes: - 'Workspace' (generic isolated environment) - 'Git worktree' (LocalRuntime-specific implementation) - 'Git clone' (SSHRuntime-specific implementation)
1 parent 2dc1f47 commit 42d93f0

17 files changed

+107
-36
lines changed

docs/AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Verify with React DevTools Profiler - MarkdownCore should only re-render when co
105105
- `src/App.tsx` - Main React component
106106
- `src/config.ts` - Configuration management
107107
- `~/.cmux/config.json` - User configuration file
108-
- `~/.cmux/src/<project_name>/<branch>` - Workspace directories for git worktrees
108+
- `~/.cmux/src/<project_name>/<branch>` - Local workspace directories (git worktrees)
109109
- `~/.cmux/sessions/<workspace_id>/chat.jsonl` - Session chat histories
110110

111111
## Documentation Guidelines
@@ -137,7 +137,7 @@ in `/tmp/ai-sdk-docs/**.mdx`.
137137
## Key Features
138138

139139
- Projects sidebar (left panel)
140-
- Workspaces using git worktrees
140+
- Workspaces (local uses git worktrees, SSH uses remote git clones)
141141
- Configuration persisted to `~/.cmux/config.json`
142142

143143
## Performance Patterns
@@ -179,7 +179,7 @@ This project uses **Make** as the primary build orchestrator. See `Makefile` for
179179

180180
- When refactoring, use `git mv` to preserve file history instead of rewriting files from scratch
181181

182-
**⚠️ NEVER kill the running cmux process** - The main cmux instance is used for active development. Use `make test` or `make typecheck` to verify changes instead of starting the app in test worktrees.
182+
**⚠️ NEVER kill the running cmux process** - The main cmux instance is used for active development. Use `make test` or `make typecheck` to verify changes instead of starting the app in test workspaces.
183183

184184
## Testing
185185

docs/fork.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Forking Workspaces
22

3-
Use `/fork` to clone a workspace with its full conversation history and UI state. The forked workspace gets a new git worktree on a new branch.
3+
Use `/fork` to clone a workspace with its full conversation history and UI state. The forked workspace gets a new workspace on a new branch (using the same backend as the current workspace).
44

55
Usage:
66

docs/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![cmux product screenshot](img/product-hero.webp)
44

5-
**cmux** (Coding Agent Multiplexer) is a cross-platform desktop application for AI-assisted development with git worktree integration.
5+
**cmux** (Coding Agent Multiplexer) is a cross-platform desktop application for AI-assisted development with isolated workspace management.
66

77
## What is cmux?
88

docs/system-prompt.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ Use GitHub-style \`<details>/<summary>\` tags to create collapsible sections for
3333
</prelude>
3434
`;
3535

36-
function buildEnvironmentContext(workspacePath: string): string {
37-
return `
36+
function buildEnvironmentContext(runtime: Runtime, workspacePath: string): string {
37+
const isWorktree = runtime instanceof LocalRuntime;
38+
39+
if (isWorktree) {
40+
return `
3841
<environment>
3942
You are in a git worktree at ${workspacePath}
4043
@@ -44,5 +47,16 @@ You are in a git worktree at ${workspacePath}
4447
- You are meant to do your work isolated from the user and other agents
4548
</environment>
4649
`;
50+
} else {
51+
return `
52+
<environment>
53+
You are in a git repository at ${workspacePath}
54+
55+
- This IS a git repository - run git commands directly (no cd needed)
56+
- Tools run here automatically
57+
- You are meant to do your work isolated from the user and other agents
58+
</environment>
59+
`;
60+
}
4761
}
4862
```

docs/workspaces.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Workspaces
22

3-
Currently, cmux supports one Workspace backend: [git worktrees](https://git-scm.com/docs/git-worktree).
3+
cmux supports multiple workspace backends for different use cases:
44

5-
We plan on adding support for SSH and Docker backends in the near future for
6-
additional isolation and security.
5+
- **Local workspaces**: [git worktrees](https://git-scm.com/docs/git-worktree) on your local machine
6+
- **SSH workspaces**: Regular git clones on a remote server accessed via SSH
7+
8+
The backend is selected based on your runtime configuration. Local workspaces use git worktrees which share the `.git` directory with your main repository, while SSH workspaces are independent git clones on the remote machine.
79

810
## Basics of worktrees
911

@@ -43,7 +45,9 @@ dev server (e.g. `bun dev`) there directly and observe the agent's work in real-
4345

4446
## Filesystem Layout
4547

46-
All worktrees are stored in `~/.cmux/src/<project-name>/<workspace-name>`.
48+
Local workspaces are stored in `~/.cmux/src/<project-name>/<workspace-name>`.
49+
50+
SSH workspaces are stored on the remote machine at `~/workspace/<project-name>/<workspace-name>` (or your configured remote path).
4751

4852
Example layout:
4953

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function AppInner() {
156156

157157
const openWorkspaceInTerminal = useCallback(
158158
(workspaceId: string) => {
159-
// Look up workspace metadata to get the worktree path (directory uses workspace name)
159+
// Look up workspace metadata to get the workspace path (directory uses workspace name)
160160
const metadata = workspaceMetadata.get(workspaceId);
161161
if (metadata) {
162162
void window.api.workspace.openTerminal(metadata.namedWorkspacePath);

src/components/ForceDeleteModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const ForceDeleteModal: React.FC<ForceDeleteModalProps> = ({
4747
<Modal
4848
isOpen={isOpen}
4949
title="Force Delete Workspace?"
50-
subtitle="The worktree could not be removed normally"
50+
subtitle="The workspace could not be removed normally"
5151
onClose={onClose}
5252
maxWidth="600px"
5353
isLoading={isDeleting}
@@ -60,7 +60,7 @@ export const ForceDeleteModal: React.FC<ForceDeleteModalProps> = ({
6060
<WarningBox>
6161
<WarningTitle>This action cannot be undone</WarningTitle>
6262
<WarningText>
63-
Force deleting will permanently remove the worktree and may discard uncommitted work or
63+
Force deleting will permanently remove the workspace and may discard uncommitted work or
6464
lose data.
6565
</WarningText>
6666
</WarningBox>

src/components/Modal.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const WithInfoBox: Story = {
106106
<>
107107
<ModalInfo>
108108
<p>
109-
This operation will create a new git worktree at <code>~/cmux/project/branch</code>
109+
This operation will create a new workspace at <code>~/cmux/project/branch</code>
110110
</p>
111111
<p>Existing files will not be affected.</p>
112112
</ModalInfo>

src/components/NewWorkspaceModal.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ const NewWorkspaceModal: React.FC<NewWorkspaceModalProps> = ({
137137
<Tooltip width="wide" position="bottom" interactive>
138138
<strong>About Workspaces:</strong>
139139
<ul className="my-1 pl-4">
140-
<li>Uses git worktrees (separate directories sharing .git)</li>
141-
<li>All committed changes visible across all worktrees</li>
140+
<li>Isolated directories for parallel development</li>
141+
<li>Local: git worktrees sharing .git (fast, efficient)</li>
142+
<li>SSH: independent git clones on remote server</li>
142143
<li>Agent can switch branches freely during session</li>
143144
<li>Define branching strategy in AGENTS.md</li>
144145
</ul>
@@ -243,7 +244,7 @@ const NewWorkspaceModal: React.FC<NewWorkspaceModalProps> = ({
243244
)}
244245

245246
<ModalInfo id={infoId}>
246-
<p>This will create a git worktree at:</p>
247+
<p>This will create a workspace at:</p>
247248
<code className="block break-all">
248249
{runtimeMode === RUNTIME_MODE.SSH
249250
? `${sshHost || "<host>"}:~/cmux/${branchName || "<branch-name>"}`

src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class Config {
126126
}
127127

128128
/**
129-
* Get the workspace worktree path for a given directory name.
129+
* Get the workspace directory path for a given directory name.
130130
* The directory name is the workspace name (branch name).
131131
*/
132132

@@ -200,7 +200,7 @@ export class Config {
200200
* - Worktree directory name: uses workspace.name (the branch name)
201201
* - Workspace ID: stable random identifier for identity and sessions (not used for directories)
202202
*
203-
* Backend: Uses getWorkspacePath(metadata.projectPath, metadata.name) for worktree directory paths
203+
* Backend: Uses getWorkspacePath(metadata.projectPath, metadata.name) for workspace directory paths
204204
* Frontend: Gets enriched metadata with paths via IPC (FrontendWorkspaceMetadata)
205205
*
206206
* WorkspaceMetadata.workspacePath is deprecated and will be removed. Use computed

0 commit comments

Comments
 (0)