yera.ui.server
Run Yera apps through the local browser UI.
The server owns live app runtimes, event routers, persisted session history, SSE publication, and the FastAPI application. HTTP route modules receive narrow callbacks rather than the server itself, keeping transport concerns separate from execution and persistence.
Symbols
ServerLaunchConfig
Configure behavior when entering a Yera server.
Fields
App to launch immediately when the root URL is opened,
or None to redirect to app discovery.
Methods
ServerLaunchConfig.__init__
__init__(
startup_app_id: str | None = None,
) → NoneYeraServer
uvicorn.ServerCoordinate app execution, persistence, event rendering, and HTTP delivery.
Each live session owns an executor, event stream, browser publisher, and router task. Output events are rendered into HTMX fragments and persisted before publication. Submitted input is correlated with the active request, validated, redacted for storage when necessary, and then returned to the app's event stream.
Stored sessions can be replayed without executing their app again. Server startup marks sessions that could not survive a previous process exit as interrupted, while shutdown stops active executors and wakes blocked router threads.
Methods
YeraServer.__init__
__init__(
apps: Mapping[str, AppReference],
executor_factory: Callable[[AppFunctionWrapper, tuple, dict, str], PyRuntimeExecutor] | None = None,
session_store: BaseSessionStore | None = None,
launch_config: ServerLaunchConfig | None = None,
update_service: UpdateService | None = None,
host: str = '127.0.0.1',
port: int = 8000,
server_socket: socket.socket | None = None,
)Configure a local Yera UI server.
The server copies the supplied app registry, creates a session store when none is provided, and builds a FastAPI application from route registrars bound to its capabilities. App execution does not begin until a session is launched.
Parameters
Applications available to the UI, keyed by stable app ID.
Optional factory used to construct an executor for a newly launched session.
Persistent session store. Defaults to a local SQLite store.
Initial navigation and startup-app behavior.
Optional service that checks for a newer Yera release in the background.
Network interface on which the local server listens.
TCP port on which the local server listens.
Optional pre-bound socket supplied by the terminal launcher to make port selection race-safe.
Raises
If launch_config names an app absent from apps.
YeraServer.handle_exit
handle_exit(
sig: int,
frame: FrameType | None,
) → NoneHandles server exit signals by stopping all active session executors.
Parameters
The signal number.
The current stack frame.
YeraServer.__aenter__
__aenter__() → YeraServerOpen persistence and start serving the local UI.
Startup initializes the session database, marks persisted running or
waiting sessions as interrupted because their former process cannot
resume them, and starts the optional release check in the background.
The method waits until Uvicorn reports that it is serving.
Returns
The running Yera server.
Raises
If the server exits before it finishes starting.
YeraServer.__aexit__
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) → NoneStop live runtimes and close server-owned resources.
Shutdown signals every router, closes its event stream, stops its executor, and closes its publisher. Remaining live lifecycle states are persisted as interrupted before the session store and router thread pool are released.
Parameters
Exception type if an error occurred.
Exception value if an error occurred.
Traceback if an error occurred.