Skip to content

fix(client): avoid abort on terminal hangup - #2427

Open
akbash-bot wants to merge 2 commits into
masterfrom
akbash/2424-hungup-stderr
Open

fix(client): avoid abort on terminal hangup#2427
akbash-bot wants to merge 2 commits into
masterfrom
akbash/2424-hungup-stderr

Conversation

@akbash-bot

Copy link
Copy Markdown
Collaborator

Summary

  • make terminal restoration fully best-effort when the outer PTY has hung up
  • cover real PTY-master closure and verify the detached server survives
  • keep direct-SIGHUP and server-EOF restoration behavior covered

Checks

  • cargo test --test client_mode client_exits_cleanly_when_terminal_hangs_up -- --exact
  • cargo test --test client_mode client_restores_terminal_on_sighup -- --exact
  • cargo test --test client_mode client_restores_terminal_on_server_eof -- --exact
  • just lint
  • 3,240 Rust tests passed (one unrelated live-handoff harness test skipped because this issue's required external CARGO_TARGET_DIR is outside its hardcoded checkout-root process scan)
  • just windows-lint
  • integration asset, plugin marketplace, and maintenance script tests
  • live PTY hangup: SIGABRT/core before; exit 0 with server surviving after

refs #2424

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 345bc42e-fdb0-4c85-8b47-22abfb49f27e

📥 Commits

Reviewing files that changed from the base of the PR and between c6885a2 and af7c05e.

📒 Files selected for processing (1)
  • tests/client_mode.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/client_mode.rs

📝 Walkthrough

Walkthrough

The client now uses fallible terminal restoration. Unix-only client-mode tests detect PTY closure, verify clean client exit, and confirm server responsiveness.

Changes

Terminal hangup handling

Layer / File(s) Summary
Fallible terminal restoration
src/client/mod.rs
restore_terminal_state now calls ratatui::try_restore() and ignores the returned error.
PTY closure integration test
tests/client_mode.rs
The tests run on Unix, distinguish SIGHUP handling from terminal-window closure, detect client attachment through nonblocking PTY output, simulate PTY closure, verify client exit, and confirm server ping responsiveness.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • herdrdev/herdr#2041: Updates client terminal restoration and extends PTY and SIGHUP closure coverage.
  • herdrdev/herdr#2347: Modifies client terminal-state restoration and adds guarded restoration logic.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the client terminal hangup fix, which is the main change in the pull request.
Description check ✅ Passed The description accurately summarizes the terminal restoration fix, added PTY coverage, validation checks, and expected behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch akbash/2424-hungup-stderr

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

@kangal-bot kangal-bot added the ai-review Trigger automated AI reviews for pull requests admitted by the PR gate label Aug 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 12a5ae19-61d9-4b2f-ae6e-2c598a20a545

📥 Commits

Reviewing files that changed from the base of the PR and between 3825c0c and c6885a2.

📒 Files selected for processing (2)
  • src/client/mod.rs
  • tests/client_mode.rs

Comment thread tests/client_mode.rs
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

The PR prevents terminal restoration from aborting a client after its outer PTY hangs up while preserving the detached server.

  • Replaces the panicking terminal restoration call with its fallible, best-effort counterpart.
  • Adds an end-to-end Unix PTY hangup test that verifies clean client exit and server survival.
  • Retains coverage for direct SIGHUP and server-EOF restoration paths.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or non-blocking defects identified in the changed behavior.

The production change is narrowly scoped to suppressing restoration failure after terminal hangup, and the new integration coverage exercises the intended client-exit and detached-server-survival behavior.

Important Files Changed

Filename Overview
src/client/mod.rs Makes ratatui terminal restoration fallible and best-effort so teardown cannot abort when the outer PTY is already unwritable.
tests/client_mode.rs Gates the Unix-specific integration suite appropriately and adds real PTY-master closure coverage for clean client exit and server survival.

Reviews (1): Last reviewed commit: "test(client): gate PTY integration on un..." | Re-trigger Greptile

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

Labels

ai-review Trigger automated AI reviews for pull requests admitted by the PR gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants