feat(vm): Screenshot pro VM im Desktop-Panel (VM sehen ohne Live-VNC)
Solange das Live-VNC-Bild noch hakt, ist ein Standbild der pragmatische Weg die VM zu sehen — genau wie ARIA es beim basic_os-Test gemacht hat. - Brain: POST /projects/<pid>/vms/<name>/screenshot → aria-vm screenshot (PNG in /shared/uploads) → als Base64 zurueck. End-to-end auf dem Host validiert (Brain-Container sieht die Datei unter /shared/uploads). - App: 📷-Knopf pro laufender VM im DesktopTile → zeigt den Screenshot im Modal. py/tsc clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1038,6 +1038,35 @@ def project_vm_stop(project_id: str, name: str):
|
||||
return {"ok": rc == 0, "name": name, "output": (out.strip() or err.strip())[:500]}
|
||||
|
||||
|
||||
@app.post("/projects/{project_id}/vms/{name}/screenshot")
|
||||
def project_vm_screenshot(project_id: str, name: str):
|
||||
"""Macht einen Screenshot der laufenden VM (aria-vm screenshot → PNG in
|
||||
/shared/uploads) und liefert ihn als Base64 zurueck. So sieht Stefan den
|
||||
VM-Bildschirm auch ohne Live-VNC (genau wie ARIA es beim Testen macht)."""
|
||||
import base64
|
||||
import time as _t
|
||||
rc, out, err = _ssh_aria_vm("screenshot", name, timeout=30)
|
||||
if rc != 0:
|
||||
raise HTTPException(status_code=400, detail=f"Screenshot fehlgeschlagen: {(err or out).strip()[:200]}")
|
||||
path = ""
|
||||
for line in out.splitlines():
|
||||
if line.startswith("screenshot="):
|
||||
path = line.split("=", 1)[1].strip()
|
||||
if not path:
|
||||
raise HTTPException(status_code=500, detail=f"Kein Screenshot-Pfad: {out.strip()[:200]}")
|
||||
local = os.path.join("/shared/uploads", os.path.basename(path))
|
||||
for _ in range(10): # kurze Bind-Mount-Latenz abfangen
|
||||
if os.path.isfile(local):
|
||||
break
|
||||
_t.sleep(0.2)
|
||||
if not os.path.isfile(local):
|
||||
raise HTTPException(status_code=500, detail=f"Screenshot-Datei nicht gefunden: {local}")
|
||||
with open(local, "rb") as f:
|
||||
data = f.read()
|
||||
return {"ok": True, "name": name, "filename": os.path.basename(local),
|
||||
"base64": base64.b64encode(data).decode("ascii")}
|
||||
|
||||
|
||||
@app.get("/conversation/stats")
|
||||
def conversation_stats():
|
||||
return conversation().stats()
|
||||
|
||||
Reference in New Issue
Block a user