Files
Nexus/tests/test_webssh_terminal_payload.py
T
Nexus Agent 8312a6cf81 fix(terminal): WebSSH xterm SSH 交互区 ANSI 彩色输出
PTY 环境变量注入 TERM=xterm-256color,DATA 帧 base64 保 ESC;前端解码写入 xterm;命令栏 Shell 高亮 CSS 与黑屏分离。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 12:35:27 +08:00

24 lines
717 B
Python

"""WebSSH terminal DATA payload encoding (ANSI-safe base64)."""
import base64
from server.api.webssh import WEBSSH_PTY_ENV, _terminal_payload_b64
def test_pty_env_has_color_term():
assert WEBSSH_PTY_ENV["TERM"] == "xterm-256color"
assert WEBSSH_PTY_ENV["COLORTERM"] == "truecolor"
assert WEBSSH_PTY_ENV["FORCE_COLOR"] == "1"
def test_terminal_payload_b64_preserves_ansi_escapes():
raw = "\x1b[31mred\x1b[32mgreen\x1b[0m\n"
b64 = _terminal_payload_b64(raw)
decoded = base64.b64decode(b64)
assert decoded == raw.encode("utf-8")
def test_terminal_payload_b64_from_bytes():
raw = b"\x1b[33myellow\x1b[0m"
b64 = _terminal_payload_b64(raw)
assert base64.b64decode(b64) == raw