Bound engineering UI state and session events for M9.8b

This commit is contained in:
dingo
2026-10-02 08:22:25 -04:00
parent 22c7c341ce
commit a6e8094f57
20 changed files with 327 additions and 19 deletions
+1
View File
@@ -43,6 +43,7 @@ class Application {
[[nodiscard]] WindowState state() const noexcept;
[[nodiscard]] std::expected<void, Error> poll_events();
[[nodiscard]] std::expected<Step, Error> present(const render::Frame& frame);
// 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;
[[nodiscard]] Navigation take_navigation() noexcept;
+49
View File
@@ -0,0 +1,49 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <expected>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <vector>
namespace evo::client {
enum class UiError : std::uint8_t { invalid, stale_time, busy, exhausted };
enum class NoticeLevel : std::uint8_t { info, warning, error };
struct Notice {
std::uint64_t id{}, expires_at_ms{};
NoticeLevel level{};
std::string text;
};
struct Dialog {
std::uint64_t id{};
std::string title, body;
};
// Main-thread, bounded presentation state. Never store credentials or authority here.
class UiState {
public:
static constexpr std::size_t max_notices = 8, max_text = 240, max_title = 96;
[[nodiscard]] std::expected<void, UiError> advance(std::uint64_t now_ms);
[[nodiscard]] std::expected<std::uint64_t, UiError>
notify(std::string_view text, NoticeLevel level, std::uint64_t lifetime_ms = 5000);
[[nodiscard]] bool dismiss(std::uint64_t id);
[[nodiscard]] std::expected<std::uint64_t, UiError> open_dialog(std::string_view title,
std::string_view body);
[[nodiscard]] bool close_dialog(std::uint64_t id);
[[nodiscard]] std::span<const Notice> notices() const noexcept {
return notices_;
}
[[nodiscard]] const std::optional<Dialog>& dialog() const noexcept {
return dialog_;
}
[[nodiscard]] std::uint64_t evicted_notices() const noexcept {
return evicted_;
}
private:
std::uint64_t now_{}, next_id_{1}, evicted_{};
std::vector<Notice> notices_;
std::optional<Dialog> dialog_;
};
} // namespace evo::client
+8 -6
View File
@@ -37,11 +37,12 @@ struct ClientEvent {
enum class Kind : std::uint8_t {
welcome,
closed,
lost, // Transport/TLS failure or deadline: no Close received.
result, // IntentResult.
outcome, // IntentOutcome (durable or not committed).
unknown, // Admitted intention whose outcome died with its connection.
exhausted // No grants left; reconnection stops.
lost, // Transport/TLS failure or deadline: no Close received.
result, // IntentResult.
outcome, // IntentOutcome (durable or not committed).
unknown, // Sent intention whose outcome died with its connection.
backpressure, // Local event backlog: reconnect waits for take_events().
exhausted // No grants left; reconnection stops.
} kind{};
Welcome welcome{};
CloseReason reason{};
@@ -52,7 +53,7 @@ struct ClientEvent {
enum class SessionClientError : std::uint8_t { configuration };
class SessionClient {
public:
static constexpr std::size_t max_outstanding = 256;
static constexpr std::size_t max_outstanding = 256, max_events = 1024;
[[nodiscard]] static std::expected<std::unique_ptr<SessionClient>, SessionClientError>
create(SessionClientConfig config);
SessionClient(const SessionClient&) = delete;
@@ -69,6 +70,7 @@ 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;
// Drains at most max_events and resumes reconnect after local backpressure.
[[nodiscard]] std::vector<ClientEvent> take_events();
private: