Remove enter binding, ; hide batched correction steps by default

This commit is contained in:
sebastien committed 2026-09-21 16:07:56 +02:00
1 parent 55f9a29677
commit c8ce04cf50
4 files changed
+139 -22

No files matched your search

+46 -16
View File
@@ -591,7 +591,10 @@ class CopienatorApp(tk.Tk):
opened = {self.tree.item(item, "text"): self.tree.item(item, "open") for item in self.tree.get_children()}
self.tree.delete(*self.tree.get_children())
section_items: dict[str, str] = {}
show_batches = self._has_batch_correction()
for step in self.steps:
if step.skip_for_live_correction and not show_batches:
continue
if step.section not in section_items:
section_id = f"section:{len(section_items)}"
section_items[step.section] = section_id
@@ -607,6 +610,25 @@ class CopienatorApp(tk.Tk):
)
if selected and self.tree.exists(selected):
self.tree.selection_set(selected)
elif selected and self.tree.exists("correction"):
self.tree.selection_set("correction")
def _has_batch_correction(self) -> bool:
evaluation = self.state_store.evaluation
if evaluation is None:
return False
correction = self.state_store.step("correction")
if correction.get("batch_started") or correction.get("last_run_variant") in {"batch", "hybrid", "integrate"}:
return True
for name in ("batch_requests_flash.jsonl", "batch_requests_pro.jsonl",
"batch_jobs.json", "batched_correction_result.jsonl"):
path = evaluation / name
try:
if path.is_file() and path.stat().st_size > 0:
return True
except OSError:
continue
return False
def _step_status(self, step: StepDefinition) -> str:
if self.state_store.evaluation:
@@ -721,16 +743,6 @@ class CopienatorApp(tk.Tk):
# trigger the same automatic behavior twice.
self.state_store.update_step(step.id, visited=True)
if step.skip_for_live_correction:
correction = self.state_store.step("correction")
if correction.get("variant", "live") == "live":
self.after_idle(
lambda step_id=step.id: self._automatic_skip(
step_id, "correction immédiate sélectionnée"
)
)
return
if step.skip_without_manual_conflicts:
evaluation = self.evaluation
conflicts = evaluation / "manual_resolutions.txt" if evaluation else None
@@ -1217,7 +1229,9 @@ class CopienatorApp(tk.Tk):
def _progression_ids(self, step_id: str) -> list[str]:
redo = step_id.startswith("refaire_")
return [step.id for step in self.steps if step.id.startswith("refaire_") == redo]
show_batches = self._has_batch_correction()
return [step.id for step in self.steps if step.id.startswith("refaire_") == redo
and (not step.skip_for_live_correction or show_batches)]
def _refaire_selection(self) -> list[list]:
evaluation = self.evaluation
@@ -1473,6 +1487,8 @@ class CopienatorApp(tk.Tk):
self._append_console(f"\n$ {command_display(command)}\n")
try:
self.runner.start(command, self.repository, environment, log_path)
if step.id == "correction" and variant.id in {"batch", "hybrid"}:
self.state_store.update_step("correction", batch_started=True)
except (OSError, RuntimeError) as exc:
self.state_store.update_step(step.id, status="failed")
self.state_store.add_history(
@@ -1614,15 +1630,18 @@ class CopienatorApp(tk.Tk):
self._populate_tree()
message = f"{evaluation.name} : tous les résultats batch sont prêts à récupérer."
self.info_var.set(message)
try:
notify_desktop("Copienator — batchs terminés", message)
except (OSError, RuntimeError) as exc:
self.bell()
self._append_console(f"Notification de bureau indisponible : {exc}\n{message}\n")
self._notify_completion("Copienator — batchs terminés", message)
if (self.current_step and self.current_step.id == "batch_status"
and not self.active_step_id and not self.runner.running):
self._move_selection_from("batch_status", 1)
def _notify_completion(self, title: str, message: str) -> None:
try:
notify_desktop(title, message)
except (OSError, RuntimeError) as exc:
self.bell()
self._append_console(f"Notification de bureau indisponible : {exc}\n{message}\n")
def _finish_process(self, return_code: int, interrupted: bool) -> None:
step_id = self.active_step_id
if not step_id:
@@ -1709,6 +1728,17 @@ class CopienatorApp(tk.Tk):
"sur « Marquer terminée »."
)
return
if step_id in {"labels", "correction"} and self.state_store.evaluation:
completion = (
"détection des labels terminée"
if step_id == "labels" else "étape de correction terminée"
)
outcome = STATUS_LABELS[status].lower()
self._notify_completion(
f"Copienator — {completion} ({outcome})",
f"{self.state_store.evaluation.name} : {completion} — {outcome} "
f"(code {return_code}).",
)
if status == "success":
if step_id == "batch_status" and self.batch_monitor.active:
self.batch_monitor.stop()