Skip to content

[codex] Structure terminal PTY operation failures#3364

Open
juliusmarminge wants to merge 4 commits into
mainfrom
codex/structure-terminal-pty-failures
Open

[codex] Structure terminal PTY operation failures#3364
juliusmarminge wants to merge 4 commits into
mainfrom
codex/structure-terminal-pty-failures

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • convert synchronous PTY write and resize exceptions from defects into typed terminal errors
  • preserve the exact adapter cause and attach thread, terminal, PID, and resize dimensions without copying terminal input data
  • apply the same resize boundary to explicit resize, reopen, and attach paths, and only mutate stored dimensions after a successful resize

Verification

  • vp test apps/server/src/terminal/Manager.test.ts (46 passed)
  • vp check (passes with 20 pre-existing warnings)
  • vp run typecheck

Note

Medium Risk
Changes the terminal error contract and PTY failure paths (write/resize/open); callers matching old TerminalCwdError.reason must use new tags, but behavior is more predictable and input is not leaked on write failures.

Overview
Replaces the monolithic TerminalCwdError (reason + optional cause) with TerminalCwdNotFoundError, TerminalCwdNotDirectoryError, and TerminalCwdStatError (stat failures keep the PlatformError as cause). TerminalCwdError remains a union type for TerminalError.

Adds TerminalWriteError and TerminalResizeError for synchronous PTY write / resize failures, with threadId, terminalId, terminalPid, and resize dimensions; write errors do not include input data.

TerminalManager wraps PTY I/O in Effect.try via resizePtyProcess, applies resize on open/attach/resize only after success, and logs full cause objects instead of error.message strings. Tests cover cwd variants and PTY I/O error shape.

Reviewed by Cursor Bugbot for commit 30a32cf. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Structure terminal PTY operation failures into typed errors for cwd, write, and resize

  • Replaces the single TerminalCwdError class with a union of TerminalCwdNotFoundError, TerminalCwdNotDirectoryError, and TerminalCwdStatError, each with distinct tags and appropriate cause fields.
  • Adds TerminalWriteError and TerminalResizeError tagged errors that carry thread/terminal/PID context and the underlying cause without leaking input data.
  • Wraps raw PTY write and resize calls in Effect.try (and a new resizePtyProcess helper) so failures surface as structured errors instead of thrown exceptions.
  • Extends the TerminalError union in terminal.ts to include the two new I/O error types.
  • Risk: callers that previously matched on TerminalCwdError or caught raw exceptions from PTY operations must now handle the new error variants.

Macroscope summarized 30a32cf.

Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge juliusmarminge added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Jun 20, 2026
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. 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.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 69e65eab-4f3f-4b0c-8d93-1b467cc9cadc

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
  • Commit unit tests in branch codex/structure-terminal-pty-failures

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

@github-actions github-actions Bot added the size:M 30-99 changed lines (additions + deletions). label Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR restructures terminal PTY error handling by splitting a generic error type into specific variants (NotFound, NotDirectory, StatError) and adding structured error handling for write/resize operations. The changes improve error observability without altering core functionality, and include comprehensive test coverage.

You can customize Macroscope's approvability policy. Learn more.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 13:34

Dismissing prior approval to re-evaluate 7e5a4d6

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 13:46

Dismissing prior approval to re-evaluate 4219331

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant