Files
aevolution/docs/engineering/CLIENT_UI_STATE.md
T

8.2 KiB

M9.8b/c UI state, launcher and event bounds

Cellular v10 application state

apps/evo-client/cellular_play.hpp owns toolkit-independent presentation state: the current owner life/offer, latest death notice, one outstanding discrete action, and at most eight completed or unresolved records. It never changes biology. Receipts are admission only; outcomes settle a request. A refused retry cannot disprove a lost original reply. Mutation not_ready may mean an uncertain durable reservation, so it remains unresolved. IDs never wrap; stale offers, dead lives, unfresh sessions and duplicate clicks cannot submit new choices.

Reconnect drops the offer until a fresh owner view, cancels unsent queued actions, and retains sent requests for reconciliation. Life changes cannot carry a queued action to the new life. Delayed final replies can update retained unknown records. New lives receive new birth request IDs; retries of an outstanding birth keep its ID. Death messages are deduplicated so a retained notice cannot end a later life. Meaningful engulf/bud diagnostics retain their observed tick and reset on life change. UI does not infer action success from a receipt, empty view or vanished offer.

cellular_controls.hpp selects only stocked patches in observed contact, scales movement intentions for speed/precision/food assistance, and compares every mutation cost channel with the displayed reserve. cellular_scene.hpp renders each patch in at most three clipped rectangles; the application reserves that worst-case budget before drawing organisms. No dependency or simulation rule changes.

The v10 panels consume this state and return actions; the app owns session sends. Cell/Food/Log tabs and a separate Evolution panel replace the default engineering panels in cellular mode. A narrow viewport moves evolution to a Life tab. Log can show the existing engineering panels. The existing platform adapter owns the palette, rounded geometry, embedded font and input capture. client-ui-model, client-remote-session and client-panels exercise state, loopback v10 delivery, production widget clicks, duplicate suppression and bounded layout under NDEBUG.

evo-client-panel-tests OUTPUT_DIRECTORY additionally saves actual rendered review BMPs at 640x480, 960x640 and 1280x800, including the death screen; those use explicit test presentation values and are not evidence of a live DEV playtest.

Owned, toolkit-independent state; all calls on the client main thread. No authority or simulation state. Time is explicit monotonic milliseconds supplied by the host.

Notifications: at most eight, text at most 240 bytes; reject invalid/oversized input, expire by deadline, dismiss by unique id. Overflow evicts oldest and increments a visible saturating counter. Notifications are not durable outcome history. Dialogs: one active modal, title at most 96 bytes and body at most 240; opening a second fails. Close requires the matching id so a stale click cannot close a newer dialog. IDs never wrap. No credentials or grant bytes enter display messages.

SessionClient keeps at most 1024 queued ClientEvents. At 766 regular events it emits a local backpressure event, disconnects, and has room for loss plus 256 unknown intentions. It preserves all previously queued events and pauses reconnect until take_events drains the queue. This is a local condition, not a protocol change. Unprocessed wire outcomes remain unknown, never assumed failed or committed.

The native adapter's externally requested capture cannot be disabled by the legacy Tab toggle. Releasing capture drains already queued input before new world actions. M9.8c renders these through the toolkit overlay (below).

M9.8c launcher, selection and panels

Toolkit-independent models (src/client/ui, tested by client-ui-model):

  • Launcher (launcher.hpp): phases choosing, fixture, connecting, connected, failed. Fields are at most 1024 bytes; endpoint is host:port with port 1-65535. Files are read only when Connect is pressed: the CA at most 64 KiB and PEM-shaped, the grant bundle 1-64 whole 108-byte records. Nothing is persisted; material lives only in the session client. Errors are an enum with fixed text that never contains paths or file bytes. Before the first Welcome, three losses (including refused TCP/TLS attempts, counted by SessionClient::unreachable_attempts()) fail as unreachable; a refused grant or exhausted bundle fails at once. Failed offers Retry/Cancel; Cancel drops the session (its unresolved intentions become unknown).
  • Selection (selection.hpp): topmost organism under the click, else the habitat cell, else none. A selected organism absent from the latest view is cleared; with no view at all the selection is kept but shows nothing.
  • Labels (labels.hpp): value, present zero, missing (requested, no value), not requested and undefined moisture are distinct kinds and texts. Freshness is printed as current, stale or none.
  • Outcome log (outcome_log.hpp): last 64 intentions by sequence with sent, admitted, rejected, durable, not committed or unknown. It is the visible record; notifications are not.

Native adapter (Application): toolkit events are processed first. Keyboard focus in a widget (reported by the toolkit's last frame) captures world keys. Pointer ownership is resolved per event against the panel rectangles retained from the last frame (and any open popup), so a move onto a panel followed by a press or wheel in the same SDL batch never reaches the world; a press that begins on a panel owns the button until release. After a press on a panel, world key-downs in the same batch are dropped (releases still pass) because that press may focus a text field before the toolkit can report it; those keys need a fresh press. A click is a left press and release within 4 pixels, both outside any panel. Capture changes from toolkit focus release world actions and require fresh presses. External capture (launcher, modal) and the Tab toggle are independent: Tab is ignored while external capture holds, and an external release (sent every host frame outside a modal) does not cancel the toggle. The overlay callback runs after world drawing; request_screenshot saves the next frame as BMP (engineering review). Toolkit settings files and logs are disabled (IniFilename/LogFilename null).

Host ownership (session_host.hpp): the launcher phase and the remote session change together. Entering the local fixture, Cancel, Disconnect or a launcher failure drops the session at once (unresolved intentions become unknown); the session is serviced, and intentions sent, only while connecting or connected, so nothing runs behind a LOCAL FIXTURE banner. Retry opens a new session.

Notices (app panels): newest at the bottom right, at most 320 logical pixels wide (narrower viewports shrink them), text wrapped beside a reserved close column. The stack stops at 60 % of the viewport height and shows how many notices are not drawn and how many were discarded. client-panels renders the production panels through the adapter and checks notice geometry and close-button dismissal.

M9.8d controls panel

Opened from the launcher ("Controls...") or the mode banner. While open the host keeps UI capture on, so neither keys nor clicks reach the world. Each slot button arms adapter key capture for that slot (other buttons disabled); Escape or "Cancel capture" ends it without a change, focus loss cancels it. A conflicting or unbindable key is refused with fixed text naming the other action; the draft is unchanged. Apply validates the whole set, installs it (held actions released) and saves; Reset defaults and Cancel only change the draft/close. A save failure leaves the bindings active for the session with a warning notice. The Legend hint lists the keys in force. client-panels checks the panel geometry and that a slot click requests capture without a world click.

Capture and toolkit (M9.8d review): arming binding capture clears the toolkit's held keys/modifiers and its queued keyboard/text input; every chosen key is consumed until its own release (repeats, text, release), across successive captures; focus loss frees them all. With no overlay or a paused window the adapter still runs idle toolkit frames; more than 512 queued toolkit events are dropped with all toolkit keys/buttons released.