The best way to control Claude Code, Codex and more from any computer or phone
Fix terminal stability bugs: remove autoFocus from effect deps, stabilize memo, remove dead export
- Remove autoFocus from the main terminal setup effect dependency array to prevent full terminal teardown/recreation when switching tabs in split view. Focus is already handled by a dedicated effect. - Change threadTerminalRuntimeEnv memo dependency from activeProject to activeProject?.cwd so unrelated project state changes (e.g. saving scripts) don't trigger terminal re-initialization. - Unexport injectEnvIntoShellCommand which is never imported by production code (env injection is handled server-side), and remove its tests. Applied via @cursor push command
Cursor Agent committed
Feb 18, 2026 at 08:20 UTC
0e73dc15275f24b7ba94a7c200939907690f70b2
4 files changed
+3
-23
apps/web/src/components/ChatView.tsx
+1
-1
@@ -552,7 +552,7 @@ export default function ChatView() {
552
},
553
worktreePath: activeThread?.worktreePath ?? null,
554
});
555
- }, [activeProject, activeThread?.worktreePath]);
555
+ }, [activeProject?.cwd, activeThread?.worktreePath]);
556
// Default true while loading to avoid toolbar flicker.
557
const isGitRepo = branchesQuery.data?.isRepo ?? true;
558
const splitTerminalShortcutLabel = useMemo(
apps/web/src/components/ThreadTerminalDrawer.tsx
+1
-1
@@ -372,7 +372,7 @@ function TerminalViewport({
372
fitAddonRef.current = null;
373
terminal.dispose();
374
};
375
- }, [api, autoFocus, cwd, runtimeEnv, terminalId, threadId]);
375
+ }, [api, cwd, runtimeEnv, terminalId, threadId]);
376
377
useEffect(() => {
378
if (!autoFocus) return;
apps/web/src/projectScripts.test.ts
-20
@@ -2,7 +2,6 @@ import { describe, expect, it } from "vitest";
2
3
import {
4
commandForProjectScript,
5
- injectEnvIntoShellCommand,
5
nextProjectScriptId,
6
primaryProjectScript,
7
projectScriptRuntimeEnv,
@@ -24,25 +23,6 @@ describe("projectScripts helpers", () => {
23
expect(nextProjectScriptId("!!!", [])).toBe("script");
24
});
25
27
- it("injects environment variables for posix shells", () => {
28
- const command = injectEnvIntoShellCommand("bun install", { T3CODE_PROJECT_ROOT: "/tmp/project" }, "MacIntel");
29
- expect(command).toBe("env T3CODE_PROJECT_ROOT='/tmp/project' bun install");
30
- });
31
-
32
- it("injects environment variables for windows shells", () => {
33
- const command = injectEnvIntoShellCommand("bun install", { T3CODE_PROJECT_ROOT: "C:\\\\repo path" }, "Win32");
34
- expect(command).toBe('set "T3CODE_PROJECT_ROOT=C:\\\\repo path" && bun install');
35
- });
36
-
37
- it("escapes windows env values that trigger interpolation", () => {
38
- const command = injectEnvIntoShellCommand(
39
- "bun install",
40
- { T3CODE_PROJECT_ROOT: '%USERPROFILE%^"repo"' },
41
- "Win32",
42
- );
43
- expect(command).toBe('set "T3CODE_PROJECT_ROOT=^%USERPROFILE^%^^""repo""" && bun install');
44
- });
45
-
26
it("resolves primary and setup scripts", () => {
27
const scripts = [
28
{
apps/web/src/projectScripts.ts
+1
-1
@@ -60,7 +60,7 @@ function shellEscapeWindowsSetValue(value: string): string {
60
return value.replace(/\^/g, "^^").replace(/%/g, "^%").replace(/"/g, '""');
61
}
62
63
-export function injectEnvIntoShellCommand(
63
+function injectEnvIntoShellCommand(
64
command: string,
65
env: Record<string, string>,
66
platform = typeof navigator === "undefined" ? "" : navigator.platform,