Skip to content

Commit b1300e5

Browse files
ctemrubens
andauthored
Bring back roomote control (#6796)
Co-authored-by: Matt Rubens <[email protected]>
1 parent 4ae9014 commit b1300e5

30 files changed

+558
-85
lines changed

pnpm-lock.yaml

Lines changed: 101 additions & 13 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: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
isBlockingAsk,
3434
} from "@roo-code/types"
3535
import { TelemetryService } from "@roo-code/telemetry"
36-
import { CloudService } from "@roo-code/cloud"
36+
import { CloudService, TaskBridgeService } from "@roo-code/cloud"
3737

3838
// api
3939
import { ApiHandler, ApiHandlerCreateMessageMetadata, buildApiHandler } from "../../api"
@@ -108,6 +108,7 @@ export type TaskOptions = {
108108
apiConfiguration: ProviderSettings
109109
enableDiff?: boolean
110110
enableCheckpoints?: boolean
111+
enableTaskBridge?: boolean
111112
fuzzyMatchThreshold?: number
112113
consecutiveMistakeLimit?: number
113114
task?: string
@@ -238,6 +239,10 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
238239
checkpointService?: RepoPerTaskCheckpointService
239240
checkpointServiceInitializing = false
240241

242+
// Task Bridge
243+
enableTaskBridge: boolean
244+
taskBridgeService: TaskBridgeService | null = null
245+
241246
// Streaming
242247
isWaitingForFirstChunk = false
243248
isStreaming = false
@@ -261,6 +266,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
261266
apiConfiguration,
262267
enableDiff = false,
263268
enableCheckpoints = true,
269+
enableTaskBridge = false,
264270
fuzzyMatchThreshold = 1.0,
265271
consecutiveMistakeLimit = DEFAULT_CONSECUTIVE_MISTAKE_LIMIT,
266272
task,
@@ -309,6 +315,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
309315
this.globalStoragePath = provider.context.globalStorageUri.fsPath
310316
this.diffViewProvider = new DiffViewProvider(this.cwd, this)
311317
this.enableCheckpoints = enableCheckpoints
318+
this.enableTaskBridge = enableTaskBridge
312319

313320
this.rootTask = rootTask
314321
this.parentTask = parentTask
@@ -973,6 +980,22 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
973980
// Start / Abort / Resume
974981

975982
private async startTask(task?: string, images?: string[]): Promise<void> {
983+
if (this.enableTaskBridge && CloudService.hasInstance()) {
984+
if (!this.taskBridgeService) {
985+
const bridgeConfig = await CloudService.instance.cloudAPI?.bridgeConfig()
986+
987+
if (bridgeConfig) {
988+
this.taskBridgeService = await TaskBridgeService.createInstance({
989+
...bridgeConfig,
990+
})
991+
}
992+
}
993+
994+
if (this.taskBridgeService) {
995+
await this.taskBridgeService.subscribeToTask(this)
996+
}
997+
}
998+
976999
// `conversationHistory` (for API) and `clineMessages` (for webview)
9771000
// need to be in sync.
9781001
// If the extension process were killed, then on restart the
@@ -1024,6 +1047,22 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
10241047
}
10251048

10261049
private async resumeTaskFromHistory() {
1050+
if (this.enableTaskBridge && CloudService.hasInstance()) {
1051+
if (!this.taskBridgeService) {
1052+
const bridgeConfig = await CloudService.instance.cloudAPI?.bridgeConfig()
1053+
1054+
if (bridgeConfig) {
1055+
this.taskBridgeService = await TaskBridgeService.createInstance({
1056+
...bridgeConfig,
1057+
})
1058+
}
1059+
}
1060+
1061+
if (this.taskBridgeService) {
1062+
await this.taskBridgeService.subscribeToTask(this)
1063+
}
1064+
}
1065+
10271066
const modifiedClineMessages = await this.getSavedClineMessages()
10281067

10291068
// Remove any resume messages that may have been added before
@@ -1269,6 +1308,14 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
12691308
this.pauseInterval = undefined
12701309
}
12711310

1311+
// Unsubscribe from TaskBridge service.
1312+
if (this.taskBridgeService) {
1313+
this.taskBridgeService
1314+
.unsubscribeFromTask(this.taskId)
1315+
.catch((error) => console.error("Error unsubscribing from task bridge:", error))
1316+
this.taskBridgeService = null
1317+
}
1318+
12721319
// Release any terminals associated with this task.
12731320
try {
12741321
// Release any terminals associated with this task.

0 commit comments

Comments
 (0)