feat: Consolidated Phase 7 - File locks, tool integration, background task history & replay wiring#12356
Open
roomote-v0[bot] wants to merge 25 commits into
Open
feat: Consolidated Phase 7 - File locks, tool integration, background task history & replay wiring#12356roomote-v0[bot] wants to merge 25 commits into
roomote-v0[bot] wants to merge 25 commits into
Conversation
Phase 1 of #12330 - improves context handoff visibility between parent and child tasks during delegation. Changes: - Add SubtaskSummary type to @roo-code/types for structured handoff data - Create buildSubtaskSummary utility that extracts files modified/read, commands executed, tool usage, and todo stats from task history - Modify AttemptCompletionTool to build structured summary on completion - Update reopenParentFromDelegation to format enriched API history text so the parent LLM gets better context about what the subtask did - Update ChatRow UI to render structured summaries with mode badge, file lists, command lists, and todo progress - Add i18n translation keys for new UI elements - Add 19 tests for buildSubtaskSummary and formatSubtaskSummaryForApi - Backward compatible: plain-text summaries still work as before
… of #12330) Adds subtask queue support to the new_task tool, allowing the orchestrator to define multiple subtasks that execute automatically in sequence without returning to the parent between each one. This saves LLM API calls and enables more efficient multi-agent workflows. Key changes: - SubtaskQueueItem, SubtaskResult types in packages/types/src/history.ts - task_queue parameter on new_task tool (optional JSON array) - NewTaskTool parses and validates queued subtasks, stores on parent - delegateParentAndOpenChild persists queue in parent HistoryItem - reopenParentFromDelegation auto-advances queue via advanceSubtaskQueue - formatAggregatedQueueResults aggregates all results when queue completes - 9 new tests covering queue advance, exhaustion, and result formatting - All 56 existing delegation tests continue to pass
…advanceSubtaskQueue - Fix off-by-one: dispatch subtaskQueue[currentIndex] instead of subtaskQueue[nextIndex], preventing the first queued item from being skipped - Fix completedMode: fetch child history to get the child actual mode instead of incorrectly using the parent historyItem.mode - Update tests to reflect corrected queue semantics (subtaskQueueIndex represents the next item to dispatch, not the currently running item)
The Windows CI bundle step fails with EBUSY when antivirus or indexing services hold brief locks on files during copyFileSync. Add a copyFileWithRetry helper (matching the existing rmDir retry pattern) that retries up to 5 times with exponential backoff for EBUSY, EPERM, and EACCES errors.
Introduces the foundation for isolated task execution (Phase 3a of #12330): - TaskContext: immutable snapshot of mode, API config, and workspace for each task, replacing runtime reads from shared ClineProvider state - TaskPermissions: fine-grained permission boundaries (file patterns, command restrictions, read-only mode, tool allowlists) that the orchestrator can attach when spawning subtasks - TaskContextBuilder: factory functions to build TaskContext from provider state and to derive child contexts with merged permissions - Task constructor now accepts optional taskContext, using it for mode and API config initialization instead of provider.getState() - delegateParentAndOpenChild builds and passes a TaskContext to child tasks - Permission merging follows most-restrictive-wins semantics This is a pure refactor with no behavioral change -- tasks still execute sequentially, but they now carry their own isolated context. Enforcement of permission boundaries is deferred to Phase 3b/3d. Ref: #12330
Adds an optional `permissions` parameter to the `new_task` tool, allowing the Orchestrator (or any parent task) to dynamically set permission boundaries for subtasks: - New `TaskPermissions` type with filePatterns, commandPatterns, allowedTools, and deniedTools - Permission merging with most-restrictive-wins semantics for nested subtask delegation - Runtime enforcement in validateToolUse() for all permission types - Full test coverage for merging logic and enforcement Addresses Issue #12330 (Phase 3b)
…pattern merging 1. NativeToolCallParser: Remove permissions from update_todo_list cases (was erroneously added to wrong tool case, should only be on new_task) 2. deniedTools: Exempt ALWAYS_AVAILABLE_TOOLS (attempt_completion, etc.) from deniedTools check, matching the existing allowedTools behavior. Prevents parent from trapping subtask by denying completion tools. 3. Pattern merging: Replace broken exact-string intersection with layered enforcement. filePatterns/commandPatterns from parent and child are kept as separate layers (AND between layers, OR within each layer). This correctly handles narrowing: parent ["src/.*"] + child ["src/components/.*"] now allows only files matching BOTH patterns, instead of producing an empty intersection.
…ema level, simplify validation code 1. Anchor regex patterns in matchesAnyPattern with ^(?:...)$ wrapping so patterns like "src/.*" require full-path matching instead of substring matching. Prevents "evil/src/foo" from matching a "src/.*" permission. 2. Add regex validation at schema level (regexString refinement) so invalid patterns are rejected at parse time rather than silently failing at runtime. 3. Simplify duplicate file/command pattern validation in validateToolUse by unifying layered and flat code paths into a single branch that falls back to wrapping flat patterns as a single layer. 4. Remove unused matchesAnyPattern import from validateToolUse.ts. 5. Add tests for anchoring behavior, pre-anchored patterns, and invalid regex rejection at schema level.
1. Persist taskPermissions in HistoryItem so permissions survive task
restarts. Added taskPermissions field to historyItemSchema, included
it in taskMetadata output, and restored it in the Task constructor
when loading from history.
2. Add ReDoS mitigation for model-provided regex patterns:
- isSafeRegex() heuristic rejects nested quantifiers like (a+)+
and overlapping alternations in repeated groups like (a|a)+
- Max pattern length capped at 200 characters
- Both checks enforced at schema validation time via Zod refinements
- 11 new tests covering ReDoS detection and persistence round-trips
- Enhance Orchestrator customInstructions with guidance on using the permissions parameter (filePatterns, commandPatterns, allowedTools, deniedTools) including example use cases and most-restrictive-wins semantics explanation - Add permission boundaries display in the ChatRow newTask approval message so users can see what restrictions are being set before approving subtask creation - Add i18n translation keys for permission display - Add 8 new tests across packages/types and webview-ui
…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
…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)
Adds a collapsible Background Tasks Panel to the chat sidebar that shows active and recently completed background tasks. This builds on the Phase 4 BackgroundTaskRunner to give users visibility into background work. Key changes: - BackgroundTaskStatusInfo type for exposing task status to the webview - BackgroundTaskRunner tracks completed tasks with result summaries - BackgroundTaskRunner.getTasksStatus() returns combined active + completed - BackgroundTaskRunner.onStateChanged callback for UI refresh - backgroundTasks field added to ExtensionState and getStateToPostToWebview - cancelBackgroundTask webview message handler - postBackgroundTasksToWebview() for lightweight status-only updates - BackgroundTasksPanel React component with collapsible panel, cancel buttons, active count badge, and result summaries - 31 backend tests (BackgroundTaskRunner) + 7 UI tests (panel component)
…tension-point comments
…#12330) Phase 4: Background Read-Only Concurrency Phase 5: Background Tasks Panel UI Phase 6a: Conversation Replay for background tasks Phase 6b: Tab/Panel Switching for background tasks Phase 6c: Real-time Progress Streaming
…coordination Advisory file-level locking so concurrent tasks coordinate write access safely. - FileLockManager class with acquire/release/releaseAll operations - Per-file locks with automatic expiration (configurable timeout, default 2min) - Re-entrant lock support (same task can re-acquire its own lock) - Lock conflict detection with detailed conflict info - Event system for lock lifecycle (acquired/released/expired) - Reverse index for efficient per-task lock lookup - Path normalization for consistent lock keys - 39 comprehensive unit tests covering all operations Part of Phase 7 (Controlled Write Parallelism) for Issue #12330
- Integrate file lock guards into presentAssistantMessage.ts tool dispatch - Acquire locks before write tool execution, release in finally block - Block concurrent writes with LLM-friendly conflict error messages - Wire releaseAllLocks into Task.dispose() for stale lock cleanup - Add singleton getters (getFileLockManager, getLockGuardedToolExecutor) - Add 14 integration tests covering lifecycle, conflicts, and cleanup Phase 7b tool runner integration for parallel agent file coordination.
- Add background field to HistoryItem schema - Add interrupted status for background tasks stopped mid-execution - Add background option to TaskMetadataOptions - Detect and mark interrupted background tasks on TaskHistoryStore init - Add showBackgroundTasks filter to useTaskSearch hook - Add background task filter toggle to HistoryView UI - Add background/interrupted visual indicators in TaskItemFooter - Add i18n translation keys for background task labels - Add unit tests for all changes
Add backgroundTag, interruptedTag, showBackgroundTasks, hideBackgroundTasks, and filter.* keys to all 17 non-English locale files (ca, de, es, fr, hi, id, it, ja, ko, nl, pl, pt-BR, ru, tr, vi, zh-CN, zh-TW).
…dd interrupted tooltip - Consolidate Phase 7a (FileLockManager), 7b (LockGuardedToolExecutor + tool runner integration), and 7c (persistent background task history) into single branch - Wire background task clicks in History view to open the read-only BackgroundTaskReplayView instead of creating a resumable task - Add StandardTooltip on interrupted background tasks explaining they were interrupted due to VS Code closing - Add interruptedTooltip i18n key across all locales - Add tests for replay view routing and tooltip rendering Addresses feedback from #12330
This was referenced May 12, 2026
This was referenced May 12, 2026
|
@roomote please mark as ready to review |
|
@roomote please fix the conflicts |
Contributor
Author
Resolved merge conflicts with main (i18n chat.json files - retiredProvider updates + contextHandoff sections) and marked PR as ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR attempts to address Issue #12330 by consolidating all Phase 7 work into a single PR for review, as requested in the issue feedback.
What is consolidated
This PR merges the following draft PRs into one:
New changes (addressing feedback from #12330)
1. Replay view wiring for background tasks (Q1)
Background tasks clicked in the History view now open the read-only
BackgroundTaskReplayView(from Phase 6a) instead of creating a resumable task. This is done by sending aswitchTabmessage withbgTaskReplaytab and the task ID.2. Interrupted task tooltip (Q2)
Interrupted background tasks now show a
StandardTooltipexplaining: "This background task was interrupted because VS Code was closed while it was still running."3. Pre-existing type fixes
new_task.tspermissions propertytabtype declarations inExtensionMessageTaskPermissions/taskPermissionsSchemaexports fromtask-context.jsandtask-permissions.jsTest coverage
Files changed
webview-ui/src/components/history/TaskItem.tsx- route bg tasks to replay viewwebview-ui/src/components/history/TaskItemFooter.tsx- tooltip for interrupted taskswebview-ui/src/i18n/locales/*/history.json- addedinterruptedTooltipkeypackages/types/src/vscode-extension-host.ts- deduplicate tab typepackages/types/src/index.ts- fix duplicate exportssrc/core/prompts/tools/native-tools/new_task.ts- fix missing braceFeedback and guidance are welcome.
Interactively review PR in Roo Code Cloud