Skip to content

Commit 754685b

Browse files
committed
refactor(ui): cache attribute lookups in session message handling
Use local variables to cache repeated attribute lookups for _query_in_progress and query_context, improving code readability and avoiding redundant getattr calls. Generated with Ripperdoc Co-Authored-By: Ripperdoc
1 parent 40c65d3 commit 754685b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

ripperdoc/cli/ui/rich_ui/session.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,13 +1523,15 @@ def _schedule_background_notification_response(
15231523
# query that would race prompt_toolkit redraw and spinner rendering.
15241524
# Defer it into pending messages so it is consumed on the next user turn.
15251525
prompt_app = getattr(getattr(self, "_prompt_session", None), "app", None)
1526+
query_in_progress = bool(getattr(self, "_query_in_progress", False))
1527+
query_context = getattr(self, "query_context", None)
15261528
if (
1527-
not self._query_in_progress
1529+
not query_in_progress
15281530
and prompt_app is not None
15291531
and bool(getattr(prompt_app, "is_running", False))
1530-
and self.query_context is not None
1532+
and query_context is not None
15311533
):
1532-
self.query_context.pending_message_queue.enqueue_text(
1534+
query_context.pending_message_queue.enqueue_text(
15331535
agent_message,
15341536
metadata=metadata,
15351537
)

0 commit comments

Comments
 (0)