Files
agent-zero/plugins/_time_travel/api/history_present.py
Alessandro 28e36b5fef Load Time Travel history without staging workspace files
Page saved commits directly, batch metadata and file statistics, and bound file-filter scans to Git batches. Keep the snapshot index stat cache instead of clearing and rebuilding it on every capture.

Inspect current changes explicitly in a disposable repository borrowing saved objects read-only. Offload Git work from API event loops and discard stale UI responses when the selection or workspace changes.

Verified with 42 Python tests and 3 frontend tests, including unchanged saved-repository contents after inspection, unusual filenames, filtering, and a 25-process ceiling for a ten-entry history page.
2026-11-12 15:41:23 +01:00

21 lines
801 B
Python

from __future__ import annotations
import asyncio
from helpers.api import ApiHandler, Request, Response
from plugins._time_travel.helpers.time_travel import TimeTravelError, TimeTravelService, resolve_workspace
class HistoryPresent(ApiHandler):
async def process(self, input: dict, request: Request) -> dict | Response:
try:
workspace = resolve_workspace(
str(input.get("context_id") or ""),
workspace_id=str(input.get("workspace_id") or ""),
context_loader=self.use_context,
)
present = await asyncio.to_thread(TimeTravelService(workspace).present_summary)
return {"ok": True, "present": present}
except TimeTravelError as exc:
return {"ok": False, "error": str(exc)}