[eric] dashboard: clicks inside a webview page select its browser card (guest app-clicked IPC, select+raise only, no camera yank)

This commit is contained in:
ciregenz
2026-07-09 16:26:04 -07:00
parent 9fdfa12cc5
commit 72e71d6710
2 changed files with 15 additions and 2 deletions
@@ -369,8 +369,9 @@ const BrowserCard: React.FC<Props> = ({
}),
);
} 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 } }));
}
};
@@ -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) {