feat(remote): provision daemon-created worktrees like the desktop#90
Merged
Zeus-Deus merged 1 commit intoJun 9, 2026
Conversation
The headless daemon's worktree_create tool now runs the same post-create pipeline as the desktop (issue #78): gitignored include files are copied from the parent repo before the tool returns, and the project's .codemux/config.json setup commands run on a background thread with the standard CODEMUX_* env and the deterministic per-workspace port. Combined with the existing fetch-before-branch in remote/git.rs, remote-created workspaces are provisioned and start from the freshly-fetched origin tip. - extract a UI-free run_setup_commands core in scripts.rs; the desktop's run_setup_scripts_with_config is now a thin wrapper that forwards SetupEvents as the unchanged Tauri events - provision_worktree_workspace in remote/tools/mod.rs wires the shared core into the daemon: includes copy runs inline, setup commands run detached, progress logs to stderr, and a failing setup script never fails the tool; the response gains a `setup` summary ({port, includes_copied, setup_commands, setup_running}) - isolate HOME in the serve-test fixture so the integration suite stops rewriting the developer's real agent configs with paths to transient debug binaries - scope the project_codemux_entry_is_filtered_out assertions to project-level sources so a legitimate user-level codemux entry no longer fails the discovery test - cover the parity end-to-end: unit tests for env/includes/graceful paths plus a stale-clone HTTP integration test against the real daemon
This was referenced Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #78
Summary
The headless daemon's
worktree_createMCP tool now runs the same post-create pipeline as the desktop, so workspaces created on a remote host are provisioned (deps,.env, env vars, port) and start from the latest remote commit.crate::scripts::run_setup_commandsis a new UI-free extraction of the setup-command loop. The desktop'srun_setup_scripts_with_configis now a thin wrapper that forwardsSetupEvents as the unchanged Tauri events — one command loop for both paths, no duplication.remote/tools/mod.rs::provision_worktree_workspace):.env& co,.codemuxinclude→ defaults) are copied from the parent repo synchronously, before the tool returns.codemux/config.jsonsetup commands run on a detached background thread withCODEMUX_ROOT_PATH/CODEMUX_WORKSPACE_PATH/CODEMUX_BRANCH/CODEMUX_PORT(+NAME/ID), using the same deterministicallocate_workspace_portas the desktopsetupsummary:{port, includes_copied, setup_commands, setup_running}remote/git.rs([git] Fetch origin before creating a new workspace branch so it starts from the latest remote #76 parity); this PR covers it end-to-end through the daemon.HOME, so the integration suite stops rewriting the developer's real agent configs (~/.claude.json, …) with paths to transient debug binaries. Thecommands::mcpdiscovery test is scoped to project-level sources so a legitimate user-level codemux entry no longer fails it.Headless config is file-based only (
.codemux/config.jsonin worktree → repo root) — the Settings-UI fallback lives in the desktop SQLite DB, which doesn't exist on a headless host.Acceptance criteria
origin/<base>CODEMUX_*env vars + a unique port are present for remote workspacesTesting
remote/tools/mod.rs): setup script runs with correctCODEMUX_*env + reported port,.envcopied; no-config repo reportssetup_commands: 0; failing setup script doesn't fail the tool.tests/codemux_remote_serve_mcp.rs::http_worktree_create_provisions_like_desktop): real daemon over HTTP with a stale-clone scenario — new branch lands on the freshly-fetched origin tip (not the stale local ref), includes copied, setup marker written with correct env.codemux-remoteand ran it in an Arch container as the remote host, driven over HTTP with curl — verified fresh-tip branching,.envcopy, env marker, sequential multi-command setup, graceful no-config repo, and offline-origin fallback.npm run verifyfully green (all cargo suites, typecheck, 1826 frontend tests).Docs updated:
docs/core/STATUS.md,docs/features/setup-teardown.md(§ Headless Daemon Parity),docs/features/worktree-setup.md,docs/features/remote-hosts.md,docs/plans/mcp-on-remote.md.