Browse Source

Updated chat/command section behavior

Efren Yevale Varela 1 tháng trước cách đây
mục cha
commit
a20987b8a2
2 tập tin đã thay đổi với 36 bổ sung và 8 xóa
  1. 9 3
      src/stt_daemon/tui/app.py
  2. 27 5
      tests/test_tui_app.py

+ 9 - 3
src/stt_daemon/tui/app.py

@@ -39,6 +39,7 @@ class AssistantTUI(App):
     #main #triage { width: 1fr; height: 100%; border: solid $accent; }
     #main #chat { width: 2fr; height: 100%; }
     #transcript.-maximized { height: 1fr; }
+    #transcript.-grow { height: 1fr; }
     """
 
     BINDINGS = [
@@ -262,12 +263,17 @@ class AssistantTUI(App):
         return any(not from_chat for _, from_chat in state.lower)
 
     def _update_main_visibility(self) -> None:
-        if not self.triage_enabled or self.screen.maximized is not None:
+        if self.screen.maximized is not None:
             return
-        if self.query("#triage"):
+        show_chat = self._chat_has_content()
+        if self.triage_enabled and self.query("#triage"):
             self.query_one("#triage").display = True
         if self.query("#chat"):
-            self.query_one("#chat").display = self._chat_has_content()
+            self.query_one("#chat").display = show_chat
+        if not self.triage_enabled and self.query("#transcript"):
+            # No triage pane to fill the split: let the transcript take the
+            # space the hidden chat pane would otherwise leave blank.
+            self.query_one("#transcript", RichLog).set_class(not show_chat, "-grow")
 
     def _active_pane(self):
         focused = self.screen.focused

+ 27 - 5
tests/test_tui_app.py

@@ -1038,7 +1038,14 @@ def test_maximize_chat_when_triage_disabled(server):
     async def scenario():
         async with app.run_test(size=(80, 40)) as pilot:
             await pilot.pause()
-            # Disabled: no #main/#triage; focusing #chat then m maximizes #chat itself.
+            app._timer.stop()  # keep the server status from re-hiding #chat
+            # Disabled: no #main/#triage. #chat starts hidden, so give it output
+            # first, then focus it and press m to maximize #chat itself.
+            app.state.ingest(
+                {"type": "tool_result", "tool": "get_datetime", "ok": True, "result": "now"}
+            )
+            app._render()
+            await pilot.pause()
             app.query_one("#chat", RichLog).focus()
             await pilot.pause()
             await pilot.press("m")
@@ -1551,8 +1558,8 @@ def test_cleared_hides_chat_and_restores_full_width(server):
     ), (observed["triage_region"], observed["main_region"])
 
 
-def test_triage_disabled_chat_stays_visible(server):
-    """Triage disabled: #chat stays visible, no crash on render/restore."""
+def test_triage_disabled_chat_follows_content_rule(server):
+    """Triage disabled: #chat is hidden until chat mode or command output arrives."""
     pytest.importorskip("textual")
     from textual.widgets import RichLog
 
@@ -1570,13 +1577,28 @@ def test_triage_disabled_chat_stays_visible(server):
             app._render()
             await pilot.pause()
             observed["chat_display"] = app.query_one("#chat", RichLog).display
+            observed["transcript_grown"] = app.query_one("#transcript", RichLog).has_class(
+                "-grow"
+            )
             app._restore_panes()  # must not raise with no #triage/#main
             await pilot.pause()
             observed["chat_display_after"] = app.query_one("#chat", RichLog).display
+            app.state.ingest(
+                {"type": "tool_result", "tool": "get_datetime", "ok": True, "result": "now"}
+            )
+            app._render()
+            await pilot.pause()
+            observed["chat_with_output"] = app.query_one("#chat", RichLog).display
+            observed["transcript_grown_with_output"] = app.query_one(
+                "#transcript", RichLog
+            ).has_class("-grow")
 
     asyncio.run(scenario())
-    assert observed["chat_display"] is True
-    assert observed["chat_display_after"] is True
+    assert observed["chat_display"] is False
+    assert observed["chat_display_after"] is False
+    assert observed["transcript_grown"] is True
+    assert observed["chat_with_output"] is True
+    assert observed["transcript_grown_with_output"] is False
 
 
 def test_maximize_restore_with_chat_content_keeps_chat_visible(server):