Skip to content

Sessions: Use ITaskService to run tasks instead of terminal commands#304397

Merged
benibenj merged 1 commit intomainfrom
copilot/useful-sheep
Mar 24, 2026
Merged

Sessions: Use ITaskService to run tasks instead of terminal commands#304397
benibenj merged 1 commit intomainfrom
copilot/useful-sheep

Conversation

@benibenj
Copy link
Contributor

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 only shell and npm task types were supported.

Changes

sessionsConfigurationService.ts:

  • runTask() now resolves the session's workspace folder via IWorkspaceContextService, looks up the task by label via ITaskService.getTask(), and runs it with ITaskService.run() — delegating all platform-specific execution to the task system
  • Removed ITerminalService dependency, _resolveCommand, _appendArgs, _getExistingTerminalInstance, _taskTerminals cache, and _SUPPORTED_TASK_TYPES filter
  • All task types are now supported (not just shell and npm)

sessionsConfigurationService.test.ts:

  • Replaced terminal mocks with ITaskService and IWorkspaceContextService mocks
  • Updated runTask tests to verify task service interaction instead of terminal creation/command sending
  • Updated filter tests to reflect that all task types are now accepted

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>
Copilot AI review requested due to automatic review settings March 24, 2026 08:42
@vs-code-engineering vs-code-engineering bot added this to the 1.114.0 milestone Mar 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/npm task types are included.
  • Updated unit tests to mock ITaskService + IWorkspaceContextService and 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.

@benibenj benibenj merged commit de4d27a into main Mar 24, 2026
34 of 35 checks passed
@benibenj benibenj deleted the copilot/useful-sheep branch March 24, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants