fix(tui): handle Windows PTY stdin and detached WS frames

This commit is contained in:
qWaitCrypto
2026-06-08 16:48:04 +08:00
parent 4d18717b6c
commit 65b2f95a6c
5 changed files with 91 additions and 19 deletions
+6 -2
View File
@@ -1207,10 +1207,14 @@ class ProcessRegistry:
if session.exited:
return {"status": "already_exited", "error": "Process has already finished"}
# PTY mode -- write through pty handle (expects bytes)
# PTY mode -- write through pty handle.
if hasattr(session, '_pty') and session._pty:
try:
pty_data = data.encode("utf-8") if isinstance(data, str) else data
# pywinpty expects str on Windows; ptyprocess expects bytes on POSIX.
if _IS_WINDOWS:
pty_data = data.decode("utf-8") if isinstance(data, bytes) else str(data)
else:
pty_data = data.encode("utf-8") if isinstance(data, str) else data
session._pty.write(pty_data)
return {"status": "ok", "bytes_written": len(data)}
except Exception as e: