From 72e71d671034c334aaa3bf9bcf966312fdc3ca85 Mon Sep 17 00:00:00 2001 From: ciregenz Date: Thu, 9 Jul 2026 16:26:04 -0700 Subject: [PATCH] [eric] dashboard: clicks inside a webview page select its browser card (guest app-clicked IPC, select+raise only, no camera yank) --- .../src/app/pages/Dashboard/cards/BrowserCard.tsx | 3 ++- .../hooks/interaction/useDashboardInteractions.ts | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/pages/Dashboard/cards/BrowserCard.tsx b/frontend/src/app/pages/Dashboard/cards/BrowserCard.tsx index 431fce3d..1bd759da 100644 --- a/frontend/src/app/pages/Dashboard/cards/BrowserCard.tsx +++ b/frontend/src/app/pages/Dashboard/cards/BrowserCard.tsx @@ -369,8 +369,9 @@ const BrowserCard: React.FC = ({ }), ); } else if (e?.channel === 'app-clicked') { - // First in-guest mousedown: a page click never reaches the host document, so this IPC is how a webview-content click marks this browser as last-interacted (drives Ctrl+R/zoom/tab targeting). + // In-guest mousedown: a page click never reaches the host document, so this IPC is how a webview-content click marks this browser as last-interacted (drives Ctrl+R/zoom/tab targeting) and selected (spawn-beside anchor). setLastInteractedBrowser(browserId); + window.dispatchEvent(new CustomEvent('openswarm:browser-guest-select', { detail: { browserId } })); } }; diff --git a/frontend/src/app/pages/Dashboard/hooks/interaction/useDashboardInteractions.ts b/frontend/src/app/pages/Dashboard/hooks/interaction/useDashboardInteractions.ts index 8c126eb0..1d4765aa 100644 --- a/frontend/src/app/pages/Dashboard/hooks/interaction/useDashboardInteractions.ts +++ b/frontend/src/app/pages/Dashboard/hooks/interaction/useDashboardInteractions.ts @@ -1,4 +1,4 @@ -import React, { useCallback, useRef, type Dispatch, type SetStateAction } from 'react'; +import React, { useCallback, useEffect, useRef, type Dispatch, type SetStateAction } from 'react'; import { report } from '@/shared/serviceClient'; import { useAppDispatch } from '@/shared/hooks'; import { collapseSession, expandSession } from '@/shared/state/agentsSlice'; @@ -89,6 +89,18 @@ export function useDashboardInteractions({ dispatch(bringToFront({ id, type })); }, [dispatch]); + // A click INSIDE a webview's page never reaches the host DOM; BrowserCard forwards the guest's app-clicked IPC as this event. Select + raise only, no camera fit: you're clicking around inside the page, re-framing the canvas every tap would be hostile (same carve-out as the Workflows window). + useEffect(() => { + const onGuestSelect = (e: Event) => { + const browserId = (e as CustomEvent).detail?.browserId; + if (typeof browserId !== 'string' || !browserId) return; + selection.selectCard(browserId, 'browser', false); + dispatch(bringToFront({ id: browserId, type: 'browser' })); + }; + window.addEventListener('openswarm:browser-guest-select', onGuestSelect); + return () => window.removeEventListener('openswarm:browser-guest-select', onGuestSelect); + }, [selection, dispatch]); + // ---- Viewport event handlers (compose pan + marquee) ---- const handleViewportMouseDown = useCallback((e: React.MouseEvent) => { if (e.button === 1) {