The best way to control Claude Code, Codex and more from any computer or phone
chore(lint): fail lint when the React Compiler skips a listed file (#20292)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 17:39 UTC
48a16040891d90aa87491c9d215e0bdb40cd6573
6 files changed
+198
-181
apps/web/src/components/PersistentThreadTerminals.tsx
+92
-181
@@ -8,7 +8,7 @@ import {
8
import { scopeProjectRef } from "@t3tools/client-runtime/environment";
9
import { projectScriptCwd, projectScriptRuntimeEnv } from "@t3tools/shared/projectScripts";
10
import { resolveTerminalSessionLabel } from "@t3tools/shared/terminalLabels";
11
-import { memo, useCallback, useEffect, useMemo, useState } from "react";
11
+import { memo, useEffect, useState } from "react";
12
import { useComposerDraftStore } from "../composerDraftStore";
13
import { useStableCallback } from "../hooks/useStableCallback";
14
import type { TerminalContextSelection } from "../lib/terminalContext";
@@ -70,6 +70,12 @@ function serverTerminalIdsStrictSubsetOfClient(
70
return true;
71
}
72
73
+interface TerminalLaunchLocationWithEnv {
74
+ readonly cwd: string;
75
+ readonly worktreePath: string | null;
76
+ readonly runtimeEnv: Record<string, string>;
77
+}
78
+
79
interface PersistentThreadTerminalDrawerProps {
80
threadRef: { environmentId: EnvironmentId; threadId: ThreadId };
81
threadId: ThreadId;
@@ -118,67 +124,36 @@ export const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerm
124
const panelSurfaces = useRightPanelStore(
125
(state) => selectThreadRightPanelState(state.byThreadKey, threadRef).surfaces,
126
);
121
- const panelTerminalIds = useMemo(
122
- () =>
123
- new Set(
124
- panelSurfaces.flatMap((surface) =>
125
- surface.kind === "terminal" ? surface.terminalIds : [],
126
- ),
127
- ),
128
- [panelSurfaces],
129
- );
130
- const drawerTerminalSessions = useMemo(
131
- () =>
132
- knownTerminalSessions?.filter(
133
- (session) => !panelTerminalIds.has(session.target.terminalId),
134
- ) ?? [],
135
- [knownTerminalSessions, panelTerminalIds],
127
+ const panelTerminalIds = new Set(
128
+ panelSurfaces.flatMap((surface) => (surface.kind === "terminal" ? surface.terminalIds : [])),
129
);
137
- const terminalLabelsById = useMemo(() => {
138
- const next = new Map<string, string>();
139
- for (const session of drawerTerminalSessions) {
140
- next.set(
141
- session.target.terminalId,
142
- resolveTerminalSessionLabel(session.target.terminalId, session.state.summary),
143
- );
144
- }
145
- return next;
146
- }, [drawerTerminalSessions]);
147
- const terminalLaunchLocationsById = useMemo(() => {
148
- const next = new Map<
149
- string,
150
- {
151
- readonly cwd: string;
152
- readonly worktreePath: string | null;
153
- readonly runtimeEnv: Record<string, string>;
154
- }
155
- >();
156
- if (!project) {
157
- return next;
158
- }
159
-
160
- for (const session of drawerTerminalSessions) {
161
- const summary = session.state.summary;
162
- if (!summary) {
163
- continue;
164
- }
165
- const worktreePathForLaunch =
166
- launchContext !== null ? launchContext.worktreePath : summary.worktreePath;
167
- next.set(session.target.terminalId, {
168
- cwd: launchContext?.cwd ?? summary.cwd,
130
+ const drawerTerminalSessions =
131
+ knownTerminalSessions?.filter((session) => !panelTerminalIds.has(session.target.terminalId)) ??
132
+ [];
133
+ const terminalLabelsById = new Map<string, string>();
134
+ for (const session of drawerTerminalSessions) {
135
+ terminalLabelsById.set(
136
+ session.target.terminalId,
137
+ resolveTerminalSessionLabel(session.target.terminalId, session.state.summary),
138
+ );
139
+ }
140
+ const terminalLaunchLocationsById = new Map<string, TerminalLaunchLocationWithEnv>();
141
+ for (const session of drawerTerminalSessions) {
142
+ const summary = session.state.summary;
143
+ if (!project || !summary) continue;
144
+ const worktreePathForLaunch =
145
+ launchContext !== null ? launchContext.worktreePath : summary.worktreePath;
146
+ terminalLaunchLocationsById.set(session.target.terminalId, {
147
+ cwd: launchContext?.cwd ?? summary.cwd,
148
+ worktreePath: worktreePathForLaunch,
149
+ runtimeEnv: projectScriptRuntimeEnv({
150
+ project: { cwd: project.workspaceRoot },
151
worktreePath: worktreePathForLaunch,
170
- runtimeEnv: projectScriptRuntimeEnv({
171
- project: { cwd: project.workspaceRoot },
172
- worktreePath: worktreePathForLaunch,
173
- }),
174
- });
175
- }
176
-
177
- return next;
178
- }, [drawerTerminalSessions, launchContext, project]);
179
- const serverOrderedTerminalIds = useMemo(
180
- () => drawerTerminalSessions.map((session) => session.target.terminalId),
181
- [drawerTerminalSessions],
152
+ }),
153
+ });
154
+ }
155
+ const serverOrderedTerminalIds = drawerTerminalSessions.map(
156
+ (session) => session.target.terminalId,
157
);
158
const storeSetTerminalHeight = useTerminalUiStateStore((state) => state.setTerminalHeight);
159
const storeSplitTerminal = useTerminalUiStateStore((state) => state.splitTerminal);
@@ -203,47 +178,32 @@ export const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerm
178
}, [reconcileTerminalIds, serverOrderedTerminalIds, terminalUiState.terminalIds, threadRef]);
179
const [localFocusRequestId, setLocalFocusRequestId] = useState(0);
180
const worktreePath = serverThread?.worktreePath ?? draftThread?.worktreePath ?? null;
206
- const effectiveWorktreePath = useMemo(() => {
207
- if (launchContext !== null) {
208
- return launchContext.worktreePath;
209
- }
210
- return worktreePath;
211
- }, [launchContext, worktreePath]);
212
- const cwd = useMemo(
213
- () =>
214
- launchContext?.cwd ??
215
- (project
216
- ? projectScriptCwd({
217
- project: { cwd: project.workspaceRoot },
218
- worktreePath: effectiveWorktreePath,
219
- })
220
- : null),
221
- [effectiveWorktreePath, launchContext?.cwd, project],
222
- );
223
- const runtimeEnv = useMemo(
224
- () =>
225
- project
226
- ? projectScriptRuntimeEnv({
227
- project: { cwd: project.workspaceRoot },
228
- worktreePath: effectiveWorktreePath,
229
- })
230
- : {},
231
- [effectiveWorktreePath, project],
232
- );
181
+ const effectiveWorktreePath = launchContext !== null ? launchContext.worktreePath : worktreePath;
182
+ const cwd =
183
+ launchContext?.cwd ??
184
+ (project
185
+ ? projectScriptCwd({
186
+ project: { cwd: project.workspaceRoot },
187
+ worktreePath: effectiveWorktreePath,
188
+ })
189
+ : null);
190
+ const runtimeEnv = project
191
+ ? projectScriptRuntimeEnv({
192
+ project: { cwd: project.workspaceRoot },
193
+ worktreePath: effectiveWorktreePath,
194
+ })
195
+ : {};
196
234
- const bumpFocusRequestId = useCallback(() => {
197
+ const bumpFocusRequestId = () => {
198
if (!visible) {
199
return;
200
}
201
setLocalFocusRequestId((value) => value + 1);
239
- }, [visible]);
202
+ };
203
241
- const setTerminalHeight = useCallback(
242
- (height: number) => {
243
- storeSetTerminalHeight(threadRef, height);
244
- },
245
- [storeSetTerminalHeight, threadRef],
246
- );
204
+ const setTerminalHeight = (height: number) => {
205
+ storeSetTerminalHeight(threadRef, height);
206
+ };
207
208
const launchDrawerTerminal = (place: (terminalId: string) => void) => {
209
if (!cwd) return;
@@ -265,13 +225,10 @@ export const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerm
225
launchDrawerTerminal((terminalId) => storeNewTerminal(threadRef, terminalId)),
226
);
227
268
- const activateTerminal = useCallback(
269
- (terminalId: string) => {
270
- storeSetActiveTerminal(threadRef, terminalId);
271
- bumpFocusRequestId();
272
- },
273
- [bumpFocusRequestId, storeSetActiveTerminal, threadRef],
274
- );
228
+ const activateTerminal = (terminalId: string) => {
229
+ storeSetActiveTerminal(threadRef, terminalId);
230
+ bumpFocusRequestId();
231
+ };
232
233
const closeTerminal = useStableCallback((terminalId: string) => {
234
if (!terminalActions.canWrite()) return;
@@ -280,15 +237,12 @@ export const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerm
237
bumpFocusRequestId();
238
});
239
283
- const handleAddTerminalContext = useCallback(
284
- (selection: TerminalContextSelection) => {
285
- if (!visible) {
286
- return;
287
- }
288
- onAddTerminalContext(selection);
289
- },
290
- [onAddTerminalContext, visible],
291
- );
240
+ const handleAddTerminalContext = (selection: TerminalContextSelection) => {
241
+ if (!visible) {
242
+ return;
243
+ }
244
+ onAddTerminalContext(selection);
245
+ };
246
247
if (!project || (!terminalUiState.terminalOpen && !active) || !cwd) {
248
return null;
@@ -394,81 +348,38 @@ export const PersistentThreadTerminalPanel = memo(function PersistentThreadTermi
348
?.state.summary ?? null;
349
const worktreePath =
350
launchContext?.worktreePath ?? activeSummary?.worktreePath ?? threadWorktreePath;
397
- const cwd = useMemo(
398
- () =>
399
- launchContext?.cwd ??
400
- activeSummary?.cwd ??
401
- (project
402
- ? projectScriptCwd({
403
- project: { cwd: project.workspaceRoot },
404
- worktreePath,
405
- })
406
- : null),
407
- [activeSummary?.cwd, launchContext?.cwd, project, worktreePath],
408
- );
409
- const runtimeEnv = useMemo(
410
- () =>
411
- project
412
- ? projectScriptRuntimeEnv({
413
- project: { cwd: project.workspaceRoot },
414
- worktreePath,
415
- })
416
- : {},
417
- [project, worktreePath],
418
- );
419
- const terminalLabelsById = useMemo(() => {
420
- const labels = new Map<string, string>();
421
- for (const terminalId of surface.terminalIds) {
422
- const summary =
423
- knownTerminalSessions?.find((session) => session.target.terminalId === terminalId)?.state
424
- .summary ?? null;
425
- labels.set(terminalId, resolveTerminalSessionLabel(terminalId, summary));
426
- }
427
- return labels;
428
- }, [knownTerminalSessions, surface.terminalIds]);
429
- const terminalLaunchLocationsById = useMemo(() => {
430
- const locations = new Map<
431
- string,
432
- {
433
- readonly cwd: string;
434
- readonly worktreePath: string | null;
435
- readonly runtimeEnv: Record<string, string>;
436
- }
437
- >();
438
- for (const terminalId of surface.terminalIds) {
439
- const summary =
440
- knownTerminalSessions?.find((session) => session.target.terminalId === terminalId)?.state
441
- .summary ?? null;
442
- const terminalWorktreePath =
443
- launchContext?.worktreePath ?? summary?.worktreePath ?? threadWorktreePath;
444
- const terminalCwd =
351
+ const cwd =
352
+ launchContext?.cwd ??
353
+ activeSummary?.cwd ??
354
+ (project ? projectScriptCwd({ project: { cwd: project.workspaceRoot }, worktreePath }) : null);
355
+ const runtimeEnv = project
356
+ ? projectScriptRuntimeEnv({ project: { cwd: project.workspaceRoot }, worktreePath })
357
+ : {};
358
+ const terminalLabelsById = new Map<string, string>();
359
+ const terminalLaunchLocationsById = new Map<string, TerminalLaunchLocationWithEnv>();
360
+ for (const terminalId of surface.terminalIds) {
361
+ const summary =
362
+ knownTerminalSessions?.find((session) => session.target.terminalId === terminalId)?.state
363
+ .summary ?? null;
364
+ terminalLabelsById.set(terminalId, resolveTerminalSessionLabel(terminalId, summary));
365
+ if (!project) continue;
366
+ const terminalWorktreePath =
367
+ launchContext?.worktreePath ?? summary?.worktreePath ?? threadWorktreePath;
368
+ terminalLaunchLocationsById.set(terminalId, {
369
+ cwd:
370
launchContext?.cwd ??
371
summary?.cwd ??
447
- (project
448
- ? projectScriptCwd({
449
- project: { cwd: project.workspaceRoot },
450
- worktreePath: terminalWorktreePath,
451
- })
452
- : null);
453
- if (!terminalCwd || !project) continue;
454
- locations.set(terminalId, {
455
- cwd: terminalCwd,
456
- worktreePath: terminalWorktreePath,
457
- runtimeEnv: projectScriptRuntimeEnv({
372
+ projectScriptCwd({
373
project: { cwd: project.workspaceRoot },
374
worktreePath: terminalWorktreePath,
375
}),
461
- });
462
- }
463
- return locations;
464
- }, [
465
- knownTerminalSessions,
466
- launchContext?.cwd,
467
- launchContext?.worktreePath,
468
- project,
469
- surface.terminalIds,
470
- threadWorktreePath,
471
- ]);
376
+ worktreePath: terminalWorktreePath,
377
+ runtimeEnv: projectScriptRuntimeEnv({
378
+ project: { cwd: project.workspaceRoot },
379
+ worktreePath: terminalWorktreePath,
380
+ }),
381
+ });
382
+ }
383
384
if (!project || !cwd) return null;
385
docs/internals/web-ui.md
+13
@@ -53,3 +53,16 @@ Calls inside the component keep the plain function, so work that resumes after a
53
acts on the render it started in. A function that a child calls during render, or after an
54
`await`, comes from a module-level factory memoized on its inputs, so its closure keeps only
55
those inputs.
56
+
57
+## React Compiler
58
+
59
+The compiler memoizes a component or hook only when it can prove the code follows React's rules.
60
+Anything it can't prove, such as reading a ref during render or calling `setState` from an effect,
61
+makes it skip the whole function without a build error. Lint reports each skip as a
62
+`react(...)` warning with the note "React Compiler skipped optimizing this component or hook".
63
+
64
+Files listed in the React Compiler override in [`vite.config.ts`](../../vite.config.ts) must
65
+compile. There those rules are errors, and `t3code/no-manual-memo` rejects `useMemo` and
66
+`useCallback`, which the compiler makes redundant. `useStableCallback` still marks handlers
67
+that leave a large component, as described above. Add a file to the list once its skips are
68
+fixed, and drop its manual memoization in the same change.
oxlint-plugin-t3code/index.ts
+2
@@ -5,6 +5,7 @@ import noGlobalProcessRuntime from "./rules/no-global-process-runtime.ts";
5
import noHermesUnsupportedApis from "./rules/no-hermes-unsupported-apis.ts";
6
import noInlineSchemaCompile from "./rules/no-inline-schema-compile.ts";
7
import noLowValueComments from "./rules/no-low-value-comments.ts";
8
+import noManualMemo from "./rules/no-manual-memo.ts";
9
import noManualEffectRuntimeInTests from "./rules/no-manual-effect-runtime-in-tests.ts";
10
import noMobileUniwindThemeEscapeHatches from "./rules/no-mobile-uniwind-theme-escape-hatches.ts";
11
import noNativeTitleTooltip from "./rules/no-native-title-tooltip.ts";
@@ -29,6 +30,7 @@ export default definePlugin({
30
"no-inline-schema-compile": noInlineSchemaCompile,
31
"no-low-value-comments": noLowValueComments,
32
"no-manual-effect-runtime-in-tests": noManualEffectRuntimeInTests,
33
+ "no-manual-memo": noManualMemo,
34
"no-mobile-uniwind-theme-escape-hatches": noMobileUniwindThemeEscapeHatches,
35
"no-native-title-tooltip": noNativeTitleTooltip,
36
"no-outset-state-indicators": noOutsetStateIndicators,
oxlint-plugin-t3code/rules/no-manual-memo.test.ts
new
+24
@@ -0,0 +1,24 @@
1
+import { describe } from "@effect/vitest";
2
+
3
+import { createOxlintRuleHarness } from "../test/utils.ts";
4
+
5
+const rule = createOxlintRuleHarness("t3code/no-manual-memo", {
6
+ filename: "fixture.tsx",
7
+});
8
+
9
+describe("t3code/no-manual-memo", () => {
10
+ rule.valid("allows plain derived values", `const total = items.length * 2;`);
11
+
12
+ rule.valid("allows useStableCallback", `const onClick = useStableCallback(() => save());`);
13
+
14
+ rule.valid("allows other React members", `const ref = React.useRef(null);`);
15
+
16
+ rule.invalid("reports useMemo", `const total = useMemo(() => items.length, [items]);`);
17
+
18
+ rule.invalid("reports useCallback", `const onClick = useCallback(() => save(), []);`);
19
+
20
+ rule.invalid(
21
+ "reports React.useMemo",
22
+ `const total = React.useMemo(() => items.length, [items]);`,
23
+ );
24
+});
oxlint-plugin-t3code/rules/no-manual-memo.ts
new
+42
@@ -0,0 +1,42 @@
1
+import { defineRule, type ESTree } from "@oxlint/plugins";
2
+
3
+const MANUAL_MEMO_HOOKS = new Set(["useCallback", "useMemo"]);
4
+
5
+function manualMemoHookName(callee: ESTree.Node): string | null {
6
+ if (callee.type === "Identifier") {
7
+ return MANUAL_MEMO_HOOKS.has(callee.name) ? callee.name : null;
8
+ }
9
+ if (
10
+ callee.type === "MemberExpression" &&
11
+ !callee.computed &&
12
+ callee.object.type === "Identifier" &&
13
+ callee.object.name === "React" &&
14
+ callee.property.type === "Identifier" &&
15
+ MANUAL_MEMO_HOOKS.has(callee.property.name)
16
+ ) {
17
+ return callee.property.name;
18
+ }
19
+ return null;
20
+}
21
+
22
+export default defineRule({
23
+ meta: {
24
+ type: "suggestion",
25
+ docs: {
26
+ description:
27
+ "Disallow useCallback and useMemo in files the React Compiler must compile; it memoizes them.",
28
+ },
29
+ },
30
+ create(context) {
31
+ return {
32
+ CallExpression(node) {
33
+ const name = manualMemoHookName(node.callee);
34
+ if (name === null) return;
35
+ context.report({
36
+ node: node.callee,
37
+ message: `Drop ${name}: the React Compiler memoizes this file. Write the plain value or function, and use useStableCallback only where a handler must keep one identity across renders.`,
38
+ });
39
+ },
40
+ };
41
+ },
42
+});
vite.config.ts
+25
@@ -320,6 +320,31 @@ export default defineConfig({
320
],
321
},
322
},
323
+ {
324
+ // Files the React Compiler must compile. Any bailout (a ref read in render, a
325
+ // setState in an effect, a manual memo it cannot preserve) fails lint instead of
326
+ // silently leaving the file unoptimized, and manual memoization is redundant here.
327
+ // Add a file once it compiles cleanly. ChatView is being split toward this list.
328
+ files: [
329
+ "apps/web/src/components/PersistentThreadTerminals.tsx",
330
+ "apps/web/src/components/terminal/**",
331
+ ],
332
+ rules: {
333
+ "react/exhaustive-effect-dependencies": "error",
334
+ "react/globals": "error",
335
+ "react/hooks": "error",
336
+ "react/immutability": "error",
337
+ "react/memo-dependencies": "error",
338
+ "react/preserve-manual-memoization": "error",
339
+ "react/purity": "error",
340
+ "react/refs": "error",
341
+ "react/set-state-in-effect": "error",
342
+ "react/set-state-in-render": "error",
343
+ "react/static-components": "error",
344
+ "react/unsupported-syntax": "error",
345
+ "t3code/no-manual-memo": "error",
346
+ },
347
+ },
348
{
349
// The sign-in masthead is T3 brand artwork: fixed gradients, not theme surfaces.
350
files: ["apps/web/src/components/auth/AuthSurfaceShell.tsx"],