client: skip used grants; scale the engineering UI with the window
Foundation / checks (deploy) (push) Successful in 3m26s
Foundation / checks (ecs) (push) Successful in 2m2s
Foundation / checks (client) (push) Successful in 12m47s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 11m44s
Foundation / checks (checks) (push) Canceled after 17m14s
Foundation / checks (postgres) (push) Canceled after 4m27s

- A stale_grant before Welcome spends only that grant: the session tries the next one
  in the bundle and ends as exhausted when none is left (other refusals still stop).
- UI scale (ADR-0084 amendment): embedded scalable font (ProggyForever), scale from
  logical window height (720 reference, 1.0-2.5) times a Ctrl+= / Ctrl+- nudge; panel
  sizes and table columns in logical units; movable panels placed again per scale.
- --size W,H for engineering review screenshots.
- Tests: client_remote_session (stale grant, exhausted), client_ui_state (scale).
Refresh the dev session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-09 12:09:57 -04:00
co-authored by Claude Opus 5.5
parent c468c70933
commit 3320a8a574
11 changed files with 200 additions and 37 deletions
+7 -1
View File
@@ -276,6 +276,12 @@ int main(int argc, char** argv) try {
scripted_pick = parse_point(argv[++i]);
if (!scripted_pick)
return 2;
} else if (arg == "--size" && i + 1 < argc) { // Initial window size, WIDTH,HEIGHT.
const auto size = parse_point(argv[++i]);
if (!size || size->x < 320 || size->y < 240)
return 2;
config.width = static_cast<int>(size->x);
config.height = static_cast<int>(size->y);
} else if (arg == "--screenshot" && i + 1 < argc) { // Last frame, as BMP.
screenshot = argv[++i];
} else if (arg == "--controls" && i + 1 < argc) {
@@ -286,7 +292,7 @@ int main(int argc, char** argv) try {
show_controls = true;
} else {
std::fputs("usage: evo-client [--version] [--renderer NAME] [--hidden] "
"[--frames 1..100000]\n"
"[--frames 1..100000] [--size W,H]\n"
" [--fixture | --connect HOST:PORT --server-name NAME "
"--ca FILE --grants FILE]\n"
" [--layer water|nitrogen|...|heat|moisture]\n"
+51 -32
View File
@@ -9,6 +9,18 @@
namespace evo::client_app {
namespace {
using client::LaunchPhase;
// Logical sizes at the current UI scale (window height and Ctrl+= / Ctrl+-).
float px(float v) {
return v * ImGui::GetStyle().FontScaleMain;
}
// A panel placed once (the user may move or resize it), and again at each new UI scale.
ImGuiCond placed(float& seen) {
const float scale = ImGui::GetStyle().FontScaleMain;
if (scale == seen)
return ImGuiCond_FirstUseEver;
seen = scale;
return ImGuiCond_Always;
}
ImVec4 color(render::Color c) {
return {static_cast<float>(c.red) / 255.0F, static_cast<float>(c.green) / 255.0F,
static_cast<float>(c.blue) / 255.0F, static_cast<float>(c.alpha) / 255.0F};
@@ -31,7 +43,7 @@ void row(const char* label, const std::string& value, const std::string& unit =
}
void swatch(const char* id, render::Color c, const char* label) {
ImGui::ColorButton(id, color(c), ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoAlpha,
{14, 14});
{px(14), px(14)});
ImGui::SameLine();
ImGui::TextUnformatted(label);
}
@@ -93,14 +105,14 @@ void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) {
const auto& io = ImGui::GetIO();
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, io.DisplaySize.y * 0.5F}, ImGuiCond_Always,
{0.5F, 0.5F});
ImGui::SetNextWindowSize({520, 0}, ImGuiCond_Always);
ImGui::SetNextWindowSize({std::min(px(520), io.DisplaySize.x - px(16)), 0}, ImGuiCond_Always);
ImGui::Begin("Aeternalis Evolution - engineering client", nullptr,
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
ImGui::TextWrapped("Choose a data source. Nothing here is a game or a player account.");
if (ImGui::SmallButton("Controls..."))
a.open_controls = true;
ImGui::Separator();
if (ImGui::Button("Local fixture", {160, 0}))
if (ImGui::Button("Local fixture", {px(160), 0}))
a.fixture = true;
ImGui::SameLine();
ImGui::TextWrapped("In-memory stand-in: environment changes and static organisms. Not a "
@@ -112,7 +124,7 @@ void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) {
ImGui::InputText("Server name", form.server_name.data(), form.server_name.size());
ImGui::InputText("Dev CA file", form.authority.data(), form.authority.size());
ImGui::InputText("Grant bundle file", form.grants.data(), form.grants.size());
const bool start = phase == LaunchPhase::choosing && ImGui::Button("Connect", {160, 0});
const bool start = phase == LaunchPhase::choosing && ImGui::Button("Connect", {px(160), 0});
ImGui::EndDisabled();
if (start)
a.connect = true;
@@ -122,15 +134,15 @@ void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) {
error_text(*v.form_error);
if (phase == LaunchPhase::connecting) {
ImGui::TextColored(amber, "Connecting (TLS handshake and grant check)...");
if (ImGui::Button("Cancel", {120, 0}))
if (ImGui::Button("Cancel", {px(120), 0}))
a.cancel = true;
}
if (phase == LaunchPhase::failed) {
error_text(v.launcher->error());
if (ImGui::Button("Retry", {120, 0}))
if (ImGui::Button("Retry", {px(120), 0}))
a.retry = true;
ImGui::SameLine();
if (ImGui::Button("Cancel", {120, 0}))
if (ImGui::Button("Cancel", {px(120), 0}))
a.cancel = true;
}
ImGui::TextDisabled("Files are read when you connect; nothing is saved.");
@@ -139,7 +151,7 @@ void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) {
void banner(const PanelView& v, PanelActions& a) {
const auto& io = ImGui::GetIO();
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, 4}, ImGuiCond_Always, {0.5F, 0});
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, px(4)}, ImGuiCond_Always, {0.5F, 0});
ImGui::Begin("##mode", nullptr,
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings);
@@ -166,8 +178,10 @@ void banner(const PanelView& v, PanelActions& a) {
}
void legend(const PanelView& v, render::EnvironmentDisplay& display) {
ImGui::SetNextWindowPos({8, 40}, ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize({300, 0}, ImGuiCond_FirstUseEver);
static float seen = 0;
const auto when = placed(seen);
ImGui::SetNextWindowPos({px(8), px(40)}, when);
ImGui::SetNextWindowSize({px(300), 0}, when);
ImGui::Begin("Legend");
int current = display.mode == render::EnvironmentDisplay::Mode::moisture
? static_cast<int>(world::field_count)
@@ -213,8 +227,10 @@ void legend(const PanelView& v, render::EnvironmentDisplay& display) {
void inspector(const PanelView& v) {
const auto& io = ImGui::GetIO();
ImGui::SetNextWindowPos({io.DisplaySize.x - 8, 40}, ImGuiCond_FirstUseEver, {1, 0});
ImGui::SetNextWindowSize({420, 0}, ImGuiCond_FirstUseEver);
static float seen = 0;
const auto when = placed(seen);
ImGui::SetNextWindowPos({io.DisplaySize.x - px(8), px(40)}, when, {1, 0});
ImGui::SetNextWindowSize({px(420), 0}, when);
ImGui::Begin("Inspector");
const auto* env = v.environment ? v.environment->current() : nullptr;
const auto* orgs = v.organisms ? v.organisms->current() : nullptr;
@@ -235,7 +251,7 @@ void inspector(const PanelView& v) {
}
if (cell != nullptr && ImGui::BeginTable("fields", 2, ImGuiTableFlags_RowBg)) {
// Values wrap inside the column so missing/not-requested explanations stay readable.
ImGui::TableSetupColumn("field", ImGuiTableColumnFlags_WidthFixed, 150);
ImGui::TableSetupColumn("field", ImGuiTableColumnFlags_WidthFixed, px(150));
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch);
for (std::size_t k = 0; k < world::field_count; ++k) {
const auto field = static_cast<world::Field>(k);
@@ -274,7 +290,7 @@ void controls(const PanelView& v, PanelActions& a) {
const auto& io = ImGui::GetIO();
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, io.DisplaySize.y * 0.5F}, ImGuiCond_Always,
{0.5F, 0.5F});
ImGui::SetNextWindowSize({std::min(460.0F, io.DisplaySize.x - 16), 0}, ImGuiCond_Always);
ImGui::SetNextWindowSize({std::min(px(460), io.DisplaySize.x - px(16)), 0}, ImGuiCond_Always);
ImGui::Begin("Controls", nullptr,
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoSavedSettings);
@@ -282,8 +298,8 @@ void controls(const PanelView& v, PanelActions& a) {
"wheel (zoom) are fixed. Escape cancels a key capture.");
if (ImGui::BeginTable("bindings", 3, ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Primary", ImGuiTableColumnFlags_WidthFixed, 120);
ImGui::TableSetupColumn("Secondary", ImGuiTableColumnFlags_WidthFixed, 150);
ImGui::TableSetupColumn("Primary", ImGuiTableColumnFlags_WidthFixed, px(120));
ImGui::TableSetupColumn("Secondary", ImGuiTableColumnFlags_WidthFixed, px(150));
ImGui::TableHeadersRow();
for (std::size_t k = 0; k < client::action_count; ++k) {
const auto action = static_cast<client::Action>(k);
@@ -299,7 +315,7 @@ void controls(const PanelView& v, PanelActions& a) {
(v.capturing == here ? std::string{"Press a key"} : key_label(key)) + "##" +
std::to_string(k) + (secondary ? "s" : "p");
ImGui::BeginDisabled(v.capturing.has_value());
if (ImGui::Button(label.c_str(), {100, 0}))
if (ImGui::Button(label.c_str(), {px(100), 0}))
a.capture_key = here;
if (secondary && key != client::no_key) {
ImGui::SameLine();
@@ -314,7 +330,7 @@ void controls(const PanelView& v, PanelActions& a) {
if (v.capturing) {
ImGui::TextColored(amber, "Press a key for %s (Escape cancels).",
std::string{client::action_name(v.capturing->action)}.c_str());
if (ImGui::Button("Cancel capture", {140, 0}))
if (ImGui::Button("Cancel capture", {px(140), 0}))
a.cancel_capture = true;
}
if (v.controls_problem) {
@@ -323,13 +339,13 @@ void controls(const PanelView& v, PanelActions& a) {
ImGui::PopStyleColor();
}
ImGui::BeginDisabled(v.capturing.has_value());
if (ImGui::Button("Apply", {100, 0}))
if (ImGui::Button("Apply", {px(100), 0}))
a.apply_controls = true;
ImGui::SameLine();
if (ImGui::Button("Reset defaults", {130, 0}))
if (ImGui::Button("Reset defaults", {px(130), 0}))
a.reset_controls = true;
ImGui::SameLine();
if (ImGui::Button("Cancel", {100, 0}))
if (ImGui::Button("Cancel", {px(100), 0}))
a.close_controls = true;
ImGui::EndDisabled();
ImGui::End();
@@ -339,8 +355,10 @@ void session(const PanelView& v) {
if (!v.remote)
return;
const auto& io = ImGui::GetIO();
ImGui::SetNextWindowPos({8, io.DisplaySize.y - 8}, ImGuiCond_FirstUseEver, {0, 1});
ImGui::SetNextWindowSize({360, 0}, ImGuiCond_FirstUseEver);
static float seen = 0;
const auto when = placed(seen);
ImGui::SetNextWindowPos({px(8), io.DisplaySize.y - px(8)}, when, {0, 1});
ImGui::SetNextWindowSize({px(360), 0}, when);
ImGui::Begin("Session");
const auto& s = *v.remote;
if (ImGui::BeginTable("status", 3, ImGuiTableFlags_SizingFixedFit)) {
@@ -406,9 +424,9 @@ void session(const PanelView& v) {
// once space frees). Notices are not the outcome record (Session panel is).
void notices(const PanelView& v, PanelActions& a) {
const auto& io = ImGui::GetIO();
const float width = std::min(notice_width, io.DisplaySize.x - 16);
const float width = std::min(px(notice_width), io.DisplaySize.x - px(16));
const float top = io.DisplaySize.y * 0.4F;
float y = io.DisplaySize.y - 8;
float y = io.DisplaySize.y - px(8);
const auto list = v.ui->notices();
std::size_t hidden = 0;
for (auto it = list.rbegin(); it != list.rend(); ++it) {
@@ -417,7 +435,7 @@ void notices(const PanelView& v, PanelActions& a) {
++hidden;
continue;
}
ImGui::SetNextWindowPos({io.DisplaySize.x - 8, y}, ImGuiCond_Always, {1, 1});
ImGui::SetNextWindowPos({io.DisplaySize.x - px(8), y}, ImGuiCond_Always, {1, 1});
ImGui::SetNextWindowSize({width, 0}, ImGuiCond_Always);
const std::string id = notice_window_prefix + std::to_string(n.id);
ImGui::Begin(id.c_str(), nullptr,
@@ -425,7 +443,8 @@ void notices(const PanelView& v, PanelActions& a) {
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing);
if (ImGui::BeginTable("notice", 2)) {
ImGui::TableSetupColumn("text", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("close", ImGuiTableColumnFlags_WidthFixed, notice_close_width);
ImGui::TableSetupColumn("close", ImGuiTableColumnFlags_WidthFixed,
px(notice_close_width));
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_Text, n.level == client::NoticeLevel::error ? red
@@ -434,15 +453,15 @@ void notices(const PanelView& v, PanelActions& a) {
ImGui::TextWrapped("%s", n.text.c_str());
ImGui::PopStyleColor();
ImGui::TableNextColumn();
if (ImGui::Button(("x" + id).c_str(), {notice_close_width, 0}))
if (ImGui::Button(("x" + id).c_str(), {px(notice_close_width), 0}))
a.dismiss_notice = n.id;
ImGui::EndTable();
}
y -= ImGui::GetWindowHeight() + 4;
y -= ImGui::GetWindowHeight() + px(4);
ImGui::End();
}
if (v.ui->evicted_notices() > 0 || hidden > 0) {
ImGui::SetNextWindowPos({io.DisplaySize.x - 8, y}, ImGuiCond_Always, {1, 1});
ImGui::SetNextWindowPos({io.DisplaySize.x - px(8), y}, ImGuiCond_Always, {1, 1});
ImGui::Begin("##evicted", nullptr,
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing);
@@ -463,10 +482,10 @@ void dialog(const PanelView& v, PanelActions& a) {
ImGui::OpenPopup(id.c_str());
if (ImGui::BeginPopupModal(id.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextWrapped("%s", d->body.c_str());
if (ImGui::Button("Confirm", {120, 0}))
if (ImGui::Button("Confirm", {px(120), 0}))
a.confirm_dialog = d->id;
ImGui::SameLine();
if (ImGui::Button("Cancel", {120, 0}))
if (ImGui::Button("Cancel", {px(120), 0}))
a.cancel_dialog = d->id;
ImGui::EndPopup();
}
+7 -1
View File
@@ -609,7 +609,13 @@ class RemoteSession {
reason == SessionCloseReason::rate_limited ||
reason == SessionCloseReason::stale_epoch ||
(was_established && reason == SessionCloseReason::expired);
if (reason == SessionCloseReason::superseded) {
if (reason == SessionCloseReason::stale_grant && !was_established) {
// This grant (or a newer one) was already presented, by this or another client:
// only this grant is spent, so try the next one; an empty bundle ends as exhausted.
launcher.observe(client::ConnectSignal::not_ready);
notify(ui, "That grant was already used; trying the next one.",
client::NoticeLevel::info);
} else if (reason == SessionCloseReason::superseded) {
// Another client holds this account's newer grant: never fight it.
launcher.fail(client::LaunchError::grant_refused);
notify(ui, "Another client opened a session with this account.",