Files
webterm/REFACTORING.md
T
Rui Carmo a0e31d43fd merge
2026-01-21 23:53:57 +00:00

1.3 KiB

Refactoring & Audit Checklist

Tooling

  • Makefile restored (install, lint, format, test, coverage, check)
  • Coverage gate at fail_under=80 (current ~88%)

Dead Code Removal

  • Removed packets/environment protocol code
  • Removed unused Account model
  • Removed retry.py and related tests

LocalServer / Protocol

  • JSON WS protocol enforced (stdin/resize/ping/pong)
  • Static assets delegated to textual-serve
  • /screenshot.svg renders replay buffer to SVG
  • Disconnect triggers resize to 132x45
  • Narrow WebSocket error handling (avoid bare Exception)
  • Consider TaskGroup/cleanup context for aiohttp runner

Sessions

  • Session.is_running() added
  • AppSession double JSON parse fixed; payload capped (16MB)
  • TerminalSession replay buffer; resize on disconnect
  • TerminalSession set_terminal_size is blocking; consider run_in_executor

Poller

  • OSError-only read handling; write error handling added
  • TwoWayDict enforces 1:1 mapping (raises on duplicate value)

CLI / Config

  • File-path detection helper deduped
  • Config uses tomllib (py311+)

Tests

  • 135 tests passing; coverage ~88%

Remaining Ideas (Low Priority)

  • Consolidate WS dispatch table
  • Simplify _get_ws_url_from_request
  • Normalize logging style (f-string vs %%)