From 07669d7d1ca8a549ebe79d049baf5b78ac33e515 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 18 Feb 2026 04:12:11 +0000 Subject: [PATCH] Fix stale scripts sync, worktree env closure, and terminal limit check - SYNC_PROJECTS: Always use server scripts instead of falling back to stale local scripts when server returns empty array - runProjectScript: Pass T3CODE_WORKTREE_PATH via options.env to avoid stale closure after SET_THREAD_BRANCH dispatch - runProjectScript: Check hasReachedTerminalLimit before creating a new terminal to prevent orphaned server-side PTY processes --- apps/web/src/components/ChatView.tsx | 4 +++- apps/web/src/store.ts | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 0e0a05ad90..833ba3c5d5 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -667,6 +667,7 @@ export default function ChatView() { const baseTerminalId = activeThread.activeTerminalId; const isBaseTerminalBusy = activeThread.runningTerminalIds.includes(baseTerminalId); const shouldCreateNewTerminal = Boolean(options?.preferNewTerminal) || isBaseTerminalBusy; + if (shouldCreateNewTerminal && hasReachedTerminalLimit) return; const targetTerminalId = shouldCreateNewTerminal ? `terminal-${crypto.randomUUID()}` : baseTerminalId; @@ -727,7 +728,7 @@ export default function ChatView() { }); } }, - [activeProject, activeThread, activeThreadId, api, dispatch, gitCwd], + [activeProject, activeThread, activeThreadId, api, dispatch, gitCwd, hasReachedTerminalLimit], ); const saveProjectScript = useCallback( async (input: NewProjectScriptInput) => { @@ -1350,6 +1351,7 @@ export default function ChatView() { if (setupScript) { void runProjectScript(setupScript, { cwd: result.worktree.path, + env: { T3CODE_WORKTREE_PATH: result.worktree.path }, }); } } catch (err) { diff --git a/apps/web/src/store.ts b/apps/web/src/store.ts index 8cc75e235b..1e790fbea8 100644 --- a/apps/web/src/store.ts +++ b/apps/web/src/store.ts @@ -481,10 +481,7 @@ export function reducer(state: AppState, action: Action): AppState { ); const nextProjects = action.projects.map((project) => { const previous = previousByCwd.get(project.cwd); - const scripts = - project.scripts.length > 0 - ? normalizeProjectScripts(project.scripts) - : normalizeProjectScripts(previous?.scripts ?? []); + const scripts = normalizeProjectScripts(project.scripts); return { ...project, model: resolveModelSlug(previous?.model ?? project.model),