Chunk terminal output below MTU

This commit is contained in:
DuProcess
2026-06-19 16:30:51 -04:00
parent 41cdb0f54f
commit 774da7371e
2 changed files with 69 additions and 5 deletions
+51
View File
@@ -1382,6 +1382,57 @@ fn tui_control_sequences_survive_transport_verbatim() {
}
}
#[test]
fn large_tui_paint_is_delivered_in_mtu_safe_frames() {
let dir = tempfile::tempdir().unwrap();
let port = free_udp_port();
let config = write_server_config(&dir, port);
let mut server = start_server(&dir, &config);
let (socket, bootstrap, ok) = direct_attach(&config, port, "read-write");
let input = Input {
bytes: b"printf '\\033[?1049h'; yes DOSH_TUI_BIG_PAINT | head -n 300 | tr -d '\\n'; printf '\\033[?1049l'\n".to_vec(),
};
send_encrypted(
&socket,
port,
PacketKind::Input,
ok.client_id,
2,
0,
&bootstrap.session_key,
&protocol::to_body(&input).unwrap(),
);
let mut text = String::new();
let mut saw_split_frame = false;
let deadline = std::time::Instant::now() + Duration::from_secs(3);
while std::time::Instant::now() < deadline && text.matches("DOSH_TUI_BIG_PAINT").count() < 200
{
if let Some((_header, frame)) = recv_frame(&socket, &bootstrap.session_key) {
if frame.bytes.len() <= 1400 && frame.bytes.len() >= 900 {
saw_split_frame = true;
}
text.push_str(&String::from_utf8_lossy(&frame.bytes));
}
}
let _ = server.kill();
let _ = server.wait();
assert!(
text.contains("\x1b[?1049h") && text.matches("DOSH_TUI_BIG_PAINT").count() >= 200,
"large alternate-screen paint did not survive transport, enter_alt={} markers={} bytes={}",
text.contains("\x1b[?1049h"),
text.matches("DOSH_TUI_BIG_PAINT").count(),
text.len()
);
assert!(
saw_split_frame,
"expected large TUI paint to be split into MTU-safe frames"
);
}
#[test]
fn resume_snapshot_preserves_alternate_screen_mode() {
let dir = tempfile::tempdir().unwrap();