refactor(tui): improve agent node expansion handling and add tree node selection functionality
This commit is contained in:
@@ -522,7 +522,7 @@ class StrixTUIApp(App): # type: ignore[misc]
|
|||||||
agent_updates = True
|
agent_updates = True
|
||||||
|
|
||||||
if agent_updates:
|
if agent_updates:
|
||||||
self._expand_all_agent_nodes()
|
self._expand_new_agent_nodes()
|
||||||
|
|
||||||
self._update_chat_view()
|
self._update_chat_view()
|
||||||
|
|
||||||
@@ -1077,6 +1077,13 @@ class StrixTUIApp(App): # type: ignore[misc]
|
|||||||
|
|
||||||
logging.warning(f"Failed to add agent node {agent_id}: {e}")
|
logging.warning(f"Failed to add agent node {agent_id}: {e}")
|
||||||
|
|
||||||
|
def _expand_new_agent_nodes(self) -> None:
|
||||||
|
if len(self.screen_stack) > 1 or self.show_splash:
|
||||||
|
return
|
||||||
|
|
||||||
|
if not self.is_mounted:
|
||||||
|
return
|
||||||
|
|
||||||
def _expand_all_agent_nodes(self) -> None:
|
def _expand_all_agent_nodes(self) -> None:
|
||||||
if len(self.screen_stack) > 1 or self.show_splash:
|
if len(self.screen_stack) > 1 or self.show_splash:
|
||||||
return
|
return
|
||||||
@@ -1156,7 +1163,7 @@ class StrixTUIApp(App): # type: ignore[misc]
|
|||||||
old_node.remove()
|
old_node.remove()
|
||||||
|
|
||||||
parent_node.allow_expand = True
|
parent_node.allow_expand = True
|
||||||
self._expand_all_agent_nodes()
|
parent_node.expand()
|
||||||
|
|
||||||
def _render_chat_content(self, msg_data: dict[str, Any]) -> Text | None:
|
def _render_chat_content(self, msg_data: dict[str, Any]) -> Text | None:
|
||||||
role = msg_data.get("role")
|
role = msg_data.get("role")
|
||||||
@@ -1266,6 +1273,22 @@ class StrixTUIApp(App): # type: ignore[misc]
|
|||||||
if agent_id:
|
if agent_id:
|
||||||
self.selected_agent_id = agent_id
|
self.selected_agent_id = agent_id
|
||||||
|
|
||||||
|
@on(Tree.NodeSelected) # type: ignore[misc]
|
||||||
|
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:
|
||||||
|
return
|
||||||
|
|
||||||
|
node = event.node
|
||||||
|
|
||||||
|
if node.allow_expand:
|
||||||
|
if node.is_expanded:
|
||||||
|
node.collapse()
|
||||||
|
else:
|
||||||
|
node.expand()
|
||||||
|
|
||||||
def _send_user_message(self, message: str) -> None:
|
def _send_user_message(self, message: str) -> None:
|
||||||
if not self.selected_agent_id:
|
if not self.selected_agent_id:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
import litellm
|
import litellm
|
||||||
|
|
||||||
from .config import LLMConfig
|
from .config import LLMConfig
|
||||||
@@ -11,3 +13,4 @@ __all__ = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
litellm._logging._disable_debugging()
|
litellm._logging._disable_debugging()
|
||||||
|
logging.getLogger("aiohttp").setLevel(logging.CRITICAL)
|
||||||
|
|||||||
Reference in New Issue
Block a user