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
16 changes: 13 additions & 3 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1892,7 +1892,7 @@ export class ClineProvider
includeDiagnosticMessages: includeDiagnosticMessages ?? true,
maxDiagnosticMessages: maxDiagnosticMessages ?? 50,
includeTaskHistoryInEnhance: includeTaskHistoryInEnhance ?? true,
remoteControlEnabled: remoteControlEnabled ?? false,
remoteControlEnabled,
}
}

Expand Down Expand Up @@ -2080,8 +2080,18 @@ export class ClineProvider
maxDiagnosticMessages: stateValues.maxDiagnosticMessages ?? 50,
// Add includeTaskHistoryInEnhance setting
includeTaskHistoryInEnhance: stateValues.includeTaskHistoryInEnhance ?? true,
// Add remoteControlEnabled setting
remoteControlEnabled: stateValues.remoteControlEnabled ?? false,
// Add remoteControlEnabled setting - get from cloud settings
remoteControlEnabled: (() => {
try {
const cloudSettings = CloudService.instance.getUserSettings()
return cloudSettings?.settings?.extensionBridgeEnabled ?? false
} catch (error) {
console.error(
`[getState] failed to get remote control setting from cloud: ${error instanceof Error ? error.message : String(error)}`,
)
return false
}
})(),
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,13 @@ export const webviewMessageHandler = async (
await provider.postStateToWebview()
break
case "remoteControlEnabled":
await updateGlobalState("remoteControlEnabled", message.bool ?? false)
try {
await CloudService.instance.updateUserSettings({
extensionBridgeEnabled: message.bool ?? false,
})
} catch (error) {
provider.log(`Failed to update cloud settings for remote control: ${error}`)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the cloud settings update fails, we're only logging the error. Should we also show a user-facing notification so they know their setting change didn't persist?

Suggested change
provider.log(`Failed to update cloud settings for remote control: ${error}`)
} catch (error) {
provider.log(`Failed to update cloud settings for remote control: ${error}`)
vscode.window.showErrorMessage('Failed to update remote control setting. Please try again.')
// Don't fall back to local storage - cloud settings are the source of truth
}

}
await provider.remoteControlEnabled(message.bool ?? false)
await provider.postStateToWebview()
break
Expand Down
45 changes: 39 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,36 @@ export async function activate(context: vscode.ExtensionContext) {
// Initialize Roo Code Cloud service.
const postStateListener = () => ClineProvider.getVisibleInstance()?.postStateToWebview()
authStateChangedHandler = postStateListener
settingsUpdatedHandler = postStateListener

settingsUpdatedHandler = async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider adding JSDoc comments to document this enhanced settings handler's functionality, especially since it now handles BridgeOrchestrator updates in addition to posting state.

const userInfo = CloudService.instance.getUserInfo()
if (userInfo && CloudService.instance.cloudAPI) {
try {
const config = await CloudService.instance.cloudAPI.bridgeConfig()

const isCloudAgent =
typeof process.env.ROO_CODE_CLOUD_TOKEN === "string" && process.env.ROO_CODE_CLOUD_TOKEN.length > 0

const remoteControlEnabled = isCloudAgent
? true
: (CloudService.instance.getUserSettings()?.settings?.extensionBridgeEnabled ?? false)

cloudLogger(`[CloudService] Settings updated - remoteControlEnabled = ${remoteControlEnabled}`)

await BridgeOrchestrator.connectOrDisconnect(userInfo, remoteControlEnabled, {
...config,
provider,
sessionId: vscode.env.sessionId,
})
} catch (error) {
cloudLogger(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it intentional that we're not notifying the user when BridgeOrchestrator update fails? The error is logged but users might want to know if their remote control connection has issues.

`[CloudService] Failed to update BridgeOrchestrator on settings change: ${error instanceof Error ? error.message : String(error)}`,
)
}
}

postStateListener()
}

userInfoHandler = async ({ userInfo }: { userInfo: CloudUserInfo }) => {
postStateListener()
Expand All @@ -146,11 +175,15 @@ export async function activate(context: vscode.ExtensionContext) {

cloudLogger(`[CloudService] isCloudAgent = ${isCloudAgent}, socketBridgeUrl = ${config.socketBridgeUrl}`)

await BridgeOrchestrator.connectOrDisconnect(
userInfo,
isCloudAgent ? true : contextProxy.getValue("remoteControlEnabled"),
{ ...config, provider, sessionId: vscode.env.sessionId },
)
const remoteControlEnabled = isCloudAgent
? true
: (CloudService.instance.getUserSettings()?.settings?.extensionBridgeEnabled ?? false)

await BridgeOrchestrator.connectOrDisconnect(userInfo, remoteControlEnabled, {
...config,
provider,
sessionId: vscode.env.sessionId,
})
} catch (error) {
cloudLogger(
`[CloudService] Failed to fetch bridgeConfig: ${error instanceof Error ? error.message : String(error)}`,
Expand Down
Loading