Skip to content

fix(pty): process output alongside wake events - #2454

Closed
akbash-bot wants to merge 2 commits into
masterfrom
akbash/2449-no-focus-pane-input
Closed

fix(pty): process output alongside wake events#2454
akbash-bot wants to merge 2 commits into
masterfrom
akbash/2449-no-focus-pane-input

Conversation

@akbash-bot

Copy link
Copy Markdown
Collaborator

Summary

  • process PTY read and write readiness even when the actor wake FD is ready in the same poll
  • add deterministic simultaneous wake/read/write regression coverage
  • document the background-pane output fix

Checks

  • cargo test pty::actor::unix::tests -- --nocapture
  • cargo clippy --all-targets --locked -- -D warnings
  • just windows-lint
  • integration asset, plugin marketplace, and maintenance-script suites
  • cargo nextest run --locked -E 'all() - test(live_server_holds_one_pty_master_fd_per_pane) - test(metadata_clear_only_without_ttl_does_not_extend_old_ttl)' (3248 passed; the handoff PID-discovery test fails identically on the base commit in this host, and the timing test passes in isolation)
  • live restored-session reproduction: a fresh --no-focus pane surfaced command output in 321 ms while the active workspace remained unchanged

refs #2449

@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: 39be6553-b00f-4b70-8099-e27860714112

📥 Commits

Reviewing files that changed from the base of the PR and between 1cb8565 and 544d940.

📒 Files selected for processing (1)
  • docs/next/CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/next/CHANGELOG.md

📝 Walkthrough

Walkthrough

The PTY actor now processes wake, read, and write readiness in one cycle. Tests cover simultaneous readiness, and the changelog records reliable pane output for fresh background workspaces.

Changes

PTY readiness handling

Layer / File(s) Summary
Readiness processing
src/pty/actor/unix.rs
run delegates readiness handling to handle_poll_readiness. The handler drains wake notifications, processes PTY reads, flushes writes, and stops on relevant failures.
Readiness validation and release note
src/pty/actor/unix.rs, docs/next/CHANGELOG.md
Tests retain the wake writer and verify simultaneous wake, PTY read, and PTY write readiness. The changelog records the pane output fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PTYActor
  participant WakeSource
  participant PTY
  WakeSource->>PTYActor: wake readiness
  PTY->>PTYActor: read and write readiness
  PTYActor->>WakeSource: drain wake notifications
  PTYActor->>PTY: process reads and flush writes
Loading

Possibly related PRs

  • herdrdev/herdr#2426: Both changes address reliable PTY output readiness through different code paths.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main PTY change: processing output alongside wake events.
Description check ✅ Passed The description directly explains the PTY fix, regression coverage, documentation, and validation results.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch akbash/2449-no-focus-pane-input

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

@akbash-bot
akbash-bot force-pushed the akbash/2449-no-focus-pane-input branch from 65d8d06 to 1cb8565 Compare August 6, 2026 23:13
@akbash-bot akbash-bot added the ai-review Trigger automated AI reviews for pull requests admitted by the PR gate label Aug 6, 2026
@greptile-apps

greptile-apps Bot commented Aug 9, 2026

Copy link
Copy Markdown

Greptile Summary

The PR fixes delayed output in background panes by handling PTY read and write readiness even when the actor wake descriptor is simultaneously ready.

  • Extracts readiness handling into handle_poll_readiness.
  • Drains wake notifications without skipping already-reported PTY I/O.
  • Adds deterministic regression coverage for simultaneous wake, read, and write readiness.
  • Documents the background-workspace output fix in the changelog.

Confidence Score: 5/5

The PR appears safe to merge, with the simultaneous-readiness behavior covered by a deterministic regression test.

The actor continues to drain wake notifications while now processing PTY readiness already returned by the same poll; lifecycle commands remain serialized through the next command-drain step, and no concrete contract violation or blocking failure remains.

Important Files Changed

Filename Overview
src/pty/actor/unix.rs Refactors poll readiness handling so wake notifications no longer suppress simultaneous PTY reads or writes, with focused regression coverage.
docs/next/CHANGELOG.md Adds an accurate release note for reliable output from fresh background workspaces.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  P[Poll PTY and wake descriptors] --> W{Wake ready?}
  W -->|Yes| D[Drain wake descriptor]
  W -->|No| R
  D --> R{PTY read ready and actor running?}
  R -->|Yes| Read[Process PTY output]
  R -->|No| X
  Read --> X{PTY write ready and writes pending?}
  X -->|Yes| Write[Flush pending input]
  X -->|No| Loop[Continue actor loop]
  Write --> Loop
Loading

Reviews (1): Last reviewed commit: "Merge branch 'master' into akbash/2449-n..." | Re-trigger Greptile

@ogulcancelik

ogulcancelik commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

thanks akbash. reproduced #2449 on Herdr 0.8.0 with an 11-workspace/27-pane restored session. The reported screen symptoms reproduced, but an external side effect and syscall tracing confirmed that pane run delivered and executed the command and the PTY actor read its output. The output was briefly visible, then cleared by the still-initializing zsh/Pure prompt; pane wait-output missed it while polling terminal snapshots. This PR therefore addresses a different scheduling behavior rather than the cause of #2449, and its new ordering can process PTY EOF before queued lifecycle commands such as handoff. Closing rather than iterating on the wrong layer.

@kangal-bot kangal-bot removed the ai-review Trigger automated AI reviews for pull requests admitted by the PR gate label Aug 9, 2026
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.

3 participants