From 44a622baa6da7b8d1196c0e29624fd3095134613 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:32:05 -0400 Subject: [PATCH] Add quit button --- src/marvin/cli/tui.css | 12 ++++++++++++ src/marvin/cli/tui.py | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/marvin/cli/tui.css b/src/marvin/cli/tui.css index d0d257672..725ab5cc5 100644 --- a/src/marvin/cli/tui.css +++ b/src/marvin/cli/tui.css @@ -22,6 +22,18 @@ Sidebar Button#settings { dock: bottom; } +Sidebar #meta-buttons-container { + height: auto; +} + +Sidebar #quit { + background: $error 25%; +} + +Sidebar #quit:hover { + background: $error 50%; +} + Sidebar TabbedContent { height: 100%; } diff --git a/src/marvin/cli/tui.py b/src/marvin/cli/tui.py index 49cefd551..df6458afc 100644 --- a/src/marvin/cli/tui.py +++ b/src/marvin/cli/tui.py @@ -154,7 +154,9 @@ def compose(self) -> ComposeResult: yield Button("Bots \[b]", variant="success", id="show-bots") yield Button("New thread \[n]", id="create-new-thread", variant="primary") yield Button("Delete thread \[x]", id="delete-thread", variant="error") - yield Button("Settings \[s]", id="show-settings") + with Horizontal(id="meta-buttons-container"): + yield Button("Settings \[s]", id="show-settings") + yield Button("Quit \[ctrl-c]", id="quit") class ResponseHover(Message): @@ -598,6 +600,8 @@ async def on_button_pressed(self, event: Button.Pressed) -> None: self.action_new_thread() elif event.button.id == "delete-thread": await self.action_delete_thread() + elif event.button.id == "quit": + self.app.exit() async def update_last_bot_response(self, token_buffer: list[str]): streaming_response = "".join(token_buffer)