Skip to content

[FEATURE]: Background Tasks Managerย #9714

Closed

Description

@avillagran

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

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Jan 20, 2026
  2. github-actions commented on Jan 20, 2026

    @github-actions
    Contributor

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

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

  3. DarickBrokaw commented on Jan 23, 2026

    @DarickBrokaw

    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.

  4. XiaoLiuAI commented on Feb 10, 2026

    @XiaoLiuAI

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

  5. github-actions commented on Apr 12, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  6. workdocyeye commented on Apr 25, 2026

    @workdocyeye

    Came across this โ€” I have a skill that solves the dev server side of things:
    https://github.com/workdocyeye/server-manager

    start-server runs the command in background via cmd /c redirection, keeps track of ports/PIDs in a JSON file, and you can tail/grep the logs afterward. Tested on Next.js, Streamlit, Flask, and a few Go servers on Windows.

    Not the full task manager described here, but enough to keep dev servers from blocking the terminal while you work on other things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions