mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Disconnect extension bridge on logout (#7563)
* Disconnect extension bridge on logout * Remove bad test * Cleanup
This commit is contained in:
parent
63b71d8299
commit
c97027427b
2 changed files with 31 additions and 4 deletions
|
|
@ -61,13 +61,19 @@ export class BridgeOrchestrator {
|
|||
public static async connectOrDisconnect(
|
||||
userInfo: CloudUserInfo | null,
|
||||
remoteControlEnabled: boolean | undefined,
|
||||
options: BridgeOrchestratorOptions,
|
||||
options?: BridgeOrchestratorOptions,
|
||||
): Promise<void> {
|
||||
const isEnabled = BridgeOrchestrator.isEnabled(userInfo, remoteControlEnabled)
|
||||
const instance = BridgeOrchestrator.instance
|
||||
|
||||
if (isEnabled) {
|
||||
if (!instance) {
|
||||
if (!options) {
|
||||
console.error(
|
||||
`[BridgeOrchestrator#connectOrDisconnect] Cannot connect: options are required for connection`,
|
||||
)
|
||||
return
|
||||
}
|
||||
try {
|
||||
console.log(`[BridgeOrchestrator#connectOrDisconnect] Connecting...`)
|
||||
BridgeOrchestrator.instance = new BridgeOrchestrator(options)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ try {
|
|||
console.warn("Failed to load environment variables:", e)
|
||||
}
|
||||
|
||||
import type { CloudUserInfo } from "@roo-code/types"
|
||||
import type { CloudUserInfo, AuthState } from "@roo-code/types"
|
||||
import { CloudService, BridgeOrchestrator } from "@roo-code/cloud"
|
||||
import { TelemetryService, PostHogTelemetryClient } from "@roo-code/telemetry"
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ let outputChannel: vscode.OutputChannel
|
|||
let extensionContext: vscode.ExtensionContext
|
||||
let cloudService: CloudService | undefined
|
||||
|
||||
let authStateChangedHandler: (() => void) | undefined
|
||||
let authStateChangedHandler: ((data: { state: AuthState; previousState: AuthState }) => Promise<void>) | undefined
|
||||
let settingsUpdatedHandler: (() => void) | undefined
|
||||
let userInfoHandler: ((data: { userInfo: CloudUserInfo }) => Promise<void>) | undefined
|
||||
|
||||
|
|
@ -127,7 +127,28 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||
|
||||
// Initialize Roo Code Cloud service.
|
||||
const postStateListener = () => ClineProvider.getVisibleInstance()?.postStateToWebview()
|
||||
authStateChangedHandler = postStateListener
|
||||
|
||||
authStateChangedHandler = async (data: { state: AuthState; previousState: AuthState }) => {
|
||||
postStateListener()
|
||||
|
||||
// Check if user has logged out
|
||||
if (data.state === "logged-out") {
|
||||
try {
|
||||
// Disconnect the bridge when user logs out
|
||||
// When userInfo is null and remoteControlEnabled is false, BridgeOrchestrator
|
||||
// will disconnect. The options parameter is not needed for disconnection.
|
||||
await BridgeOrchestrator.connectOrDisconnect(null, false)
|
||||
|
||||
cloudLogger("[CloudService] BridgeOrchestrator disconnected on logout")
|
||||
} catch (error) {
|
||||
cloudLogger(
|
||||
`[CloudService] Failed to disconnect BridgeOrchestrator on logout: ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
settingsUpdatedHandler = async () => {
|
||||
const userInfo = CloudService.instance.getUserInfo()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue