Host Agent now persists step-level execution detail locally (via a real TaskMetadataStore/Timeline wired into TaskRunner) and reports a bounded in-progress snapshot piggybacked on lease renewal. Cloud persists that snapshot per active assignment and exposes it through the existing task list/detail query path; Cloud Console renders it as a live badge. Host Agent's local console gains authenticated, read-only task list and detail/timeline pages (same-origin, server-rendered) with inlined screenshots. Also fixes a pre-existing gap in the shared Timeline: the actual per-step LLM prompt is now recorded instead of the task goal, benefiting both Runtime and Host Agent consoles. When a host uses the cloud planner transport, each decide call's prompt and resulting tool decision are durably logged in a new planner_decision_log table (with bounded retention) and browsable from Cloud Console; direct-transport hosts explicitly surface a "not reported" state. Includes Alembic migrations 0008 (progress columns on scheduled_tasks) and 0009 (planner_decision_log), bounded Host-Agent-local retention, dual-backend repository parity, and Vitest + pytest coverage. Task 6.5 (manual end-to-end device verification) remains. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
import threading
|
|
from dataclasses import dataclass
|
|
from datetime import UTC, datetime
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from collections.abc import Callable
|
|
|
|
_MAX_SUMMARY_LENGTH = 500
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class TaskProgressSnapshot:
|
|
step_index: int
|
|
step_status: str
|
|
summary: str
|
|
updated_at: datetime
|
|
|
|
|
|
class TaskProgressHolder:
|
|
"""Thread-safe latest-step-progress holder for one in-flight assignment.
|
|
|
|
Written by the execution thread (via ``update``, wired as the
|
|
``TaskRunner.on_step_progress`` callback) and read by the asyncio
|
|
lease-renewal loop (via ``snapshot``) just before each renewal call.
|
|
"""
|
|
|
|
def __init__(self, *, now: Callable[[], datetime] | None = None) -> None:
|
|
self._now = now or (lambda: datetime.now(UTC))
|
|
self._lock = threading.Lock()
|
|
self._snapshot: TaskProgressSnapshot | None = None
|
|
|
|
def update(self, step_index: int, step_status: str, summary: str) -> None:
|
|
if len(summary) > _MAX_SUMMARY_LENGTH:
|
|
summary = summary[:_MAX_SUMMARY_LENGTH]
|
|
with self._lock:
|
|
self._snapshot = TaskProgressSnapshot(
|
|
step_index=step_index,
|
|
step_status=step_status,
|
|
summary=summary,
|
|
updated_at=self._now(),
|
|
)
|
|
|
|
def clear(self) -> None:
|
|
with self._lock:
|
|
self._snapshot = None
|
|
|
|
def snapshot(self) -> TaskProgressSnapshot | None:
|
|
with self._lock:
|
|
return self._snapshot
|