fix(webui): show per-run automation replies and simplify details
This commit is contained in:
1 parent
e7da868574
commit
037438e7d1
28 files changed
+985
-183
No files matched your search
@@ -22,6 +22,7 @@ from nanobot.cron.types import (
|
||||
CronJobState,
|
||||
CronPayload,
|
||||
CronRunRecord,
|
||||
CronRunResult,
|
||||
CronSchedule,
|
||||
CronStore,
|
||||
)
|
||||
@@ -176,7 +177,7 @@ class CronService:
|
||||
def __init__(
|
||||
self,
|
||||
store_path: Path,
|
||||
on_job: Callable[[CronJob], Coroutine[Any, Any, str | None]] | None = None,
|
||||
on_job: Callable[[CronJob], Coroutine[Any, Any, str | CronRunResult | None]] | None = None,
|
||||
max_sleep_ms: int = 300_000, # 5 minutes
|
||||
):
|
||||
self.store_path = store_path
|
||||
@@ -413,6 +414,7 @@ class CronService:
|
||||
"status": r.status,
|
||||
"durationMs": r.duration_ms,
|
||||
"error": r.error,
|
||||
"runId": r.run_id,
|
||||
}
|
||||
for r in j.state.run_history
|
||||
],
|
||||
@@ -586,10 +588,11 @@ class CronService:
|
||||
"""Execute a single job."""
|
||||
start_ms = _now_ms()
|
||||
logger.info("Cron: executing job '{}' ({})", job.name, job.id)
|
||||
result: str | CronRunResult | None = None
|
||||
|
||||
try:
|
||||
if self.on_job:
|
||||
await self.on_job(job)
|
||||
result = await self.on_job(job)
|
||||
|
||||
job.state.last_status = "ok"
|
||||
job.state.last_error = None
|
||||
@@ -620,6 +623,7 @@ class CronService:
|
||||
status=job.state.last_status,
|
||||
duration_ms=end_ms - start_ms,
|
||||
error=job.state.last_error,
|
||||
run_id=result.run_id if isinstance(result, CronRunResult) else None,
|
||||
))
|
||||
job.state.run_history = job.state.run_history[-self._MAX_RUN_HISTORY:]
|
||||
|
||||
|
||||
Reference in new issue
Block a user