ovis icon indicating copy to clipboard operation
ovis copied to clipboard

Windows: fit and scroll terminal panes through herdr's terminal session stream

Open Noobear opened this issue 1 month ago • 3 comments

Problem

Thank you for herdr web ui. It has become my daily way into herdr from my phone and other PCs. I would like to ask about one area before proposing any code.

On a Windows server PC, a terminal pane is a mirror of a fixed grid. herdr 0.9.3 cannot terminal-attach there, so the browser draws whatever size the console already has. In practice:

  • The console never follows the browser. A pane opened on a phone or in a narrow split shows a grid cut off at the edge, or a lot of empty space.
  • Scrolling back is not the same as on an attached pane. Wheel, trackpad and touch on a mirrored pane do not move through herdr's scrollback the way they do on Linux and macOS.

Proposal

herdr already exposes a terminal session stream for Windows (terminal session control and observe). The Web UI could use it for Windows panes instead of the fixed mirror:

  • Fit: the interact connection that drives the pane resizes the console to the browser's grid. Observers never resize it, and take-over stays explicit, as the review rules require.
  • Scroll: wheel, trackpad, touch and plain PageUp/PageDown become explicit terminal.scroll commands instead of input. Fine trackpad deltas are gathered into two-row steps, and a finger drag sends one request per ~2 rows of travel so it moves about as far as the finger.
  • Keep the mirror as the fallback, for a herdr whose version or protocol is not known to support the stream.

I have run this as a local patch on every 0.4.x release (0.4.0 to 0.4.8) on a Windows 11 PC with herdr 0.9.3 (protocol 22), pinned to that version. It covers isolated-core browser tests for fit, observe and take-over, plus touch and trackpad scroll. It also works alongside 0.4.7's 80-column narrow split font: a narrow split gets 11px and an 86-column console. The diff is about 460 lines across server/pty/terminal-control.ts, server/index.ts, shared/protocol.ts, PaneTerminal.tsx and ws.ts.

Before preparing a PR, I wanted to ask whether this is a direction you would welcome. In particular:

  1. Is the terminal session stream the right path for Windows, or is a terminal-attach for Windows planned in herdr?
  2. How should the version pin work: herdr version, protocol number, or a capability probe?
  3. One PR for fit and scroll, or fit first and scroll second?

Where

Terminal

Workarounds and alternatives

Today: zoom the browser or resize the window until the mirrored grid fits, and scroll with the herdr key bindings in the terminal.

I completely understand if this does not fit your plans for Windows. In that case I am happy to keep it as a local patch. Thank you for considering it.

Noobear avatar Oct 12 '26 06:10 Noobear

Native Windows reproduction and bounded fixes: #1534.

Tested a fresh temporary clone on the designated Windows 11 QA PC, PowerShell 5.1, herdr 0.9.3/protocol 22, Bun 1.4.2 and installed Chrome, using only an isolated test session and temporary app state.

  • Released v0.4.12 reproduces the no-wheel-history symptom. Main includes #1446 and real PowerShell wheel/touch history scrolling works there; that commit is not in a released tag yet.
  • Sizing remains exactly as reported here: an attach asking for 40x15 receives fixed 120x40, and browser resize does not resize the console.
  • Three additional viewport bugs were reproduced on main and fixed in #1534: text insertion moved horizontal offset 0→288; incoming output undid a local wheel pan; an unmoved touch posted a stale shared history offset. Native regression now passes, including IME and font changes.

This does not resolve browser-driven Windows fitting or application-owned alternate-screen scrolling. The native terminal-session control stream is a separate ownership change: terminal.resize is a stream command, not an ordinary resize RPC, and control claims the exclusive attachment slot while observe must not resize. The PR deliberately preserves those ownership/takeover protections and leaves this issue open. The native temporary checkout has been removed.

devswha avatar Oct 21 '26 11:10 devswha

Would you be open to a fit-only native Windows PR for this issue, separate from scrolling?

I read the October 21 explanation that #1534 intentionally leaves fitting out because terminal.resize belongs to the exclusive terminal-session control stream. I would preserve that boundary, rather than resize through an ordinary RPC or merely scale the browser mirror.

Proposed constraints, for your approval before implementation:

  • Enable the path only with positively confirmed support from the CLI/daemon; otherwise retain today's mirror behavior.
  • Acquire control only through the existing explicit interact/claim flow. Observers and keep_size attachments never resize; an occupied slot requires explicit takeover by the requesting attachment.
  • Preserve existing ownership/liveness rules, without adding automatic takeover or stealing control from an idle or disconnected owner.
  • Drop queued input and resizes for a retired controller on demotion, detach, disconnect, or pane replacement. Reconnect must not replay input or takeover.
  • Reuse existing geometry messages where possible. If confirmed geometry needs an HTTP/WS contract change, bring that detail back for approval before implementation.

Validation would separate automated ownership/fallback regressions from native Windows QA proving that an isolated console actually changes from 120x40 to 40x15 and back. Browser regressions would cover the shared terminal view; CSS-only fitting would not count as a fix.

Does that scope match the intended solution? I have not written the implementation.

YuuuXie avatar Nov 18 '26 10:11 YuuuXie

Closing this as done on main.

  • Fit: a native Windows pane now follows the size of the browser that controls it (#4138, shipped in 0.5.12).
  • Scroll: wheel, trackpad and touch move through a mirrored pane's history (#1446, #1534).

Remaining: scrolling inside a full-screen (alt-screen) app on a native Windows pane.

If you still need that remaining part, please open a new issue for it — thank you!

devswha avatar Nov 27 '26 18:11 devswha