Sessions: Use ITaskService to run tasks instead of terminal commands#304397
Merged
Sessions: Use ITaskService to run tasks instead of terminal commands#304397
Conversation
Replace the hacky terminal-based task execution (creating a terminal and sending commands directly) with proper ITaskService.run() delegation. This ensures all task types are supported on all platforms, not just shell and npm tasks. Changes: - runTask now looks up the task by label via ITaskService.getTask() using the workspace folder for the session worktree, then runs it via ITaskService.run() - Removed _resolveCommand, _appendArgs, _getExistingTerminalInstance and the _taskTerminals cache (no longer needed) - Removed _SUPPORTED_TASK_TYPES filter since the task service handles all task types - Replaced ITerminalService dependency with ITaskService and IWorkspaceContextService - Updated tests to mock ITaskService and IWorkspaceContextService Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Agent Sessions window task execution flow to delegate task running to VS Code’s task system (ITaskService.run) instead of manually sending command strings to a terminal, enabling support for all task types and better platform consistency.
Changes:
- Replaced terminal-command-based task execution with
ITaskService.getTask(...)/run(...)in the sessions configuration service. - Removed terminal-specific task filtering/caching logic so non-
shell/npmtask types are included. - Updated unit tests to mock
ITaskService+IWorkspaceContextServiceand assert task-service-based execution paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/vs/sessions/contrib/chat/browser/sessionsConfigurationService.ts | Switches runTask to resolve tasks by label via ITaskService and run them through the tasks system; broadens task filtering. |
| src/vs/sessions/contrib/chat/test/browser/sessionsConfigurationService.test.ts | Refactors tests away from terminal mocks toward task service/workspace context mocks and updates expectations for additional task types. |
src/vs/sessions/contrib/chat/test/browser/sessionsConfigurationService.test.ts
Show resolved
Hide resolved
joaomoreno
approved these changes
Mar 24, 2026
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.
Summary
Replace the hacky terminal-based task execution in the sessions window with proper
ITaskService.run()delegation. Previously, running a task from the dropdown menu created a terminal instance and sent a command string directly, which meant onlyshellandnpmtask types were supported.Changes
sessionsConfigurationService.ts:runTask()now resolves the session's workspace folder viaIWorkspaceContextService, looks up the task by label viaITaskService.getTask(), and runs it withITaskService.run()— delegating all platform-specific execution to the task systemITerminalServicedependency,_resolveCommand,_appendArgs,_getExistingTerminalInstance,_taskTerminalscache, and_SUPPORTED_TASK_TYPESfiltershellandnpm)sessionsConfigurationService.test.ts:ITaskServiceandIWorkspaceContextServicemocksrunTasktests to verify task service interaction instead of terminal creation/command sending