docs: consolidate pyte patches documentation

Rename ink-clear-fix.md → pyte-patches.md and rewrite as a
comprehensive reference for all pyte monkeypatches:
- Patch 1: CSI S/T (SU/SD scroll) — primary ghost content fix
- Patch 2: Alternate screen buffer (DECSET 1049)
- Patch 3: Ink partial clear expansion (secondary defense)

Update README.md Known Issues to reflect the actual fix approach.
Update ARCHITECTURE.md to document alt_screen.py and pyte patching.
This commit is contained in:
GitHub Copilot
2026-02-06 21:24:52 +00:00
parent d538cae2fa
commit 10ffb9d8cc
4 changed files with 98 additions and 132 deletions
+2 -3
View File
@@ -34,8 +34,7 @@ Coupled with [`agentbox`](https://github.com/rcarmo/agentbox), you can use it to
## Known Issues
- `pyte` (the library used to capture the underlying terminal state for screenshots) is buggier than a bait store and some partial screen clearing ANSI sequences don't work, resulting in occasionally mis-rendered screenshots. And yet, it is better than most other alternatives, so I'm waiting for `libghostty-vt` to be finished to port this whole thing to Go (or even plain C) and have full fidelity.
- CLI frameworks like [Ink](https://github.com/vadimdemedes/ink) (used by GitHub Copilot CLI) clear their output using line-by-line erase sequences (`EL2+CUU1`) rather than full-screen erase (`ED2`). When `/clear` resets the framework's line counter, partial clears can leave ghost content in pyte's screen buffer. This is mitigated by `AltScreen.expand_clear_sequences()` — see [docs/ink-clear-fix.md](docs/ink-clear-fix.md) for details.
- `pyte` (the library used to capture the underlying terminal state for screenshots) does not implement some standard escape sequences, resulting in occasionally mis-rendered screenshots. We monkeypatch pyte at runtime to add missing support (CSI S/T scroll, alternate screen buffers, etc.) — see [docs/pyte-patches.md](docs/pyte-patches.md) for details. I'm waiting for `libghostty-vt` to be finished to port this whole thing to Go (or even plain C) and have full fidelity.
## Installation
@@ -268,7 +267,7 @@ make bundle-watch
- WebSocket protocol (browser ↔ server) is JSON: `["stdin", data]`, `["resize", {"width": w, "height": h}]`, `["ping", data]`.
- Frontend source is in `src/webterm/static/js/terminal.ts`.
- Screenshots use [pyte](https://github.com/selectel/pyte) for ANSI interpretation and custom SVG rendering. `AltScreen` adds alternate screen buffer support and [Ink partial clear expansion](docs/ink-clear-fix.md).
- Screenshots use [pyte](https://github.com/selectel/pyte) for ANSI interpretation and custom SVG rendering. `AltScreen` adds alternate screen buffer support, [CSI S/T scroll handling, and Ink partial clear expansion](docs/pyte-patches.md).
- CPU stats are read directly from Docker socket using asyncio (no additional dependencies).
## Requirements