@@ -52,6 +52,7 @@ import { BrowserSession } from "../../services/browser/BrowserSession"
5252import { McpHub } from "../../services/mcp/McpHub"
5353import { McpServerManager } from "../../services/mcp/McpServerManager"
5454import { RepoPerTaskCheckpointService } from "../../services/checkpoints"
55+ import { TaskBridgeService } from "../../services/task-bridge/TaskBridgeService"
5556
5657// integrations
5758import { DiffViewProvider } from "../../integrations/editor/DiffViewProvider"
@@ -247,6 +248,9 @@ export class Task extends EventEmitter<TaskEvents> {
247248 checkpointService ?: RepoPerTaskCheckpointService
248249 checkpointServiceInitializing = false
249250
251+ // Task Bridge
252+ taskBridgeService ?: TaskBridgeService
253+
250254 // Streaming
251255 isWaitingForFirstChunk = false
252256 isStreaming = false
@@ -351,6 +355,12 @@ export class Task extends EventEmitter<TaskEvents> {
351355
352356 this . toolRepetitionDetector = new ToolRepetitionDetector ( this . consecutiveMistakeLimit )
353357
358+ // TODO: Figure out when to enable task bridge.
359+ // eslint-disable-next-line no-constant-condition
360+ if ( true ) {
361+ this . taskBridgeService = TaskBridgeService . getInstance ( )
362+ }
363+
354364 onCreated ?.( this )
355365
356366 if ( startTask ) {
@@ -1210,6 +1220,13 @@ export class Task extends EventEmitter<TaskEvents> {
12101220 this . pauseInterval = undefined
12111221 }
12121222
1223+ // Unsubscribe from TaskBridge service.
1224+ if ( this . taskBridgeService ) {
1225+ this . taskBridgeService
1226+ . unsubscribeFromTask ( this . taskId )
1227+ . catch ( ( error ) => console . error ( "Error unsubscribing from task bridge:" , error ) )
1228+ }
1229+
12131230 // Release any terminals associated with this task.
12141231 try {
12151232 // Release any terminals associated with this task.
@@ -1304,6 +1321,11 @@ export class Task extends EventEmitter<TaskEvents> {
13041321 // Kicks off the checkpoints initialization process in the background.
13051322 getCheckpointService ( this )
13061323
1324+ if ( this . taskBridgeService ) {
1325+ await this . taskBridgeService . initialize ( )
1326+ await this . taskBridgeService . subscribeToTask ( this )
1327+ }
1328+
13071329 let nextUserContent = userContent
13081330 let includeFileDetails = true
13091331
0 commit comments