From 12223d7aa33a4326fd7b21199986cf8a9f4509a3 Mon Sep 17 00:00:00 2001 From: MarkSant Date: Sat, 15 Aug 2026 15:40:33 -0300 Subject: [PATCH] refactor(ui): remove unwired _on_send_selected_video_to_analysis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Its only caller was the "Enviar Vídeo Selecionado para Análise" button in create_zone_control_widgets, a dead duplicate Zones-tab Treeview removed in 62162e9a. The handler was accidentally left behind, and it never actually worked in production: it read self.gui.video_selector_tree, an attribute that doesn't exist on ApplicationGUI (the real tree lives at gui.zone_controls.video_selector_tree) — only the test's stand-in gui object had it set directly. Co-Authored-By: Claude Sonnet 5 --- .../ui/builders/zone_control_builder.py | 45 +------------------ .../ui/builders/test_zone_control_builder.py | 21 --------- 2 files changed, 1 insertion(+), 65 deletions(-) diff --git a/src/zebtrack/ui/builders/zone_control_builder.py b/src/zebtrack/ui/builders/zone_control_builder.py index d467a18b..5916a13c 100644 --- a/src/zebtrack/ui/builders/zone_control_builder.py +++ b/src/zebtrack/ui/builders/zone_control_builder.py @@ -4,7 +4,6 @@ Extracted from WidgetFactory to separate concern of zone control construction. """ -import os from datetime import datetime from tkinter import BooleanVar from typing import TYPE_CHECKING @@ -329,7 +328,7 @@ def _show_conclude_next_step_guidance(self) -> None: with no pending session) there is currently no other cue in the UI, so point the user at the "Controle Principal" tab. Only applies to live projects — pre-recorded projects have their own explicit "Iniciar - Análise" / "Enviar Vídeo Selecionado para Análise" buttons. + Análise" button. """ zone_controls = getattr(self.gui, "zone_controls", None) if zone_controls is not None and zone_controls.has_pending_live_session(): @@ -351,45 +350,3 @@ def _show_conclude_next_step_guidance(self) -> None: 'and click "Start Recording".' ), ) - - def _on_send_selected_video_to_analysis(self) -> None: - """Open analysis configuration for the real video selected in the zone tree.""" - tree = getattr(self.gui, "video_selector_tree", None) - selection = tree.selection() if tree is not None else () - if tree is None or not selection: - self.gui.dialog_manager.show_warning( - _("No Video Selected"), - _("Select a recorded video from the list before sending it for analysis."), - ) - return - - tags = tree.item(selection[0], "tags") or () - video_path = str(tags[0]) if tags else "" - is_video_entry = video_path and video_path not in {"group", "day", "subject"} - if not is_video_entry or not os.path.isfile(video_path): - self.gui.dialog_manager.show_info( - _("Video Unavailable"), - _( - "Only recorded videos can be sent for analysis. Planned sessions " - "must be recorded first." - ), - ) - return - - zone_controls = getattr(self.gui, "zone_controls", None) - if zone_controls and zone_controls.has_pending_live_session(): - self.gui.dialog_manager.show_info( - _("Recording Pending"), - _( - "Start or cancel the pending recording before sending another " - "video for analysis." - ), - ) - return - - event_dispatcher = getattr(self.gui, "event_dispatcher", None) - if event_dispatcher is None: - log.error("zone_control_builder.send_to_analysis.no_event_dispatcher") - return - - event_dispatcher.handle_analyze_single_video_clicked(video_path=video_path) diff --git a/tests/ui/builders/test_zone_control_builder.py b/tests/ui/builders/test_zone_control_builder.py index 0afa2fa5..c61f2d1a 100644 --- a/tests/ui/builders/test_zone_control_builder.py +++ b/tests/ui/builders/test_zone_control_builder.py @@ -134,24 +134,3 @@ def test_conclude_video_pre_recorded_project_skips_guidance_dialog(): builder._on_conclude_video() gui.dialog_manager.show_info.assert_not_called() - - -def test_send_selected_video_to_analysis_uses_selected_file(tmp_path): - """The explicit action sends the selected recorded file to the config dialog.""" - video_path = tmp_path / "recorded.mp4" - video_path.touch() - tree = Mock() - tree.selection.return_value = ("video-item",) - tree.item.return_value = (str(video_path),) - gui = _conclude_gui(editing_zone=None, edited_points=[]) - gui.video_selector_tree = tree - gui.zone_controls = SimpleNamespace(has_pending_live_session=lambda: False) - gui.event_dispatcher = Mock() - gui.dialog_manager = Mock() - builder = ZoneControlBuilder(gui, event_bus_v2=Mock()) - - builder._on_send_selected_video_to_analysis() - - gui.event_dispatcher.handle_analyze_single_video_clicked.assert_called_once_with( - video_path=str(video_path) - )