This sample contains the a sample worktree dashboard that permits easily inspecting and launching isolated backend + front-end dev servers for your app across different worktrees.
worktrunk hooks are used to automatically prepare new worktrees and assign each worktree unique ports to listen on.
Port detection is also available to display the PID of externally-launched backend instances that are currently bound to the port(s) assigned to the worktree.
The repo currently has three runtime pieces:
- Sample backend: the Rust binary in
src-tauri, run withcargo runfromsrc-tauriwhen it is not launched by the Tauri CLI. - Sample Web UI: the Solid app at
webui/index.html, served by Vite withnpm run dev. - Worktree dashboard: a Node API at
worktree-dashboard/worktree-dashboard.mjsplus the Solid dashboard page atwebui/worktree-dashboard.html.
Current npm scripts:
| Script | Purpose |
|---|---|
npm run dev |
Start Vite and open /worktree-dashboard.html. |
npm run build |
Build the Vite web UI into webui/dist. |
npm run serve |
Preview the built Vite output. |
npm run tauri |
Run the Tauri CLI. Pass commands after --. |
npm run worktree:dashboard |
Start the dashboard API with Node watch mode. |
npm run worktree:mcp |
Start the dashboard MCP server. |
npm run worktree:stop-services |
Ask the dashboard API to stop services for WORKTREE_TARGET. |
npm run setup-env |
Generate the current worktree's .env. |
npm run test:webui-playwright |
Run the Playwright wrapper. See validation notes below. |
npm run lint |
Run Biome checks. |
npm run typecheck |
Run TypeScript project references with no emit. |
Install dependencies:
npm installCreate or refresh the current worktree's .env:
npm run setup-envsetup-env writes:
WORKTREE_APP_PORT=<random 3000-3999 port, or supplied value>
VITE_APP_TITLE=Sample Worktree App (<branch>)
PLAYWRIGHT_BROWSERS_PATH=<shared-playwright-cache>
Pin a specific app base port when needed:
WORKTREE_APP_PORT=3410 npm run setup-envWith that value, the backend listens on 3410 and Vite listens on 3411.
Start the backend:
cd src-tauri
cargo runIn another shell, start the Web UI from the repo root:
npm run devOpen the sample app at the Vite root:
http://localhost:<WORKTREE_APP_PORT + 1>/
The sample UI polls:
http://127.0.0.1:<WORKTREE_APP_PORT>/api/app-state
The backend also exposes:
GET /health
GET /api/app-state
Start the dashboard API:
npm run worktree:dashboardStart Vite in another shell:
npm run devOpen:
http://localhost:<Vite port>/worktree-dashboard.html
If .env contains WORKTREE_APP_PORT, the Vite port is
WORKTREE_APP_PORT + 1. Without .env, Vite defaults to 3031.
The dashboard API defaults to:
http://127.0.0.1:4781/api
Override the dashboard API address with:
WORKTREE_DASHBOARD_HOST=127.0.0.1
WORKTREE_DASHBOARD_PORT=4781or set the browser-facing API base directly:
VITE_WORKTREE_DASHBOARD_API_BASE=http://127.0.0.1:4781/apiThe dashboard discovers worktrees with git worktree list, reads each
worktree's .env, and can start, stop, or recycle two managed services:
backend:cargo runinsrc-tauriui:npm run devfrom the worktree root
Managed service logs are written under the system temp directory in
worktree-dashboard/.
The Tauri config uses:
devUrl:http://localhost:3031/frontendDist:../webui/distbeforeBuildCommand:npm run build
Run the desktop app in development:
npm run tauri -- devBuild a debug app bundle:
npm run tauri -- build --debugThe Rust binary behaves differently depending on how it is launched. When the
Tauri CLI sets TAURI_ENV_PLATFORM, it starts the desktop app. Without that
environment variable, cargo run starts the sample backend server.
The included .config/wt.toml defines:
pre-start: runnode ./scripts/setup-env.mjs, thennpm installpost-start: runcargo build --workspacepre-remove: callscripts/stop-processes.mjsthrough the dashboard API
The stop hook requires the dashboard API to be running.
The MCP server lets agents inspect and manage worktrees through the dashboard API.
Start the dashboard API first:
npm run worktree:dashboardThen configure an MCP client to run:
npm run worktree:mcpExample:
{
"mcpServers": {
"worktree-dashboard": {
"command": "npm",
"args": ["run", "worktree:mcp"],
"cwd": "/absolute/path/to/worktree-dashboard"
}
}
}The MCP server targets http://127.0.0.1:4781 by default. Override with:
WORKTREE_DASHBOARD_URL=http://127.0.0.1:4781or:
WORKTREE_DASHBOARD_HOST=127.0.0.1
WORKTREE_DASHBOARD_PORT=4781Available MCP tools:
dashboard_list_worktreesdashboard_worktree_statusdashboard_worktree_manage
dashboard_worktree_manage requires worktree and action. action is one
of start, stop, or recycle. services defaults to ["backend", "ui"]
and accepts backend, ui, or all.
Currently runnable checks:
npm run lint
npm run typecheck
npm run build
npm run tauri -- build --debugThe Playwright wrapper exists as npm run test:webui-playwright, but the
current playwright.config.ts references npm run worktree:dashboard:ui, which
is not defined in package.json.