Uh oh!
There was an error while loading. Please reload this page.
fix(terminal): prevent project action commands from getting stuck - #6338
fix(terminal): prevent project action commands from getting stuck#6338amitray007 wants to merge 1 commit into
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
0da3209 to
e00060aCompareApprovabilityVerdict: Needs human review This PR changes how terminal commands are executed by embedding them in shell spawn arguments rather than writing to the terminal after startup. The shell command construction logic and platform-specific behavior changes warrant human review. You can customize Macroscope's approvability policy. Learn more. |
e00060a to
0919e07CompareThere was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0919e076d012a610a5d3d628b2765ee6cf2239bc. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
0919e07 to
59b7e5aCompareamitray007
commented
Aug 21, 2026
Won't be able to maintain this PR anymore. Feel free to use the code if needed, using a personal fork going forward. |

What Changed
Fixes#6337.
Why
Project actions previously opened the terminal and immediately sent the command through a separate terminal write. When the terminal had never been opened, interactive shell initialization could race that write, leaving commands such as
npm run devstuck above the new prompt without executing.The fix includes the command in fresh terminal startup where supported and has the server acknowledge whether it handled the command. This removes the race while preserving the existing fallback behavior for Windows, unsupported shells, running terminals, and older servers.
UI Changes
Before: With the terminal unopened, the project-action command could get stuck above the initialized prompt without executing.
After: The command executes exactly once after shell initialization. Stopping a long-running command with Ctrl+C returns to a usable prompt without closing the terminal.
Verification
vp test run packages/contracts/src/terminal.test.ts apps/server/src/terminal/Manager.test.ts— 80 tests passed@t3tools/contracts,t3, and@t3tools/webtypecheckst3-testingproject: a long-running custom action executed exactly once when launched with the terminal previously unopenedChecklist
Prepared with GPT-5.6 Codex in T3 Code.
Note
Prevent project action commands from getting stuck by running them during terminal startup
initialCommandfield toTerminalOpenInputand aninitialCommandHandledflag toTerminalSessionSnapshotin the contract schemas.-i -cto run the command, trapsINTto avoid early exit, thenexecs back into the interactive shell.initialCommandwhen opening a terminal for a project script and only falls back to writing the command if the server did not setinitialCommandHandled: true.Macroscope summarized 59b7e5a.
Note
Medium Risk
Changes terminal spawn arguments and project-action execution paths; POSIX startup uses embedded shell
-cwith user-supplied commands, though existing write fallback and version skew handling limit blast radius.Overview
Fixes project actions that could appear above the prompt without running when the terminal had never been opened, by racing shell init against a separate
write.Contracts add optional
initialCommandonTerminalOpenInputandinitialCommandHandledonTerminalSessionSnapshotso the client knows whether the server ran the command at spawn.Server (
Manager.ts): on fresh POSIX spawns (zsh/bash/sh), rewrites shell args to run the command via interactive-c, trapsINTso Ctrl+C stops the action but keeps an interactive shell (execback into the normal shell). ReturnsinitialCommandHandled: trueonly when that path runs; Windows and an already-running session do not use it.Web (
ChatView.tsx): project scripts passinitialCommandonopenTerminaland only fall back to the legacywriteTerminalpath wheninitialCommandHandled !== true(older servers, Windows, reused terminals).Reviewed by Cursor Bugbot for commit 59b7e5a. Bugbot is set up for automated code reviews on this repo. Configure here.