Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 101 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 48 additions & 1 deletion src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
isBlockingAsk,
} from "@roo-code/types"
import { TelemetryService } from "@roo-code/telemetry"
import { CloudService } from "@roo-code/cloud"
import { CloudService, TaskBridgeService } from "@roo-code/cloud"

// api
import { ApiHandler, ApiHandlerCreateMessageMetadata, buildApiHandler } from "../../api"
Expand Down Expand Up @@ -107,6 +107,7 @@ export type TaskOptions = {
apiConfiguration: ProviderSettings
enableDiff?: boolean
enableCheckpoints?: boolean
enableTaskBridge?: boolean
fuzzyMatchThreshold?: number
consecutiveMistakeLimit?: number
task?: string
Expand Down Expand Up @@ -237,6 +238,10 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
checkpointService?: RepoPerTaskCheckpointService
checkpointServiceInitializing = false

// Task Bridge
enableTaskBridge: boolean
taskBridgeService: TaskBridgeService | null = null

// Streaming
isWaitingForFirstChunk = false
isStreaming = false
Expand All @@ -260,6 +265,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
apiConfiguration,
enableDiff = false,
enableCheckpoints = true,
enableTaskBridge = false,
fuzzyMatchThreshold = 1.0,
consecutiveMistakeLimit = DEFAULT_CONSECUTIVE_MISTAKE_LIMIT,
task,
Expand Down Expand Up @@ -308,6 +314,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
this.globalStoragePath = provider.context.globalStorageUri.fsPath
this.diffViewProvider = new DiffViewProvider(this.cwd, this)
this.enableCheckpoints = enableCheckpoints
this.enableTaskBridge = enableTaskBridge

this.rootTask = rootTask
this.parentTask = parentTask
Expand Down Expand Up @@ -972,6 +979,22 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
// Start / Abort / Resume

private async startTask(task?: string, images?: string[]): Promise<void> {
if (this.enableTaskBridge && CloudService.hasInstance()) {
if (!this.taskBridgeService) {
const bridgeConfig = await CloudService.instance.cloudAPI?.bridgeConfig()

if (bridgeConfig) {
this.taskBridgeService = await TaskBridgeService.createInstance({
...bridgeConfig,
})
}
}

if (this.taskBridgeService) {
await this.taskBridgeService.subscribeToTask(this)
}
}

// `conversationHistory` (for API) and `clineMessages` (for webview)
// need to be in sync.
// If the extension process were killed, then on restart the
Expand Down Expand Up @@ -1023,6 +1046,22 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
}

private async resumeTaskFromHistory() {
if (this.enableTaskBridge && CloudService.hasInstance()) {
if (!this.taskBridgeService) {
const bridgeConfig = await CloudService.instance.cloudAPI?.bridgeConfig()

if (bridgeConfig) {
this.taskBridgeService = await TaskBridgeService.createInstance({
...bridgeConfig,
})
}
}

if (this.taskBridgeService) {
await this.taskBridgeService.subscribeToTask(this)
}
}

const modifiedClineMessages = await this.getSavedClineMessages()

// Remove any resume messages that may have been added before
Expand Down Expand Up @@ -1268,6 +1307,14 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
this.pauseInterval = undefined
}

// Unsubscribe from TaskBridge service.
if (this.taskBridgeService) {
this.taskBridgeService
.unsubscribeFromTask(this.taskId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar error handling is needed here for the unsubscribe operation. Is it safe to continue if unsubscription fails?

.catch((error) => console.error("Error unsubscribing from task bridge:", error))
this.taskBridgeService = null
}

// Release any terminals associated with this task.
try {
// Release any terminals associated with this task.
Expand Down
Loading
Loading