Add M9.8c launcher, legend, labelled inspector and click selection

Toolkit-independent launcher, selection, label and outcome-log models with
bounded inputs and fixed error text; Dear ImGui overlay in the native adapter
with toolkit-first event routing and capture; engineering panels for fixture vs
dev region, legend, inspector, session outcomes, notices and dialog. Additive
SessionClient::unreachable_attempts() bounds unreachable connects. Docs, CI
targets and validation evidence updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-02 10:09:11 -04:00
co-authored by Claude Opus 5.5
parent a6e8094f57
commit 897055883a
36 changed files with 2106 additions and 200 deletions
+10
View File
@@ -3,6 +3,7 @@
#include "evo/render/frame.hpp"
#include <cstdint>
#include <expected>
#include <functional>
#include <memory>
#include <string>
@@ -32,6 +33,10 @@ struct WindowState {
logical_height > 0 && pixel_width > 0 && pixel_height > 0;
}
};
// Engineering UI callback, run once per rendered frame on the main thread after the
// immutable frame is drawn. It may call the private toolkit (ADR-0084); no toolkit
// type appears in this header.
using Overlay = std::function<void()>;
// One owner, process main thread only (including destruction). No SDL owner may coexist.
class Application {
public:
@@ -46,6 +51,11 @@ class Application {
// External modal/widget capture cannot be disabled by the legacy Tab toggle.
void set_ui_capture(bool captured) noexcept;
[[nodiscard]] bool ui_captured() const noexcept;
void set_overlay(Overlay overlay);
// The toolkit held the pointer during the last poll (no world click, pan or zoom).
[[nodiscard]] bool ui_wants_pointer() const noexcept;
// Engineering visual review: the next rendered frame is saved as a BMP file.
[[nodiscard]] bool request_screenshot(std::string path);
[[nodiscard]] Navigation take_navigation() noexcept;
[[nodiscard]] std::expected<Intention, InputError> sample_intention(std::uint64_t tick);
// Borrows the immutable frame for this call only. Errors latch until destruction.
+6
View File
@@ -22,6 +22,9 @@ struct Navigation {
int x{}, y{};
double wheel{};
ScreenPoint pointer{};
// One primary click on the world (press and release, not taken by the UI), consumed
// once. Used for presentation selection only; never an authoritative command.
std::optional<ScreenPoint> click;
};
// Main-thread value state; no event queue or authoritative position.
class InputState {
@@ -39,6 +42,8 @@ class InputState {
[[nodiscard]] std::expected<void, InputError> key(Key key, bool down, bool repeat = false);
[[nodiscard]] std::expected<void, InputError> pointer(ScreenPoint point);
[[nodiscard]] std::expected<void, InputError> wheel(double steps);
// Records a world click while input is admitted and not captured; otherwise ignored.
[[nodiscard]] std::expected<void, InputError> click(ScreenPoint point);
[[nodiscard]] Navigation take_navigation() noexcept;
[[nodiscard]] std::expected<Intention, InputError> sample(std::uint64_t tick);
@@ -48,6 +53,7 @@ class InputState {
bool admitted_{false}, captured_{false};
ScreenPoint pointer_{};
double wheel_{};
std::optional<ScreenPoint> click_;
std::uint64_t sequence_{};
std::optional<std::uint64_t> tick_;
};
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include "evo/client/environment_view.hpp"
#include "evo/client/organism_view.hpp"
#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
// M9.8c readable engineering labels (toolkit-independent). Text describes copied
// presentation values only; every distinct data state keeps a distinct description.
namespace evo::client {
enum class ValueKind : std::uint8_t { value, zero, missing, not_requested, undefined };
struct ValueText {
ValueKind kind{};
std::string text;
};
struct Row {
std::string label, value, unit;
};
[[nodiscard]] std::string_view field_name(world::Field field) noexcept;
[[nodiscard]] std::string_view field_unit(world::Field field) noexcept; // "fg" or "pJ"
[[nodiscard]] std::string_view freshness_name(Freshness freshness) noexcept;
// Present values give the quantity and its density per habitat volume; zero, missing,
// not requested and undefined each have their own wording (never "0" for missing).
[[nodiscard]] ValueText describe_field(const EnvironmentCell& cell, world::Field field);
[[nodiscard]] ValueText describe_moisture(const EnvironmentCell& cell);
// Labelled rows with units for the inspector. The opaque organism id is not shown.
[[nodiscard]] std::vector<Row> organism_rows(const OrganismCell& cell);
[[nodiscard]] std::vector<Row> cell_rows(const EnvironmentCell& cell);
// The density scale the renderer's ramp uses (log2 of unit per cubic micrometre).
[[nodiscard]] std::string density_scale(world::Field field);
} // namespace evo::client
+92
View File
@@ -0,0 +1,92 @@
#pragma once
#include <array>
#include <cstddef>
#include <cstdint>
#include <expected>
#include <string>
#include <string_view>
#include <vector>
// M9.8c launcher model (toolkit- and network-independent). Validates what the user
// typed, loads the two credential files within bounds, and tracks the connect flow.
// Error texts are fixed: they never contain file contents, grant bytes or keys, and
// nothing here is persisted or logged.
namespace evo::client {
inline constexpr std::size_t grant_record_bytes = 108; // network::dev_grant_bytes.
inline constexpr std::size_t max_grant_records = 64; // As issued by evo-dev-session.
inline constexpr std::size_t max_authority_bytes = 65536; // One small PEM CA.
inline constexpr std::size_t max_field_bytes = 1024; // Every text field.
using GrantRecord = std::array<std::uint8_t, grant_record_bytes>;
enum class LaunchError : std::uint8_t {
endpoint,
server_name,
authority_path,
grants_path,
authority_unreadable,
authority_invalid,
grants_unreadable,
grants_invalid,
grant_refused,
server_unreachable,
grants_exhausted,
no_session
};
[[nodiscard]] std::string_view launch_error_text(LaunchError error) noexcept;
struct ConnectForm {
std::string endpoint{"127.0.0.1:17400"}, server_name{"dev-region.evolution.test"};
std::string authority_path, grants_path;
};
struct Endpoint {
std::string host;
std::uint16_t port{};
};
struct ConnectMaterial {
Endpoint endpoint;
std::string server_name, authority_pem;
std::vector<GrantRecord> grants;
};
// "host:port", "[ipv6]:port" or "a.b.c.d:port"; plain DNS host names only.
[[nodiscard]] std::expected<Endpoint, LaunchError> parse_endpoint(std::string_view text);
[[nodiscard]] std::expected<ConnectMaterial, LaunchError> load_connect(const ConnectForm& form);
// What the session reports while connecting, reduced to what the launcher decides on.
enum class ConnectSignal : std::uint8_t {
welcome, // A session was opened.
lost, // Transport/TLS failure or deadline before a Close.
refused, // Closed as unauthenticated/expired/duplicate: this grant cannot work.
not_ready, // Closed as server_shutdown/capacity: the server will retry later.
exhausted // No unused grant remains.
};
enum class LaunchPhase : std::uint8_t { choosing, fixture, connecting, connected, failed };
class Launcher {
public:
static constexpr int max_attempts_without_welcome = 3;
void start_fixture() noexcept;
// From choosing or failed (retry). The caller then creates a fresh session.
[[nodiscard]] bool begin_connect() noexcept;
// Cancel returns to choosing from connecting, connected or failed; the caller
// drops its session. Fixture mode also returns to choosing.
void cancel() noexcept;
// Lost connections after a welcome are reconnects, not failures; before any
// welcome, repeated loss means the endpoint, name or CA is wrong.
void observe(ConnectSignal signal) noexcept;
void fail(LaunchError error) noexcept;
[[nodiscard]] LaunchPhase phase() const noexcept {
return phase_;
}
[[nodiscard]] LaunchError error() const noexcept {
return error_;
}
[[nodiscard]] bool ever_connected() const noexcept {
return welcomed_;
}
private:
LaunchPhase phase_{LaunchPhase::choosing};
LaunchError error_{LaunchError::no_session};
int losses_{};
bool welcomed_{};
};
} // namespace evo::client
+40
View File
@@ -0,0 +1,40 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <deque>
// M9.8c bounded intention history for the session panel (toolkit-independent). It is
// the inspectable record; notifications may expire, this keeps the latest entries.
// Values are copied from session events; nothing here is authority.
namespace evo::client {
enum class OutcomeState : std::uint8_t {
sent, // Queued to the server; no reply yet.
admitted, // Accepted for scheduling; not yet durable.
rejected, // IntentResult other than admitted (final).
durable, // Committed with no biological effect (final).
not_committed, // The carrying input was dropped (final).
unknown // The connection ended first; the outcome is not known (final).
};
struct OutcomeEntry {
std::uint64_t sequence{};
OutcomeState state{};
std::uint8_t detail{}; // IntentStatus code for rejections.
std::uint64_t tick{}, commit_sequence{}; // For durable outcomes.
};
class OutcomeLog {
public:
static constexpr std::size_t capacity = 64;
// Updates the entry for `sequence` (newest match) or appends one, evicting the oldest.
void record(OutcomeEntry entry);
[[nodiscard]] const std::deque<OutcomeEntry>& entries() const noexcept {
return entries_;
}
[[nodiscard]] std::uint64_t evicted() const noexcept {
return evicted_;
}
private:
std::deque<OutcomeEntry> entries_;
std::uint64_t evicted_{};
};
} // namespace evo::client
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#include "evo/client/camera.hpp"
#include "evo/client/environment_view.hpp"
#include "evo/client/organism_view.hpp"
#include <cstdint>
#include <optional>
// M9.8c click selection (toolkit-independent). Selection names a presentation item by
// key (organism id or voxel) and re-resolves it against each new presentation; it
// never holds pointers into presentations across frames and selects nothing in the
// world itself.
namespace evo::client {
class Selection {
public:
enum class Kind : std::uint8_t { none, organism, cell };
enum class Change : std::uint8_t { none, organism_gone, cell_gone };
// Topmost organism whose drawn body contains the point wins; otherwise the habitat
// cell whose voxel contains it; otherwise the selection clears.
void pick(ScreenPoint point, const EnvironmentPresentation* environment,
const OrganismPresentation* organisms, const Camera& camera);
// Clears when the selected item is absent from a present presentation. Without a
// presentation (no view yet, reconnecting) the selection is kept but not shown.
[[nodiscard]] Change refresh(const EnvironmentPresentation* environment,
const OrganismPresentation* organisms);
void clear() noexcept {
kind_ = Kind::none;
}
[[nodiscard]] Kind kind() const noexcept {
return kind_;
}
[[nodiscard]] const OrganismCell* organism(const OrganismPresentation* organisms) const;
[[nodiscard]] const EnvironmentCell* cell(const EnvironmentPresentation* environment) const;
private:
Kind kind_{Kind::none};
std::uint64_t organism_{};
world::VoxelAddress voxel_{};
};
} // namespace evo::client
+3
View File
@@ -70,6 +70,9 @@ class SessionClient {
[[nodiscard]] std::optional<Welcome> welcome() const noexcept;
[[nodiscard]] std::optional<ViewHeader> latest_view() const noexcept;
[[nodiscard]] std::size_t grants_left() const noexcept;
// Attempts that failed before any session event (TCP connect or TLS handshake), so a
// caller can bound "unreachable" without an event per retry. Never reset.
[[nodiscard]] std::uint64_t unreachable_attempts() const noexcept;
// Drains at most max_events and resumes reconnect after local backpressure.
[[nodiscard]] std::vector<ClientEvent> take_events();