The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 06:45 UTC
perf(web): device controls compile without manual memoization (#20652)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 21:57 UTC
c7fe6d37b3a328fb5427b330d1cb11ae66a6da14
1 file changed
+5
-8
apps/web/src/components/device/useDeviceControls.ts
+5
-8
@@ -5,7 +5,7 @@ import type {
5
DeviceSummary,
6
EnvironmentId,
7
} from "@t3tools/contracts";
8
-import { useEffect, useMemo, useRef, useState } from "react";
8
+import { useEffect, useRef, useState } from "react";
9
import { deviceEnvironment } from "~/state/device";
10
import { formatEnvironmentQueryError } from "~/state/query";
11
import { useAtomCommand } from "~/state/use-atom-command";
@@ -36,15 +36,12 @@ export function useDeviceControls(options: {
36
const busy = useRef(false);
37
const generation = useRef(0);
38
const visibleRead = useRef<Parameters<typeof readDetail>[0] | null>(null);
39
- const target = useMemo(
40
- () => ({ hostId: device.hostId, deviceId: device.id }),
41
- [device.hostId, device.id],
42
- );
39
+ const { hostId, id: deviceId } = device;
40
41
useEffect(() => {
42
const revision = ++generation.current;
43
if (!visible) return;
47
- const request = { environmentId, input: target };
44
+ const request = { environmentId, input: { hostId, deviceId } };
45
visibleRead.current = request;
46
void readDetail(request).then((result) => {
47
if (generation.current !== revision) return;
@@ -60,7 +57,7 @@ export function useDeviceControls(options: {
57
visibleRead.current = null;
58
generation.current++;
59
};
63
- }, [environmentId, readDetail, target, visible]);
60
+ }, [deviceId, environmentId, hostId, readDetail, visible]);
61
62
useEffect(() => {
63
if (!access || !visible) return;
@@ -87,7 +84,7 @@ export function useDeviceControls(options: {
84
setError(null);
85
return runAction({
86
environmentId,
90
- input: { ...target, ...body } as DeviceActionInput,
87
+ input: { hostId, deviceId, ...body } as DeviceActionInput,
88
})
89
.then((result) => {
90
if (generation.current !== revision) {