Repository navigation
Description
What are you trying to do?
I want "save this workspace" to mean save what my setup was doing, not just the shape of it.
Today I can save a workspace and get the split layout and each pane's cwd back. But every pane
10BC8
comes back as a bare prompt, so after a restore I still hand-run the same ritual: start the API, start the web app, start the worker, bring up docker, launch claude in the agent pane, then open the browser panel on the right localhost URL. For a single service that's annoying. For a monorepo it's five different commands in five different folders that I have to remember the order of. At that point the saved workspace is a folder bookmark with a layout attached — it is not the setup I meant to save.
What I actually want is one named, reusable, checked-into-the-repo definition: panes + their cwds + the command each one runs + the browser tabs it needs, so that wmux workspace open <name> brings the entire dev environment up, and so a teammate who clones the repo gets the identical environment without me writing a README section about it.
What already works in 2.21.0 (so this is a smaller delta than it sounds)
I poked at the installed app before filing, because most of the primitives are already here:
- Per-surface startup commands already exist and already persist.
SurfaceRef.startupCommandsround-trips throughsession.json, and there is already a merge helper that copiesstartupCommandsacross split trees where the target surface has none. Restore Claude Code sessions on workspace restore (claude --resume), behind an opt-in setting #186 built this forclaude --resume. - Execution is already hardened.
typeStartupCommands(), theWMUX_STARTUP_COMMANDSenv handoff and the PowerShellbakeIntoInitpath exist specifically because of the shell-startup race in Restore races the shell: the injected 'claude --resume' is partly swallowed, leaving 'esume' in the session picker #251. There is no need to invent a new way to run a command in a fresh pane. freezeSurfaceCwdsis the existing pattern for folding a live value into the saved tree at save time (another issue with save session? #134). The same shape works for commands.- Surfaces are already typed
terminal | browser | markdown, so a browser or markdown pane is already representable insidesplitTree. browserUrlis already captured and restored per workspace (there's even a guard comment about snapshots not silently dropping it).- A declarative profile shape already exists in the quick-launch profiles work from Feedback from a Windows user: notification sounds, installer/Store distribution, CLI new-instance bug, and per-pane quick-launch profiles #32:
{ "profiles": [ { name, type, cwd, startupCommands, ... } ] }. - Saved workspaces are already real files:
%APPDATA%/wmux/sessions/saved/<name>.json, with a clean recursivesplitTreeofbranch/leaf+surfaces[].
So the engine is there. What is missing is the authoring and portability layer on top of it.
What's missing
Here is an actual saved workspace of mine (sessions/saved/Auto-save 2026-10-14 16-34.json, trimmed). Note what a surface records:
{
"type": "leaf",
"paneId": "pane-2e4c386d-…",
"surfaces": [
{
"id": "surf-b7611f17-…",
"type": "terminal",
"resolvedShell": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
"currentCwd": "D:\\…\\bu-order-ms",
"cwd": "D:\\…\\bu-order-ms"
}
],
"activeSurfaceIndex": 0
}Shell, cwd, cwd again — and nothing about what was running. Concretely the gaps are:
- No way to author a command per pane when saving.
startupCommandscan be persisted, but as a user I have no UI or file to put my own commands in. They only get populated implicitly (agent spawn,--cmd, the Restore Claude Code sessions on workspace restore (claude --resume), behind an opt-in setting #186 resume path) and are marked consumed after firing. - No project-local, shareable workspace file. Saved workspaces live in a machine-global
%APPDATA%folder. I cannot commit one next to the code it brings up, so I cannot share it with the team, version it with the repo, or have different branches imply different bring-up. - Browser panel is one URL, not a tab set. Monorepo work needs web app + API docs + admin + Grafana open simultaneously.
- No ordering or readiness. Postgres must be listening before the API's migrations run; the API must be up before the e2e watcher is useful. Firing all panes at t=0 just means some of them crash-loop in front of me.
- No run-once vs run-every-time distinction that I control.
startupConsumedis an internal one-shot flag; I wantnpm installto be once-per-create andnpm run devto be every-open.
Real-world use cases
These are the ones that actually cost me time, not hypotheticals.
1. Morning bring-up of a monorepo. Five services, five folders, five commands, one dependency order. Currently ~2 minutes of mechanical typing before I can do anything, every single morning, and I get the order wrong often enough to notice.
2. Onboarding a new developer. Right now this is a README section titled "Running locally" that is always slightly out of date. With a committed workspace file it becomes: clone, wmux workspace open, trust the prompt, done. The environment definition lives next to the code and rots at the same rate as the code — which is to say it gets fixed when it breaks.
3. Incident / hotfix. A dedicated hotfix workspace: one pane tailing prod logs, one pane on the hotfix branch, browser tabs pinned to Grafana + the incident doc + the deploy pipeline. I want to enter that context in one command at 2am, not assemble it.
4. Code review. A review workspace: pane 1 gh pr checkout $PR && git diff main...HEAD, pane 2 running the app at a different port than my main dev workspace so both can coexist, browser on that preview port. Today the port collision alone makes me tear down my main workspace first.
5. Multi-agent work (wmux's whole premise). Three claude panes, each already cd'd into a different package with a different scoped starting prompt, plus one orchestrator pane at the repo root. This is exactly the layout wmux is built for, and it is currently the thing I rebuild by hand most often. #186 solved resuming an existing session; this is about standing up the intended set in the first place.
6. Client/context switching. Two client monorepos with overlapping default ports. Each workspace file pins its own PORT env and its own browser tabs, so switching contexts is one command instead of a port-conflict scavenger hunt.
7. Demos. Deterministic bring-up with fixed ports and pre-opened tabs, so a demo never starts with me typing commands on a projector.
Proposed design
A. Per-pane startup commands in the save flow (the minimum useful version).
When saving a workspace, each pane gets an editable command field, prefilled with a best guess from what that pane actually ran (wmux already receives this: report_startup_command / report_command arrive over raw-v1 from the shell integration). Persist it into the existing per-surface startupCommands. That alone fixes the single-service case with no new file format.
B. A project-local workspace manifest (the part that makes it shareable).
A file the repo owns — wmux.workspace.json at the repo root, or .wmux/workspace.json:
{
"version": 1,
"name": "platform-monorepo",
"root": ".", // resolved relative to the manifest
"browser": {
"tabs": [
"http://localhost:5173", // web app
"http://localhost:4000/docs" // API docs
],
"active": 0
},
"layout": { "direction": "vertical", "ratio": 0.6 },
"panes": [
{
"id": "infra",
"cwd": ".",
"run": ["docker compose up db redis"],
"when": "always"
},
{
"id": "api",
"cwd": "apps/api",
"run": ["pnpm install", "pnpm dev"],
"runOnce": ["pnpm install"], // first create only
"after": ["infra"],
"waitFor": { "port": 5432, "timeoutMs": 60000 },
"env": { "PORT": "4000" }
},
{
"id": "web",
"cwd": "apps/web",
"run": ["pnpm dev"],
"after": ["api"],
"waitFor": { "http": "http://localhost:4000/health", "timeoutMs": 60000 },
"env": { "PORT": "5173", "VITE_API_URL": "http://localhost:4000" }
},
{ "id": "worker", "cwd": "apps/worker", "run": ["pnpm dev:worker"], "after": ["infra"] },
{ "id": "agent", "cwd": ".", "type": "agent", "run": ["claude"] }
]
}Single-service projects just write the short version:
{
"version": 1,
"name": "my-api",
"panes": [
{ "cwd": ".", "run": ["npm run dev"] },
{ "cwd": ".", "run": ["claude"] }
],
"browser": { "tabs": ["http://localhost:3000"] }
}C. CLI surface.
wmux workspace save <name> [--to ./wmux.workspace.json] # capture live workspace → manifest
wmux workspace open [path|name] [--trust] [--dry-run] # bring it up
wmux workspace list
wmux workspace validate ./wmux.workspace.json--dry-run prints the pane tree, resolved cwds, resolved order and the exact commands, and runs nothing. That doubles as the preview for the trust prompt below.
How this could be built without much new machinery
Roughly in dependency order, each step shippable on its own:
- Capture + edit. Add a
freezeSurfaceStartupCommandsalongside the existingfreezeSurfaceCwdsso the save path folds live/authored commands into the saved tree. Prefill from thereport_startup_commandvalue wmux already receives. (Schema already supports it — nothing new to persist.) - UI. Per-pane command field in the save dialog; the
startupCommandsPlaceholder/startupCommandsTogglecomponents already exist in the bundle and can be reused rather than designed. - Browser tabs. Widen the existing workspace-level
browserUrl: stringto an optionalbrowserTabs: string[](keepbrowserUrlas the v1 fallback so old saves keep working). Browser is already a surface type, so panel tabs and in-tree browser surfaces can share the restore path. - Manifest reader. Parse
wmux.workspace.jsoninto the same internal spec the quick-launch profiles from Feedback from a Windows user: notification sounds, installer/Store distribution, CLI new-instance bug, and per-pane quick-launch profiles #32 already consume ({name, type, cwd, startupCommands}). The manifest is then just a second, project-local front-end to an object shape the app already understands. - Execution. Reuse
typeStartupCommands+WMUX_STARTUP_COMMANDS/bakeIntoInitexactly as-is. This is the path already hardened against Restore races the shell: the injected 'claude --resume' is partly swallowed, leaving 'esume' in the session picker #251; the feature must not introduce a second, unhardened way to inject text into a pane. - Ordering.
afteris a tiny DAG (topological sort, reject cycles at validate time).waitForis a bounded poll in the main process —port= TCP connect,http= GET expecting <500,delay= ms — gating only the dependent pane's command dispatch, never the pane creation itself. Panes with noafterall start at t=0 as today. - CLI verb.
workspacejoins the existing verb set over the current local-socket transport. No new IPC mechanism.
Guardrails
This feature executes commands from a file, and point B means that file can arrive from a git clone. That is the whole risk surface and it needs to be designed in from the start, not added later.
Security
- Workspace trust, mandatory. A manifest must never auto-run on first open. Prompt once per (path + content hash), showing the full resolved command list, exactly like VS Code Workspace Trust or
direnv allow. Store the allowlist outside the repo (in%APPDATA%/wmux), so the repo can never mark itself trusted. - Re-prompt on change. Any edit to the manifest invalidates the stored hash and re-prompts, with a diff of what changed. Otherwise a trusted repo becomes a persistent execution channel that a later
git pullcan quietly repoint. - Never auto-open a manifest just because one is present in the cwd. Opening a workspace manifest is always an explicit user action (
wmux workspace open, or a clearly-labelled "this folder has a workspace file — open it?" affordance). No ambient discovery-and-run. - No secrets in the manifest. It is committed.
envvalues should support indirection (${env:FOO}, or a pointer to a gitignored.env) and the docs should say plainly that literal tokens do not belong there. Consider warning at validate time on values that look like credentials. - Path containment. Resolve every
cwdagainst the manifest root and reject escapes (.., absolute paths, symlinks out of the tree) unless the user explicitly opts in. A manifest should not be able to point a pane atC:\Windows\System32without the user seeing it. - Shell-injection realism. Commands are strings run in a shell by design; the protection is the trust prompt and the visible preview, so the preview must show the final resolved string after any variable expansion, not the template.
Reliability
- Reuse the Restore races the shell: the injected 'claude --resume' is partly swallowed, leaving 'esume' in the session picker #251-hardened injection path. Do not type into a cold PTY. If a shell has no integration available, fall back to the env/init handoff rather than racing.
- Bounded waits. Every
waitForneeds a timeout with a sane default. On timeout, surface a clear error in that pane and continue with the rest — a stuck dependency must not hang the whole restore. - Visible failures. If a command exits non-zero immediately, or a port is already in use, that pane should show it loudly. The current failure mode of this feature class is a pane that looks fine but silently never started — worse than no automation at all.
- Idempotency / double-start. Detect that the target port is already listening and ask rather than starting a second copy. Re-opening an already-open workspace should focus it, not fork the whole environment.
runOncevsrun. Honour the existing consumed-once semantics for the install-type steps, and re-run the long-lived ones. The user, not the app, decides which is which.- Concurrency cap. Bringing up 8 services at once on a laptop is a thundering herd. A small default parallelism limit (with an override) keeps restore from pinning the machine.
- Respect the existing per-pane toggle. If the user has startup commands switched off for a pane, the manifest must not override it.
- Graceful degradation. Missing folder, missing binary, unparseable manifest → fail that pane with a readable message and still restore the layout. Never refuse to open the workspace at all.
Relationship to existing issues
Not a duplicate of these, but it builds directly on them:
- Restore Claude Code sessions on workspace restore (claude --resume), behind an opt-in setting #186 — restores an existing Claude session automatically on restart. This is about declaring the intended set of processes up front, for any command, authored by the user.
- Configurable defaults for a new workspace: terminal pane count and browser start URL #212 — global defaults for new workspaces (pane count, browser start URL). This is per-workspace, named, saved and shareable, rather than one global default.
- Feedback from a Windows user: notification sounds, installer/Store distribution, CLI new-instance bug, and per-pane quick-launch profiles #32 — per-pane quick-launch profiles. This composes those into a whole-workspace manifest; ideally both read the same internal spec.
- Restore races the shell: the injected 'claude --resume' is partly swallowed, leaving 'esume' in the session picker #251 — the injection race. This feature multiplies the number of injected commands, so it should explicitly inherit that fix rather than re-implement injection.
- another issue with save session? #134 —
freezeSurfaceCwdssave-time folding, the pattern step 1 copies.
Acceptance criteria
- A pane's startup command can be entered/edited by the user and survives save → restore.
- A workspace can be saved to, and opened from, a project-local file that can be committed.
- Opening a monorepo manifest brings up N panes in N different cwds with N different commands, plus the agent pane, in one action.
- Browser panel restores multiple tabs, not just one URL.
-
after/waitFororder the bring-up, with bounded timeouts and visible failures. - An untrusted manifest never executes anything before an explicit, preview-showing consent; edits re-prompt.
-
--dry-runshows the fully resolved plan and runs nothing. - Existing saved workspaces (no commands,
browserUrlonly) keep working unchanged.
Environment
- wmux 2.21.0, Windows 11 Pro 10.0.26300, default shell pwsh 7.
Activity
feat(workspace): project-local workspace manifests (#284)
amirlehmam commentedon Oct 14, 2026
Thanks, this was an excellent writeup. Shipped in 2.23.0. The format is your proposal B almost as written, and the guardrails are built in rather than added later. Full reference:
docs/workspace-manifest.md.Your acceptance criteria
startupCommandsfield, so it runs on restore and from saved sessions and layouts, andwmux workspace savewrites it as that pane'srun.wmux.workspace.jsonor.wmux/workspace.json, viawmux workspace save [--to …]andwmux workspace open [path]. The palette also has Open workspace file….browser.tabsopens as tabs in one browser pane. The old single-URL side panel is unchanged, so existing saves keep working.after/waitFororder the bring-up, with bounded timeouts and visible failures.afteris sorted so dependencies go first, and a cycle is rejected when the file is checked.waitFortakes exactly one ofport,http(any answer below 500) ordelay. The timeout defaults to 60 s, with a 10 min maximum.[wmux] waiting for api, port 5432…line. A timed-out pane says so and runs nothing, and the panes after it still start.--dry-runshows the fully resolved plan and runs nothing.Guardrails, and where I went a different way
--trustflag. Consent is a wmux dialog, not a pipe argument. Every terminal wmux opens can talk to the pipe, AI agents included, so an agent could pass--truston a manifest it just edited. That is exactly the hole the trust prompt exists to close.(path, sha256)and stored in%APPDATA%\wmux. Any edit re-prompts with the added and removed commands.cwdmust be relative and stay inside the repo, also after resolving links, so a junction can't point out of it.waitForonly probes this machine: a file someone else wrote shouldn't be able to make wmux scan other hosts.${env:NAME}is resolved when the pane starts and saved only as the reference. A literal value under a key that looks like a secret gets a warning at validate time. A command can't contain a line break, so the preview is always exactly what gets typed.wmux workspace openstarts the processes again. Replaying them on restore would skip the trust check after agit pullchanged the file. Re-opening a workspace that's already open focuses it;--newopens a second copy.whenvalues other thanalways.layouttakes the same presets aswmux new-workspace --layoutrather than a direction and ratio. If any of these turns out to matter in practice, I'm happy to add it.Every command goes through the same input path as #251, so this adds no second way of typing into a pane. A held pane gets its commands once its shell is ready.
fix(cli): give list-workspaces its workspace.list back (#398)