tui: bound chat history render cost (cache + visible-item cap)
The chat panel rebuilt every renderable on each WS event, including
per-token stream_delta — so markdown was re-parsed for the entire history
on every token and the TUI lagged as conversations grew.

- Cache renderables keyed by id(item)+signature so only the changed item
  (the streaming assistant bubble) is rebuilt per token; the rest are
  reused. Prune orphaned entries so cache stays bounded by live items.
- Add max_visible_items TUI setting (default 200): render only the last
  N items with a "… N earlier messages not shown" hint when truncated.
  Items stay in the in-memory model (non-destructive) but are not laid
  out, so per-refresh cost is constant regardless of history length.
- Rename the cache attr to _chat_render_cache to avoid collision with
  Textual Widget._render_cache, which it resets on mount.

Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 721f44a commit c35169b58a93bc2852800246d5fd76e61a6dece2
@Eugene Sukhodolskiy Eugene Sukhodolskiy authored 1 day ago
Showing 4 changed files
View
clients/terminal/tui/settings.py
View
clients/terminal/tui/widgets/chat_panel.py
View
tests/clients/test_chat_panel.py 0 → 100644
View
tests/clients/test_tui_settings.py