zlh-grind/Frontend/TerminalView_Component.md

47 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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: 15 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=<cmd>` to server stdin
---
## Constraints
- Portal never calls the agent directly — all traffic through API
- Console does not enforce real policy — agent enforces