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

@ -9,6 +9,11 @@
<link rel="stylesheet" href="/admin/assets/theme-deepseek.css" />
<link rel="stylesheet" href="/admin/assets/theme-presets.css" />
<style>
html,
body {
width: 100%;
min-width: 100%;
}
body.theme-ds-body.chat-standalone-page {
margin: 0;
min-height: 100vh;
@ -24,6 +29,8 @@
flex-direction: column;
padding: 0;
box-sizing: border-box;
width: 100%;
min-width: 100%;
}
.chat-app--login {
flex: 1;
@ -37,6 +44,8 @@
#app .chat-layout {
flex: 1;
min-height: 0;
width: 100%;
min-width: 100%;
}
.chat-sess-row {
display: flex;

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())