Skip to content

feat: 真实 PTY resize 控制通道修复终端错位 - #103

Closed
sakuradairong wants to merge 10 commits into
GSManagerXZ:mainfrom
sakuradairong:feat/terminal-real-resize
Closed

feat: 真实 PTY resize 控制通道修复终端错位#103
sakuradairong wants to merge 10 commits into
GSManagerXZ:mainfrom
sakuradairong:feat/terminal-real-resize

Conversation

@sakuradairong

Copy link
Copy Markdown
Contributor

背景

现有终端方案(Xterm.js)在窗口/布局变化后容易发生错位(已确认错位情况 A):旧实现以估算字符宽度 + setTimeout 散落 resize + socket 消息方式同步尺寸,未真实作用于 PTY winsize。

方案

保留 Xterm.js,不更换终端库;改为真实 PTY resize 控制通道:

  • 服务端
    • 固定 PTY release/asset manifest(release 297277624、commit 09fc369d),下载/校验(SHA-256 + size)/本机 probe/原子替换统一入口 ptyAssets.ts + ptyAssetCli.ts,运行时/打包/Docker/安装脚本统一来源
    • RESIZE frame(04 | uint16be(len) | {"width","height"})经 POSIX FIFO / Windows Named Pipe control channel 写入原生 PTY;latest-wins 串行队列、尺寸校验、resize identity 防迟到回执
    • 真实生命周期:create reservation/readiness/fallback、single-flight bounded close(3s TERM + 1s KILL)、close-retained 保留与重试、typed reconnect(ready/pending/closing/not-found)、多 requester 完成 ACK
    • Socket payload 规范化、PTY/stream-forward stdin 永久 error listener、实例配置持久化串行/原子写、graceful shutdown 冻结准入 + drain + final flush
  • 客户端
    • 统一 Xterm factory(createTerminalView),不接收/不推算尺寸
    • 单一 ResizeObserver → proposeDimensionsfit() → 校验实际 cols/rows;单一 50ms trailing reporter;active/ready 门控、无 feedback loop
    • 七状态生命周期(creating/ready/disconnected/reconnecting/closing/exited/disposed)、断线重连、显式 close 重试、ACK-owned 断线 close 队列

提交

  • feat(pty): fixed asset manifest, probe and control-channel transports
  • feat(terminal): real PTY lifecycle, typed socket handlers and graceful shutdown
  • feat(client): unified terminal view, observer/reporter and lifecycle state machine
  • build: architecture-specific Linux packaging, Docker and installer
  • docs: PTY/Docker integration docs and executed plan

验证

  • server/client npx tsc --noEmit 通过;server Jest 5 suites / 40 tests 通过
  • Linux x64 低层原生验证:真实 binary + FIFO + RESIZE frame,stty size/tput cols/tput lines 随 frame 从 120x40 变为 90x25(约 21ms 生效)
  • node --check scripts/package.jsbash -n install-gsm3.sh 通过
  • client 全量 Vitest:chunkUpload 5 个既有失败 + 3 个既有 unhandled rejection 为基线红灯,与本改动无关

已声明限制

  • 浏览器端到端、Linux ARM64、Windows 原生、双架构安装包验收未执行(当前环境限制),不冒充通过
  • 范围外残留(已登记):shutdown quiescence / 全局 mutation 链 head-of-line、Scheduler destroy 后 admission 与 saveTasks 并发、跨进程 PTY asset 并发 ensure(单写者假设)、Steam retained close 生命周期边界
  • 未新增 owner/actor 授权;terminal-resized 仅证明 frame 写入 pipe,不代表上游 PTY 正向 ACK

sakuradairong and others added 10 commits July 29, 2026 21:20
fix: prevent duplicate file deployment races
Register deployments before asynchronous archive validation so cancellation remains effective, and remove claimed upload directories when validation fails.
Add SteamCMD branch discovery and deployment version selection, secure credential handling, instance operation locks, and reconnectable background update progress.

Verified with server/client TypeScript checks and a real anonymous SteamCMD branch query for AppID 896660.
@sakuradairong

Copy link
Copy Markdown
Contributor Author

Superseded by a clean branch rebuilt on the latest upstream main for the terminal resize fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant