[FEATURE]: Background Tasks Manager #6995

Open
opened 2026-02-16 18:05:51 -05:00 by yindo · 3 comments
Owner

Originally created by @avillagran on GitHub (Jan 20, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Key Features

🔧 Core Task Manager (packages/opencode/src/task/)

  • TaskManager with full lifecycle operations:
    • create() - Spawn new background processes
    • 📋 list() - Get all running tasks
    • 🔍 get() - Retrieve specific task info
    • kill() - Terminate processes
    • 📖 read() - Read task output (full or partial)
    • 📜 tail() - Stream recent output
    • ⌨️ input() - Send input to running processes
    • 🔄 adopt() - Migrate foreground processes to background
  • Persistence Layer (.opencode/tasks/{taskId}.json):
    • 💾 Tasks survive session restarts
    • 🔌 Auto-reconnect to running processes by PID
    • 📊 State tracking and recovery
  • Event Bus System:
    • 🎉 task:created - New task spawned
    • 📝 task:output - Output received
    • ✔️ task:completed - Task finished
    • task:killed - Task terminated

🤖 Process Query Tool (packages/opencode/src/tool/process-query.ts)

New LLM tool that enables Claude to:

  • 📋 List all background tasks
  • Check task status
  • 📖 Read full or partial output
  • 🔍 Search for patterns in task logs
  • 🎯 Resolve tasks by ID, "last" keyword, or description match

🎨 User Interface Components

Background Tasks Modal (ctrl+p > "Background tasks"):

  • 📊 View all running background tasks
  • 📈 Real-time output streaming
  • Kill tasks directly from UI
  • 🔄 Auto-refresh with live updates

Process Controls:

  • 🔵 [bg] button - Migrate running processes to background
  • 🔴 [kill] button - Terminate running processes
  • 🎮 Available for both Bash commands and shell commands (! prefix)

🛠️ Enhanced Bash Tool

  • run_in_background parameter for spawning background tasks
  • 🔄 Foreground process registry for tracking
  • 🎯 Support for process migration while running
  • 🧹 Optimized latency with fire-and-forget persistence

📊 Implementation Stats

  • Files Changed: 20 files
  • Lines Added: ~4,878 lines
  • Test Coverage: 46 comprehensive tests
    • 29 tests for TaskManager core
    • 17 tests for foreground process management

🎬 Demo

(https://x.com/avillagran/status/2013709707563708491/video/1)

🔍 Technical Details

Architecture:

  1. Task Layer - Process management and lifecycle
  2. Persistence Layer - State storage and recovery
  3. Transport Layer - RPC handlers for TUI communication
  4. UI Layer - React components for user interaction

Key Design Decisions:

  • 🚀 Fire-and-forget persistence to minimize migration latency
  • 🔄 PID-based reconnection for session recovery
  • 🎯 Unified interface for both foreground and background processes
  • 📝 Clean logging using Log utility instead of console

🧪 Testing

Comprehensive test suite covering:

  • Task creation and lifecycle
  • Output streaming and reading
  • Process termination
  • Session recovery
  • Foreground to background migration
  • Error handling and edge cases

📚 Use Cases

  • 🏗️ Long-running builds (webpack, vite, etc.)
  • 🧪 Test watchers and development servers
  • 📦 Package installations
  • 🔍 Log monitoring and analysis
  • 🤖 Any command that needs to run while working on other tasks
Originally created by @avillagran on GitHub (Jan 20, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request ✨ Key Features 🔧 Core Task Manager (packages/opencode/src/task/) - TaskManager with full lifecycle operations: - ✅ create() - Spawn new background processes - 📋 list() - Get all running tasks - 🔍 get() - Retrieve specific task info - ⚡ kill() - Terminate processes - 📖 read() - Read task output (full or partial) - 📜 tail() - Stream recent output - ⌨️ input() - Send input to running processes - 🔄 adopt() - Migrate foreground processes to background - Persistence Layer (.opencode/tasks/{taskId}.json): - 💾 Tasks survive session restarts - 🔌 Auto-reconnect to running processes by PID - 📊 State tracking and recovery - Event Bus System: - 🎉 task:created - New task spawned - 📝 task:output - Output received - ✔️ task:completed - Task finished - ❌ task:killed - Task terminated 🤖 Process Query Tool (packages/opencode/src/tool/process-query.ts) New LLM tool that enables Claude to: - 📋 List all background tasks - ✅ Check task status - 📖 Read full or partial output - 🔍 Search for patterns in task logs - 🎯 Resolve tasks by ID, "last" keyword, or description match 🎨 User Interface Components Background Tasks Modal (ctrl+p > "Background tasks"): - 📊 View all running background tasks - 📈 Real-time output streaming - ⚡ Kill tasks directly from UI - 🔄 Auto-refresh with live updates Process Controls: - 🔵 [bg] button - Migrate running processes to background - 🔴 [kill] button - Terminate running processes - 🎮 Available for both Bash commands and shell commands (! prefix) 🛠️ Enhanced Bash Tool - ✅ run_in_background parameter for spawning background tasks - 🔄 Foreground process registry for tracking - 🎯 Support for process migration while running - 🧹 Optimized latency with fire-and-forget persistence 📊 Implementation Stats - Files Changed: 20 files - Lines Added: ~4,878 lines - Test Coverage: 46 comprehensive tests - 29 tests for TaskManager core - 17 tests for foreground process management 🎬 Demo (https://x.com/avillagran/status/2013709707563708491/video/1) 🔍 Technical Details Architecture: 1. Task Layer - Process management and lifecycle 2. Persistence Layer - State storage and recovery 3. Transport Layer - RPC handlers for TUI communication 4. UI Layer - React components for user interaction Key Design Decisions: - 🚀 Fire-and-forget persistence to minimize migration latency - 🔄 PID-based reconnection for session recovery - 🎯 Unified interface for both foreground and background processes - 📝 Clean logging using Log utility instead of console 🧪 Testing Comprehensive test suite covering: - ✅ Task creation and lifecycle - ✅ Output streaming and reading - ✅ Process termination - ✅ Session recovery - ✅ Foreground to background migration - ✅ Error handling and edge cases 📚 Use Cases - 🏗️ Long-running builds (webpack, vite, etc.) - 🧪 Test watchers and development servers - 📦 Package installations - 🔍 Log monitoring and analysis - 🤖 Any command that needs to run while working on other tasks
yindo added the discussion label 2026-02-16 18:05:51 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 20, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #9462: Support background tool execution

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 20, 2026): This issue might be a duplicate of existing issues. Please check: - #9462: Support background tool execution Feel free to ignore if none of these address your specific case.
Author
Owner

@DarickBrokaw commented on GitHub (Jan 23, 2026):

anthropic claude code just created https://code.claude.com/docs/en/interactive-mode#task-list and this may be a new model for how to proceed. Not sure if this is the same intent but worth a look.

@DarickBrokaw commented on GitHub (Jan 23, 2026): anthropic claude code just created https://code.claude.com/docs/en/interactive-mode#task-list and this may be a new model for how to proceed. Not sure if this is the same intent but worth a look.
Author
Owner

@XiaoLiuAI commented on GitHub (Feb 10, 2026):

Agree, oh-my-opencode implemented it as part of plugin. As it is framework-level feature, it should be supported directly by official codebase.

@XiaoLiuAI commented on GitHub (Feb 10, 2026): Agree, oh-my-opencode implemented it as part of plugin. As it is framework-level feature, it should be supported directly by official codebase.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6995