orca icon indicating copy to clipboard operation
orca copied to clipboard

[Bug]: SSH host terminal size does not match the pane (appears locked to host pane dimensions) on macOS

Open minho-pinta-sh opened this issue 5 months ago • 2 comments

Operating system

macOS

Orca version

v1.4.119

Details

Short summary: When connected to an SSH host, the terminal's size does not match the pane it's rendered in. It looks like the PTY is locked to the host's pane dimensions rather than resizing to the local (client) pane, so content is clipped / wrapped wrong / leaves dead space.

What happened? On macOS, opening a terminal on an SSH remote host renders at a size that doesn't fit the actual pane. My best guess is the PTY's columns/rows are pinned to whatever size the host side thinks the pane is, instead of following the size of the pane on my machine. Resizing the pane/window doesn't reliably make the PTY adopt the local pane size.

Expected: the SSH-host terminal should take on the size of the local pane it's shown in — the same way the mobile client makes the shared PTY adopt its viewport (the "Restore desktop size" behavior in #1900 / #4221 shows the PTY already follows a client's dimensions in that flow). The desktop pane should "claim" the PTY size for SSH hosts too.

How can we reproduce it?

  1. Connect to an SSH host on macOS.
  2. Open a terminal on that host.
  3. Observe the terminal content doesn't match the pane size (clipped edges / wrong wrapping / empty margin), as if fixed to the host pane's dimensions.
  4. Resizing the pane/window doesn't correct it to the local pane size.

Anything else that might help:

  • Desired behavior mirrors the mobile "take over pane size" flow — the active client's pane dimensions should drive the PTY resize for SSH hosts.
  • Related: #1900 and #4221 ("Restore desktop size" — desktop terminal stuck at phone dimensions after the mobile app takes over), which involve the same shared-PTY-follows-a-client-viewport mechanism.

minho-pinta-sh avatar Jul 03 '26 07:07 minho-pinta-sh

Status: REPRODUCED — root cause pinned by an executed unit test against the real relay PtyHandler.

Root cause: The relay's pty.attach handler (src/relay/pty-handler.ts, attach() ~L940) receives the attaching client's pane cols/rows — the desktop SSH provider sends them explicitly on reattach (src/main/providers/ssh-pty-provider.ts spawn({ sessionId }) → pty.attach({ id, cols, rows }), ~L116) — but never calls managed.pty.resize(cols, rows). So on every reattach path (app restart, SSH reconnect, tab reveal) the remote PTY stays pinned to its previous/spawn ("host") dimensions instead of adopting the local pane size, producing the clipped/wrong-wrap/dead-margin symptom. Compare resize() in the same file (~L1024), which does resize the PTY; attach has no equivalent. The renderer's drift-correction (pty-size-reassertion.ts) can't rescue it because pty:getSize falls back to the requested-size cache for SSH PTYs (the SSH provider has no getAppliedSize), so the divergence is never detected/re-forwarded.

Fix direction: In attach(), after the liveness check, clamp and apply params.cols/params.rows (managed.pty.resize(cols, rows)) using the same bounds as resize(), and also pass cols/rows from attachForReconnect so the reconnect path is covered — making attach "claim" the local viewport like the mobile/remote-desktop takeover flow.

Re-run:

pnpm exec vitest run --config config/vitest.config.ts src/relay/repro-7209-ssh-attach-ignores-client-size.test.ts

Key files: src/relay/pty-handler.ts, src/main/providers/ssh-pty-provider.ts, src/main/ipc/pty.ts, docs/bug-reproductions/7209.md.


Automated bug-reproduction pass. Artifact on branch nwparker/bug-repro-pass2; writeup docs/bug-reproductions/7209.md.

nwparker avatar Jul 18 '26 08:07 nwparker

Thanks @minho-pinta-sh for the report, and for the clear repro. The root cause was in the old SSH relay's reattach path, which has now been removed (#27214, #27215). SSH terminals run on the host's managed Orca server, and the desktop pane claims the terminal size whenever it subscribes or resizes. Closing — please reopen if the size still doesn't follow the pane on 1.4.224 or later.

OrcaWin avatar Oct 11 '26 06:10 OrcaWin