Skip to content

fix: honor droid scrollback clear requests in panes - #4432

Merged
JJLiebig merged 2 commits into
herdrdev:masterfrom
factory-ain3sh:fix/droid-scrollback-clear
Sep 21, 2026
Merged

JJLiebig merged 2 commits into
herdrdev:masterfrom
factory-ain3sh:fix/droid-scrollback-clear

Conversation

@factory-ain3sh

Copy link
Copy Markdown
Contributor

Description

What: Honor Droid's scrollback-clear requests so replaying a primary-screen transcript does not retain duplicate welcome headers and stale rows. The process-aware regression fails on current master with two headers and passes with this change.

Why: Herdr's Droid-specific filter strips ESC[3J and ESC[?3J before they reach the terminal parser. Clearing the visible screen still works, but the old scrollback survives beneath the replayed content. Filtering also depends on where PTY chunks split the escape sequence.

How: Remove the filter and pass the original PTY bytes to the existing parser and trackers. The vendored parser already implements the screen/history boundaries; no new rendering logic is needed.

Related Issue

No linked GitHub issue.

Reviewer Guide

  1. src/pane/osc.rs: removes the process-specific filter and tests that enforced suppression.
  2. src/pane/terminal.rs: passes unmodified bytes through the existing write path, eliminating the extra foreground-process lookup for ED3.
  3. src/pane/terminal/migration_tests.rs: extends the existing harness with a real foreground process identifying as droid; checks replay across whole writes, bytewise writes, seven-byte chunks, and every split within the erase prefix.

Risk & Impact

Droid can now clear primary-screen history when it explicitly requests ED3, rather than retaining that history. ED2 still preserves scrollback, ED3 preserves the visible screen, and alternate-screen clearing leaves the saved primary screen intact. Manual clear-pane handling is unchanged. No dependencies, persistence, or protocol changes.

Verification

Behavior verified @ 0fe2b62b: two 55-line frames replayed into a 24-row terminal leave one welcome header and no old-frame rows, both at the bottom and when scrolled up.

  • Sentinel test: primary_screen_replay_honors_ed3_for_droid_at_chunk_boundaries, observed failing on original production code and passing after the fix.
  • erase_display_preserves_screen_and_history_boundaries passes for both clear sequences.
  • Standard validators: just ci 'test(pane::terminal::)' passed: formatting, Clippy on all targets, 148 pane-terminal tests, 144 maintenance tests, six architecture tests, and 44 Bun tests. Commit hooks also passed.
  • Not tested here: macOS, Windows, the full Rust suite, or a fresh interactive Droid UI run. Native Linux regression coverage includes real PTY foreground-process detection.

Remove the droid-specific filter that discarded ED3 before PTY output
reached the terminal parser. Keeping stale scrollback beneath replayed
primary-screen frames duplicated the welcome header and old transcript.

Pass the original bytes to the parser and trackers. Add process-aware
regression coverage across PTY chunk boundaries and preserve ED2/ED3
screen-history separation and alternate-screen isolation.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ai-review

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: Advanced

Run ID: 68e0e390-7625-4837-92e3-d346bc02552f

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 3fe444ec-54ad-4843-9521-42fad5d0f140

📥 Commits

Reviewing files that changed from the base of the PR and between 5a64914 and 0fe2b62.

📒 Files selected for processing (3)
  • src/pane/osc.rs
  • src/pane/terminal.rs
  • src/pane/terminal/migration_tests.rs
💤 Files with no reviewable changes (1)
  • src/pane/osc.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change removes Droid-specific scrollback-clear filtering from OSC handling and PTY processing. Scrollback-clear sequences now pass through unchanged, and terminal trackers inspect the original PTY bytes. Migration tests can provide a foreground process ID and cover ED3 behavior across complete, bytewise, and split writes, including primary-screen, alternate-screen, ED2, and ED3 cases.

Suggested reviewers: ogulcancelik

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: allowing Droid scrollback-clear requests in panes.
Description check ✅ Passed The description directly explains the Droid scrollback-clear issue, the implementation, regression coverage, validation, and known test limitations.
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.

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.

❤️ Share

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

@kangal-bot

Copy link
Copy Markdown
Collaborator

@coderabbitai review
@greptileai

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

@kangal-bot: I will review pull request #4432.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@greptile-apps

greptile-apps Bot commented Sep 21, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the raw-byte path restores standard ED3 handling and is covered across relevant screen and chunk-boundary cases.

Summary

This PR removes the Droid-specific ED3 suppression so original PTY bytes consistently reach the terminal parser and associated trackers.

  • Removes process-name detection and scrollback-clear filtering from the OSC helpers.
  • Eliminates the foreground-process lookup from the terminal write path.
  • Adds regression coverage for both ED3 forms across whole, bytewise, fixed-size, and split writes.
  • Verifies primary-screen history clearing, visible-screen preservation, and alternate-screen isolation.
Diagram
sequenceDiagram
  participant P as PTY process
  participant T as Pane terminal
  participant O as Sequence trackers
  participant G as Ghostty parser
  participant S as Screen and history
  P->>T: Original PTY bytes, including ED3
  T->>O: Observe unmodified bytes
  T->>G: Write unmodified bytes
  G->>S: Apply ED3 screen/history boundaries
  S-->>T: Preserve display and clear applicable scrollback
Loading

Reviews (1) · Last reviewed commit: "fix: honor droid scrollback clear reques..."

@JJLiebig
JJLiebig self-requested a review September 21, 2026 12:28

@JJLiebig JJLiebig left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved, tested the current master binary against this PR head with a fresh Droid session. Droid’s /clear leaves one welcome header, removes stale transcript and shell rows, and resets scrollback to zero. The model and Herdr lifecycle hook continued working normally.

Only note: I tested this with a the cli-proxy-api since I don't have a factory sub. But I see no reason why this should change the outcome.

@JJLiebig
JJLiebig merged commit 309749a into herdrdev:master Sep 21, 2026
6 checks passed
@factory-ain3sh

Copy link
Copy Markdown
Contributor Author

Approved, tested the current master binary against this PR head with a fresh Droid session. Droid’s /clear leaves one welcome header, removes stale transcript and shell rows, and resets scrollback to zero. The model and Herdr lifecycle hook continued working normally.

Only note: I tested this with a the cli-proxy-api since I don't have a factory sub. But I see no reason why this should change the outcome.

Ty! Yup, no difference in TUI whether you use direct or byok

kaushikgopal added a commit to kaushikgopal/herdr that referenced this pull request Sep 21, 2026
Merged upstream/master b88e811..2836010. Zero conflicts: all six
overlapping files split into disjoint regions (mouse.rs navigator
scrollbar/row-click work, state.rs navigator fields and close-tab
confirmation, config/model.rs clear_pane keybinding, config-reference.json
keys.clear_pane, AGENTS.md detection policy, tests/mod.rs mod close_tab).
No src/protocol/wire.rs change, so no protocol conflict.

Notable upstream fixes absorbed:
- distinguish agent completion from startup and session changes (herdrdev#4457)
- honor droid scrollback clear requests in panes (herdrdev#4432)
- refresh forwarded ssh agents after reconnect (herdrdev#4443)
- index navigator tabs and panes per endpoint (herdrdev#4426)
- preserve session layouts across shutdown and restore failures (herdrdev#4400)
- confirm closing the last tab in the tui (herdrdev#4409)
- reject terminal-less attach before starting a session (herdrdev#4395)
- drain event subscriptions and report history loss (herdrdev#4225)
- preserve explicit worktree workspace membership (herdrdev#4301)
- keep workspace navigation visible in terminal theme (herdrdev#4408)
- preserve delayed mouse reports with confirmed keyboard input (herdrdev#4247)
- detect codex status with custom interrupt keys (herdrdev#4196)
- detect kiro status from live controls and osc signals (herdrdev#4372)
- recover the cursor during animated redraws (herdrdev#4404)
- stabilize windows cursor redraws and settle deadlines (herdrdev#4389)
- show every agent and terminal in the go to picker (herdrdev#4384)
- add configurable pane screen and scrollback clearing (herdrdev#4383)
- reveal selected agent when cycling the sidebar (herdrdev#4355)
- preserve request ids in socket error responses (herdrdev#4353)
- enable ssh compression for remote connections (herdrdev#4340)
- correct grok activity detection with custom or disabled osc signals (herdrdev#4337)
- preserve windows mouse capture during refresh (herdrdev#4319)
abhijit-s pushed a commit to abhijit-s/herdr that referenced this pull request Sep 22, 2026
Merges 6 upstream commits: ssh-agent identity clearing on session
reconnect (herdrdev#4461, herdrdev#4443), agent-completion vs startup/session-change
detection (herdrdev#4457), droid scrollback clear requests (herdrdev#4432), navigator
tab/pane indexing per endpoint (herdrdev#4426), and a contributor approval.

refs upstream herdrdev/herdr@8ac95427
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.

4 participants