Skip to content

Command failure tolerance - #114

Closed
juliusmarminge wants to merge 1 commit into
mainfrom
cursor/command-failure-tolerance-a10d
Closed

Command failure tolerance#114
juliusmarminge wants to merge 1 commit into
mainfrom
cursor/command-failure-tolerance-a10d

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Feb 28, 2026

Copy link
Copy Markdown
Member

Make terminal write and resize tolerant of exited processes to prevent errors when a terminal closes.

The terminal's write and resize methods were throwing errors when called on a process that had already exited (e.g., after an exit command), causing error messages to appear in the UI. This change makes these operations silently return or catch errors, allowing the terminal to close gracefully without user-facing errors.


Open in Web Open in Cursor 

Note

Make TerminalManagerRuntime.write and TerminalManagerRuntime.resize tolerate command failures in Manager.ts by returning early when the terminal is missing or exited

Update terminal runtime methods to return without throwing when the session is absent or exited and wrap process calls in try/catch; add tests asserting resolved promises on exited sessions in Manager.test.ts.

📍Where to Start

Start with the TerminalManagerRuntime.write and TerminalManagerRuntime.resize implementations in Manager.ts.

📊 Macroscope summarized 25ea66c. 1 file reviewed, 2 issues evaluated, 0 issues filtered, 1 comment posted

🗂️ Filtered Issues

Commands like exit that cause the shell to close should not produce
errors on subsequent write or resize calls. Instead of throwing when
the terminal is not running, silently drop the operation. Also wrap
the raw PTY write/resize calls in try/catch to handle the race where
the process exits between the status check and the call.

Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@cursor

cursor Bot commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai

coderabbitai Bot commented Feb 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/command-failure-tolerance-a10d

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment on lines 455 to +462
}
session.cols = input.cols;
session.rows = input.rows;
session.updatedAt = new Date().toISOString();
session.process.resize(input.cols, input.rows);
try {
session.process.resize(input.cols, input.rows);
} catch {
// Process may have exited between the status check and the resize call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low Layers/Manager.ts:455

Consider moving session.cols and session.rows assignments inside the try block, after session.process.resize() succeeds. Currently, if resize() throws, the session state will reflect dimensions the PTY never adopted.

-    session.cols = input.cols;
-    session.rows = input.rows;
-    session.updatedAt = new Date().toISOString();
     try {
       session.process.resize(input.cols, input.rows);
+      session.cols = input.cols;
+      session.rows = input.rows;
+      session.updatedAt = new Date().toISOString();
     } catch {
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file apps/server/src/terminal/Layers/Manager.ts around lines 455-462:

Consider moving `session.cols` and `session.rows` assignments inside the `try` block, after `session.process.resize()` succeeds. Currently, if `resize()` throws, the session state will reflect dimensions the PTY never adopted.

Evidence trail:
apps/server/src/terminal/Layers/Manager.ts lines 450-464 at REVIEWED_COMMIT: The `resize` method shows `session.cols = input.cols` (line 456) and `session.rows = input.rows` (line 457) are assigned BEFORE the `try` block. The `session.process.resize(input.cols, input.rows)` call is inside the `try` block (line 460). The catch block comment confirms the known failure mode: "Process may have exited between the status check and the resize call."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants