Skip to content

Commit 5c93d22

Browse files
authored
Fix system message to conditionally describe workspace type (#436)
System message incorrectly stated all workspaces are git worktrees. With SSHRuntime, workspaces can be either worktrees (LocalRuntime) or regular git clones (SSHRuntime). ## Changes ### System Message Fix (based on review feedback) - `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 - Uses `runtime instanceof LocalRuntime` - cleaner than git detection - Added test to verify different messages for different runtimes ### Worktree Reference Audit - Updated 30+ user-facing references from 'worktree' to 'workspace' - Fixed documentation (workspaces.md, intro.md, fork.md, system-prompt.md, AGENTS.md) - Updated UI components (NewWorkspaceModal, ForceDeleteModal, Modal.stories) - Fixed comments in types, config, and service files - Kept 170+ accurate references (git commands, LocalRuntime specifics) ## Testing - ✅ All tests passing (6/6 in systemMessage.test.ts) - ✅ New test: verifies LocalRuntime vs SSHRuntime produce different messages ## Result The codebase now correctly distinguishes: - **Workspace** - Generic term for isolated development environments - **Git worktree** - Specific LocalRuntime implementation - **Git clone** - Specific SSHRuntime implementation --- **Files changed**: 17 files, +107 insertions, -36 deletions
1 parent 611a180 commit 5c93d22

File tree

15 files changed

+50
-35
lines changed

15 files changed

+50
-35
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/instruction-files.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22

33
## Overview
44

5-
cmux layers instructions from two sources:
5+
cmux layers instructions from two locations:
66

7-
1. **Global**: `~/.cmux/AGENTS.md` (+ optional `AGENTS.local.md`) — always included
8-
2. **Project**: Either workspace OR project AGENTS.md (not both):
9-
- **Workspace**: `<workspace>/AGENTS.md` (+ optional `AGENTS.local.md`) — if exists
10-
- **Project**: `<project>/AGENTS.md` (+ optional `AGENTS.local.md`) — fallback if workspace doesn't exist
7+
1. `~/.cmux/AGENTS.md` (+ optional `AGENTS.local.md`) — global defaults
8+
2. `<workspace>/AGENTS.md` (+ optional `AGENTS.local.md`) — workspace-specific context
119

1210
Priority within each location: `AGENTS.md``AGENT.md``CLAUDE.md` (first match wins). If the base file is found, cmux also appends `AGENTS.local.md` from the same directory when present.
1311

14-
**Fallback behavior**: Workspace instructions **replace** project instructions (not layered). If a workspace doesn't have AGENTS.md, the project root's AGENTS.md is used. This is particularly useful for SSH workspaces where files may not be fully cloned yet.
15-
1612
## Mode Prompts
1713

1814
> Use mode-specific sections to optimize context and customize the behavior specific modes.
@@ -23,7 +19,7 @@ cmux reads mode context from sections inside your instruction files. Add a headi
2319

2420
Rules:
2521

26-
- Project instructions (workspace or project fallback) are checked first, then global instructions
22+
- Workspace instructions are checked first, then global instructions
2723
- The first matching section wins (at most one section is used)
2824
- The section's content is everything until the next heading of the same or higher level
2925
- Missing sections are ignored (no error)

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>"}`

0 commit comments

Comments
 (0)