fix(chat): handle missing branding dir and full-width layout

Create optional _local/branding directory at startup to avoid StaticFiles FileNotFoundError, and force standalone chat root containers to occupy full width.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-09 14:53:30 +08:00
parent 38de5a305f
commit 04050747ae
2 changed files with 15 additions and 0 deletions

View file

@ -236,6 +236,12 @@ async def _lifespan(app: FastAPI): # type: ignore[no-untyped-def]
def create_app() -> FastAPI:
app = FastAPI(title="ops-gateway", version="0.1", lifespan=_lifespan)
brand_assets_dir = (Path(PROJECT_ROOT) / "_local" / "branding").resolve()
try:
brand_assets_dir.mkdir(parents=True, exist_ok=True)
except Exception:
# Branding assets are optional; if we can't create the directory (permissions),
# the static mount should still be safe when empty.
pass
app.mount("/admin/brand-assets", StaticFiles(directory=str(brand_assets_dir), check_dir=False), name="admin-brand-assets")
app.mount("/admin/assets", StaticFiles(directory=str(admin_static_dir())), name="admin-assets")
app.include_router(build_admin_router())