Skip to content

Automations PR 2 (Runner)#323810

Merged
benvillalobos merged 4 commits into
mainfrom
bv/automations-2-runner
Jul 1, 2026
Merged

Automations PR 2 (Runner)#323810
benvillalobos merged 4 commits into
mainfrom
bv/automations-2-runner

Conversation

@benvillalobos

Copy link
Copy Markdown
Member

Context

Second PR in the 4-part Automations stack. Builds on PR 1 (Foundation) which has been merged to main.

This PR implements the AutomationRunner, the execution engine that bridges the automation data layer (PR 1) to the sessions layer. When the scheduler decides an automation is due, the runner creates a chat session, configures it, sends the prompt, and records the outcome.

Architecture

classDiagram
    class AutomationRunner {
        +runOnce(automation, trigger, windowId, token)
        -_runOnceInner()
        -_markCancelled()
    }

    class ISessionsManagementService {
        +createAndSendNewChatRequest(folderUri, options, createOptions)
        -_resolveProviderForNewSession()
        -_sendNewChatRequestInBackground()
    }

    class ISessionsProvider {
        +createNewSession(folderUri, sessionTypeId)
        +setModel(sessionId, modelId)
        +setMode?(sessionId, modeId)
        +setPermissionLevel?(sessionId, level)
        +setIsolationMode?(sessionId, mode)
        +setBranch?(sessionId, branch)
        +sendRequest(sessionId, chatResource, options)
    }

    class AutomationService {
        +recordRunStart()
        +updateRun()
        Data layer (from PR 1)
    }

    AutomationRunner --> ISessionsManagementService : creates session + sends prompt
    AutomationRunner --> AutomationService : records run start/completion/failure
    ISessionsManagementService --> ISessionsProvider : configures + dispatches
Loading

Execution Flow

sequenceDiagram
    participant Sch as Scheduler
    participant R as AutomationRunner
    participant AS as AutomationService
    participant SM as SessionsManagementService
    participant P as Provider

    Sch->>R: runOnce(automation, trigger, token)
    R->>AS: recordRunStart(automationId, trigger)
    R->>SM: createAndSendNewChatRequest(folderUri, options, createOptions)
    SM->>P: createNewSession(folderUri, sessionTypeId)
    SM->>P: setModel / setMode / setPermissionLevel / setIsolationMode / setBranch
    SM->>P: sendRequest(sessionId, chatResource, options)
    P-->>SM: session
    SM-->>R: session
    alt cancelled mid-flight
        R->>AS: updateRun(failed, "Cancelled")
    else success
        R->>AS: updateRun(completed, sessionId)
    else error
        R->>AS: updateRun(failed, errorMessage)
        R->>Notification: show error to user
    end
Loading

What's New

New file: src/vs/sessions/contrib/automations/browser/automationRunner.ts

  • Implements IAutomationRunner (interface from PR 1).
  • Creates sessions programmatically via createAndSendNewChatRequest.
  • Handles mid-flight cancellation by re-checking the token post-send.
  • Reports telemetry on success and failure.

Sessions layer extensions:

  • ISessionsManagementService.createAndSendNewChatRequest() for programmatic session creation without the composer UI. Cleans up stranded sessions on failure.
  • ISessionsProvider gains 4 optional setters: setMode?, setPermissionLevel?, setIsolationMode?, setBranch?. These were previously only callable through the concrete provider class from UI widgets.
  • ISendRequestOptions.title lets callers pre-name the session so it shows a meaningful title during launch.

Telemetry: Refactored to report actual enum values (permissionLevel, isolationMode) instead of boolean flags.

…a sessions layer

Implements AutomationRunner:
- Creates sessions with configured prompt, mode, model, and permission level
- Dispatches via createAndSendNewChatRequest (background session)
- Tracks run lifecycle: recordRunStart/updateRun on IAutomationService
- Error notification on run failure
- Cancellation handling for mid-flight stops
- Sessions titled with automation name via renameChat

Supporting changes:
- ICreateNewSessionOptions: added modelId, modeId, permissionLevel, isolationMode, branch
- ISessionsProvider: added optional setMode/setPermissionLevel/setIsolationMode/setBranch
- ISendRequestOptions: added optional source field
- createAndSendNewChatRequest now returns ISession | undefined
- Implementation applies createOptions to provider before sending

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 1, 2026 00:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds the sessions-layer execution engine for Chat Automations by introducing an AutomationRunner that creates and configures a new chat session via ISessionsManagementService, sends the automation prompt in the background, and records run outcomes. It also extends the sessions management/provider APIs to support programmatic session configuration (model/mode/permission/isolation/branch) and pre-titling sessions for better UX during launch.

Changes:

  • Add AutomationRunner (sessions layer) plus unit tests; wire it into the automations contribution.
  • Extend ISessionsManagementService.createAndSendNewChatRequest to return the started ISession | undefined and accept richer ICreateNewSessionOptions for session configuration.
  • Extend ISessionsProvider request options with an optional title, and add optional provider setters (setMode, setPermissionLevel, setIsolationMode, setBranch).
Show a summary per file
File Description
src/vs/sessions/services/sessions/test/browser/sessionNavigation.test.ts Updates mock signature for createAndSendNewChatRequest return type.
src/vs/sessions/services/sessions/common/sessionsProvider.ts Adds ISendRequestOptions.title and optional provider configuration setter APIs.
src/vs/sessions/services/sessions/common/sessionsManagement.ts Extends ICreateNewSessionOptions and updates createAndSendNewChatRequest return type.
src/vs/sessions/services/sessions/browser/sessionsManagementService.ts Implements configuration application before send; returns committed session (or undefined).
src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.ts Uses options.title when setting initial session title.
src/vs/sessions/contrib/automations/test/browser/automationRunner.test.ts Adds coverage for runner success/failure/cancellation and option pass-through.
src/vs/sessions/contrib/automations/browser/automations.contribution.ts Registers the real AutomationRunner instead of a stub.
src/vs/sessions/contrib/automations/browser/automationRunner.ts New runner implementation bridging automations to sessions + telemetry/notifications.

Review details

  • Files reviewed: 8/8 changed files
  • Comments generated: 9
  • Review effort level: Low

Comment thread src/vs/sessions/contrib/automations/browser/automationRunner.ts Outdated
Comment thread src/vs/sessions/contrib/automations/browser/automationRunner.ts
Comment thread src/vs/sessions/contrib/automations/browser/automationRunner.ts Outdated
Comment thread src/vs/sessions/contrib/automations/browser/automationRunner.ts Outdated
Comment thread src/vs/sessions/contrib/automations/browser/automationRunner.ts
Comment thread src/vs/sessions/services/sessions/common/sessionsProvider.ts Outdated
Comment thread src/vs/sessions/services/sessions/common/sessionsManagement.ts
Comment thread src/vs/sessions/services/sessions/browser/sessionsManagementService.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 8/8 changed files
  • Comments generated: 7
  • Review effort level: Low

Comment thread src/vs/sessions/services/sessions/common/sessionsProvider.ts Outdated
Comment thread src/vs/sessions/contrib/automations/browser/automationRunner.ts Outdated
Comment thread src/vs/sessions/contrib/automations/browser/automationRunner.ts Outdated
Comment thread src/vs/sessions/services/sessions/common/sessionsManagement.ts Outdated
Comment thread src/vs/sessions/services/sessions/browser/sessionsManagementService.ts Outdated
@benvillalobos
benvillalobos force-pushed the bv/automations-2-runner branch 2 times, most recently from 339bef7 to ec62d82 Compare July 1, 2026 05:18
@benvillalobos
benvillalobos requested a review from Copilot July 1, 2026 15:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 9/9 changed files
  • Comments generated: 6
  • Review effort level: Low

Comment thread src/vs/sessions/services/sessions/common/sessionsManagement.ts Outdated
Comment thread src/vs/sessions/services/sessions/common/sessionsManagement.ts Outdated
Comment thread src/vs/sessions/services/sessions/common/sessionsManagement.ts Outdated
Comment thread src/vs/sessions/services/sessions/common/sessionsManagement.ts Outdated
Comment thread src/vs/sessions/services/sessions/common/sessionsManagement.ts Outdated
Comment thread src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts Outdated
@benvillalobos
benvillalobos force-pushed the bv/automations-2-runner branch 3 times, most recently from 9238578 to d93331d Compare July 1, 2026 16:14
@benvillalobos
benvillalobos marked this pull request as ready for review July 1, 2026 16:31
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@sandy081

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsManagementService.ts
  • src/vs/sessions/services/sessions/common/sessionsManagement.ts
  • src/vs/sessions/services/sessions/common/sessionsProvider.ts
  • src/vs/sessions/services/sessions/test/browser/sessionNavigation.test.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts

@lszomoru

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsManagementService.ts
  • src/vs/sessions/services/sessions/common/sessionsManagement.ts
  • src/vs/sessions/services/sessions/common/sessionsProvider.ts
  • src/vs/sessions/services/sessions/test/browser/sessionNavigation.test.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts

Thread an optional title through ISendRequestOptions and apply it in
_sendFirstChat before sending, falling back to the query's first line.
The automation runner passes the automation name, so launch-time prompts
(e.g. worktree file transfer) show the automation name instead of the
prompt text. The post-send renameChat still sets the committed CLI title.
@benvillalobos
benvillalobos force-pushed the bv/automations-2-runner branch from d93331d to 6cbac8f Compare July 1, 2026 16:35
@benvillalobos
benvillalobos enabled auto-merge (squash) July 1, 2026 16:39
@benvillalobos
benvillalobos merged commit 126f9a2 into main Jul 1, 2026
29 checks passed
@benvillalobos
benvillalobos deleted the bv/automations-2-runner branch July 1, 2026 17:02
@vs-code-engineering vs-code-engineering Bot added this to the 1.128.0 milestone Jul 1, 2026
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