fix(live): defer zone overlay redraw + fix ROI naming ask_string - #436
Merged
Conversation
Follow-up to #435. After approving live auto-detection, the polygon still did not appear until the user double-clicked the "arena principal" item. `display_roi_video_frame` (run via UI_DISPLAY_VIDEO_FRAME inside run_live_calibration) schedules its own `root.after(10, _draw_bg_image_to_canvas)` background repaint. The synchronous UI_REDRAW_ZONES from #435 drew the overlay first, then that deferred bg repaint wiped it 10 ms later. Fix: defer `_refresh_zone_tab_after_live_detection` via `root.after(60, ...)` so the overlay redraw runs after the bg repaint. Falls back to a synchronous call when no Tk root is available (unit tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drawing the first ROI raised "'ApplicationGUI' object has no attribute 'ask_string'": ROICompletionStrategy.complete called `gui.ask_string(...)` (guarded by a `# type: ignore[attr-defined]`), but ask_string lives on DialogManager. Route through `gui.dialog_manager.ask_string(...)`, matching zone_editor.py. Tests updated to mock the correct target. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Correção de dois regressos no fluxo de auto-detecção/edição de zonas em projetos LIVE: (1) overlay do polígono sendo “apagado” por um repaint diferido do frame após aprovação da detecção, e (2) chamada incorreta de ask_string no alvo errado durante a conclusão de ROI.
Changes:
- Defere o refresh do overlay/lista de zonas após live auto-detect para ocorrer depois do repaint do background (via
root.after(60, ...), com fallback síncrono em ambiente sem Tk root). - Corrige a coleta do nome da ROI para usar
gui.dialog_manager.ask_string(...)(em vez degui.ask_string(...)). - Atualiza testes para mockar o alvo correto (
dialog_manager.ask_string).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/zebtrack/ui/components/single_video_workflow.py | Defere o refresh do overlay/lista após live auto-detect para evitar que um repaint posterior do background apague o polígono. |
| src/zebtrack/ui/components/polygon_drawing_service.py | Ajusta a coleta do nome da ROI para chamar ask_string via DialogManager (alvo correto). |
| tests/ui/components/test_polygon_drawing_service.py | Atualiza mocks para refletir a mudança do alvo de ask_string (via dialog_manager). |
Comment on lines
+317
to
+321
| root = getattr(gui, "root", None) | ||
| if root is not None and hasattr(root, "after"): | ||
| # 60 ms > the 10 ms bg repaint scheduled by display_roi_video_frame. | ||
| root.after(60, _do_refresh) | ||
| else: |
…stant Addresses Copilot review on #436: the `root.after(60, ...)` in _refresh_zone_tab_after_live_detection was a magic number coupled to the `root.after(10, ...)` bg repaint inside display_roi_video_frame. If that 10 ms changed, the overlay bug could silently return. Extract `VideoFrameManager.BG_REPAINT_DELAY_MS` (used by the repaint itself) and derive the refresh delay as `BG_REPAINT_DELAY_MS + 50`, so the two values can no longer drift apart. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up de #433/#435 — dois erros no fluxo de definição de zonas de projeto LIVE.
Erro 1 — polígono não aparece após aceitar a detecção
Após aprovar a auto-detecção pela câmera, o frame e os botões de edição apareciam, mas o polígono só surgia ao dar duplo-clique no item "arena principal".
Causa raiz:
display_roi_video_frame(disparado porUI_DISPLAY_VIDEO_FRAMEdentro derun_live_calibration) agenda um repaint próprio do fundo viaroot.after(10, _draw_bg_image_to_canvas). OUI_REDRAW_ZONESsíncrono do #435 desenhava o overlay primeiro, e esse repaint diferido do fundo apagava o polígono 10 ms depois.Correção: deferir
_refresh_zone_tab_after_live_detectionviaroot.after(60, ...)(60 ms > 10 ms), para o redraw do overlay rodar depois do repaint do fundo. Sem Tk root (testes), cai no caminho síncrono.Erro 2 —
'ApplicationGUI' object has no attribute 'ask_string'Ao terminar o polígono principal e desenhar a primeira ROI,
ROICompletionStrategy.completechamavagui.ask_string(...)(com# type: ignore[attr-defined]), masask_stringexiste noDialogManager, não noApplicationGUI.Correção:
gui.dialog_manager.ask_string(...), igual aozone_editor.py. Testes atualizados para mockar o alvo correto.Testes
test_single_video_workflow_auto_detect.pyetest_polygon_drawing_service.py: 21 passed.ruff✅ ·ruff format✅ ·mypy✅ (via venv MAIN).🤖 Generated with Claude Code