From accf9e141f4d9bbf9ad5a4ccdb34aa565b14b7d3 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Tue, 1 Apr 2025 22:34:03 +0200 Subject: [PATCH 1/2] Add missing type annotation --- src/serena/agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/serena/agent.py b/src/serena/agent.py index 6a4121af..2b516e2e 100644 --- a/src/serena/agent.py +++ b/src/serena/agent.py @@ -40,7 +40,7 @@ SUCCESS_RESULT = "OK" class LinesRead: def __init__(self) -> None: - self.files = defaultdict(lambda: set()) + self.files: dict[str, set[tuple[int, int]]] = defaultdict(lambda: set()) def add_lines_read(self, relative_path: str, lines: tuple[int, int]) -> None: self.files[relative_path].add(lines) @@ -304,7 +304,7 @@ class ReadFileTool(Tool): result_lines = result_lines[start_line:] else: self.agent.lines_read.add_lines_read(relative_path, (start_line, end_line)) - result_lines = result_lines[start_line:end_line+1] + result_lines = result_lines[start_line : end_line + 1] result = "\n".join(result_lines) return self._limit_length(result, max_answer_chars) From 057edca38ab770d59bba144420b3edc6c2722dbb Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Tue, 1 Apr 2025 22:44:53 +0200 Subject: [PATCH 2/2] Improve log viewer scrolling behaviour [first change by Serena] --- src/serena/gui_log_viewer.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/serena/gui_log_viewer.py b/src/serena/gui_log_viewer.py index 0d38fedd..89a8faa0 100644 --- a/src/serena/gui_log_viewer.py +++ b/src/serena/gui_log_viewer.py @@ -117,6 +117,12 @@ class GuiLogViewer: self.root.quit() return + # Check if scrollbar is at the bottom before adding new text + # Get current scroll position + current_position = self.text_widget.yview() + # If near the bottom (allowing for small floating point differences) + was_at_bottom = current_position[1] > 0.99 + log_level = self._determine_log_level(message) # Insert the message at the end of the text @@ -124,8 +130,9 @@ class GuiLogViewer: self.text_widget.insert(tk.END, message + "\n", log_level.name) self.text_widget.configure(state=tk.DISABLED) - # Auto-scroll to the bottom - self.text_widget.see(tk.END) + # Auto-scroll to the bottom only if it was already at the bottom + if was_at_bottom: + self.text_widget.see(tk.END) # Schedule to check the queue again if self.running: