Skip to content

feat: General-purpose Launch App with process tracking and multi-language support #1317

@youngmrz

Description

@youngmrz

Summary

Extend the "Launch App" feature from Node.js-only to support all major programming languages and frameworks, with proper process tracking and cleanup capabilities.

Problem

The current Launch App implementation (#1313) has several limitations:

  1. Node.js Only: Only detects package.json and npm/pnpm/yarn commands
  2. No Process Tracking: Spawned dev servers are "fire and forget" - no way to stop them
  3. Port Conflicts: Multiple launches can pile up on ports 5173, 5174, etc.
  4. No Stop Button: Users must manually find and kill processes
  5. Stale Processes: Closing Auto-Claude doesn't terminate spawned dev servers
  6. Single-Instance Conflicts: Apps with mutex locks (like Pyloid) fail if old instance exists

Proposed Solution

Phase 1: Process Tracking (P0)

Track all spawned processes per task/worktree to enable clean shutdown.

interface TrackedProcess {
  pid: number;
  taskId: string;
  worktreePath: string;
  command: string;
  startedAt: Date;
  port?: number;
  type: 'node' | 'python' | 'rust' | 'go' | 'java' | 'dotnet' | 'other';
}

// In-memory registry with optional persistence
const processRegistry: Map<string, TrackedProcess[]> = new Map();

Features:

  • Register PIDs when launching
  • Unregister when processes terminate
  • Query processes by task/worktree
  • Persist to file for crash recovery

Phase 2: Stop App Button (P1)

Add UI to terminate running dev servers.

UI Changes:

  • "Stop App" button appears when dev server is running for the task
  • Confirmation dialog for safety
  • Loading state during termination
  • Toast notification on success/failure

Backend:

  • TASK_WORKTREE_STOP_APP IPC handler
  • Graceful shutdown (SIGTERM) with fallback to force kill (SIGKILL)
  • Clean up process registry

Phase 3: Multi-Language Project Detection (P1-P2)

Detect project type from files and use appropriate commands.

Project Type Detection Files Install Command Launch Command
Node.js package.json npm/pnpm/yarn install npm run dev/start
Python (uv) pyproject.toml + uv.lock uv sync uv run python main.py
Python (pip) requirements.txt pip install -r requirements.txt python main.py / flask run / uvicorn
Python (poetry) pyproject.toml + poetry.lock poetry install poetry run python main.py
Rust Cargo.toml cargo build cargo run
Go go.mod go mod download go run .
Java (Maven) pom.xml mvn install mvn spring-boot:run / mvn exec:java
Java (Gradle) build.gradle gradle build gradle bootRun / gradle run
.NET *.csproj / *.sln dotnet restore dotnet run
Ruby Gemfile bundle install rails server / ruby app.rb
PHP composer.json composer install php artisan serve / php -S

Implementation:

interface ProjectConfig {
  type: ProjectType;
  packageManager: string | null;
  installCommand: string | null;
  launchCommand: string | null;
  launchScript?: string;  // For Node.js: 'dev', 'start', etc.
  processPatterns: string[];  // Regex patterns for cleanup
  ports: number[];  // Default ports to check
}

function detectProjectType(worktreePath: string): ProjectConfig {
  // Check files in priority order
  // Return first match with full config
}

Phase 4: System-Wide Cleanup (P2)

Nuclear option to kill all Auto-Claude-spawned processes.

Features:

  • "Kill All Dev Servers" button in settings or toolbar
  • Cleans up all tracked processes across all tasks
  • Useful when switching contexts or debugging port issues
  • Optional: Run on Auto-Claude startup to clean stale processes

Implementation:

  • Persist process registry to ~/.auto-claude/process-registry.json
  • On startup: check if registered PIDs are still running, clean stale entries
  • On quit: optionally terminate all tracked processes

Phase 5: UI Enhancements (P3)

Running Indicator:

  • Green dot or badge on tasks with active dev servers
  • Hover shows: command, port, uptime

Port Display:

  • Show which port the dev server is running on
  • Click to open in browser

Logs Panel (stretch goal):

  • Stream dev server stdout/stderr in UI
  • Collapsible panel below workspace status
  • Search/filter capabilities

Implementation Plan

Milestone 1: Core Process Tracking

  • Create ProcessRegistry class with CRUD operations
  • Persist registry to file with debounced writes
  • Register processes on launch
  • Add TASK_WORKTREE_STOP_APP IPC handler
  • Add "Stop App" button to WorkspaceStatus

Milestone 2: Python Support

  • Add Python project detection (uv, pip, poetry)
  • Detect Python launch commands from pyproject.toml
  • Handle virtual environment activation
  • Test with Pyloid apps (VoiceFlow)

Milestone 3: Additional Languages

  • Rust detection and launch
  • Go detection and launch
  • Java/Gradle/Maven detection
  • .NET detection

Milestone 4: Polish

  • Running indicator on task cards
  • Port display in UI
  • System-wide cleanup button
  • Startup cleanup of stale processes

Acceptance Criteria

  • Can launch Node.js, Python, Rust, and Go projects
  • "Stop App" button terminates the dev server
  • Launching twice kills the first instance automatically
  • Closing Auto-Claude cleans up spawned processes
  • Process registry survives app restart
  • UI shows which tasks have running dev servers

Related Issues/PRs

Technical Notes

Cross-Platform Considerations

Windows:

  • Use taskkill /F /PID for force kill
  • Process tree may need /T flag
  • PowerShell for process queries

macOS/Linux:

  • Use kill -TERM then kill -9 as fallback
  • May need to kill process group with - prefix
  • Use pgrep/pkill for pattern matching

Process Groups

When spawning terminal windows, the actual dev server runs as a child of the terminal. We may need to:

  1. Track the terminal PID
  2. Find child processes of that PID
  3. Kill the entire process tree

Port Detection

For showing ports in UI:

  • Parse stdout for "listening on port X" patterns
  • Or query netstat/lsof filtered by PID
  • Store detected port in process registry

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions