From 3b90c5df8341075167c06a3408adff823327ad9d Mon Sep 17 00:00:00 2001 From: Aniket Shukla Date: Thu, 30 Jul 2026 19:02:04 +0530 Subject: [PATCH] fix(tui): use the is_running property for app guards that never fired (#894) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit textual's App.is_mounted is a method taking a widget, not a property, so a bare self.is_mounted is an always-truthy bound method and every 'if not self.is_mounted: return' guard was dead. Worst case, the dead guard let query_one run against a missing screen, raise, get caught, and re-schedule via call_after_refresh — looping instead of returning. Switch the 13 app-level guards to App.is_running (the bool property these guards want). The one correct widget.is_mounted (a Widget property) is left unchanged. Resolves the mypy 'could always be true' / pyright reportUnnecessaryComparison findings in the issue. --- strix/interface/tui/app.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/strix/interface/tui/app.py b/strix/interface/tui/app.py index 14bc6cb1f..f8c1e459f 100644 --- a/strix/interface/tui/app.py +++ b/strix/interface/tui/app.py @@ -870,7 +870,7 @@ def compose(self) -> ComposeResult: yield SplashScreen(id="splash_screen") def watch_show_splash(self, show_splash: bool) -> None: - if not show_splash and self.is_mounted: + if not show_splash and self.is_running: try: splash = self.query_one("#splash_screen") splash.remove() @@ -942,7 +942,7 @@ def _focus_chat_input(self) -> None: if len(self.screen_stack) > 1 or self.show_splash: return - if not self.is_mounted: + if not self.is_running: return try: @@ -957,7 +957,7 @@ def _focus_agents_tree(self) -> None: if len(self.screen_stack) > 1 or self.show_splash: return - if not self.is_mounted: + if not self.is_running: return try: @@ -989,7 +989,7 @@ def _update_ui(self) -> None: if len(self.screen_stack) > 1: return - if not self.is_mounted: + if not self.is_running: return try: @@ -1128,7 +1128,7 @@ def _get_chat_content( return self._get_rendered_events_content(events), "chat-content" def _update_chat_view(self) -> None: - if len(self.screen_stack) > 1 or self.show_splash or not self.is_mounted: + if len(self.screen_stack) > 1 or self.show_splash or not self.is_running: return try: @@ -1492,7 +1492,7 @@ def watch_selected_agent_id(self, _agent_id: str | None) -> None: if len(self.screen_stack) > 1 or self.show_splash: return - if not self.is_mounted: + if not self.is_running: return self._displayed_events.clear() @@ -1565,7 +1565,7 @@ def _add_agent_node(self, agent_data: dict[str, Any]) -> None: if len(self.screen_stack) > 1 or self.show_splash: return - if not self.is_mounted: + if not self.is_running: return agent_id = agent_data["id"] @@ -1704,7 +1704,7 @@ def handle_tree_highlight(self, event: Tree.NodeHighlighted) -> None: if len(self.screen_stack) > 1 or self.show_splash: return - if not self.is_mounted: + if not self.is_running: return node = event.node @@ -1724,7 +1724,7 @@ def handle_tree_node_selected(self, event: Tree.NodeSelected) -> None: if len(self.screen_stack) > 1 or self.show_splash: return - if not self.is_mounted: + if not self.is_running: return node = event.node @@ -1776,7 +1776,7 @@ def _get_agent_name(self, agent_id: str) -> str: return "Unknown Agent" def action_toggle_help(self) -> None: - if self.show_splash or not self.is_mounted: + if self.show_splash or not self.is_running: return try: @@ -1794,7 +1794,7 @@ def action_toggle_help(self) -> None: self.push_screen(HelpScreen()) async def action_request_quit(self) -> None: - if self.show_splash or not self.is_mounted: + if self.show_splash or not self.is_running: await self.action_custom_quit() return @@ -1810,7 +1810,7 @@ async def action_request_quit(self) -> None: self.push_screen(QuitScreen()) def action_stop_selected_agent(self) -> None: - if self.show_splash or not self.is_mounted: + if self.show_splash or not self.is_running: return if len(self.screen_stack) > 1: @@ -1969,7 +1969,7 @@ def _safe_widget_operation( return True def on_resize(self, event: events.Resize) -> None: - if self.show_splash or not self.is_mounted: + if self.show_splash or not self.is_running: return try: