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
+34 -2
View File
@@ -1,4 +1,5 @@
#include "evo/client/application.hpp"
#include "evo/client/ui_state.hpp"
#include "render/sdl_renderer.hpp"
#define SDL_MAIN_HANDLED
#include <SDL3/SDL_main.h>
@@ -41,11 +42,26 @@ struct Toolkit {
auto& io = ImGui::GetIO();
io.IniFilename = nullptr; // Nothing is persisted (no paths, no window layout).
io.LogFilename = nullptr;
if (io.Fonts->AddFontDefaultBitmap() == nullptr)
// The embedded scalable font (ProggyForever, notices kept per ADR-0084): the UI
// scales with the window, which the bitmap font cannot do cleanly.
if (io.Fonts->AddFontDefaultVector() == nullptr)
return false;
base_style = ImGui::GetStyle();
platform = ImGui_ImplSDL3_InitForSDLRenderer(window, target);
return platform && attach_renderer(target);
}
// Applies a UI scale to sizes and fonts from the unscaled style, only when it changes.
void scale(float factor) {
if (factor == applied)
return;
auto& style = ImGui::GetStyle();
style = base_style;
style.ScaleAllSizes(factor);
style.FontScaleMain = factor;
applied = factor;
}
ImGuiStyle base_style;
float applied{1};
bool attach_renderer(SDL_Renderer* target) {
renderer = ImGui_ImplSDLRenderer3_Init(target);
return renderer;
@@ -120,7 +136,8 @@ struct Application::Impl {
std::string renderer_name;
WindowState state;
std::optional<Error> failure;
Toolkit toolkit; // After window/renderer: destroyed first.
Toolkit toolkit; // After window/renderer: destroyed first.
float ui_user{1}; // The user's UI scale nudge (Ctrl+= / Ctrl+-); not persisted.
Overlay overlay;
InputState input;
Bindings bindings{Bindings::defaults()};
@@ -322,6 +339,20 @@ std::expected<void, Error> Application::poll_events() {
}
continue;
}
// UI scale nudge, a view setting (Ctrl+= / Ctrl+-): consumed before the toolkit and
// the world, and its repeats and release with it.
if (keyboard && known && event.type == SDL_EVENT_KEY_DOWN &&
(event.key.mod & SDL_KMOD_CTRL) != 0) {
const auto k = event.key.key;
const int direction = k == SDLK_EQUALS || k == SDLK_PLUS || k == SDLK_KP_PLUS ? 1
: k == SDLK_MINUS || k == SDLK_KP_MINUS ? -1
: 0;
if (direction != 0) {
p.ui_user = client::ui_user_nudge(p.ui_user, direction);
p.owned_keys.set(code);
continue;
}
}
// Toolkit first: widgets see every event before world input is derived.
ImGui_ImplSDL3_ProcessEvent(&event);
if (event.type == SDL_EVENT_QUIT)
@@ -472,6 +503,7 @@ std::expected<Step, Error> Application::present(const render::Frame& frame) {
}
if (p.overlay) {
// Engineering UI over the immutable frame; the callback reads copies only.
p.toolkit.scale(client::ui_scale(p.state.logical_height, p.ui_user));
ImGui_ImplSDLRenderer3_NewFrame();
ImGui_ImplSDL3_NewFrame();
ImGui::NewFrame();
+16
View File
@@ -1,5 +1,6 @@
#include "evo/client/ui_state.hpp"
#include <algorithm>
#include <cmath>
#include <limits>
#include <utility>
namespace evo::client {
@@ -53,4 +54,19 @@ bool UiState::close_dialog(std::uint64_t id) {
dialog_.reset();
return true;
}
float ui_scale(int logical_height, float user) noexcept {
const auto clamp = [](float v, float lo, float hi) {
return !std::isfinite(v) || v <= 0 ? 1.0F : std::clamp(v, lo, hi);
};
const float window =
logical_height > 0 ? static_cast<float>(logical_height) / ui_reference_height : 1.0F;
return clamp(window, ui_window_min, ui_window_max) * clamp(user, ui_user_min, ui_user_max);
}
float ui_user_nudge(float user, int direction) noexcept {
const float base = !std::isfinite(user) || user <= 0 ? 1.0F : user;
const float tenths = std::round(base / ui_user_step) + static_cast<float>(direction);
return std::clamp(tenths * ui_user_step, ui_user_min, ui_user_max);
}
} // namespace evo::client