Skip to content

Commit c971821

Browse files
committed
fix: only click extension icon if side panel is not already open
Check if a page with sidepanel.html exists before clicking. This prevents accidentally clicking the extensions button when the side panel is already visible.
1 parent db85bb7 commit c971821

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

internal/claude/loader.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,27 @@ func pinExtension(ctx context.Context, client kernel.Client, browserID, extensio
230230

231231
// OpenSidePanel clicks on the pinned Claude extension icon to open the side panel.
232232
// This uses the computer API to click at the known coordinates of the extension icon.
233+
// If the side panel is already open, it does nothing.
233234
func OpenSidePanel(ctx context.Context, client kernel.Client, browserID string) error {
235+
// First check if the side panel is already open
236+
checkScript := `
237+
const sidepanel = context.pages().find(p => p.url().includes('sidepanel.html'));
238+
return { isOpen: !!sidepanel };
239+
`
240+
result, err := client.Browsers.Playwright.Execute(ctx, browserID, kernel.BrowserPlaywrightExecuteParams{
241+
Code: checkScript,
242+
TimeoutSec: kernel.Opt(int64(10)),
243+
})
244+
if err == nil && result.Success {
245+
if resultMap, ok := result.Result.(map[string]any); ok {
246+
if isOpen, ok := resultMap["isOpen"].(bool); ok && isOpen {
247+
// Side panel is already open, no need to click
248+
return nil
249+
}
250+
}
251+
}
252+
253+
// Side panel is not open, click to open it
234254
return client.Browsers.Computer.ClickMouse(ctx, browserID, kernel.BrowserComputerClickMouseParams{
235255
X: ExtensionIconX,
236256
Y: ExtensionIconY,

0 commit comments

Comments
 (0)