Skip to content

Add isolated dev mode per worktree#138

Merged
realDuang merged 4 commits intomainfrom
feat/dev-isolated-worktree-appdata
Apr 30, 2026
Merged

Add isolated dev mode per worktree#138
realDuang merged 4 commits intomainfrom
feat/dev-isolated-worktree-appdata

Conversation

@realDuang
Copy link
Copy Markdown
Owner

Summary

  • Add bun run dev:isolated to launch per-worktree isolated dev instances using .codemux-dev/ for app data, session data, logs, and persisted port allocation.
  • Split the Electron main entry into an early bootstrap plus app-main so isolated paths are configured before logger/store modules load.
  • Centralize Electron persistence paths and service ports, including CODEMUX_PORT_OFFSET and per-port overrides for Vite, Electron, and Playwright config.

Test plan

  • bun run typecheck
  • bun run test:unit
  • bun run build
  • git diff --check

Closes #137

🤖 Generated with Claude Code

Add a per-worktree dev startup path so developers can run an isolated CodeMux instance without interrupting the normal app session.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 28, 2026 10:00
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 75.38% (🎯 50%) 10849 / 14391
🔵 Statements 74% (🎯 50%) 11552 / 15610
🔵 Functions 71.38% (🎯 50%) 1826 / 2558
🔵 Branches 68.49% (🎯 50%) 6745 / 9847
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
electron/main/ipc-handlers.ts 97.41% 100% 94.44% 97.31% 260, 266, 271-272
electron/main/channels/base-session-mapper.ts 100% 97.91% 100% 100%
electron/main/channels/channel-manager.ts 92.7% 78.65% 90% 92.48% 29, 83-86, 99, 120-127, 183-188
electron/main/channels/feishu/feishu-session-mapper.ts 97.87% 76.59% 97.22% 97.84% 40, 139, 372
electron/main/gateway/ws-server.ts 77.73% 79.23% 52.63% 77.87% 172, 219, 247-252, 376-377, 488-555, 571-574, 585-588, 606-609, 613-616, 620-623, 627-630, 634-637, 641-644, 648-651, 655-658, 669-672, 675-678, 683
electron/main/services/app-paths.ts 93.75% 100% 88.23% 93.54% 34, 61
electron/main/services/conversation-store.ts 75.92% 63.51% 77.41% 77.81% 206-209, 311-337, 395, 512-616, 702-703
electron/main/services/default-workspace.ts 100% 100% 100% 100%
electron/main/services/device-store.ts 100% 100% 100% 100%
electron/main/services/logger.ts 93.75% 65.71% 77.77% 93.75% 15-18, 81-82
electron/main/services/orchestrator-service.ts 93.57% 79.11% 98.18% 95.56% 61, 157-160, 231-232, 267, 312, 316, 333, 338, 382, 406, 420, 458, 510-511
electron/main/services/scheduled-task-service.ts 96.4% 95% 92.85% 97% 102-112, 484, 493
electron/main/services/tunnel-manager.ts 100% 97.72% 100% 100%
electron/main/services/worktree-manager.ts 98.66% 86.58% 100% 98.59% 152, 351
electron/main/services/worktree-store.ts 81.11% 59.09% 88.88% 84.33% 42, 71-84, 111, 142-143, 155, 158, 175-177
src/lib/gateway-client.ts 7.53% 0% 0% 7.93% 137-630
Generated in workflow #448 for commit 13a3ee7 by the Vitest Coverage Report Action

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an “isolated dev mode” intended to let multiple CodeMux worktrees run concurrently by isolating Electron persistence paths under .codemux-dev/ and by centralizing service port selection (with a global offset + per-port overrides) across Electron, Vite, and Playwright.

Changes:

  • Introduces isolated dev launcher (bun run dev:isolated) that allocates/persists a per-worktree port offset and sets isolation env vars.
  • Splits Electron main entry into an early bootstrap (electron/main/index.ts) plus the lifecycle/app wiring (electron/main/app-main.ts) so path overrides are applied before modules like logging load.
  • Centralizes persistence paths (app-paths.ts) and port configuration (shared/ports.ts), and updates configs/proxies accordingly.

Reviewed changes

Copilot reviewed 29 out of 31 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vitest.config.ts Excludes app-main.ts from unit runs (Electron lifecycle needs real app).
vite.config.ts Uses centralized ports for standalone dev server + proxies.
tests/unit/shared/ports.test.ts Adds unit tests for offset + per-port override behavior.
tests/unit/scripts/dev-isolated.test.ts Adds unit tests for isolated port plan construction.
tests/unit/electron/services/app-paths.test.ts Tests isolated path redirection under .codemux-dev/.
tests/unit/electron/ipc-handlers.test.ts Updates mocks to reflect app-main split.
src/lib/gateway-client.ts Updates comments about dev/prod WS URL behavior.
shared/ports.ts Implements env-driven ports with global offset + per-port overrides.
scripts/dev-isolated.ts Implements isolated dev port allocation + spawn of bun run dev.
playwright.config.ts Uses centralized WEB_PORT for baseURL default.
package.json Adds dev:isolated script and cross-env dev dependency.
electron/main/services/worktree-store.ts Uses centralized worktree persistence path.
electron/main/services/worktree-manager.ts Uses centralized worktree persistence path.
electron/main/services/tunnel-manager.ts Writes cloudflared config under centralized userData path.
electron/main/services/scheduled-task-service.ts Uses centralized scheduled tasks persistence path.
electron/main/services/orchestrator-service.ts Uses centralized orchestrations persistence path.
electron/main/services/logger.ts Uses centralized logs + settings paths; supports isolated logs dir.
electron/main/services/device-store.ts Uses centralized devices path + shared-vs-isolated dev behavior.
electron/main/services/default-workspace.ts Re-exports centralized default workspace path helper.
electron/main/services/conversation-store.ts Uses centralized conversations persistence path.
electron/main/services/app-paths.ts New: centralized persistence path helpers + isolated dev path setup.
electron/main/ipc-handlers.ts Imports startup/channel exports from app-main; reports isolated userData.
electron/main/index.ts New early bootstrap: configure isolated paths before importing app-main.
electron/main/gateway/ws-server.ts Reads settings via centralized settings path.
electron/main/channels/feishu/feishu-session-mapper.ts Uses centralized channel bindings path.
electron/main/channels/channel-manager.ts Uses centralized channel config paths.
electron/main/channels/base-session-mapper.ts Uses centralized channel bindings path.
electron/main/app-main.ts New: main-process lifecycle wiring moved from index.ts.
electron.vite.config.ts Uses centralized ports for dev server + proxy targets.
bun.lock Locks new cross-env dependency and transitive updates.
.gitignore Ignores .codemux-dev/ workspace-local isolated state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread shared/ports.ts
Comment thread scripts/dev-isolated.ts
Comment thread electron/main/channels/channel-manager.ts Outdated
@FridayLiu
Copy link
Copy Markdown
Collaborator

Very good update, I've always want it.

Comment thread scripts/dev-isolated.ts
Comment thread scripts/dev-isolated.ts Outdated
Comment thread shared/ports.ts Outdated
Comment thread scripts/dev-isolated.ts
Comment thread package.json
realDuang and others added 2 commits April 30, 2026 16:10
Tighten port validation and reservation behavior so isolated dev startup fails early on invalid or conflicting plans, and document the worktree workflow for contributors.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add targeted Electron device-store tests and keep the incremental coverage source filter aligned with the existing app-main lifecycle exclusion.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@realDuang realDuang merged commit 327b578 into main Apr 30, 2026
16 checks passed
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.

Support isolated multi-instance dev mode per worktree

3 participants