fix(web): the page records its window, or every cursor key vanishes

sendViewport called the associated Client.viewport, which builds the
handshake frame without RECORDING the window. A client learns its window
only from what it announced -- row_labels.len() is the window clipped to the
grid, so the two differ exactly at the bottom edge, which is where the scroll
arithmetic matters. Without the record the client cannot clamp, so every
cursor key goes upstream into Host::handle's empty vec and the arrow keys
silently do nothing.

Flagged by the improvise-bpq2 agent as the one line its work depended on and
which it could not make, web/ being another agent's ground.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EoW5BB87ZZdm96SvBTWawH
This commit is contained in:
Edward Langley
2026-09-19 19:36:26 -07:00
parent 12febcf73b
commit 145d76e7da
+10 -2
View File
@@ -6,7 +6,8 @@
// decides whether a cell is editable or whether a typed string is a number.
// Five calls are the whole harness —
//
// Client.viewport(rows, cols) -> the handshake frame, and every resize
// client.set_viewport(rows, cols) -> the handshake frame, and every resize;
// also records the window so keys resolve here
// client.on_frame(json) -> fold one frame, in arrival order
// client.render_model() -> everything to paint, already decided
// client.typed_cell(r, c, s) -> the frame for "the user typed s here"
@@ -85,7 +86,14 @@ function extent() {
function sendViewport() {
const { rows, cols } = extent();
transport.send(Client.viewport(rows, cols));
// `client.set_viewport`, NOT the associated `Client.viewport`: the same
// frame, but it also RECORDS the window. A client learns its window only
// from what it announced -- `row_labels.len()` is the window clipped to the
// grid, so the two differ exactly at the bottom edge, which is where the
// scroll arithmetic matters. Without this the client cannot clamp, so every
// cursor key goes upstream into `Host::handle`'s empty vec and the arrow
// keys silently do nothing (improvise-bpq2).
transport.send(client.set_viewport(rows, cols));
}
// A peer that never answers the handshake. The socket has an `error` event