yera 0.11.1

yera.ui.session_runtime

Track the live execution and pending input state of one browser session.

A server runtime joins an app executor, its event stream, the browser fragment publisher, and the router task that connects them. It also owns the single pending input contract used to correlate and validate browser submissions before they reach the app.

Symbols

class ServerRuntime — Hold the in-process execution state for one persisted session.

ServerRuntime

Hold the in-process execution state for one persisted session.

A runtime begins inactive and gains an executor, event stream, publisher, and router task when the server launches its app. Persisted identity and history remain in the session store; this object contains only state that is meaningful inside the current server process.

The runtime permits one pending input request at a time. Incoming responses must match its request ID and data type, pass the request's JSON Schema, and use cancellation only when the request exposes a cancellation action. A lock protects this contract because router work and HTTP input handling run on different threads.

Attributes

id

Stable persisted session identifier.

app_id

Stable identifier of the app associated with the session.

executor
type: PyRuntimeExecutor | None

Active app executor, or None before launch.

publisher
type: Publisher | None

Browser-fragment publisher, or None before launch.

router_task
type: asyncio.Future | None

Future running the event router, or None before launch.

router_shutdown

Signal used to wake and stop router work during server shutdown.

Methods

__init__ — Initialize inactive runtime state for one app session.
recorded_input — Build the safe persisted copy of a submitted input event.

ServerRuntime.__init__

__init__(
    session_id: str,
    app_id: str,
) → None

Initialize inactive runtime state for one app session.

Parameters

session_id
type: str

Stable identifier used to address the UI session.

app_id
type: str

Identifier of the app executed by the session.

ServerRuntime.recorded_input

recorded_input(
    event: InputEvent,
) → InputEvent

Build the safe persisted copy of a submitted input event.

This method must run while the matching request is still pending, before validation consumes that pending state. Ordinary input is returned unchanged. For form input, fields marked writeOnly in the request schema are replaced with redacted values. Cancelled forms persist an empty object rather than any values sent alongside the cancellation.

The returned copy is intended only for session history. The original event is validated separately and delivered to the app unchanged.

Parameters

event
type: InputEvent

Input submitted for the currently pending request.

Returns

type: InputEvent

A persistence-safe copy of matching form input, or the original event when no form redaction applies.