mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-12-04 12:08:11 +00:00
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.
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import asyncio
|
|
|
|
from helpers.api import ApiHandler, Request, Response
|
|
from plugins._time_travel.helpers.time_travel import (
|
|
TimeTravelError,
|
|
TimeTravelService,
|
|
WorkspaceRejectedError,
|
|
resolve_workspace,
|
|
)
|
|
|
|
|
|
class HistoryDiff(ApiHandler):
|
|
async def process(self, input: dict, request: Request) -> dict | Response:
|
|
context_id = str(input.get("context_id") or "").strip()
|
|
workspace_id = str(input.get("workspace_id") or "").strip()
|
|
try:
|
|
workspace = resolve_workspace(
|
|
context_id,
|
|
workspace_id=workspace_id,
|
|
context_loader=self.use_context,
|
|
)
|
|
return await asyncio.to_thread(
|
|
TimeTravelService(workspace).history_diff,
|
|
commit_hash=str(input.get("commit_hash") or ""),
|
|
path=str(input.get("path") or ""),
|
|
mode=str(input.get("mode") or "commit"),
|
|
)
|
|
except WorkspaceRejectedError as exc:
|
|
return {"ok": False, "locked": True, "error": str(exc)}
|
|
except TimeTravelError as exc:
|
|
return {"ok": False, "error": str(exc)}
|