Skip to content

Commit c632b22

Browse files
authored
Revert "Extension bridge (#6677)" (#6729)
1 parent ea79dfe commit c632b22

30 files changed

+84
-400
lines changed

pnpm-lock.yaml

Lines changed: 13 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/task/Task.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
isBlockingAsk,
3333
} from "@roo-code/types"
3434
import { TelemetryService } from "@roo-code/telemetry"
35-
import { CloudService, TaskBridgeService } from "@roo-code/cloud"
35+
import { CloudService } from "@roo-code/cloud"
3636

3737
// api
3838
import { ApiHandler, ApiHandlerCreateMessageMetadata, buildApiHandler } from "../../api"
@@ -118,7 +118,6 @@ export type TaskOptions = {
118118
parentTask?: Task
119119
taskNumber?: number
120120
onCreated?: (task: Task) => void
121-
enableTaskBridge?: boolean
122121
}
123122

124123
export class Task extends EventEmitter<TaskEvents> implements TaskLike {
@@ -238,9 +237,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
238237
checkpointService?: RepoPerTaskCheckpointService
239238
checkpointServiceInitializing = false
240239

241-
// Task Bridge
242-
taskBridgeService?: TaskBridgeService
243-
244240
// Streaming
245241
isWaitingForFirstChunk = false
246242
isStreaming = false
@@ -272,7 +268,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
272268
parentTask,
273269
taskNumber = -1,
274270
onCreated,
275-
enableTaskBridge = false,
276271
}: TaskOptions) {
277272
super()
278273

@@ -350,11 +345,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
350345

351346
this.toolRepetitionDetector = new ToolRepetitionDetector(this.consecutiveMistakeLimit)
352347

353-
// Initialize TaskBridgeService only if enabled
354-
if (enableTaskBridge) {
355-
this.taskBridgeService = TaskBridgeService.getInstance()
356-
}
357-
358348
onCreated?.(this)
359349

360350
if (startTask) {
@@ -941,11 +931,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
941931
// Start / Abort / Resume
942932

943933
private async startTask(task?: string, images?: string[]): Promise<void> {
944-
if (this.taskBridgeService) {
945-
await this.taskBridgeService.initialize()
946-
await this.taskBridgeService.subscribeToTask(this)
947-
}
948-
949934
// `conversationHistory` (for API) and `clineMessages` (for webview)
950935
// need to be in sync.
951936
// If the extension process were killed, then on restart the
@@ -997,11 +982,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
997982
}
998983

999984
private async resumeTaskFromHistory() {
1000-
if (this.taskBridgeService) {
1001-
await this.taskBridgeService.initialize()
1002-
await this.taskBridgeService.subscribeToTask(this)
1003-
}
1004-
1005985
const modifiedClineMessages = await this.getSavedClineMessages()
1006986

1007987
// Remove any resume messages that may have been added before
@@ -1247,13 +1227,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
12471227
this.pauseInterval = undefined
12481228
}
12491229

1250-
// Unsubscribe from TaskBridge service.
1251-
if (this.taskBridgeService) {
1252-
this.taskBridgeService
1253-
.unsubscribeFromTask(this.taskId)
1254-
.catch((error) => console.error("Error unsubscribing from task bridge:", error))
1255-
}
1256-
12571230
// Release any terminals associated with this task.
12581231
try {
12591232
// Release any terminals associated with this task.

src/core/webview/ClineProvider.ts

Lines changed: 3 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
6566
import { setTtsEnabled, setTtsSpeed } from "../../utils/tts"
6667
import { getWorkspaceGitInfo } from "../../utils/git"
6768
import { getWorkspacePath } from "../../utils/path"
68-
import { isRemoteControlEnabled } from "../../utils/remoteControl"
6969

7070
import { 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

src/core/webview/webviewMessageHandler.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -907,11 +907,6 @@ export const webviewMessageHandler = async (
907907
await updateGlobalState("enableMcpServerCreation", message.bool ?? true)
908908
await provider.postStateToWebview()
909909
break
910-
case "remoteControlEnabled":
911-
await updateGlobalState("remoteControlEnabled", message.bool ?? false)
912-
await provider.handleRemoteControlToggle(message.bool ?? false)
913-
await provider.postStateToWebview()
914-
break
915910
case "refreshAllMcpServers": {
916911
const mcpHub = provider.getMcpHub()
917912
if (mcpHub) {

0 commit comments

Comments
 (0)