Skip to content

feat: switch a worktree to another profile after creation - #302

Merged
diegoimbert merged 3 commits into
mainfrom
feat/switch-worktree-profile
Jul 29, 2026
Merged

feat: switch a worktree to another profile after creation#302
diegoimbert merged 3 commits into
mainfrom
feat/switch-worktree-profile

Conversation

@diegoimbert

Copy link
Copy Markdown
Contributor

Summary

Picking full / frontendOnly / agentOnly at creation time used to be permanent — the profile was baked into the worktree's metadata and never revisited. This adds a profile switch: change your mind later and the worktree is rebuilt with that profile's tmux layout and pane commands, resuming the agent conversation rather than starting it over.

When the worktree is open, its tmux window is torn down and recreated from the new profile's pane templates (splits, sizes, command panes and their startup commands). When it's closed, the metadata is updated and the new layout applies on the next open. Leaving a docker profile removes the container first — containers are keyed by branch and reused on launch, so a stale one would otherwise be re-adopted by the next profile.

Changes

  • Contract: PUT /api/worktrees/:name/profile with SetWorktreeProfileRequest/Response ({ profile, restarted }).
  • Backend: LifecycleService.setWorktreeProfile() — validates the profile (400 on unknown), requires managed metadata (409), persists profile + runtime, tears down a docker container when leaving a docker profile, and delegates to the existing open path so the layout rebuild and agent resume reuse one code path. No-ops when the profile is unchanged.
  • Frontend: new WorktreeProfileDialog, opened from "Change profile…" in the sidebar row menu. Tells you whether the switch restarts the session now or applies on next open; remounts the terminal after a restart.
  • CLI: webmux profile <branch> <profile> (also --profile=<name>), wired into help, dispatch, and bash/zsh completions.
  • Dev fix (second commit): the vite dev proxy only matched /api and /ws at the root, but since feat: serve all projects from one webmux dashboard on one port #271 every project's calls go to /<prefix>/api/.... Vite was serving index.html for those instead of proxying, breaking the dev dashboard for any project. The proxy contexts are now regexes matching both forms.

Test plan

  • bun run test — 484 backend / 4 contract / 183 CLI / 141 frontend, all green; bun run --cwd backend check and bun run --cwd frontend check clean
  • New backend tests cover: open worktree rebuilt with the new profile's panes, closed worktree deferring to next open, docker teardown on leaving a docker profile, unchanged-profile no-op, unknown profile rejected
  • Real tmux smoke test in a scratch repo: 1-pane profile → 3-pane profile produced the right splits with both command panes running their startup commands; switching back collapsed to 1 pane; a closed worktree picked up the new layout on reopen
  • In the UI: ⋮ on a worktree → "Change profile…" → switch agentOnlyfull and confirm the backend/frontend panes come up and the agent resumes
  • From the CLI: webmux profile <branch> full, then webmux profile <branch> agentOnly
  • Dev proxy: ./dev.sh and confirm the dashboard loads and the terminal WebSocket connects under /<prefix>/

Note: the rebuild recreates the window, so panes split manually outside the profile are not preserved. A profile's systemPrompt still only applies on a fresh agent launch, so a resumed agent isn't re-prompted.


Generated with Claude Code

https://claude.ai/code/session_01Vx7XU35JjpJ26Rcn4jTKWB

diegoimbert and others added 2 commits July 29, 2026 11:55
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vx7XU35JjpJ26Rcn4jTKWB
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vx7XU35JjpJ26Rcn4jTKWB
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
webmux 7bb7819 Commit Preview URL

Branch Preview URL
Jul 29 2026, 10:04 AM

@diegoimbert
diegoimbert marked this pull request as ready for review July 29, 2026 10:00
…profile

# Conflicts:
#	bin/src/completions.ts
#	bin/src/webmux.ts
#	bin/src/worktree-commands.ts
#	frontend/src/App.svelte
#	frontend/src/lib/WorktreeList.svelte
@diegoimbert
diegoimbert merged commit 2c320ef into main Jul 29, 2026
2 checks passed
@diegoimbert
diegoimbert deleted the feat/switch-worktree-profile branch July 29, 2026 22:24
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.

1 participant