feat: add Profiles — save and restore workspace layouts
Summary
-
What changed? Adds a Profiles feature that lets users save their current workspace layout as a named profile (e.g. "Work", "Personal") and restore it later — either in the current window or a new one. Think of it like VS Code workspaces: a preset of terminals, splits, and browser panels you can switch between.
-
Why? Power users often have distinct contexts — a "Work" setup with API server, frontend, and test workspaces, and a "Personal" setup with side projects. Today, these have to be manually recreated each time. Profiles make this a one-click operation.
What's included
| Component | Details |
|---|---|
Sources/ProfileStore.swift | Profile model + ProfileStore persistence layer (save/load/delete/rename/list as JSON in ~/Library/Application Support/cmux/profiles/) |
Sources/cmuxApp.swift | File → Workspace → Profiles submenu (save, load in new window / current window, delete) |
Sources/ContentView.swift | Sidebar footer badge showing active profile name, inline next to the ? help button |
Sources/AppDelegate.swift | Auto-save active profiles on existing 8s timer + app termination (with scrollback) |
Sources/TabManager.swift | activeProfileName published property — persists across workspace changes |
Sources/TerminalController.swift | Socket commands: profile.list, profile.save, profile.load, profile.delete (v1 + v2) |
cmuxTests/ProfileStoreTests.swift | 18 unit tests |
Socket/CLI API
v1:
profile_list
profile_save <name>
profile_load <name> [--new-window]
profile_delete <name>
v2 JSON:
profile.list → {profiles: [...], count: N}
profile.save {name, include_scrollback?} → {id, name, workspace_count}
profile.load {name, new_window?} → {name, window_id, workspace_count, mode}
profile.delete {name} → {name, deleted}
How it works
Profiles are a thin layer on top of the existing SessionTabManagerSnapshot — the same system powering session restore on app restart. Saving calls tabManager.sessionSnapshot(), loading calls tabManager.restoreSessionSnapshot(). Auto-save piggybacks on the existing 8-second autosave timer.
Testing
- Unit tests: 18 tests in
ProfileStoreTestscovering Codable round-trip, save/load/delete/rename, list sorting, filename sanitization, active profile state, snapshot field preservation, edge cases. All passing. - Manual verification: Tested all socket commands (v1 + v2) via raw socket — save, load (both modes), delete, list, error cases. Verified auto-save updates profile after workspace changes. Verified sidebar badge appears/disappears correctly.
Demo Video
Screenshot (badge visible in sidebar footer):
The active profile badge sits inline next to the ? button in the sidebar footer, showing the currently loaded profile name (e.g. "Work"). It appears when a profile is loaded and persists across workspace additions/removals since changes auto-save back to the profile.
Checklist
- I tested the change locally
- I added or updated tests for behavior changes
- I updated docs/changelog if needed
- I requested bot reviews after my latest commit (copy/paste block above or equivalent)
- All code review bot comments are resolved
- All human review comments are resolved
Summary by cubic
Add Profiles to save the current workspace layout as a named profile and restore it in the current window or a new one. Makes switching between work/personal setups a one-click action.
- New Features
ProfileStore: save/load/delete/rename/list profiles as JSON in ~/Library/Application Support/cmux/profiles/ (max 24).- Menu: File → Workspace → Profiles with save, load (current/new window), delete, and delete-all.
- UI: sidebar badge shows the active profile name.
- Autosave: active profiles auto-save on the existing 8s timer and on app quit (includes scrollback).
- Socket/CLI: v1
profile_list,profile_save,profile_load [--new-window],profile_delete; v2profile.list|save|load|deleteJSON APIs. TabManager: newactiveProfileNamepublished property.- Tests: 18 unit tests for model, persistence, and integration.
Summary by CodeRabbit
-
New Features
- Profile management system: save, load, rename, and delete named workspace profiles
- Active profile indicator displayed in sidebar footer
- Profiles menu for quick access to profile operations
- Terminal commands for profile management automation
- Auto-save of active profiles on application termination
-
Tests
- Added comprehensive unit tests for profile functionality and persistence