41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
"""Handles "show the admin canvas" requests on this thin client.
|
|
|
|
Sibling of digest_canvas.py (docs/project-plan.md Phase 13), for the sys-admin-llm's
|
|
on-demand display surface instead of digest-engine's scheduled one. This module is
|
|
deliberately even simpler than DigestCanvas: there is no detail level, no person, no
|
|
presence resolution of any kind for it to get wrong — the MQTT payload that triggers
|
|
`show()` is never even inspected. Every call opens the exact same fixed,
|
|
locally-configured URL; whatever is currently on that page is entirely admin-canvas's
|
|
concern (see admin-canvas/README.md), never this agent's.
|
|
|
|
SECURITY BOUNDARY, same invariant as digest_canvas.py's: this module never accepts a
|
|
URL, path, or any other value from its own inbound payload. ADMIN_WEB_URL is a local
|
|
config value set at image-build/deploy time, not something MQTT can influence.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from .sway_control import WS_ADMIN, SwayControl
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
BROWSER_COMMAND = "/usr/local/bin/admin-browser"
|
|
|
|
|
|
class AdminCanvas:
|
|
def __init__(self, sway: SwayControl, admin_web_url: str):
|
|
self.sway = sway
|
|
self.admin_web_url = (admin_web_url or "").rstrip("/")
|
|
|
|
def show(self) -> None:
|
|
if not self.admin_web_url:
|
|
log.error("ADMIN_WEB_URL is not configured; cannot show the admin canvas")
|
|
return
|
|
|
|
url = f"{self.admin_web_url}/canvas.html"
|
|
log.info("showing admin canvas")
|
|
self.sway.switch_workspace(WS_ADMIN)
|
|
self.sway.open_url(url, browser_command=BROWSER_COMMAND)
|