🤖 fix: persist runtimeConfig when forking local workspaces #1863
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix local workspace fork creating corrupt worktree workspaces by persisting
runtimeConfiginconfig.addWorkspace(), then simplify the codebase by removing redundant inline fallbacks.Background
PR #1721 (commit 4238ff4) added fork support for local (project-dir) workspaces. The
LocalRuntime.forkWorkspace()was correctly implemented to return the project path, andworkspaceService.fork()correctly assembled theFrontendWorkspaceMetadatawithruntimeConfig: forkedRuntimeConfig.However, when
config.addWorkspace()stored the forked workspace entry, it discarded the runtimeConfig field:On subsequent config loads,
getAllWorkspaceMetadata()would see noruntimeConfigand applyDEFAULT_RUNTIME_CONFIG(type: "worktree" with srcBaseDir), causing the forked workspace to be treated as a worktree runtime. This created "corrupt worktree" errors because WorktreeRuntime operations would fail on directories that were never set up as git worktrees.Implementation
Commit 1: Fix runtimeConfig persistence
One-line fix: include
runtimeConfig: metadata.runtimeConfigin the workspace entry when callingaddWorkspace().Commit 2: Remove redundant fallbacks
The config layer already guarantees every
WorkspaceMetadatahas aruntimeConfig(viaDEFAULT_RUNTIME_CONFIGapplied ingetAllWorkspaceMetadata()). This commit removes 13 inline?? { type: "local", srcBaseDir }fallbacks across 5 service files that were:type: "local"while the canonical default istype: "worktree"Files cleaned up:
workspaceService.ts(5 locations)agentSession.ts(5 locations)aiService.ts,terminalService.ts,workspaceMcpOverridesService.ts(1 each)Commit 3: Fix namedWorkspacePath persistence (Codex review feedback)
config.addWorkspace()was hardcoding worktree-style paths (~/.mux/src/...) even for local workspaces. After app restart, this caused Open-in-Editor and path display to use the wrong directory.Fix: use
namedWorkspacePathfrom the metadata if provided (which is computed runtime-aware byRuntime.getWorkspacePath()), falling back to worktree-style path only for legacy callers.Validation
namedWorkspacePathis the project path (not~/.mux/src/...) after reloadmake typecheckpassesmake static-checkpassesTEST_INTEGRATION=1 bun x jest tests/ipc/forkWorkspace.test.ts- all 9 tests passGenerated with
mux· Model:anthropic:claude-sonnet-4-20250514