-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Sync extension bridge settings with cloud #7506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -950,7 +950,15 @@ export const webviewMessageHandler = async ( | |
| await provider.postStateToWebview() | ||
| break | ||
| case "remoteControlEnabled": | ||
| await updateGlobalState("remoteControlEnabled", message.bool ?? false) | ||
| // Update cloud settings instead of local globalState | ||
| try { | ||
| await CloudService.instance.updateUserSettings({ | ||
| extensionBridgeEnabled: message.bool ?? false, | ||
| }) | ||
| } catch (error) { | ||
| provider.log(`Failed to update cloud settings for remote control: ${error}`) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error is only logged but doesn't provide user feedback. Should we show an error message to the user when cloud settings fail to update? Consider adding a user-facing error notification. |
||
| // Don't fall back to local storage - cloud settings are the source of truth | ||
| } | ||
| await provider.handleRemoteControlToggle(message.bool ?? false) | ||
| await provider.postStateToWebview() | ||
| break | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,43 @@ export async function activate(context: vscode.ExtensionContext) { | |
| // Initialize Roo Code Cloud service. | ||
| const postStateListener = () => ClineProvider.getVisibleInstance()?.postStateToWebview() | ||
| authStateChangedHandler = postStateListener | ||
| settingsUpdatedHandler = postStateListener | ||
|
|
||
| // Enhanced settings updated handler that also updates ExtensionBridgeService | ||
| settingsUpdatedHandler = async () => { | ||
| // Update ExtensionBridgeService when settings change | ||
| 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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intentional? The error handling here only logs the error but doesn't provide any fallback value for remoteControlEnabled. If getUserSettings() returns null/undefined, the remote control state could be out of sync. Consider ensuring the fallback value is always applied. |
||
|
|
||
| cloudLogger(`[CloudService] Settings updated - remoteControlEnabled = ${remoteControlEnabled}`) | ||
|
|
||
| ExtensionBridgeService.handleRemoteControlState( | ||
| userInfo, | ||
| remoteControlEnabled, | ||
| { | ||
| ...config, | ||
| provider, | ||
| sessionId: vscode.env.sessionId, | ||
| }, | ||
| cloudLogger, | ||
| ) | ||
| } catch (error) { | ||
| cloudLogger( | ||
| `[CloudService] Failed to update ExtensionBridgeService on settings change: ${error instanceof Error ? error.message : String(error)}`, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| postStateListener() | ||
| } | ||
|
|
||
| userInfoHandler = async ({ userInfo }: { userInfo: CloudUserInfo }) => { | ||
| postStateListener() | ||
|
|
@@ -147,9 +183,13 @@ export async function activate(context: vscode.ExtensionContext) { | |
|
|
||
| cloudLogger(`[CloudService] isCloudAgent = ${isCloudAgent}, socketBridgeUrl = ${config.socketBridgeUrl}`) | ||
|
|
||
| const remoteControlEnabled = isCloudAgent | ||
| ? true | ||
| : (CloudService.instance.getUserSettings()?.settings?.extensionBridgeEnabled ?? false) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic for determining remoteControlEnabled is duplicated from lines 144-146. Could we extract this into a helper function to avoid duplication? For example: function getRemoteControlEnabled(isCloudAgent: boolean): boolean {
return isCloudAgent ? true : (CloudService.instance.getUserSettings()?.settings?.extensionBridgeEnabled ?? false);
} |
||
|
|
||
| ExtensionBridgeService.handleRemoteControlState( | ||
| userInfo, | ||
| isCloudAgent ? true : contextProxy.getValue("remoteControlEnabled"), | ||
| remoteControlEnabled, | ||
| { | ||
| ...config, | ||
| provider, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing null check - what happens if CloudService is not initialized yet? The code uses optional chaining but doesn't verify that CloudService.instance exists.
Consider adding a hasInstance() check before accessing the instance.