aboutsummaryrefslogtreecommitdiff
path: root/src/protocol
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-24 21:21:58 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-24 21:30:04 +0300
commit420925d141c8805e610eb0d62d49d8b9b483d961 (patch)
treebbd1f778a038bf4387c704a0df921fa53e7af615 /src/protocol
parent43c6ca3a5dbdcefc6c6dc29be9ce81d990baf39e (diff)
fix: support scrolling direct agent attaches
Diffstat (limited to 'src/protocol')
-rw-r--r--src/protocol/wire.rs49
1 files changed, 48 insertions, 1 deletions
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<u16>,
+ /// Mouse row relative to the attached terminal, when available.
+ row: Option<u16>,
+ /// 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<u8>,
+ },
}
// ---------------------------------------------------------------------------
@@ -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]