Skip to content

fix(pty-proxy): scope proxy screen restore to its own terminal via ex… - #3679

Open
davidolrik wants to merge 1 commit into
atuinsh:mainfrom
davidolrik:3566-fix-nested-repaint
Open

fix(pty-proxy): scope proxy screen restore to its own terminal via ex…#3679
davidolrik wants to merge 1 commit into
atuinsh:mainfrom
davidolrik:3566-fix-nested-repaint

Conversation

@davidolrik

Copy link
Copy Markdown
Contributor

Summary

Fixes the redraw corruption reported in #3566: activating the atuin search popup inside a terminal multiplexer pane (e.g. herdr) paints content from outside the pane — sidebars, other panes — into it on exit.

Root cause

atuin pty-proxy mirrors the shell's output into a vt100 screen model and serves snapshots over a unix socket, exporting ATUIN_PTY_PROXY_SOCKET and ATUIN_PTY_PROXY_ACTIVE=1 into the shell's environment. Environment variables are inherited by every descendant, so a multiplexer launched from a proxied shell passes both into every pane it creates.

The init guard only started a fresh proxy when ATUIN_PTY_PROXY_ACTIVE was
unset or $TMUX changed, so panes of any non-tmux multiplexer kept pointing at
the outer proxy. atuin search popup mode then fetched the outer proxy's
full-terminal screen — including the multiplexer's chrome — and
restore_popup_area blitted those full-width rows into the pane on exit.

Fix

We now export ATUIN_PTY_PROXY_TTY, and whenever the shells tty differes from it we spawn a new proxy.
This means that any multiplexer that uses a new tty for each pane will get a new pty-proxy for each pane.

As I am not a rust expert, I had a bit of help from Claude.

Closes #3566

Checks

  • I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle
  • I have checked that there are no existing pull requests for the same thing

@greptile-apps

greptile-apps Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR scopes pty-proxy screen restoration to the terminal that owns the snapshot. The main changes are:

  • Exports the proxy PTY device to child shells.
  • Starts a new proxy when shell and proxy TTY devices differ.
  • Checks TTY identity and terminal dimensions before restoring a popup.
  • Reconciles terminal size when the resize handler starts.
  • Adds tests for proxy environment and TTY guard behavior.

Confidence Score: 4/5

Unknown proxy TTY ownership can still allow a foreign screen snapshot to be restored.

  • Known, differing TTY devices are rejected correctly.
  • Legacy sockets and PTY backends without a device name use dimensions alone.
  • Same-sized multiplexer surfaces can therefore reproduce the redraw corruption.

crates/atuin/src/command/client/search/interactive.rs

Important Files Changed

Filename Overview
Cargo.toml Enables the rustix termios feature used for terminal-name lookup.
crates/atuin-pty-proxy/src/pty_proxy.rs Adds TTY-aware proxy startup guards for Bash, Zsh, Fish, and Nushell.
crates/atuin-pty-proxy/src/runtime.rs Exports the proxy slave TTY and applies the current terminal size when resize handling starts.
crates/atuin/src/command/client/search/interactive.rs Validates popup snapshots by TTY and size, but falls back to size alone when TTY ownership is unknown.

Reviews (1): Last reviewed commit: "fix(pty-proxy): scope proxy screen resto..." | Re-trigger Greptile

Comment thread crates/atuin/src/command/client/search/interactive.rs
@davidolrik
davidolrik force-pushed the 3566-fix-nested-repaint branch 2 times, most recently from 16795f7 to 0d31eef Compare July 27, 2026 23:48
@davidolrik
davidolrik force-pushed the 3566-fix-nested-repaint branch from 0d31eef to 8b9f4e4 Compare July 28, 2026 08:46
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.

[Bug]: Redraw issue

1 participant