feat: add live Neovim checkpoint views

This commit is contained in:
user
2026-07-16 18:18:52 +02:00
parent 1c06ca35d6
commit fc357bc190
4 changed files with 3035 additions and 5 deletions
+44 -1
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
import base64
import copy
import json
import html as html_lib
import os
@@ -6918,6 +6919,17 @@ def render_section_assets_tex(section: dict, data: dict) -> list[str]:
return lines
def recorded_grid_ref(data: dict, step: dict) -> str:
explicit = str((step.get("view", {}) or {}).get("recorded_grid_ref", ""))
if explicit:
return explicit
snapshot_ref = str(step.get("snapshot_ref", ""))
pattern = str((data.get("debug_checkpoints", {}) or {}).get("recorded_grid_pattern", ""))
if not snapshot_ref or "{snapshot_ref}" not in pattern:
return ""
return pattern.replace("{snapshot_ref}", snapshot_ref)
def prepare_html_figure_assets(data: dict) -> None:
output_dir = html_output_dir(data) / "figures"
output_dir.mkdir(parents=True, exist_ok=True)
@@ -6934,6 +6946,7 @@ def prepare_html_figure_assets(data: dict) -> None:
for asset in section_assets(data.get("sections", [])):
add_graphic(str(asset.get("html_path") or asset.get("path", "")))
add_graphic(str(asset.get("source_path", "")))
add_graphic(str((asset.get("interactive", {}).get("terminal_view", {}) or {}).get("path", "")))
for figure in data.get("figures", []):
add_graphic(figure.get("path", ""))
pdf_links: list[str] = []
@@ -6970,6 +6983,26 @@ def prepare_html_figure_assets(data: dict) -> None:
if source.exists():
shutil.copy2(source, output_dir / source.name)
recorded_grids: set[str] = set()
for asset in section_assets(data.get("sections", [])):
interactive = asset.get("interactive", {}) or {}
for phase in interactive.get("phases", []) or []:
for step in phase.get("steps", []) or []:
recorded_ref = recorded_grid_ref(data, step)
if recorded_ref:
recorded_grids.add(recorded_ref)
json_root = (CARD_ROOT / "json").resolve()
web_root = html_output_dir(data).resolve()
for recorded_ref in sorted(recorded_grids):
source = (json_root / recorded_ref).resolve()
target = (web_root / recorded_ref).resolve()
if json_root not in source.parents or web_root not in target.parents:
raise ValueError(f"recorded_grid_ref wychodzi poza dozwolony katalog: {recorded_ref}")
if not source.is_file():
raise FileNotFoundError(f"Brak zapisanego ekranu Neovima: {source}")
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(source, target)
def react_task_model(
task_ref: str,
@@ -7071,6 +7104,16 @@ def react_card_model(data: dict) -> dict:
include_section_assets = not task_ref or task_ref == str(task_refs[0])
for asset in (section.get("assets", []) or []) if include_section_assets else []:
source_path = str(asset.get("html_path") or asset.get("path", ""))
interactive = copy.deepcopy(asset.get("interactive"))
if interactive:
terminal_view = interactive.get("terminal_view") or {}
if terminal_view.get("path"):
terminal_view["href"] = html_figure_asset(str(terminal_view["path"]))
for phase in interactive.get("phases", []) or []:
for step in phase.get("steps", []) or []:
recorded_ref = recorded_grid_ref(data, step)
if recorded_ref:
step.setdefault("view", {})["recorded_grid_ref"] = recorded_ref
assets.append(
{
"label": str(asset.get("label", "")),
@@ -7082,7 +7125,7 @@ def react_card_model(data: dict) -> dict:
else "",
"width": float(asset.get("width", 1.0)),
"kind": str(asset.get("kind", "diagram")),
"interactive": asset.get("interactive"),
"interactive": interactive,
}
)
title = str(section.get("title", ""))