From 9ab821651e49eb76fad09580160d23405a77c288 Mon Sep 17 00:00:00 2001 From: Kailigithub Date: Sat, 23 May 2026 03:47:33 +0000 Subject: [PATCH] fix(tui): throttle sidebar refresh to reduce ANSI artifacts during streaming During streaming, every token chunk triggered a full sidebar refresh via _refresh_sidebar(). The rapid re-renders caused transient ANSI escape sequence fragments to appear in the gap between the main content and sidebar. Throttle sidebar refresh to at most once per second. The sidebar content (session list, status) rarely changes during streaming, so this has no visible impact on content freshness while eliminating the rendering artifacts. Closes #423 --- frontends/tuiapp_v2.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontends/tuiapp_v2.py b/frontends/tuiapp_v2.py index 2c7244d40..217aa6085 100644 --- a/frontends/tuiapp_v2.py +++ b/frontends/tuiapp_v2.py @@ -3974,6 +3974,11 @@ def _refresh_bottombar(self): def _refresh_sidebar(self): if not self.is_mounted: return + now = time.monotonic() + if hasattr(self, '_last_sidebar_refresh'): + if now - self._last_sidebar_refresh < 1.0: + return + self._last_sidebar_refresh = now self.query_one("#sidebar", Static).update(render_sidebar(self.sessions, self.current_id)) def _at_bottom(self, container) -> bool: