@danhachuel/thunderbolt 0.4.17 → 0.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/main.py +8 -4
- package/hermes_ui/domain.py +17 -0
- package/package.json +1 -1
package/app/main.py
CHANGED
|
@@ -34,7 +34,7 @@ def display_version(version: str) -> str:
|
|
|
34
34
|
|
|
35
35
|
APP_VERSION_LABEL = display_version(APP_VERSION)
|
|
36
36
|
|
|
37
|
-
from hermes_ui.domain import STAGES, create_batch, create_channel, create_tasks_for_batch, delete_channel, delete_task, pipeline_summary, retry_task_with_current_settings, set_channel_defaults, transition_task, update_channel, update_channel_video
|
|
37
|
+
from hermes_ui.domain import STAGES, create_batch, create_channel, create_tasks_for_batch, delete_channel, delete_task, pipeline_summary, retry_task_with_current_settings, set_channel_defaults, stop_task_by_user, transition_task, update_channel, update_channel_video
|
|
38
38
|
from hermes_ui.drafts import list_drafts, save_draft
|
|
39
39
|
from hermes_ui.automation_worker import load_worker_status
|
|
40
40
|
from hermes_ui.pipeline_worker import load_pipeline_worker_status, recover_stale_tasks, STALE_TASK_SECONDS, WORKER_HEARTBEAT_TIMEOUT_SECONDS
|
|
@@ -3778,8 +3778,12 @@ def _render_video_task_state(task: dict[str, Any]) -> None:
|
|
|
3778
3778
|
state = str(task.get("state") or "unknown").strip().lower()
|
|
3779
3779
|
progress = _video_task_progress(task)
|
|
3780
3780
|
st.caption("Estado")
|
|
3781
|
-
|
|
3782
|
-
|
|
3781
|
+
if state == "blocked" and task.get("stop_reason") == "user":
|
|
3782
|
+
st.write("Stoped by User")
|
|
3783
|
+
st.caption("Parado manualmente pelo utilizador.")
|
|
3784
|
+
else:
|
|
3785
|
+
st.write(state or "—")
|
|
3786
|
+
st.caption(VIDEO_TASK_STATE_LABELS.get(state, state.replace("_", " ").capitalize() or "Desconhecido"))
|
|
3783
3787
|
st.progress(progress, text=f"{progress}%")
|
|
3784
3788
|
helper_status = str(task.get("video_helper_status") or "").strip()
|
|
3785
3789
|
if state == "doing" and helper_status:
|
|
@@ -4240,7 +4244,7 @@ def render_automation():
|
|
|
4240
4244
|
st.rerun()
|
|
4241
4245
|
with stop_col:
|
|
4242
4246
|
if st.button("Stop", key=f"automation_stop_{task['id']}", use_container_width=True, disabled=state != "doing"):
|
|
4243
|
-
|
|
4247
|
+
stop_task_by_user(task["id"])
|
|
4244
4248
|
st.rerun()
|
|
4245
4249
|
with delete_col:
|
|
4246
4250
|
confirm_delete_key = f"automation_confirm_delete_{task['id']}"
|
package/hermes_ui/domain.py
CHANGED
|
@@ -359,6 +359,8 @@ def transition_task(task_id: str, state: str | None = None, stage: str | None =
|
|
|
359
359
|
previous_state = str(task.get("state") or "")
|
|
360
360
|
if state:
|
|
361
361
|
task["state"] = state
|
|
362
|
+
if state != "blocked":
|
|
363
|
+
task.pop("stop_reason", None)
|
|
362
364
|
if stage:
|
|
363
365
|
if stage not in STAGES and stage not in LEGACY_STAGES:
|
|
364
366
|
raise ValueError(f"Etapa inválida: {stage}")
|
|
@@ -375,6 +377,21 @@ def transition_task(task_id: str, state: str | None = None, stage: str | None =
|
|
|
375
377
|
return updated
|
|
376
378
|
|
|
377
379
|
|
|
380
|
+
def stop_task_by_user(task_id: str) -> dict[str, Any] | None:
|
|
381
|
+
"""Stop a running video task and retain the user-originated reason for the UI."""
|
|
382
|
+
task = transition_task(task_id, "blocked")
|
|
383
|
+
if task is None:
|
|
384
|
+
return None
|
|
385
|
+
tasks = read_json("tasks.json", [])
|
|
386
|
+
for persisted in tasks:
|
|
387
|
+
if persisted.get("id") == task_id:
|
|
388
|
+
persisted["stop_reason"] = "user"
|
|
389
|
+
persisted["updated_at"] = now()
|
|
390
|
+
write_json("tasks.json", tasks)
|
|
391
|
+
return persisted
|
|
392
|
+
return task
|
|
393
|
+
|
|
394
|
+
|
|
378
395
|
def retry_task_with_current_settings(task_id: str) -> dict[str, Any] | None:
|
|
379
396
|
"""Queue a failed or blocked task without persisting API credentials or provider snapshots.
|
|
380
397
|
|
package/package.json
CHANGED