This mock server allows the frontend to run independently without the actual Catnip backend container.
- Implements all
/v1/*API endpoints fromcontainer/docs/swagger.json - Provides Server-Sent Events (SSE) endpoint at
/v1/eventswith mock data - Simulates real-time events (heartbeat, port changes, git status, worktree updates)
- Supports both streaming and non-streaming Claude message responses
- Includes git diff, PR, sync, merge, and other advanced git operations
- Provides mock worktrees with proper repository linkage for app navigation
Run the frontend with mock server:
pnpm run dev:mockThis command will:
- Start Vite dev server on
$PORT(defaults to 5173) - Start the mock server on
$PORT + 1(defaults to 5174) - Configure proxy to redirect
/v1/*requests to the mock server
In the Catnip environment, it automatically uses the PORT environment variable:
# Uses PORT from environment (e.g., in Catnip container)
PORT=6369 pnpm run dev:mock # Vite on 8080, mock server on 8081Start mock server only:
pnpm run mock:serverStart Vite with mock proxy enabled:
pnpm run dev:with-mock-
Automatic Port Configuration: When using
pnpm run dev:mock:- Vite runs on
$PORT(or 5173 if not set) - Mock server runs on
$PORT + 1(or 5174 if not set)
- Vite runs on
-
Manual Configuration: When running separately:
MOCK_PORT=3002 pnpm run mock:server VITE_PORT=5173 MOCK_PORT=3002 VITE_USE_MOCK=true vite
-
Vite Proxy: When
VITE_USE_MOCK=true, Vite will proxy all/v1/*requests to the mock server on$MOCK_PORT
The mock server implements the following endpoint groups:
- Auth (
/v1/auth/github/*): GitHub authentication flow - Claude (
/v1/claude/*): Claude Code sessions, settings, messages, todos - Git (
/v1/git/*): Worktrees, branches, status, checkout - Ports (
/v1/ports/*): Port management and mappings - Sessions (
/v1/sessions/*): PTY session management - Events (
/v1/events): Server-Sent Events stream - Notifications (
/v1/notifications): System notifications - Upload (
/v1/upload): File upload endpoint
The /v1/events endpoint provides real-time updates via Server-Sent Events:
- Heartbeat: Every 5 seconds with timestamp and uptime
- Container Status: Initial connection status
- Port Events: When ports are opened/closed
- Git Events: Repository status changes (clean/dirty)
- Process Events: Process start/stop notifications
- Random Events: Simulated activity every 15 seconds
The server provides realistic mock data including:
- Active worktrees with git status
- Claude session summaries with metrics
- Port mappings for common development servers
- GitHub repository listings
Edit mock-server.js to:
- Modify mock data responses
- Add new endpoints
- Change event simulation behavior
- Adjust timing intervals
- If port 3001 is in use, set
MOCK_PORTto a different port - Check console output for unhandled routes
- SSE events can be tested at
http://localhost:3001/v1/events