Files
ai-agent/backend/users/branding.py
gabrielvidalandClaude Opus 5.5 cb6b4f9412 feat(guests): ai-agent.gabvdl.xyz, and a proper home-screen install
The guest surface moves to ai-agent.gabvdl.xyz (claude.lab redirects there)
and drops the « Claude » name: on the guest host the backend serves the
manifest and index.html as « ai-agent » (users/branding.py, name/lang per
browser). PNG icons for the home screen — iOS takes only
apple-touch-icon.png, Android the 192/512 + a full-bleed maskable one.
The MCP server's default public URL, the reachability probe and the docs
follow the new host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:35:14 +01:00

45 lines
1.9 KiB
Python

"""What the guest surface calls the app — its install manifest and its page
title — in place of the owner build's (« Claude Agent — context viewer »).
One frontend build serves both hosts, so the guest host rewrites the two
files a phone reads when it adds the app to its home screen: the manifest
(name, short name, description, language) and ``index.html``'s ``<title>``
and ``apple-mobile-web-app-title`` (what iOS proposes as the icon's label).
Icons, colours, scope and share target stay the build's.
"""
from __future__ import annotations
import json
import os
import re
from core.i18n import tr
# The full name (manifest ``name``, the tab title) and the label under the
# home-screen icon (``short_name``). APP_NAME is the mails' name too.
GUEST_APP_NAME = os.environ.get("GUEST_APP_NAME") or os.environ.get("APP_NAME") or "ai-agent"
GUEST_APP_SHORT_NAME = os.environ.get("GUEST_APP_SHORT_NAME") or "ai-agent"
def guest_manifest(raw: str, lang: str) -> str:
"""The build's manifest as the guest surface serves it, in ``lang``."""
m = json.loads(raw)
m.update(name=GUEST_APP_NAME, short_name=GUEST_APP_SHORT_NAME, lang=lang,
description=tr(lang, "Start, follow and steer your coding-agent "
"conversations from your phone."))
return json.dumps(m, ensure_ascii=False)
def guest_index(html: str, lang: str) -> str:
"""The build's ``index.html`` as the guest surface serves it."""
html = re.sub(r"<title>[^<]*</title>", f"<title>{_esc(GUEST_APP_NAME)}</title>", html, count=1)
html = re.sub(r'(<meta name="apple-mobile-web-app-title" content=")[^"]*(")',
lambda mt: mt.group(1) + _esc(GUEST_APP_SHORT_NAME) + mt.group(2), html, count=1)
return re.sub(r'<html lang="[^"]*"', f'<html lang="{lang}"', html, count=1)
def _esc(s: str) -> str:
return (s or "").replace("&", "&amp;").replace("<", "&lt;") \
.replace(">", "&gt;").replace('"', "&quot;")