@devries-cameron20 / t3code-1 / commits / 73d9a77e43
Fork 0

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

perf(web): the open-in picker compiles without manual memoization (#20698)

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

Julius Marminge committed Oct 16, 2026 at 21:48 UTC 73d9a77e43ee7cdc099726129d56576d5835c109
1 file changed +42 -49
apps/web/src/components/chat/OpenInPicker.tsx
+42 -49
@@ -6,7 +6,7 @@ import {
6 type EnvironmentId,
7 type ResolvedKeybindingsConfig,
8 } from "@t3tools/contracts";
9 -import { memo, useCallback, useEffect, useMemo, useRef } from "react";
9 +import { memo, useEffect, useRef } from "react";
10 import { isOpenFavoriteEditorShortcut, shortcutLabelForCommand } from "../../keybindings";
11 import { usePreferredEditor } from "../../editorPreferences";
12 import { editorLabelForPlatform } from "../../editorLabels";
@@ -203,6 +203,13 @@ function getOpenInIconClass(kind: OpenInOption["kind"]) {
203 return cn(kind === "brand" ? "text-foreground opacity-100" : "text-muted-foreground");
204 }
205
206 +// Resolving filters and labels every known editor; the compiler would redo
207 +// it every render because the open command hooks follow it.
208 +function useOpenInOptions(editors: ReadonlyArray<EditorId>) {
209 + "use memo";
210 + return resolveOpenInOptions(navigator.platform, editors);
211 +}
212 +
213 export const OpenInPicker = memo(function OpenInPicker({
214 environmentId,
215 keybindings,
@@ -238,59 +245,45 @@ export const OpenInPicker = memo(function OpenInPicker({
245 // the viewing machine, which only the desktop app can probe.
246 const effectiveEditors = remote.mode === "local-exec" ? availableEditors : remoteCapableEditors;
247 const [preferredEditor, setPreferredEditor] = usePreferredEditor(effectiveEditors);
241 - const options = useMemo(
242 - () => resolveOpenInOptions(navigator.platform, effectiveEditors),
243 - [effectiveEditors],
244 - );
248 + const options = useOpenInOptions(effectiveEditors);
249 const primaryOption = options.find(({ value }) => value === preferredEditor) ?? null;
250
247 - const openInEditor = useCallback(
248 - (editorId: EditorId | null) => {
249 - if (!openInCwd) return;
250 - const editor = editorId ?? preferredEditor;
251 - if (!editor) return;
252 - if (remote.mode === "remote-unavailable") return;
253 - if (remote.mode === "remote-links") {
254 - const url = buildRemoteOpenUrl({
255 - editor,
256 - host: remote.host.host,
257 - absolutePath: openInCwd,
258 - });
259 - if (url === undefined) return;
260 - // Only record hint-seen/preferred when the shell actually accepted
261 - // the URL (an older desktop build can refuse the editor scheme).
262 - void openRemoteEditorUrl(url).then((opened) => {
263 - if (!opened) return;
264 - markRemoteHintSeen();
265 - setPreferredEditor(editor);
266 - });
267 - return;
268 - }
269 - if (!readEnvironmentScope(environmentId, AuthOrchestrationOperateScope)) return;
270 - const result = openInEditorMutation({
271 - environmentId,
272 - input: {
273 - cwd: openInCwd,
274 - editor,
275 - },
251 + const openInEditor = (editorId: EditorId | null) => {
252 + if (!openInCwd) return;
253 + const editor = editorId ?? preferredEditor;
254 + if (!editor) return;
255 + if (remote.mode === "remote-unavailable") return;
256 + if (remote.mode === "remote-links") {
257 + const url = buildRemoteOpenUrl({
258 + editor,
259 + host: remote.host.host,
260 + absolutePath: openInCwd,
261 });
277 - setPreferredEditor(editor);
278 - return result;
279 - },
280 - [
262 + if (url === undefined) return;
263 + // Only record hint-seen/preferred when the shell actually accepted
264 + // the URL (an older desktop build can refuse the editor scheme).
265 + void openRemoteEditorUrl(url).then((opened) => {
266 + if (!opened) return;
267 + markRemoteHintSeen();
268 + setPreferredEditor(editor);
269 + });
270 + return;
271 + }
272 + if (!readEnvironmentScope(environmentId, AuthOrchestrationOperateScope)) return;
273 + const result = openInEditorMutation({
274 environmentId,
282 - markRemoteHintSeen,
283 - openInCwd,
284 - openInEditorMutation,
285 - preferredEditor,
286 - remote,
287 - setPreferredEditor,
288 - ],
289 - );
275 + input: {
276 + cwd: openInCwd,
277 + editor,
278 + },
279 + });
280 + setPreferredEditor(editor);
281 + return result;
282 + };
283
291 - const openFavoriteEditorShortcutLabel = useMemo(
292 - () => shortcutLabelForCommand(keybindings, "editor.openFavorite"),
293 - [keybindings],
284 + const openFavoriteEditorShortcutLabel = shortcutLabelForCommand(
285 + keybindings,
286 + "editor.openFavorite",
287 );
288
289 useEffect(() => {