@devries-cameron20 / t3code Mirror · read-only / commits / fd3420f380
Fork 0

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, 08:00 UTC

perf(web): the server browser surface compiles with the React Compiler (#20451)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 16, 2026 at 18:46 UTC fd3420f3805aed83326ec40a6a6663681a44ef27
2 files changed +47 -51
apps/web/reactCompiledFiles.ts
+1
@@ -26,4 +26,5 @@ export const REACT_COMPILED_FILES = [
26 "apps/web/src/hooks/useRightPanelSurfaceClose.ts",
27 "apps/web/src/components/ui/tooltip.tsx",
28 "apps/web/src/components/ComposerPromptEditorTiptap.tsx",
29 + "apps/web/src/browser/ServerBrowserSurface.tsx",
30 ] as const;
apps/web/src/browser/ServerBrowserSurface.tsx
+46 -51
@@ -26,7 +26,6 @@ import {
26 type KeyboardEvent,
27 type PointerEvent,
28 type Ref,
29 - useCallback,
29 useEffect,
30 useEffectEvent,
31 useImperativeHandle,
@@ -216,11 +215,13 @@ export function ServerBrowserSurface(props: {
215 const popupOpened = useEffectEvent((popupTabId: string) => onPopup?.(popupTabId));
216 const [cap, setCap] = useState<{ width: number; height: number } | null>(null);
217
219 - const send = useCallback((input: PreviewStreamInput) => {
218 + // These read only refs, so each is cached once. The stream effect keys on
219 + // clearInput and would reconnect if it changed.
220 + const send = (input: PreviewStreamInput) => {
221 clientRef.current?.send(input);
221 - }, []);
222 + };
223
223 - const clearInput = useCallback(() => {
224 + const clearInput = () => {
225 if (inputFrameRef.current !== null) cancelAnimationFrame(inputFrameRef.current);
226 inputFrameRef.current = null;
227 pendingMoveRef.current = pendingWheelRef.current = null;
@@ -231,9 +232,9 @@ export function ServerBrowserSurface(props: {
232 keySentRef.current = false;
233 if (inputRef.current) inputRef.current.value = INPUT_SENTINEL;
234 inputRef.current?.blur();
234 - }, []);
235 + };
236
236 - const flushInput = useCallback(() => {
237 + const flushInput = () => {
238 if (inputFrameRef.current !== null) cancelAnimationFrame(inputFrameRef.current);
239 inputFrameRef.current = null;
240 const move = pendingMoveRef.current;
@@ -242,52 +243,46 @@ export function ServerBrowserSurface(props: {
243 pendingWheelRef.current = null;
244 if (move) send(move);
245 if (wheel) send(wheel);
245 - }, [send]);
246 -
247 - const scheduleFlush = useCallback(() => {
248 - inputFrameRef.current ??= requestAnimationFrame(flushInput);
249 - }, [flushInput]);
250 -
251 - const queueWheel = useCallback(
252 - (point: PagePoint, deltaX: number, deltaY: number, modifiers: number) => {
253 - const pending = pendingWheelRef.current;
254 - pendingWheelRef.current = {
255 - type: "wheel",
256 - x: point.x,
257 - y: point.y,
258 - deltaX: (pending?.deltaX ?? 0) + deltaX,
259 - deltaY: (pending?.deltaY ?? 0) + deltaY,
260 - modifiers,
261 - };
262 - scheduleFlush();
263 - },
264 - [scheduleFlush],
265 - );
246 + };
247
267 - const pagePoint = useCallback(
268 - (clientX: number, clientY: number, clamp: boolean): PagePoint | null => {
269 - const canvas = canvasRef.current;
270 - const viewport = viewportRef.current;
271 - if (!canvas || !viewport || !hasFrameRef.current || controlRef.current?.controller !== "you")
272 - return null;
273 - const rect = canvas.getBoundingClientRect();
274 - const fit = Math.min(rect.width / canvas.width, rect.height / canvas.height);
275 - const width = canvas.width * fit;
276 - const height = canvas.height * fit;
277 - if (!(width > 0 && height > 0)) return null;
278 - const scale = viewport.width / width;
279 - const x = (clientX - rect.left - (rect.width - width) / 2) * scale;
280 - const y = (clientY - rect.top - (rect.height - height) / 2) * (viewport.height / height);
281 - const inside = x >= 0 && y >= 0 && x <= viewport.width && y <= viewport.height;
282 - if (!inside && !clamp) return null;
283 - return {
284 - x: Math.min(Math.max(x, 0), viewport.width),
285 - y: Math.min(Math.max(y, 0), viewport.height),
286 - scale,
287 - };
288 - },
289 - [],
290 - );
248 + const scheduleFlush = () => {
249 + if (inputFrameRef.current === null) inputFrameRef.current = requestAnimationFrame(flushInput);
250 + };
251 +
252 + const queueWheel = (point: PagePoint, deltaX: number, deltaY: number, modifiers: number) => {
253 + const pending = pendingWheelRef.current;
254 + pendingWheelRef.current = {
255 + type: "wheel",
256 + x: point.x,
257 + y: point.y,
258 + deltaX: (pending?.deltaX ?? 0) + deltaX,
259 + deltaY: (pending?.deltaY ?? 0) + deltaY,
260 + modifiers,
261 + };
262 + scheduleFlush();
263 + };
264 +
265 + const pagePoint = (clientX: number, clientY: number, clamp: boolean): PagePoint | null => {
266 + const canvas = canvasRef.current;
267 + const viewport = viewportRef.current;
268 + if (!canvas || !viewport || !hasFrameRef.current || controlRef.current?.controller !== "you")
269 + return null;
270 + const rect = canvas.getBoundingClientRect();
271 + const fit = Math.min(rect.width / canvas.width, rect.height / canvas.height);
272 + const width = canvas.width * fit;
273 + const height = canvas.height * fit;
274 + if (!(width > 0 && height > 0)) return null;
275 + const scale = viewport.width / width;
276 + const x = (clientX - rect.left - (rect.width - width) / 2) * scale;
277 + const y = (clientY - rect.top - (rect.height - height) / 2) * (viewport.height / height);
278 + const inside = x >= 0 && y >= 0 && x <= viewport.width && y <= viewport.height;
279 + if (!inside && !clamp) return null;
280 + return {
281 + x: Math.min(Math.max(x, 0), viewport.width),
282 + y: Math.min(Math.max(y, 0), viewport.height),
283 + scale,
284 + };
285 + };
286
287 const countClick = (button: PreviewStreamMouseButton, x: number, y: number, time: number) => {
288 const last = lastClickRef.current;