Skip to content

Enable multiple task instances with unique tmux sessions#72

Merged
bborn merged 2 commits intomainfrom
task/146-instance-of-the-task-app-should-be-separ
Jan 9, 2026
Merged

Enable multiple task instances with unique tmux sessions#72
bborn merged 2 commits intomainfrom
task/146-instance-of-the-task-app-should-be-separ

Conversation

@bborn
Copy link
Copy Markdown
Owner

@bborn bborn commented Jan 9, 2026

Summary

Fixes the issue where every task -l command used the same tmux session, preventing multiple task instances from running simultaneously.

Each task instance now gets its own isolated tmux sessions based on process ID, allowing users to run multiple task app instances in parallel without conflicts.

Changes

Session ID Management

  • Added getSessionID() function that generates unique session IDs based on PID
  • Session ID can be inherited via TASK_SESSION_ID environment variable
  • Session ID propagates through daemon and all child processes

Dynamic Session Naming

  • UI Session: Changed from task-ui to task-ui-{PID}
  • Daemon Session: Changed from task-daemon to task-daemon-{PID}
  • Added helper functions for consistent session naming

Updated Components

  • cmd/task/main.go: Updated all UI session references, daemon spawning, and copilot system prompt
  • internal/executor/executor.go: Updated all daemon session references and Claude task execution

How It Works

  1. When task -l starts without TASK_SESSION_ID, it generates one based on its PID
  2. The session ID is set as an environment variable and passed to all child processes
  3. All tmux session names include the session ID suffix
  4. Each instance gets:
    • Its own UI session: task-ui-12345
    • Its own daemon session: task-daemon-12345
    • Its own set of task windows within the daemon session

Instance Isolation

Each instance now maintains complete isolation:

  • ✅ Separate UI session (task-ui-{PID})
  • ✅ Separate daemon session (task-daemon-{PID})
  • ✅ Independent Claude task windows
  • ✅ No session name conflicts between instances

Testing

  • ✅ Build succeeds
  • ✅ Session naming logic verified
  • ✅ PID-based session IDs work correctly
  • ✅ Environment variable propagation works

Files Changed

  • cmd/task/main.go (98 insertions, 46 deletions)
  • internal/executor/executor.go (51 insertions, 46 deletions)

🤖 Generated with Claude Code

bborn and others added 2 commits January 9, 2026 14:06
Each `task -l` instance now gets its own isolated tmux sessions based on PID.
This allows running multiple task app instances simultaneously without conflicts.

Changes:
- Added session ID management using TASK_SESSION_ID env var
- Updated task-ui session naming: task-ui-{PID}
- Updated task-daemon session naming: task-daemon-{PID}
- Session ID propagates through daemon and executor processes
- Updated copilot system prompt to reference dynamic session name
- All tmux commands now use instance-specific session names

Each instance maintains complete isolation:
- Separate UI session (task-ui-{PID})
- Separate daemon session (task-daemon-{PID})
- Independent Claude task windows
- No session name conflicts between instances

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Resolved conflicts by:
- Keeping instance-specific session naming (task-ui-{PID}, task-daemon-{PID})
- Adopting main's removal of copilot pane split
- Adopting main's --chrome flag for Claude commands
- Removing unused buildCopilotClaudeCommand function

The merge maintains the core functionality of multiple task instances
while incorporating the latest changes from main.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@bborn bborn merged commit 367ac8c into main Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant