From 420925d141c8805e610eb0d62d49d8b9b483d961 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Sun, 24 May 2026 21:21:58 +0300 Subject: fix: support scrolling direct agent attaches --- src/protocol/wire.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'src/protocol') diff --git a/src/protocol/wire.rs b/src/protocol/wire.rs index ea81b36e..bd79c900 100644 --- a/src/protocol/wire.rs +++ b/src/protocol/wire.rs @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; // --------------------------------------------------------------------------- /// Current protocol version. Bumped when wire format changes incompatibly. -pub const PROTOCOL_VERSION: u32 = 10; +pub const PROTOCOL_VERSION: u32 = 11; /// Maximum allowed frame payload size (2 MB). Frames larger than this are /// rejected to prevent denial-of-service via oversized length prefixes. @@ -109,6 +109,37 @@ pub enum ClientMessage { /// Replace an existing writable attach owner for this terminal. takeover: bool, }, + + /// Scroll input handled by a direct terminal attach client. + AttachScroll { + /// Original input source for routing. + source: AttachScrollSource, + /// Scroll direction. + direction: AttachScrollDirection, + /// Number of terminal rows to move when using host scrollback. + lines: u16, + /// Mouse column relative to the attached terminal, when available. + column: Option, + /// Mouse row relative to the attached terminal, when available. + row: Option, + /// Crossterm-compatible modifier bits for forwarded mouse wheel events. + modifiers: u8, + }, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub enum AttachScrollDirection { + Up, + Down, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub enum AttachScrollSource { + Wheel, + PageKey { + /// Original key bytes to forward when the child application owns page keys. + input: Vec, + }, } // --------------------------------------------------------------------------- @@ -702,6 +733,22 @@ mod tests { assert_eq!(msg, decoded); } + #[test] + fn client_attach_scroll_roundtrip() { + let msg = ClientMessage::AttachScroll { + source: AttachScrollSource::Wheel, + direction: AttachScrollDirection::Up, + lines: 3, + column: Some(12), + row: Some(7), + modifiers: 4, + }; + let encoded = bincode::serde::encode_to_vec(&msg, bincode::config::standard()).unwrap(); + let (decoded, _): (ClientMessage, _) = + bincode::serde::decode_from_slice(&encoded, bincode::config::standard()).unwrap(); + assert_eq!(msg, decoded); + } + // ---- Round-trip: ServerMessage ---- #[test] -- cgit v1.2.3