diff --git a/Frontend/TerminalView_Component.md b/Frontend/TerminalView_Component.md new file mode 100644 index 0000000..c6ad515 --- /dev/null +++ b/Frontend/TerminalView_Component.md @@ -0,0 +1,46 @@ +# TerminalView Component + +> Status: ✅ Operational + +--- + +## Overview + +The terminal console is implemented using: + +- **xterm.js** — frontend terminal renderer +- **WebSocket transport** — connects portal to agent +- **PTY session** — managed by the agent via `creack/pty` + +`TerminalView` owns the WebSocket lifecycle. `ServerConsole` owns policy and session gating. + +The file panel does not interrupt the console lifecycle. + +--- + +## Reconnect Behavior + +The terminal automatically reconnects when the WebSocket closes unexpectedly. + +Behavior: + +- Reconnect delay: 1–5 seconds +- Backoff capped at 5 seconds +- Console session recreated automatically + +The user no longer needs to refresh the page to regain console access after navigating away from the console tab or after a transient disconnect. + +--- + +## Agent Side + +- One PTY read loop per `{vmid, container_type}` +- PTY-backed WebSocket served at `/console/ws` +- Commands sent via `GET /console/command?cmd=` to server stdin + +--- + +## Constraints + +- Portal never calls the agent directly — all traffic through API +- Console does not enforce real policy — agent enforces