fix(pty-proxy): forward terminal pixel size to the child pty#3529
fix(pty-proxy): forward terminal pixel size to the child pty#3529xav-ie wants to merge 1 commit into
Conversation
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 SummaryThis PR forwards terminal pixel dimensions through the pty proxy. The main changes are:
Confidence Score: 3/5This is close, but the fallback resize behavior should be fixed before merging.
crates/atuin-pty-proxy/src/runtime.rs Important Files Changed
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)), |
There was a problem hiding this comment.
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.
What
Forward the controlling terminal's pixel dimensions to the child pty in
atuin pty-proxy.The pty was created (and resized on
SIGWINCH) withpixel_width: 0/pixel_height: 0, becausecrossterm::terminal::size()only reportscolumns/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 inlineimages render far too small on HiDPI terminals.
This switches to
terminal::window_size(), which includesws_xpixel/ws_ypixel, and forwards those to the child pty both at startup and on everyresize. It falls back to cols/rows (pixels
0) on terminals that don't reportpixel 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 clippyforatuin-pty-proxy(all pass).atuin pty-proxyon a HiDPI terminal.Checks