feat: Phase 4 - Background Read-Only Concurrency (BackgroundTaskRunner)#12342
feat: Phase 4 - Background Read-Only Concurrency (BackgroundTaskRunner)#12342roomote-v0[bot] wants to merge 2 commits into
Conversation
…ner) Implements the MVP for Phase 4 of the parallel execution roadmap: - Add BackgroundTaskRunner service that manages concurrent read-only background tasks separately from the clineStack - Add isBackgroundTask flag to Task class that suppresses webview updates and auto-approves all tool uses - Extend new_task tool with optional background parameter - Background tasks are restricted to read-only tools only - Results are delivered asynchronously to the parent task via onBackgroundComplete callback - Configurable concurrency limit (default 3) and timeout (default 5min) - Proper cleanup on task cancellation, parent cancellation, and provider disposal - 17 new tests for BackgroundTaskRunner, all existing tests pass Issue #12330
|
Thanks for implementing Phase 4 so quickly. The PR looks well-structured and follows the conservative approach we discussed (separate A few questions and feedback:
Overall I'm happy with the direction. Feedback welcome. |
Added user-visible VS Code notifications for background task completion, errors, and timeouts. Also documented the auto-approval design decision for read-only background tasks. All checks pass (lint, types, 19 tests). |
…nd timeouts - Add BackgroundTaskRunnerCallbacks interface with onTaskTimeout and onTaskError - Wire VS Code notifications in ClineProvider: info on completion, warning on timeout/error - Document auto-approval design decision for read-only background tasks - Add 2 new tests for callback invocation (19 total, all passing)
|
Thanks for adding the VS Code notifications and documenting the auto-approval behavior. This addresses the visibility concern nicely without breaking the webview-silent principle. A few quick questions:
If yes, I'm okay with marking this PR as ready for review. Also, just to confirm: after this PR is reviewed and merged, what would be the next recommended phase to work on? |
I reviewed the code to answer your questions. Here's what I found: 1. What do the notifications look like?The PR uses standard VS Code notification toasts (via
Currently the notifications only show the internal task ID (a generated identifier), not a human-friendly task name or result summary. The notifications are plain text toasts with no clickable action buttons -- clicking the notification does not navigate anywhere or reveal more details. The actual result content is injected into the parent task's conversation via 2. Is the Phase 4 MVP complete?From a code perspective, yes -- the core MVP functionality is all in place:
The items listed under "What is NOT in this MVP" (parallel task UI panel, tab switching, write parallelism, real-time progress, checkpointing) are all explicitly scoped out as future work. So this looks complete for the stated MVP scope. 3. Next recommended phaseBased on the roadmap progression and what's excluded from this MVP, the natural next step would be a Parallel Task UI Panel (Phase 5) that gives users visibility into running background tasks -- showing status, progress, and results in the webview rather than just VS Code toasts. This would address the current limitation where background task results are only visible if the parent task is still the foreground task when the background task completes. No code changes were needed here -- just answering the reviewer's questions from the existing implementation. |
|
Thanks for the detailed explanation. A few takeaways from your reply:
Next steps I’d like to do:
Could you mark the PR as ready, and then share your initial thoughts on what Phase 5 should include (especially around visibility and task management UI)? We can discuss the scope in the issue before moving to coding. |
|
Closing as part of PR restructuring per issue #12330. This work will be combined into the new Remaining Phases (4+5+6) PR with proper stacked branching. |
This PR attempts to address Issue #12330 (Phase 4: Background Read-Only Concurrency).
Summary
Implements the MVP for Phase 4 of the parallel execution roadmap, enabling read-only background tasks to run concurrently alongside the user's active foreground task. This is the first time the single-open invariant is relaxed -- background tasks live in a separate
backgroundTaskscollection managed byBackgroundTaskRunner, completely isolated from theclineStack.Key Changes
New:
BackgroundTaskRunnerservice (src/core/task/BackgroundTaskRunner.ts)Map<string, BackgroundTaskInfo>of concurrent background tasksModified:
Taskclass (src/core/task/Task.ts)isBackgroundTaskflag that suppresses all webview interactionsaddToClineMessages(): skipspostStateToWebviewwhen backgroundupdateClineMessage(): skipspostMessageToWebviewwhen backgroundask(): auto-approves all tool uses immediately when background (no user interaction)saveClineMessages(): skipsupdateTaskHistoryon provider when backgroundonBackgroundCompletecallback for async result deliveryModified:
new_tasktoolbackgroundparameter ("true"to spawn as background)toolParamNamesand type definitions updated inshared/tools.tsdelegateParentAndOpenChildflow entirelyModified:
AttemptCompletionToolonBackgroundCompletecallbackModified:
ClineProviderbackgroundTaskRunnerinstancespawnBackgroundTask()method that creates isolated Task instanceshandleBackgroundTaskComplete()for async result injection into parentDesign Decisions
backgroundTasksMap rather than modifying theclineStack. This keeps all existing foreground behavior completely unchanged.postStateToWebview,postMessageToWebview, orupdateTaskHistory. They accumulate messages internally only.ask()calls in background tasks are immediately approved, enabling fully autonomous execution.enableCheckpoints: falsesince they are read-only and have nothing to roll back.Testing
BackgroundTaskRunnercovering registration, completion, cancellation, parent cascading, timeout, disposal, and concurrency limitsWhat is NOT in this MVP
Feedback and guidance are welcome!
Interactively review PR in Roo Code Cloud