fix: 终端 PTY 尺寸同步

前端在 xterm fit/resize 后通过 WebSocket 发送 resize 控制消息,后端收到后调用 ChannelShell.setPtySize 触发远端重绘,修复 less/vim/top 等全屏程序只显示部分区域的问题。

同时补齐控制消息解析与 PTY resize 的单测,并修正失配的 SftpControllerTest 断言。
This commit is contained in:
liumangmang
2026-03-24 12:03:03 +08:00
parent aced2871b2
commit acac45b692
8 changed files with 317 additions and 44 deletions

View File

@@ -85,14 +85,27 @@ public class SshService {
return outputStream;
}
public OutputStream getInputStream() {
return inputStream;
}
public OutputStream getInputStream() {
return inputStream;
}
public void resize(int cols, int rows) {
if (cols <= 0 || rows <= 0) {
return;
}
if (channel == null) {
return;
}
try {
channel.setPtySize(cols, rows, 0, 0);
} catch (Exception ignored) {
}
}
public void disconnect() {
if (channel != null && channel.isConnected()) {
channel.disconnect();
}
public void disconnect() {
if (channel != null && channel.isConnected()) {
channel.disconnect();
}
if (session != null && session.isConnected()) {
session.disconnect();
}