@@ -167,6 +167,8 @@ export class ClineProvider
167
167
168
168
this . marketplaceManager = new MarketplaceManager ( this . context , this . customModesManager )
169
169
170
+ // Forward <most> task events to the provider.
171
+ // We do something fairly similar for the IPC-based API.
170
172
this . taskCreationCallback = ( instance : Task ) => {
171
173
this . emit ( RooCodeEventName . TaskCreated , instance )
172
174
@@ -348,18 +350,18 @@ export class ClineProvider
348
350
let task = this . clineStack . pop ( )
349
351
350
352
if ( task ) {
353
+ task . emit ( RooCodeEventName . TaskUnfocused )
354
+
351
355
try {
352
356
// Abort the running task and set isAbandoned to true so
353
357
// all running promises will exit as well.
354
358
await task . abortTask ( true )
355
359
} catch ( e ) {
356
360
this . log (
357
- `[removeClineFromStack] encountered error while aborting task ${ task . taskId } .${ task . instanceId } : ${ e . message } ` ,
361
+ `[ClineProvider# removeClineFromStack] abortTask() failed ${ task . taskId } .${ task . instanceId } : ${ e . message } ` ,
358
362
)
359
363
}
360
364
361
- task . emit ( RooCodeEventName . TaskUnfocused )
362
-
363
365
// Remove event listeners before clearing the reference.
364
366
const cleanupFunctions = this . taskEventListeners . get ( task )
365
367
@@ -407,12 +409,6 @@ export class ClineProvider
407
409
await this . getCurrentTask ( ) ?. resumePausedTask ( lastMessage )
408
410
}
409
411
410
- // Clear the current task without treating it as a subtask.
411
- // This is used when the user cancels a task that is not a subtask.
412
- async clearTask ( ) {
413
- await this . removeClineFromStack ( )
414
- }
415
-
416
412
resumeTask ( taskId : string ) : void {
417
413
// Use the existing showTaskWithId method which handles both current and historical tasks
418
414
this . showTaskWithId ( taskId ) . catch ( ( error ) => {
@@ -1365,6 +1361,16 @@ export class ClineProvider
1365
1361
await this . createTaskWithHistoryItem ( { ...historyItem , rootTask, parentTask, preservedFCOState } )
1366
1362
}
1367
1363
1364
+ // Clear the current task without treating it as a subtask.
1365
+ // This is used when the user cancels a task that is not a subtask.
1366
+ async clearTask ( ) {
1367
+ if ( this . clineStack . length > 0 ) {
1368
+ const task = this . clineStack [ this . clineStack . length - 1 ]
1369
+ console . log ( `[clearTask] clearing task ${ task . taskId } .${ task . instanceId } ` )
1370
+ await this . removeClineFromStack ( )
1371
+ }
1372
+ }
1373
+
1368
1374
async updateCustomInstructions ( instructions ?: string ) {
1369
1375
// User may be clearing the field.
1370
1376
await this . updateGlobalState ( "customInstructions" , instructions || undefined )
@@ -1643,6 +1649,7 @@ export class ClineProvider
1643
1649
} )
1644
1650
} catch ( error ) {
1645
1651
console . error ( "Failed to fetch marketplace data:" , error )
1652
+
1646
1653
// Send empty data on error to prevent UI from hanging
1647
1654
this . postMessageToWebview ( {
1648
1655
type : "marketplaceData" ,
@@ -2272,24 +2279,23 @@ export class ClineProvider
2272
2279
if ( bridge ) {
2273
2280
const currentTask = this . getCurrentTask ( )
2274
2281
2275
- if ( currentTask && ! currentTask . bridge ) {
2282
+ if ( currentTask && ! currentTask . enableBridge ) {
2276
2283
try {
2277
- currentTask . bridge = bridge
2278
- await currentTask . bridge . subscribeToTask ( currentTask )
2284
+ currentTask . enableBridge = true
2285
+ await BridgeOrchestrator . subscribeToTask ( currentTask )
2279
2286
} catch ( error ) {
2280
- const message = `[ClineProvider#remoteControlEnabled] subscribeToTask failed - ${ error instanceof Error ? error . message : String ( error ) } `
2287
+ const message = `[ClineProvider#remoteControlEnabled] BridgeOrchestrator. subscribeToTask() failed: ${ error instanceof Error ? error . message : String ( error ) } `
2281
2288
this . log ( message )
2282
2289
console . error ( message )
2283
2290
}
2284
2291
}
2285
2292
} else {
2286
2293
for ( const task of this . clineStack ) {
2287
- if ( task . bridge ) {
2294
+ if ( task . enableBridge ) {
2288
2295
try {
2289
- await task . bridge . unsubscribeFromTask ( task . taskId )
2290
- task . bridge = null
2296
+ await BridgeOrchestrator . getInstance ( ) ?. unsubscribeFromTask ( task . taskId )
2291
2297
} catch ( error ) {
2292
- const message = `[ClineProvider#remoteControlEnabled] unsubscribeFromTask failed - ${ error instanceof Error ? error . message : String ( error ) } `
2298
+ const message = `[ClineProvider#remoteControlEnabled] BridgeOrchestrator# unsubscribeFromTask() failed: ${ error instanceof Error ? error . message : String ( error ) } `
2293
2299
this . log ( message )
2294
2300
console . error ( message )
2295
2301
}
0 commit comments