@@ -21,6 +21,7 @@ export class BrowserSession {
2121 private page ?: Page
2222 private currentMousePosition ?: string
2323 private lastConnectionAttempt ?: number
24+ private isUsingRemoteBrowser : boolean = false // kilocode_change https://github.com/Kilo-Org/kilocode/pull/747
2425
2526 constructor ( context : vscode . ExtensionContext ) {
2627 this . context = context
@@ -70,6 +71,7 @@ export class BrowserSession {
7071 defaultViewport : this . getViewport ( ) ,
7172 // headless: false,
7273 } )
74+ this . isUsingRemoteBrowser = false // kilocode_change https://github.com/Kilo-Org/kilocode/pull/747
7375 }
7476
7577 /**
@@ -86,6 +88,7 @@ export class BrowserSession {
8688 console . log ( `Connected to remote browser at ${ chromeHostUrl } ` )
8789 this . context . globalState . update ( "cachedChromeHostUrl" , chromeHostUrl )
8890 this . lastConnectionAttempt = Date . now ( )
91+ this . isUsingRemoteBrowser = true // kilocode_change https://github.com/Kilo-Org/kilocode/pull/747
8992
9093 return true
9194 } catch ( error ) {
@@ -192,8 +195,10 @@ export class BrowserSession {
192195 if ( this . browser || this . page ) {
193196 console . log ( "closing browser..." )
194197
195- const remoteBrowserEnabled = this . context . globalState . get ( "remoteBrowserEnabled" ) as boolean | undefined
196- if ( remoteBrowserEnabled && this . browser ) {
198+ // kilocode_change start https://github.com/Kilo-Org/kilocode/pull/747
199+ if ( this . isUsingRemoteBrowser && this . browser ) {
200+ // kilocode_change end https://github.com/Kilo-Org/kilocode/pull/747
201+
197202 await this . browser . disconnect ( ) . catch ( ( ) => { } )
198203 } else {
199204 await this . browser ?. close ( ) . catch ( ( ) => { } )
@@ -212,6 +217,7 @@ export class BrowserSession {
212217 this . browser = undefined
213218 this . page = undefined
214219 this . currentMousePosition = undefined
220+ this . isUsingRemoteBrowser = false // kilocode_change https://github.com/Kilo-Org/kilocode/pull/747
215221 }
216222
217223 async doAction ( action : ( page : Page ) => Promise < void > ) : Promise < BrowserActionResult > {
0 commit comments