Skip to content

Commit dd1b407

Browse files
committed
Improve DevTools target selection
1 parent 6527908 commit dd1b407

10 files changed

Lines changed: 759 additions & 191 deletions

File tree

client/src/api/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ export interface ChromeDevToolsTarget {
8181
}
8282

8383
export interface ChromeDevToolsTargetDiscovery {
84+
foregroundApp?: {
85+
appName?: string | null;
86+
bundleIdentifier?: string | null;
87+
processIdentifier: number;
88+
} | null;
8489
udid: string;
8590
targets: ChromeDevToolsTarget[];
8691
warnings: string[];

client/src/app/AppShell.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ export function AppShell({
355355
const [devToolsVisible, setDevToolsVisible] = useState(() =>
356356
readStoredFlag(DEVTOOLS_VISIBLE_STORAGE_KEY, false),
357357
);
358+
const [devToolsOverviewRequestKey, setDevToolsOverviewRequestKey] =
359+
useState(0);
358360
const [selectedUDID, setSelectedUDID] = useState(initialSelectedUDID ?? "");
359361
const [search, setSearch] = useState("");
360362
const openURLValueRef = useRef(
@@ -1748,6 +1750,17 @@ export function AppShell({
17481750
}
17491751
}
17501752

1753+
function prepareSimulatorInput() {
1754+
setMenuOpen(false);
1755+
setAccessibilitySelectedId("");
1756+
setAccessibilityHoveredId(null);
1757+
window.getSelection()?.removeAllRanges();
1758+
const activeElement = document.activeElement;
1759+
if (activeElement instanceof HTMLElement) {
1760+
activeElement.blur();
1761+
}
1762+
}
1763+
17511764
async function submitPairing(event: FormEvent<HTMLFormElement>) {
17521765
event.preventDefault();
17531766
const code = pairingCode.trim();
@@ -1842,6 +1855,7 @@ export function AppShell({
18421855
if (!selectedSimulator) {
18431856
return;
18441857
}
1858+
setDevToolsOverviewRequestKey((current) => current + 1);
18451859
setAccessibilitySelectedId("");
18461860
setAccessibilityHoveredId(null);
18471861
if (!sendControl(selectedSimulator.udid, { type: "home" })) {
@@ -2007,6 +2021,7 @@ export function AppShell({
20072021
setAccessibilityHoveredId(null);
20082022
setAccessibilityPickerActive(false);
20092023
}}
2024+
onSimulatorInteraction={prepareSimulatorInput}
20102025
onScreenPointerCancel={pointerInput.handleScreenPointerCancel}
20112026
onScreenPointerDown={pointerInput.handleScreenPointerDown}
20122027
onScreenPointerMove={pointerInput.handleScreenPointerMove}
@@ -2043,6 +2058,7 @@ export function AppShell({
20432058
devtoolsPanel={
20442059
<DevToolsPanel
20452060
onClose={() => setDevToolsVisible(false)}
2061+
overviewRequestKey={devToolsOverviewRequestKey}
20462062
selectedSimulator={selectedSimulator}
20472063
visible={devToolsVisible}
20482064
/>

0 commit comments

Comments
 (0)