@devries-cameron20 / t3code-1 / commits / e10f5d1b5e
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

perf(web): media actions compile with the React Compiler (#20487)

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

Julius Marminge committed Oct 16, 2026 at 18:46 UTC e10f5d1b5ebe8493b8d88790646967c031c2e14e
2 files changed +16 -15
apps/web/reactCompiledFiles.ts
+1
@@ -62,4 +62,5 @@ export const REACT_COMPILED_FILES = [
62 "apps/web/src/components/sidebar/SidebarUpdatePill.tsx",
63 "apps/web/src/components/ProviderUpdatesAction.tsx",
64 "apps/web/src/components/media/MediaVideoPlayer.tsx",
65 + "apps/web/src/components/media/MediaActions.tsx",
66 ] as const;
apps/web/src/components/media/MediaActions.tsx
+15 -15
@@ -4,11 +4,10 @@ import {
4 type MediaReference,
5 } from "@t3tools/client-runtime/media-reference";
6 import { resolveAssetUrl } from "@t3tools/client-runtime/state/assets";
7 -import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
7 +import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
8 import {
9 AuthFilesystemReadScope,
10 type AssetResource,
11 - type AuthSessionState,
11 type ContextMenuItem,
12 type EnvironmentId,
13 sessionGrantsScope,
@@ -16,7 +15,7 @@ import {
15 } from "@t3tools/contracts";
16 import * as Option from "effect/Option";
17 import { AsyncResult } from "effect/reactivity";
19 -import { useCallback, useRef, useState, type ReactElement } from "react";
18 +import { useRef, useState, type ReactElement } from "react";
19
20 import { writeTextToClipboard } from "../../hooks/useCopyToClipboard";
21 import { readLocalApi } from "../../localApi";
@@ -66,16 +65,16 @@ export function useMediaActions(source: MediaActionSource) {
65 const canReadMedia =
66 hostEnvironmentId === null ||
67 (fileSession.error === null && fileSession.data !== null && allowsHostMedia(fileSession.data));
69 - const assertCanReadMedia = useCallback(() => {
68 + const assertCanReadMedia = () => {
69 if (!canReadHostMedia(hostEnvironmentId)) {
70 throw new Error("This connection cannot read host files.");
71 }
73 - }, [hostEnvironmentId]);
72 + };
73 const createAssetUrl = useAtomQueryRunner(assetEnvironment.createUrl, {
74 reportFailure: false,
75 refresh: true,
76 });
78 - const actionUrl = useCallback(async () => {
77 + const actionUrl = async () => {
78 assertCanReadMedia();
79 if (!source.asset) {
80 if (!source.src) throw new Error("This media is unavailable. Try reopening the preview.");
@@ -90,11 +89,11 @@ export function useMediaActions(source: MediaActionSource) {
89 const url = resolveAssetUrl(connection.httpBaseUrl, result.value.relativeUrl);
90 if (!url) throw new Error("The environment returned an invalid media URL.");
91 return url;
93 - }, [source, createAssetUrl, assertCanReadMedia]);
94 - const save = useCallback(async () => {
92 + };
93 + const save = async () => {
94 await downloadMedia(await actionUrl(), mediaFileName(source));
96 - }, [actionUrl, source]);
97 - const copyImage = useCallback(async () => {
95 + };
96 + const copyImage = async () => {
97 assertCanReadMedia();
98 if (!navigator.clipboard?.write || typeof ClipboardItem === "undefined") {
99 throw new Error(
@@ -105,7 +104,7 @@ export function useMediaActions(source: MediaActionSource) {
104 await navigator.clipboard.write([
105 new ClipboardItem({ "image/png": actionUrl().then(readMediaPng) }),
106 ]);
108 - }, [actionUrl, assertCanReadMedia]);
107 + };
108 return { save, copyImage, canReadMedia, assertCanReadMedia };
109 }
110
@@ -129,7 +128,7 @@ export function MediaActions({
128 setTooltipOpen(false);
129 let failureTitle = "Could not open media menu";
130 let progressToast: ReturnType<typeof toastManager.add> | undefined;
132 - try {
131 + const result = await settlePromise(async () => {
132 const noun = source.kind === "image" ? "image" : "video";
133 const unavailable = !canReadMedia || (source.src === null && source.asset === undefined);
134 const canCopyImage =
@@ -186,7 +185,9 @@ export function MediaActions({
185 title: action === "save" ? "Download started" : "Image copied",
186 });
187 }
189 - } catch (error) {
188 + });
189 + if (AsyncResult.isFailure(result)) {
190 + const error = squashAtomCommandFailure(result);
191 const toast = stackedThreadToast({
192 type: "error",
193 title: failureTitle,
@@ -194,9 +195,8 @@ export function MediaActions({
195 });
196 if (progressToast) toastManager.update(progressToast, toast);
197 else toastManager.add(toast);
197 - } finally {
198 - menuOpen.current = false;
198 }
199 + menuOpen.current = false;
200 };
201
202 return (