Skip to content

fix(pty-proxy): forward terminal pixel size to the child pty#3529

Open
xav-ie wants to merge 1 commit into
atuinsh:mainfrom
xav-ie:fix/pty-proxy-pixel-size
Open

fix(pty-proxy): forward terminal pixel size to the child pty#3529
xav-ie wants to merge 1 commit into
atuinsh:mainfrom
xav-ie:fix/pty-proxy-pixel-size

Conversation

@xav-ie

@xav-ie xav-ie commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What

Forward the controlling terminal's pixel dimensions to the child pty in
atuin pty-proxy.

The pty was created (and resized on SIGWINCH) with pixel_width: 0 /
pixel_height: 0, because crossterm::terminal::size() only reports
columns/rows. With zero pixel dimensions, programs inside the proxy that query
TIOCGWINSZ (e.g. image.nvim) fall back to an assumed ~8×16 cell, so inline
images render far too small on HiDPI terminals.

This switches to terminal::window_size(), which includes ws_xpixel /
ws_ypixel, and forwards those to the child pty both at startup and on every
resize. It falls back to cols/rows (pixels 0) on terminals that don't report
pixel size.

Why

Zero pixel dimensions break inline image rendering for terminal programs that
rely on the kernel-reported cell pixel size.

Testing

  • cargo build / cargo test / cargo clippy for atuin-pty-proxy (all pass).
  • Manually verified inline images (image.nvim) render at the correct size inside
    atuin pty-proxy on a HiDPI terminal.

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

The pty was created (and resized on SIGWINCH) with pixel_width=0 /
pixel_height=0, so TIOCGWINSZ inside the proxy reported no pixel
dimensions. Programs that need the cell size in pixels (e.g. image.nvim)
then fall back to an assumed 8x16 cell — far smaller than a HiDPI
terminal's real cell — and render inline images too small.

Query the controlling terminal with crossterm window_size() (which
includes pixel dimensions) and forward them at pty creation and on every
resize; fall back to cols/rows-only when the terminal reports no pixels.
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR forwards terminal pixel dimensions through the pty proxy. The main changes are:

  • Adds a shared terminal-size helper using crossterm::terminal::window_size().
  • Passes pixel width and height into portable_pty::PtySize at startup.
  • Reuses the same size query on SIGWINCH resize events.

Confidence Score: 3/5

This is close, but the fallback resize behavior should be fixed before merging.

  • Failed terminal-size reads can now resize the child PTY to 80x24.
  • Startup can continue with made-up dimensions where it previously returned an error.
  • The pixel-size forwarding itself is contained to the pty setup and resize path.

crates/atuin-pty-proxy/src/runtime.rs

Important Files Changed

Filename Overview
crates/atuin-pty-proxy/src/runtime.rs Forwards pixel dimensions to the child PTY, but now treats terminal-size query failure as a real 80x24 size.

Reviews (1): Last reviewed commit: "fix(pty-proxy): forward terminal pixel s..." | Re-trigger Greptile

fn query_size() -> (u16, u16, u16, u16) {
match terminal::window_size() {
Ok(ws) => (ws.columns, ws.rows, ws.width, ws.height),
Err(_) => terminal::size().map_or((80, 24, 0, 0), |(c, r)| (c, r, 0, 0)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Avoid bogus fallback size

When both window_size() and size() fail, this now returns 80x24 and callers treat that as a real terminal size. Startup previously failed instead of spawning the child with a made-up size, and the resize handler previously ignored failed size reads instead of resizing the child PTY and vt100 parser to 80x24. A transient size-query failure on SIGWINCH can now corrupt full-screen apps by forcing them into the fallback dimensions. Preserve the error for rows/cols and only apply a resize when the query succeeds.

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.

1 participant