Add dispatch-dev for isolated agent dev environments#45
Merged
Conversation
Agents running `npm run dev` directly could kill their own process when restarting dev servers (the tmux session and agent CLI share a process tree). dispatch-dev runs DB, API, and Vite in sibling tmux windows tied to the agent session — automatic lifecycle cleanup on agent stop/delete, no orphaned servers, no port conflicts. - bin/dispatch-dev: bootstraps isolated Postgres container + API + optional Vite, all auto-assigned ports, zero-config for agents - AgentManager.cleanupDevEnvironment: removes Docker containers and state files on agent stop/delete - docker-compose.yml: ephemeral volumes per container (no shared pgdata) - CLAUDE.md/AGENTS.md: consolidated dev docs around dispatch-dev - scripts/e2e-isolated.sh + playwright TLS/isolated support Co-Authored-By: Claude Opus 4.6 <[email protected]>
npm run test:e2e now always spins up its own Postgres container and API server on random ports via e2e-isolated.sh. No more reuseExistingServer which could cause agents to accidentally share dev servers. Co-Authored-By: Claude Opus 4.6 <[email protected]>
- e2e-isolated.sh: use node net module to grab free ports from the OS instead of $RANDOM, preventing collisions between concurrent runs - cleanupDevEnvironment: fire-and-forget with 10s timeout on docker rm so it can't block agent stop/delete API calls Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Fix floating promise: add .catch() to fire-and-forget cleanupDevEnvironment calls so errors are logged not swallowed - Add docker compose project name (-p) to dispatch-dev for consistent container namespacing - Use PID+timestamp for e2e run IDs to avoid CI parallel collisions - Add TOCTOU comments to find_free_port in both scripts - Add comment explaining NODE_TLS_REJECT_UNAUTHORIZED scope - Rename DEV_DB_NAME to DEV_CONTAINER_SUFFIX for clarity - Document start/stop aliases in dispatch-dev usage - Remove unrelated .dispatch/config.json change Co-Authored-By: Claude Opus 4.6 <[email protected]>
Session names now follow the pattern dispatch_agt_xxx_task-slug (e.g. dispatch_agt_393f6be6672e_projects) instead of just dispatch_agt_393f6be6672e. Makes it easy to identify agents when debugging rogue tmux sessions with tmux list-sessions. Added agentIdFromSessionName() helper to reliably extract the agent ID from either the old or new session name format. Co-Authored-By: Claude Opus 4.6 <[email protected]>
dispatch-dev now finds the agent's tmux session by prefix match instead of exact match, since session names now include the agent name slug (e.g. dispatch_agt_xxx_my-task). Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.
Summary
dispatch-devCLI tool that agents use instead ofnpm run dev— bootstraps an isolated Postgres container, API server, and optional Vite frontend in sibling tmux windows within the agent's sessionAgentManager.cleanupDevEnvironment)dispatch-dev uppicks free ports, loads.env, prints URLsChanges
bin/dispatch-dev— new CLI withup/down/restart/status/logs/urlcommandssrc/agents/manager.ts—cleanupDevEnvironment()removes Docker containers + state files on stop/deletedocker-compose.yml— ephemeral volumes (no sharedpgdataacross agent containers)CLAUDE.md+AGENTS.md— consolidated dev server/DB docs arounddispatch-dev, removed manualnpm run devand worktree DB instructionsscripts/e2e-isolated.sh+playwright.config.ts— isolated e2e test runner with TLS supportTest plan
dispatch-dev upcreates Docker DB + API tmux window, both healthydispatch-dev up --vitecreates all three services (DB + API + Vite)dispatch-dev statusreports all services correctlydispatch-dev downtears down tmux windows, Docker container, and state filedispatch-dev restartreplaces windows without accumulating extrascleanupDevEnvironmentpath: reads state file, removes containernpm run checkpassesnpm testpasses (25/25)🤖 Generated with Claude Code