Improve project action terminal readiness#3175
Conversation
…ed-project-actions # Conflicts: # apps/web/src/components/ChatView.browser.tsx # apps/web/src/components/ChatView.tsx
…ed-project-actions
…ed-project-actions
…ed-project-actions
…ed-project-actions
|
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 Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
ApprovabilityVerdict: Needs human review This PR introduces significant new terminal readiness detection capability (~1900 additions) that changes when and how project scripts execute in terminals. The new prompt detection patterns, process tree inspection, and waiting mechanisms represent substantial runtime behavior changes that warrant human review. You can customize Macroscope's approvability policy. Learn more. |
- Relax POSIX ps mock flag matching - Share action label humanization and cover colon suffix cases
…ed-project-actions # Conflicts: # apps/server/src/terminal/Layers/Manager.ts # apps/server/src/terminal/Manager.test.ts
2d213d0 to
e599d9a
Compare
…ed-project-actions
- Treat login-shell children as shells - Recognize PowerShell and Windows prompts - Recover when terminal attach initially fails
- Require Unix prompt markers to stand alone after whitespace - Cover progress percentage output as not ready
- Allow attached bash and zsh prompt suffixes - Cover default host prompt readiness cases
- Reject spaced percent progress lines as prompts - Cover second attach timeout and Windows drive-root prompts - Type attach failure cause handling directly
…ed-project-actions
- Extract shared candidate classification logic - Reuse ready and probe terminal sets in ChatView - Cover reusable, probeable, and other-worktree cases
- Derive the candidate session shape from terminal state - Reuse classified ready terminals for initial writes - Cover ready precedence and selection edge cases
There was a problem hiding this comment.
One error-modeling convention violation found in the changed scope. See the inline comment.
Posted via Macroscope — Effect Service Conventions
…ed-project-actions
- Gate terminal open, split, and action runs on connected hosts - Keep action editing available when run controls are unavailable - Allow closing an open terminal drawer after disconnect - Disable right-panel terminal creation when hosts are unavailable
Summary
This PR implements terminal-backed project actions that route each project script through a stable action-specific terminal, wait for the target terminal to look input-ready before writing the command, and avoid reusing terminals that are still running non-shell subprocesses.
The current branch-local diff against
upstream/mainis limited to the terminal-backed project action surface: terminal selection/readiness helpers, ChatView command routing, terminal busy/idle inspection, action terminal labels, terminal UI availability guards, and focused tests.Branch Update Status
581766c495c688bb54f7d38e80323b34282a6e6a, which mergedupstream/mainata9b1190a11276927caf573d92c33c5346fc4c076intosplit/terminal-backed-project-actions; parent refs during the update wereorigin/main32d8580bf4cc1a80b782b3b13507320e511b1976and rootmain72200a3c363da256b8d839b8337728b94d884bd5.upstream/mainis29 ahead / 0 behind, covering 11 files with 1893 insertions and 85 deletions.upstream/mainmerged cleanly with no Git conflicts. Incoming upstream behavior added desktop parallel WSL plus Windows backends with a mode picker, desktop-local backend registration and settings, and browser preview automation/recording stabilization.apps/web/src/components/ChatView.tsx,apps/web/src/components/RightPanelTabs.tsx,apps/web/src/components/ProjectScriptsControl.tsx, andapps/web/src/components/chat/ChatHeader.tsxnow keep project-action and terminal-surface run controls disabled unless an active project exists and the active environment is connected.Unavailable, and the edit button remains reachable for existing actions.terminalUiAvailabledecision instead of expanding protocol shape in this branch.What Changed
apps/web/src/projectScriptTerminals.tsto resolve stable encodedaction-*terminal IDs, allocate numeric fallback instances when a primary action terminal is busy, detect prompt-like terminal output, and wait for project-action terminal input readiness with typed readiness failures.apps/web/src/state/projectActionTerminal.tsso the UI can track and strictly probe project-action terminal readiness while a command is being prepared.apps/web/src/components/ChatView.tsxto route project actions through the action-terminal flow, prefer reusable idle terminals for the same project/worktree, probe shell-labeled busy action terminals before reuse, wait again after opening in case the session restarted, respect interrupted readiness probes, and fall back to a fresh action terminal when readiness cannot be proven.Action: build (2).cmd.exe, POSIX idle-shell detection, conservative process-inspection fallback behavior, and action terminal labels.ProjectActionTerminalAttachError.ProjectScriptsControlwhen running them is unavailable.Why
Project actions can open or reuse a terminal before the shell is actually ready to receive input. Writing the command too early can drop the action or target a terminal that is already busy. This PR makes the action path wait for an input-ready prompt, separates action terminal IDs from script IDs, and keeps terminal reuse conservative when busy/idle state cannot be proven.
Validation
pnpm exec vp test related apps/web/src/components/ChatView.tsx apps/web/src/components/RightPanelTabs.tsx apps/web/src/components/ProjectScriptsControl.tsx apps/web/src/components/chat/ChatHeader.tsx --passWithNoTestspassed with 1 file and 4 tests.pnpm exec vp test run apps/web/src/projectScriptTerminals.test.ts apps/server/src/terminal/Manager.test.ts packages/shared/src/terminalLabels.test.ts --passWithNoTestspassed with 3 files and 95 tests.pnpm exec vp checkpassed with existing warnings outside the touched files.pnpm exec vp run typecheckpassed.git diff --checkpassed.Proof
Note
Medium Risk
Changes terminal busy/idle semantics on POSIX and adds concurrent script-launch orchestration; behavior is heavily tested but misclassification could still affect reuse or metadata labels.
Overview
Project scripts no longer pick a generic thread terminal and write immediately. Each script gets a stable
action-*terminal id (with numeric fallbacks when busy), the client classifies sessions by cwd/worktree and shell vs real subprocesses, reserves the chosen id for the whole open/probe/write flow, and waits for prompt-like output (strict probe + best-effort write path) before sending the command.On the server, POSIX subprocess polling now loads
comm=fromps, walks the tree, and treats an interactive shell child (including-bash) as idle when there is no non-shell descendant—reporting the first real descendant (e.g.pnpm) when present. If tree inspection fails, shell children stay busy (conservative).UI disables running scripts and opening/splitting terminals when the environment is not connected;
action-*tabs get readable Action: labels. NewprojectScriptTerminalshelpers andprojectActionTerminalcommands wire readiness intoChatView.Reviewed by Cursor Bugbot for commit e020f82. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Gate terminal UI on environment connectivity and improve project action terminal readiness detection
ProjectActionTerminalReadinessTimeoutError,ProjectActionTerminalAttachError) and readiness-wait effects in projectScriptTerminals.ts that detect shell prompts across Unix, PowerShell, and cmd, with timeout and best-effort variants.runProjectScriptin ChatView.tsx to select a ready terminal viaresolveProjectActionTerminalId, track launch reservations, wait for prompt readiness before writing, and fall back to a new terminal on failure.terminalUiAvailable, which requires an active project with a connected environment.action-*terminal IDs in terminalLabels.ts, decoding URL-encoded parts and formatting instance indices.Macroscope summarized e020f82.