Skip to content

Commit

Permalink
Merge pull request #227 from PrefectHQ/fix-query
Browse files Browse the repository at this point in the history
  • Loading branch information
jlowin authored Apr 18, 2023
2 parents 758861c + 7cdd6d8 commit 00ef03a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/marvin/cli/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,19 @@ def compose(self) -> ComposeResult:
yield Label("", id="empty-thread-bot-description")

async def add_response(self, response: Response, scroll: bool = True) -> None:
messages = self.query_one("Conversation #messages", VerticalScroll)
messages = self.app.query_one("Conversation #messages", VerticalScroll)
# wait for the responses to be fully mounted before scrolling
# to avoid issues with rendering Markdown
await messages.mount(response)
if scroll:
messages.scroll_end(duration=0.2)

# show / hide the empty thread message
empty = self.query_one("Conversation #empty-thread-container")
empty = self.app.query_one("Conversation #empty-thread-container")
empty.add_class("hidden")

def clear_responses(self) -> None:
responses = self.query("Response")
responses = self.app.query("Response")
for response in responses:
response.remove()
self.bot_name = getattr(self.app.bot, "name")
Expand All @@ -323,7 +323,7 @@ async def refresh_messages(self):
await self.add_response(BotResponse(message), scroll=False)

# scroll to bottom
messages = self.query_one("Conversation #messages", VerticalScroll)
messages = self.app.query_one("Conversation #messages", VerticalScroll)
messages.scroll_end(animate=False)


Expand Down Expand Up @@ -589,10 +589,10 @@ class MainScreen(Screen):
]

def action_focus_threads(self) -> None:
self.query_one("#threads", Threads).focus()
self.app.query_one("#threads", Threads).focus()

def action_focus_message(self) -> None:
self.query_one("#message-input", Input).focus()
self.app.query_one("#message-input", Input).focus()

def action_show_bots_screen(self) -> None:
self.app.push_screen(BotsScreen())
Expand Down Expand Up @@ -885,7 +885,7 @@ def on_threads_thread_selected(self, event: Threads.ThreadSelected) -> None:
def watch_bot_responding(self, is_responding: bool) -> None:
if not self.is_ready:
return
input_widget = self.query_one("#message-input", Input)
input_widget = self.app.query_one("#message-input", Input)
if is_responding:
input_widget.disabled = True
else:
Expand Down

0 comments on commit 00ef03a

Please sign in to comment.