"""Shared HTML layout for the internal web UI.""" from __future__ import annotations import os from webui.nav import NAV_GROUPS MVP_NOTICE = ( "Read-only MVP — Gitea, MCP tools, and canonical workflows remain the " "source of truth. No mutation endpoints." ) # Canonical docs entry point surfaced from the shell header (#638). DOCS_URL = ( "https://gitea.prgs.cc/Scaled-Tech-Consulting/Gitea-Tools/src/branch/" "master/docs/webui-local-dev.md" ) _LOCAL_HOSTS = frozenset({"", "127.0.0.1", "localhost", "::1"}) def environment_label() -> str: """Classify the serving environment as ``local`` or ``remote`` (#638). Derived from the same ``WEBUI_HOST`` default the app binds to; loopback hosts are ``local``, anything else is ``remote``. Read-only signal only. """ host = (os.environ.get("WEBUI_HOST", "127.0.0.1") or "").strip().lower() return "local" if host in _LOCAL_HOSTS else "remote" def _render_nav() -> str: groups_html = [] for group in NAV_GROUPS: links = "".join( f'{item.label}' for item in group.items ) groups_html.append( '" ) return "".join(groups_html) def _render_badges() -> str: env = environment_label() return ( '
' f'env: {env}' 'mode: read-only' f'Docs' "
" ) def render_page(*, title: str, body_html: str, extra_head: str = "") -> str: nav_links = _render_nav() header_badges = _render_badges() return f""" {title} · MCP Control Plane {extra_head}

MCP Control Plane

{header_badges}

{MVP_NOTICE}

{body_html}
"""