Skip to content

Commit 7a8f1c6

Browse files
committed
feat(ui): scaffold embedded reflex ui config
1 parent 8b28757 commit 7a8f1c6

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

src/orb/ui/rxconfig.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""Reflex configuration for the ORB UI (packaged copy).
2+
3+
This file ships inside the ``orb`` wheel at ``orb/ui/rxconfig.py`` so that
4+
``reflex run`` can find it when the package is installed from PyPI. The
5+
embedded-UI runtime (``run_embedded_foreground``) sets ``cwd`` to the
6+
directory that contains this file before exec-ing ``reflex run``.
7+
8+
A thin re-export at the repository root (``rxconfig.py``) delegates here so
9+
that ``reflex run`` from the repo root continues to work for local
10+
development.
11+
12+
Note: ``reflex`` is an optional dependency (the ``[ui]`` extra). This
13+
module must remain importable even when reflex is not installed so that
14+
pyright and other static-analysis passes that run without the UI extra do
15+
not raise ImportError. The ``rx.Config`` block is only evaluated when
16+
reflex is actually importable (i.e. at runtime with the [ui] extra or under
17+
``reflex run``).
18+
19+
# Note: pass --no-ssr when running ``reflex run`` / ``reflex export``.
20+
# The vaul drawer used in detail panels reads ``document`` at module
21+
# scope and crashes the React-Router node-side prerender. ``orb server
22+
# start`` already passes this flag automatically when ``ui.enabled``.
23+
"""
24+
25+
from __future__ import annotations
26+
27+
import os
28+
29+
# Toggle UI features via env so the same config file works for embedded
30+
# and remote modes.
31+
_ORB_UI_BACKEND_PORT = int(os.getenv("ORB_UI_BACKEND_PORT", "8001"))
32+
_ORB_UI_FRONTEND_PORT = int(os.getenv("ORB_UI_FRONTEND_PORT", "3000"))
33+
34+
try:
35+
import reflex as rx # pyright: ignore[reportMissingImports]
36+
37+
config = rx.Config(
38+
# Reflex resolves the app via this dotted module path; it imports
39+
# ``orb.ui.app`` and looks for a top-level ``app`` (rx.App instance).
40+
# ``app_name`` must match ^[a-zA-Z][a-zA-Z0-9_]*$ (Reflex requirement).
41+
# The actual dotted import path is ``app_module_import`` below.
42+
app_name="orb_ui",
43+
app_module_import="orb.ui.app",
44+
backend_port=_ORB_UI_BACKEND_PORT,
45+
frontend_port=_ORB_UI_FRONTEND_PORT,
46+
plugins=[
47+
rx.plugins.SitemapPlugin(),
48+
rx.plugins.TailwindV4Plugin(),
49+
rx.plugins.RadixThemesPlugin(
50+
theme=rx.theme(appearance="light", accent_color="blue", radius="medium"),
51+
),
52+
],
53+
)
54+
except ImportError:
55+
# reflex is not installed (CI lane without the [ui] extra, pyright, etc.).
56+
# ``config`` is left undefined; this file is only executed at runtime by
57+
# ``reflex run`` which requires the [ui] extra to be present.
58+
pass

0 commit comments

Comments
 (0)