From f4a5bffa7f536fd46445892b194a327957f3241a Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 27 Apr 2026 21:16:32 -0700 Subject: [PATCH 1/6] fix: Prevent strange characters on Windows TUI Co-authored-by: cecli (openai/gemini_cli_local/gemini-2.5-pro) --- cecli/tui/app.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cecli/tui/app.py b/cecli/tui/app.py index 464726a61c1..9a33d355fd5 100644 --- a/cecli/tui/app.py +++ b/cecli/tui/app.py @@ -5,6 +5,7 @@ import queue import time from functools import lru_cache +import platform from pathlib import Path import textual.strip @@ -359,6 +360,11 @@ def on_mouse_up(self, event: events.MouseUp) -> None: self._mouse_hold_timer = None self.update_key_hints(generating=self._currently_generating) + def on_mouse_move(self, event: events.MouseMove) -> None: + """Handle mouse move events to prevent strange characters on Windows.""" + if platform.system() == "Windows": + event.stop() + def _show_select_hint(self) -> None: """Show the shift+drag to select hint.""" try: From d390bb365a31706698201c3047a8adf20275fc8a Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 28 Apr 2026 19:31:28 -0700 Subject: [PATCH 2/6] test: Add tests for app module --- tests/tui/test_app.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/tui/test_app.py diff --git a/tests/tui/test_app.py b/tests/tui/test_app.py new file mode 100644 index 00000000000..e69de29bb2d From 3cc115efaafa963c3e2310064d15c8917d0925d8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 28 Apr 2026 19:31:31 -0700 Subject: [PATCH 3/6] test: add TUI mouse event handling tests Co-authored-by: cecli (openai/gemini_cli_local/gemini-2.5-pro) --- tests/tui/test_app.py | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/tui/test_app.py b/tests/tui/test_app.py index e69de29bb2d..28a16d6f4cc 100644 --- a/tests/tui/test_app.py +++ b/tests/tui/test_app.py @@ -0,0 +1,50 @@ +import unittest +from unittest.mock import MagicMock, patch + +from textual import events + +# Assuming TUI is in cecli.tui.app +from cecli.tui.app import TUI + + +class TestTUI(unittest.TestCase): + @patch("cecli.tui.app.TUI.__init__", return_value=None) + def setUp(self, mock_init): + self.tui = TUI(coder_worker=None, output_queue=None, input_queue=None, args=None) + # Mock attributes that might be accessed in on_mouse_move or its calls + self.tui._mouse_hold_timer = None + self.tui._currently_generating = False + + def test_on_mouse_move_windows(self): + """ + Test that on_mouse_move stops the event on Windows. + """ + # Mock the platform system to return "Windows" + with patch("platform.system", return_value="Windows"): + # Create a mock mouse move event + mock_event = MagicMock(spec=events.MouseMove) + + # Call the event handler + self.tui.on_mouse_move(mock_event) + + # Assert that event.stop() was called + mock_event.stop.assert_called_once() + + def test_on_mouse_move_linux(self): + """ + Test that on_mouse_move does not stop the event on Linux. + """ + # Mock the platform system to return "Linux" + with patch("platform.system", return_value="Linux"): + # Create a mock mouse move event + mock_event = MagicMock(spec=events.MouseMove) + + # Call the event handler + self.tui.on_mouse_move(mock_event) + + # Assert that event.stop() was not called + mock_event.stop.assert_not_called() + + +if __name__ == "__main__": + unittest.main() From 198737fa394607d999191197f254e0a20b16ed07 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 28 Apr 2026 19:33:04 -0700 Subject: [PATCH 4/6] test: refactor tests/tui/test_app.py to use pytest Co-authored-by: cecli (openai/gemini_cli_local/gemini-2.5-pro) --- tests/tui/test_app.py | 71 ++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/tests/tui/test_app.py b/tests/tui/test_app.py index 28a16d6f4cc..fe0facdcf69 100644 --- a/tests/tui/test_app.py +++ b/tests/tui/test_app.py @@ -1,4 +1,4 @@ -import unittest +import pytest from unittest.mock import MagicMock, patch from textual import events @@ -7,44 +7,31 @@ from cecli.tui.app import TUI -class TestTUI(unittest.TestCase): - @patch("cecli.tui.app.TUI.__init__", return_value=None) - def setUp(self, mock_init): - self.tui = TUI(coder_worker=None, output_queue=None, input_queue=None, args=None) - # Mock attributes that might be accessed in on_mouse_move or its calls - self.tui._mouse_hold_timer = None - self.tui._currently_generating = False - - def test_on_mouse_move_windows(self): - """ - Test that on_mouse_move stops the event on Windows. - """ - # Mock the platform system to return "Windows" - with patch("platform.system", return_value="Windows"): - # Create a mock mouse move event - mock_event = MagicMock(spec=events.MouseMove) - - # Call the event handler - self.tui.on_mouse_move(mock_event) - - # Assert that event.stop() was called - mock_event.stop.assert_called_once() - - def test_on_mouse_move_linux(self): - """ - Test that on_mouse_move does not stop the event on Linux. - """ - # Mock the platform system to return "Linux" - with patch("platform.system", return_value="Linux"): - # Create a mock mouse move event - mock_event = MagicMock(spec=events.MouseMove) - - # Call the event handler - self.tui.on_mouse_move(mock_event) - - # Assert that event.stop() was not called - mock_event.stop.assert_not_called() - - -if __name__ == "__main__": - unittest.main() +@pytest.fixture +def tui_instance(monkeypatch): + """A pytest fixture to create a mocked TUI instance.""" + monkeypatch.setattr("cecli.tui.app.TUI.__init__", lambda *args, **kwargs: None) + tui = TUI(coder_worker=None, output_queue=None, input_queue=None, args=None) + tui._mouse_hold_timer = None + tui._currently_generating = False + return tui + + +def test_on_mouse_move_windows(tui_instance): + """ + Test that on_mouse_move stops the event on Windows. + """ + with patch("platform.system", return_value="Windows"): + mock_event = MagicMock(spec=events.MouseMove) + tui_instance.on_mouse_move(mock_event) + mock_event.stop.assert_called_once() + + +def test_on_mouse_move_linux(tui_instance): + """ + Test that on_mouse_move does not stop the event on Linux. + """ + with patch("platform.system", return_value="Linux"): + mock_event = MagicMock(spec=events.MouseMove) + tui_instance.on_mouse_move(mock_event) + mock_event.stop.assert_not_called() From eae434efc94ea75dcb84fdc4c753a61a4c9a1129 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 28 Apr 2026 20:13:52 -0700 Subject: [PATCH 5/6] cli-14: fixed formatting --- cecli/tui/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cecli/tui/app.py b/cecli/tui/app.py index 9a33d355fd5..fc87bd7211b 100644 --- a/cecli/tui/app.py +++ b/cecli/tui/app.py @@ -2,10 +2,10 @@ import concurrent.futures import json +import platform import queue import time from functools import lru_cache -import platform from pathlib import Path import textual.strip From 63473d75ef49a970d106e9211896a80fdc9efb04 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 28 Apr 2026 20:21:54 -0700 Subject: [PATCH 6/6] cli-14: fixed formatting --- tests/tui/test_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tui/test_app.py b/tests/tui/test_app.py index fe0facdcf69..e6244d87cf2 100644 --- a/tests/tui/test_app.py +++ b/tests/tui/test_app.py @@ -1,6 +1,6 @@ -import pytest from unittest.mock import MagicMock, patch +import pytest from textual import events # Assuming TUI is in cecli.tui.app