Skip to content

Commit 02f551c

Browse files
Update @roo-code/cloud to enable roomote control for cloud agents (#7446)
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
1 parent f02a2bb commit 02f551c

File tree

5 files changed

+90
-35
lines changed

5 files changed

+90
-35
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ logs
4646
.qodo/
4747
.vercel
4848
.roo/mcp.json
49+
50+
# Qdrant
51+
qdrant_storage/

pnpm-lock.yaml

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

src/extension.ts

Lines changed: 70 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ try {
1212
console.warn("Failed to load environment variables:", e)
1313
}
1414

15-
import { CloudService, ExtensionBridgeService } from "@roo-code/cloud"
15+
import { CloudService, ExtensionBridgeService, type CloudUserInfo } from "@roo-code/cloud"
1616
import { TelemetryService, PostHogTelemetryClient } from "@roo-code/telemetry"
1717

1818
import "./utils/path" // Necessary to have access to String.prototype.toPosix.
@@ -51,6 +51,11 @@ import { initializeI18n } from "./i18n"
5151

5252
let outputChannel: vscode.OutputChannel
5353
let extensionContext: vscode.ExtensionContext
54+
let cloudService: CloudService | undefined
55+
56+
let authStateChangedHandler: (() => void) | undefined
57+
let settingsUpdatedHandler: (() => void) | undefined
58+
let userInfoHandler: ((data: { userInfo: CloudUserInfo }) => Promise<void>) | undefined
5459

5560
// This method is called when your extension is activated.
5661
// Your extension is activated the very first time the command is executed.
@@ -94,27 +99,66 @@ export async function activate(context: vscode.ExtensionContext) {
9499

95100
const contextProxy = await ContextProxy.getInstance(context)
96101

97-
// Initialize code index managers for all workspace folders
102+
// Initialize code index managers for all workspace folders.
98103
const codeIndexManagers: CodeIndexManager[] = []
104+
99105
if (vscode.workspace.workspaceFolders) {
100106
for (const folder of vscode.workspace.workspaceFolders) {
101107
const manager = CodeIndexManager.getInstance(context, folder.uri.fsPath)
108+
102109
if (manager) {
103110
codeIndexManagers.push(manager)
111+
104112
try {
105113
await manager.initialize(contextProxy)
106114
} catch (error) {
107115
outputChannel.appendLine(
108116
`[CodeIndexManager] Error during background CodeIndexManager configuration/indexing for ${folder.uri.fsPath}: ${error.message || error}`,
109117
)
110118
}
119+
111120
context.subscriptions.push(manager)
112121
}
113122
}
114123
}
115124

125+
// Initialize the provider *before* the Roo Code Cloud service.
126+
const provider = new ClineProvider(context, outputChannel, "sidebar", contextProxy, mdmService)
127+
116128
// Initialize Roo Code Cloud service.
117-
const cloudService = await CloudService.createInstance(context, cloudLogger)
129+
const postStateListener = () => ClineProvider.getVisibleInstance()?.postStateToWebview()
130+
authStateChangedHandler = postStateListener
131+
settingsUpdatedHandler = postStateListener
132+
133+
userInfoHandler = async ({ userInfo }: { userInfo: CloudUserInfo }) => {
134+
postStateListener()
135+
136+
if (!CloudService.instance.cloudAPI) {
137+
cloudLogger("[CloudService] CloudAPI is not initialized")
138+
return
139+
}
140+
141+
try {
142+
const config = await CloudService.instance.cloudAPI.bridgeConfig()
143+
144+
ExtensionBridgeService.handleRemoteControlState(
145+
userInfo,
146+
contextProxy.getValue("remoteControlEnabled"),
147+
{ ...config, provider, sessionId: vscode.env.sessionId },
148+
(message: string) => outputChannel.appendLine(message),
149+
)
150+
} catch (error) {
151+
cloudLogger(
152+
`[CloudService] Failed to fetch bridgeConfig: ${error instanceof Error ? error.message : String(error)}`,
153+
)
154+
}
155+
}
156+
157+
cloudService = await CloudService.createInstance(context, cloudLogger, {
158+
"auth-state-changed": authStateChangedHandler,
159+
"settings-updated": settingsUpdatedHandler,
160+
"user-info": userInfoHandler,
161+
})
118162

119163
try {
120164
if (cloudService.telemetryClient) {
@@ -126,33 +170,10 @@ export async function activate(context: vscode.ExtensionContext) {
126170
)
127171
}
128172

129-
const postStateListener = () => ClineProvider.getVisibleInstance()?.postStateToWebview()
130-
131-
cloudService.on("auth-state-changed", postStateListener)
132-
cloudService.on("settings-updated", postStateListener)
133-
134-
cloudService.on("user-info", async ({ userInfo }) => {
135-
postStateListener()
136-
137-
const bridgeConfig = await cloudService.cloudAPI?.bridgeConfig().catch(() => undefined)
138-
139-
if (!bridgeConfig) {
140-
outputChannel.appendLine("[CloudService] Failed to get bridge config")
141-
return
142-
}
143-
144-
ExtensionBridgeService.handleRemoteControlState(
145-
userInfo,
146-
contextProxy.getValue("remoteControlEnabled"),
147-
{ ...bridgeConfig, provider, sessionId: vscode.env.sessionId },
148-
(message: string) => outputChannel.appendLine(message),
149-
)
150-
})
151-
152173
// Add to subscriptions for proper cleanup on deactivate.
153174
context.subscriptions.push(cloudService)
154175

155-
const provider = new ClineProvider(context, outputChannel, "sidebar", contextProxy, mdmService)
176+
// Finish initializing the provider.
156177
TelemetryService.instance.setProvider(provider)
157178

158179
context.subscriptions.push(
@@ -280,6 +301,28 @@ export async function activate(context: vscode.ExtensionContext) {
280301
export async function deactivate() {
281302
outputChannel.appendLine(`${Package.name} extension deactivated`)
282303

304+
if (cloudService && CloudService.hasInstance()) {
305+
try {
306+
if (authStateChangedHandler) {
307+
CloudService.instance.off("auth-state-changed", authStateChangedHandler)
308+
}
309+
310+
if (settingsUpdatedHandler) {
311+
CloudService.instance.off("settings-updated", settingsUpdatedHandler)
312+
}
313+
314+
if (userInfoHandler) {
315+
CloudService.instance.off("user-info", userInfoHandler as any)
316+
}
317+
318+
outputChannel.appendLine("CloudService event handlers cleaned up")
319+
} catch (error) {
320+
outputChannel.appendLine(
321+
`Failed to clean up CloudService event handlers: ${error instanceof Error ? error.message : String(error)}`,
322+
)
323+
}
324+
}
325+
283326
const bridgeService = ExtensionBridgeService.getInstance()
284327

285328
if (bridgeService) {

src/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429
"@mistralai/mistralai": "^1.9.18",
430430
"@modelcontextprotocol/sdk": "^1.9.0",
431431
"@qdrant/js-client-rest": "^1.14.0",
432-
"@roo-code/cloud": "^0.22.0",
432+
"@roo-code/cloud": "^0.24.0",
433433
"@roo-code/ipc": "workspace:^",
434434
"@roo-code/telemetry": "workspace:^",
435435
"@roo-code/types": "workspace:^",
@@ -455,6 +455,7 @@
455455
"i18next": "^25.0.0",
456456
"ignore": "^7.0.3",
457457
"isbinaryfile": "^5.0.2",
458+
"jwt-decode": "^4.0.0",
458459
"lodash.debounce": "^4.0.8",
459460
"mammoth": "^1.9.1",
460461
"monaco-vscode-textmate-theme-converter": "^0.1.7",

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,8 +1787,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
17871787

17881788
const areButtonsVisible = showScrollToBottom || primaryButtonText || secondaryButtonText || isStreaming
17891789

1790-
console.log("ChatView - render()")
1791-
17921790
return (
17931791
<div
17941792
data-testid="chat-view"

0 commit comments

Comments
 (0)