@@ -17,6 +17,7 @@ import {
1717 type ProviderSettings ,
1818 type RooCodeSettings ,
1919 type ProviderSettingsEntry ,
20+ type ProviderSettingsWithId ,
2021 type TelemetryProperties ,
2122 type TelemetryPropertiesProvider ,
2223 type CodeActionId ,
@@ -65,7 +66,6 @@ import { fileExistsAtPath } from "../../utils/fs"
6566import { setTtsEnabled , setTtsSpeed } from "../../utils/tts"
6667import { getWorkspaceGitInfo } from "../../utils/git"
6768import { getWorkspacePath } from "../../utils/path"
68- import { isRemoteControlEnabled } from "../../utils/remoteControl"
6969
7070import { setPanel } from "../../activate/registerCommands"
7171
@@ -112,8 +112,6 @@ export class ClineProvider
112112 protected mcpHub ?: McpHub // Change from private to protected
113113 private marketplaceManager : MarketplaceManager
114114 private mdmService ?: MdmService
115- private taskCreationCallback : ( task : Task ) => void
116- private taskEventListeners : WeakMap < Task , Array < ( ) => void > > = new WeakMap ( )
117115
118116 public isViewLaunched = false
119117 public settingsImportedAt ?: number
@@ -163,40 +161,6 @@ export class ClineProvider
163161
164162 this . marketplaceManager = new MarketplaceManager ( this . context , this . customModesManager )
165163
166- this . taskCreationCallback = ( instance : Task ) => {
167- this . emit ( RooCodeEventName . TaskCreated , instance )
168-
169- // Create named listener functions so we can remove them later.
170- const onTaskStarted = ( ) => this . emit ( RooCodeEventName . TaskStarted , instance . taskId )
171- const onTaskCompleted = ( taskId : string , tokenUsage : any , toolUsage : any ) =>
172- this . emit ( RooCodeEventName . TaskCompleted , taskId , tokenUsage , toolUsage )
173- const onTaskAborted = ( ) => this . emit ( RooCodeEventName . TaskAborted , instance . taskId )
174- const onTaskFocused = ( ) => this . emit ( RooCodeEventName . TaskFocused , instance . taskId )
175- const onTaskUnfocused = ( ) => this . emit ( RooCodeEventName . TaskUnfocused , instance . taskId )
176- const onTaskActive = ( taskId : string ) => this . emit ( RooCodeEventName . TaskActive , taskId )
177- const onTaskIdle = ( taskId : string ) => this . emit ( RooCodeEventName . TaskIdle , taskId )
178-
179- // Attach the listeners.
180- instance . on ( RooCodeEventName . TaskStarted , onTaskStarted )
181- instance . on ( RooCodeEventName . TaskCompleted , onTaskCompleted )
182- instance . on ( RooCodeEventName . TaskAborted , onTaskAborted )
183- instance . on ( RooCodeEventName . TaskFocused , onTaskFocused )
184- instance . on ( RooCodeEventName . TaskUnfocused , onTaskUnfocused )
185- instance . on ( RooCodeEventName . TaskActive , onTaskActive )
186- instance . on ( RooCodeEventName . TaskIdle , onTaskIdle )
187-
188- // Store the cleanup functions for later removal.
189- this . taskEventListeners . set ( instance , [
190- ( ) => instance . off ( RooCodeEventName . TaskStarted , onTaskStarted ) ,
191- ( ) => instance . off ( RooCodeEventName . TaskCompleted , onTaskCompleted ) ,
192- ( ) => instance . off ( RooCodeEventName . TaskAborted , onTaskAborted ) ,
193- ( ) => instance . off ( RooCodeEventName . TaskFocused , onTaskFocused ) ,
194- ( ) => instance . off ( RooCodeEventName . TaskUnfocused , onTaskUnfocused ) ,
195- ( ) => instance . off ( RooCodeEventName . TaskActive , onTaskActive ) ,
196- ( ) => instance . off ( RooCodeEventName . TaskIdle , onTaskIdle ) ,
197- ] )
198- }
199-
200164 // Initialize Roo Code Cloud profile sync.
201165 this . initializeCloudProfileSync ( ) . catch ( ( error ) => {
202166 this . log ( `Failed to initialize cloud profile sync: ${ error } ` )
@@ -332,14 +296,6 @@ export class ClineProvider
332296
333297 task . emit ( RooCodeEventName . TaskUnfocused )
334298
335- // Remove event listeners before clearing the reference.
336- const cleanupFunctions = this . taskEventListeners . get ( task )
337-
338- if ( cleanupFunctions ) {
339- cleanupFunctions . forEach ( ( cleanup ) => cleanup ( ) )
340- this . taskEventListeners . delete ( task )
341- }
342-
343299 // Make sure no reference kept, once promises end it will be
344300 // garbage collected.
345301 task = undefined
@@ -696,17 +652,12 @@ export class ClineProvider
696652 enableCheckpoints,
697653 fuzzyMatchThreshold,
698654 experiments,
699- cloudUserInfo,
700- remoteControlEnabled,
701655 } = await this . getState ( )
702656
703657 if ( ! ProfileValidator . isProfileAllowed ( apiConfiguration , organizationAllowList ) ) {
704658 throw new OrganizationAllowListViolationError ( t ( "common:errors.violated_organization_allowlist" ) )
705659 }
706660
707- // Determine if TaskBridge should be enabled
708- const enableTaskBridge = isRemoteControlEnabled ( cloudUserInfo , remoteControlEnabled )
709-
710661 const task = new Task ( {
711662 provider : this ,
712663 apiConfiguration,
@@ -720,8 +671,7 @@ export class ClineProvider
720671 rootTask : this . clineStack . length > 0 ? this . clineStack [ 0 ] : undefined ,
721672 parentTask,
722673 taskNumber : this . clineStack . length + 1 ,
723- onCreated : this . taskCreationCallback ,
724- enableTaskBridge,
674+ onCreated : ( instance ) => this . emit ( RooCodeEventName . TaskCreated , instance ) ,
725675 ...options ,
726676 } )
727677
@@ -786,13 +736,8 @@ export class ClineProvider
786736 enableCheckpoints,
787737 fuzzyMatchThreshold,
788738 experiments,
789- cloudUserInfo,
790- remoteControlEnabled,
791739 } = await this . getState ( )
792740
793- // Determine if TaskBridge should be enabled
794- const enableTaskBridge = isRemoteControlEnabled ( cloudUserInfo , remoteControlEnabled )
795-
796741 const task = new Task ( {
797742 provider : this ,
798743 apiConfiguration,
@@ -805,8 +750,7 @@ export class ClineProvider
805750 rootTask : historyItem . rootTask ,
806751 parentTask : historyItem . parentTask ,
807752 taskNumber : historyItem . number ,
808- onCreated : this . taskCreationCallback ,
809- enableTaskBridge,
753+ onCreated : ( instance ) => this . emit ( RooCodeEventName . TaskCreated , instance ) ,
810754 } )
811755
812756 await this . addClineToStack ( task )
@@ -1685,7 +1629,6 @@ export class ClineProvider
16851629 includeDiagnosticMessages,
16861630 maxDiagnosticMessages,
16871631 includeTaskHistoryInEnhance,
1688- remoteControlEnabled,
16891632 } = await this . getState ( )
16901633
16911634 const telemetryKey = process . env . POSTHOG_API_KEY
@@ -1813,7 +1756,6 @@ export class ClineProvider
18131756 includeDiagnosticMessages : includeDiagnosticMessages ?? true ,
18141757 maxDiagnosticMessages : maxDiagnosticMessages ?? 50 ,
18151758 includeTaskHistoryInEnhance : includeTaskHistoryInEnhance ?? false ,
1816- remoteControlEnabled : remoteControlEnabled ?? false ,
18171759 }
18181760 }
18191761
@@ -2001,8 +1943,6 @@ export class ClineProvider
20011943 maxDiagnosticMessages : stateValues . maxDiagnosticMessages ?? 50 ,
20021944 // Add includeTaskHistoryInEnhance setting
20031945 includeTaskHistoryInEnhance : stateValues . includeTaskHistoryInEnhance ?? false ,
2004- // Add remoteControlEnabled setting
2005- remoteControlEnabled : stateValues . remoteControlEnabled ?? false ,
20061946 }
20071947 }
20081948
@@ -2115,55 +2055,6 @@ export class ClineProvider
21152055 return true
21162056 }
21172057
2118- /**
2119- * Handle remote control enabled/disabled state changes
2120- * Manages ExtensionBridgeService and TaskBridgeService lifecycle
2121- */
2122- public async handleRemoteControlToggle ( enabled : boolean ) : Promise < void > {
2123- const {
2124- CloudService : CloudServiceImport ,
2125- ExtensionBridgeService,
2126- TaskBridgeService,
2127- } = await import ( "@roo-code/cloud" )
2128- const userInfo = CloudServiceImport . instance . getUserInfo ( )
2129-
2130- // Handle ExtensionBridgeService using static method
2131- await ExtensionBridgeService . handleRemoteControlState ( userInfo , enabled , this , ( message : string ) =>
2132- this . log ( message ) ,
2133- )
2134-
2135- if ( isRemoteControlEnabled ( userInfo , enabled ) ) {
2136- // Set up TaskBridgeService for the currently active task if one exists
2137- const currentTask = this . getCurrentCline ( )
2138- if ( currentTask && ! currentTask . taskBridgeService ) {
2139- try {
2140- currentTask . taskBridgeService = TaskBridgeService . getInstance ( )
2141- await currentTask . taskBridgeService . subscribeToTask ( currentTask )
2142- this . log ( `[TaskBridgeService] Subscribed current task ${ currentTask . taskId } to TaskBridge` )
2143- } catch ( error ) {
2144- const message = `[TaskBridgeService#subscribeToTask] ${ error instanceof Error ? error . message : String ( error ) } `
2145- this . log ( message )
2146- console . error ( message )
2147- }
2148- }
2149- } else {
2150- // Disconnect TaskBridgeService for all tasks in the stack
2151- for ( const task of this . clineStack ) {
2152- if ( task . taskBridgeService ) {
2153- try {
2154- await task . taskBridgeService . unsubscribeFromTask ( task . taskId )
2155- task . taskBridgeService = undefined
2156- this . log ( `[TaskBridgeService] Unsubscribed task ${ task . taskId } from TaskBridge` )
2157- } catch ( error ) {
2158- const message = `[TaskBridgeService#unsubscribeFromTask] for task ${ task . taskId } : ${ error instanceof Error ? error . message : String ( error ) } `
2159- this . log ( message )
2160- console . error ( message )
2161- }
2162- }
2163- }
2164- }
2165- }
2166-
21672058 /**
21682059 * Returns properties to be included in every telemetry event
21692060 * This method is called by the telemetry service to get context information
0 commit comments