Skip to content
TypeScript

perf(web): the device panel compiles with the React Compiler (#20489)

Julius Marminge488af8d28b8c
diff --git a/apps/web/reactCompiledFiles.ts b/apps/web/reactCompiledFiles.ts
index 1f563dab8b4..e7173a16639 100644
--- a/apps/web/reactCompiledFiles.ts
+++ b/apps/web/reactCompiledFiles.ts
@@ -64,4 +64,5 @@ export const REACT_COMPILED_FILES = [
"apps/web/src/components/media/MediaVideoPlayer.tsx",
"apps/web/src/components/media/MediaActions.tsx",
"apps/web/src/components/device/DeviceSetup.tsx",
+ "apps/web/src/components/device/DevicePanel.tsx",
] as const;
diff --git a/apps/web/src/components/device/DevicePanel.tsx b/apps/web/src/components/device/DevicePanel.tsx
index 5b04476aab3..2d0c2127071 100644
--- a/apps/web/src/components/device/DevicePanel.tsx
+++ b/apps/web/src/components/device/DevicePanel.tsx
@@ -6,7 +6,7 @@ import type {
ScopedThreadRef,
} from "@t3tools/contracts";
import { Smartphone, X } from "lucide-react";
-import { useEffect, useMemo, useState } from "react";
+import { useEffect, useState } from "react";
import { usePreviewMiniPlayerStore } from "~/previewMiniPlayerStore";
import { useRightPanelStore, type RightPanelSurface } from "~/rightPanelStore";
@@ -54,10 +54,7 @@ export function DevicePanel(props: {
void list({ environmentId, input: {} });
}, [environmentId, list, loaded, props.visible, hostDisabled]);
- const sessions = useMemo(
- () => state.sessions.filter((session) => session.threadId === threadId),
- [state.sessions, threadId],
- );
+ const sessions = state.sessions.filter((session) => session.threadId === threadId);
const activeSession = props.surface.target
? sessions.find(
(session) =>
@@ -71,34 +68,31 @@ export function DevicePanel(props: {
)
: undefined;
- const grouped = useMemo(() => groupDevices(state), [state]);
+ const grouped = groupDevices(state);
const selectDevice = async (value: string) => {
const device = state.devices.find((candidate) => deviceKey(candidate) === value);
if (!device) return;
setOperationError(null);
setPendingDevice(device);
- try {
- const result = await open({
- environmentId,
- input: {
- threadId,
- hostId: device.hostId,
- deviceId: device.id,
- platform: device.platform,
- },
+ const result = await open({
+ environmentId,
+ input: {
+ threadId,
+ hostId: device.hostId,
+ deviceId: device.id,
+ platform: device.platform,
+ },
+ });
+ if (result._tag === "Failure") setOperationError(formatEnvironmentQueryError(result.cause));
+ else
+ useRightPanelStore.getState().openDevice(props.threadRef, {
+ hostId: result.value.hostId,
+ deviceId: result.value.deviceId,
+ platform: device.platform,
+ name: device.name,
});
- if (result._tag === "Failure") setOperationError(formatEnvironmentQueryError(result.cause));
- else
- useRightPanelStore.getState().openDevice(props.threadRef, {
- hostId: result.value.hostId,
- deviceId: result.value.deviceId,
- platform: device.platform,
- name: device.name,
- });
- } finally {
- setPendingDevice(null);
- }
+ setPendingDevice(null);
};
const floatActive = () => {