fix(client): keep nutrient readouts on stable single-line rows

This commit is contained in:
dingo
2026-10-26 17:30:47 -04:00
parent 82d21e65b2
commit 7ca5f74f03
6 changed files with 136 additions and 16 deletions
+29 -11
View File
@@ -7,6 +7,7 @@
#include <cstdio>
#include <cstring>
#include <imgui.h>
#include <limits>
#include <string>
#include <string_view>
@@ -658,9 +659,20 @@ void dot(ImU32 color, bool hollow = false) {
// One table row: a nutrient's dot and name, a bar filled to `share`, and a value.
void nutrient_row(std::size_t channel, const char* name, float share, const std::string& value,
bool highlight = false, const std::string& tip = {}) {
// Quantities are readouts, not prose: wrapping one changes every later row's baseline.
ImGui::PushTextWrapPos(-1);
ImGui::TableNextRow();
ImGui::TableNextColumn();
dot(nutrient_colors.at(channel));
if (highlight) {
const auto at = ImGui::GetCursorScreenPos();
const float line = ImGui::GetTextLineHeight();
const float marker_width = ImGui::CalcTextSize("*").x;
ImGui::GetWindowDrawList()->AddText({at.x + (line - marker_width) / 2, at.y},
ImGui::ColorConvertFloat4ToU32(amber), "*");
ImGui::Dummy({line, line});
} else {
dot(nutrient_colors.at(channel));
}
ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x);
ImGui::TextUnformatted(name);
ImGui::TableNextColumn();
@@ -683,14 +695,7 @@ void nutrient_row(std::size_t channel, const char* name, float share, const std:
ImGui::SetTooltip("%s", tip.c_str());
ImGui::TableNextColumn();
ImGui::TextUnformatted(value.c_str());
}
bool begin_nutrient_table(const char* id) {
if (!ImGui::BeginTable(id, 3, ImGuiTableFlags_SizingFixedFit))
return false;
ImGui::TableSetupColumn("name", ImGuiTableColumnFlags_WidthFixed, px(104));
ImGui::TableSetupColumn("bar", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthFixed, px(64));
return true;
ImGui::PopTextWrapPos();
}
// Three significant digits in the largest unit that keeps the value at least 1.
std::string scaled(std::uint64_t value, const std::array<const char*, 4>& units) {
@@ -711,6 +716,20 @@ std::string energy_text(std::uint64_t picojoules) {
std::string mass_text(std::uint64_t femtograms) {
return scaled(femtograms, {"fg", "pg", "ng", "\xC2\xB5g"});
}
bool begin_nutrient_table(const char* id) {
if (!ImGui::BeginTable(id, 3, ImGuiTableFlags_SizingFixedFit))
return false;
// Reserve the widest supported stock for this font/scale, never from the live
// amount. Even the full uint64 range stays legible without growing the column.
constexpr auto maximum = std::numeric_limits<std::uint64_t>::max();
const float value_width =
std::ceil(std::max({px(64), ImGui::CalcTextSize(energy_text(maximum).c_str()).x,
ImGui::CalcTextSize(mass_text(maximum).c_str()).x}));
ImGui::TableSetupColumn("name", ImGuiTableColumnFlags_WidthFixed, px(104));
ImGui::TableSetupColumn("bar", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthFixed, value_width);
return true;
}
std::uint64_t mix(std::uint64_t x) noexcept {
x += 0x9E3779B97F4A7C15ULL;
x = (x ^ (x >> 30U)) * 0xBF58476D1CE4E5B9ULL;
@@ -1353,8 +1372,7 @@ void hud_vitals(const PanelView& v, FormBuffers& form, bool compact) {
if (limiting)
tip += "\nThis is what is holding your growth back right now.";
}
nutrient_row(i + 1, nutrient_names.at(i + 1), share,
mass_text(have) + (limiting ? " *" : ""), limiting, tip);
nutrient_row(i + 1, nutrient_names.at(i + 1), share, mass_text(have), limiting, tip);
}
ImGui::EndTable();
}
@@ -12,7 +12,7 @@ spec:
env:
- {name: REGION_SESSION, value: "dev"}
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
- {name: REGION_SESSION_WINDOW, value: "dev-20261026T204344-a7cbcef9:1793061824"}
- {name: REGION_SESSION_WINDOW, value: "dev-20261026T212818-5dcfde8e:1793064498"}
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
ports:
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
@@ -52,6 +52,13 @@ a scrollable details area. Changing nutrient values, growth warnings, pending
results, region-edge notices and stale observations cannot resize or re-anchor
these panels. The responsive compact layout keeps the dock and map within the viewport.
Resource-table rows also have stable single-line geometry: names and formatted
quantities never inherit prose wrapping. The amount column reserves the widest
supported energy/mass readout at the current font/scale, including the full u64
range, independently of live values. A growth-limiting nutrient shows `*` in its
existing dot slot, with the same bar outline; the marker never lengthens an amount.
This prevents transitions such as `714 fg` to `1.54 pg` from shifting later rows.
Nearby is a camera-centred observation map with a fixed six-millimetre radius.
It reads the received food and organism views only, including observations
outside the viewport. Empty space means unknown, not confirmed empty. Rings
+52
View File
@@ -10293,3 +10293,55 @@ application restarts. Hardware DPI, accessibility, touch interaction and motion
comfort still need interactive review. No deployment, live session, World0 change,
reset or prune occurred. The required pre-push session-window refresh is desired
Git configuration only.
## 2026-10-26 - String-length stability inside nutrient tables
Reviewed the supplied Recording 2026-10-26 171124.mp4 locally (420x428, 5.83 s).
The outer Vitals card was already fixed; its carbon amount changed from
714 fg * to 1.54 pg *, wrapping the marker and shifting later nutrient rows.
The prior outer-geometry regression did not check those inner row baselines.
Changes: quantity/name cells explicitly disable prose wrapping; a font/scale-based
fixed amount-column width covers the largest supported energy and mass readouts.
The growth-limiting * occupies the existing nutrient-dot slot, with unchanged
bar outline and explanatory legend. No number formatting, simulation rule,
checkpoint, protocol, dependency or public API changed. The shared table also
serves mutation cost readouts.
Executed:
- First added the native table-geometry regression without the fix. It failed
at the baseline/height assertion on the old renderer, reproducing the recording.
- GCC 14.2 Release/NDEBUG, build/playtest-release: rebuilt evo-client and native
panel tests. Focused panel CTest passed; the final executable also passed with
review screenshots under SDL_VIDEO_DRIVER=dummy and SDL_RENDER_DRIVER=software.
- Regression spans 714, 999, 1000, 1540, 9999, 10000 and higher unit boundaries,
zero and UINT64_MAX. It checks unchanged last-row baseline, total table height,
amount-column width and zero horizontal overflow. Viewports are 640x480,
960x640, 1280x800 and 1600x1008; the latter exercises the recording's 1.4 scale.
Existing dragging, anchoring, Bud, mutation and death/restart paths still run.
- MSVC 19.44 client preset check: build succeeded and client CTests passed 10/10.
TMP/TEMP used ignored build/playtest-windows-tmp.
- Clang 19 analysis-preset build/playtest-analysis: production client and panel
regression built with clang-tidy and warnings as errors.
- Clang 19 ASan+UBSan build/client-asan: focused native panel CTest passed 1/1.
- Changed C++ files passed clang-format 19 dry-run. The full format-check initially
found an existing wrapping violation in cellular_revamp.cpp; normalized those
lines only, verified identical non-whitespace text, and the full gate passed.
git diff --check passed. No server behavior changed by that formatting correction.
- Visually reviewed generated Vitals crops for 714 fg, 1.54 pg and UINT64_MAX at
1.4 scale in ignored build/string-bounce-review/fixed/stock-comparison.png.
All four rows stay aligned and the full formatted maximum remains visible.
Video decoding used the existing ignored review-tool FFmpeg, not a new runtime
or repository dependency.
Limits: local software-renderer fixtures do not replace interactive hardware DPI
and accessibility review. No deployment, World0 change, reset or pruning was
performed. Existing unrelated drafts and untracked files were preserved; the
required pre-push session-window update is desired Git configuration only.
Publication limit: the scoped commit was created locally, but the configured
Gitea remote returned HTTP 500 during push. Two bounded read-only remote checks,
including a delayed HTTP/1.1 check, returned the same server error. Publication
remains pending remote recovery. No force push, credential-store change, server
operation or deployment was attempted.
+2 -3
View File
@@ -52,9 +52,8 @@ bool cellular_revamp_valid(const CellularRevampRules& rules) noexcept {
rules.split_share_per_thousand < 1'000 && rules.split_min_growth != 0 &&
rules.split_min_growth <= 1'000 && rules.bud_fee_scale_percent <= 100 &&
rules.bud_fee.energy.value <= most &&
std::ranges::all_of(
rules.bud_fee.matter,
[](const accounting::Femtograms& f) { return f.value <= most; }) &&
std::ranges::all_of(rules.bud_fee.matter,
[](const accounting::Femtograms& f) { return f.value <= most; }) &&
rules.organism_cap != 0 && rules.organism_cap <= biology::max_cellular_tick_lives &&
rules.organism_load_per_thousand <= 10'000 && rules.emerge_members >= 2 &&
rules.emerge_members <= 10'000 && rules.emerge_mass_fg <= most &&
+45 -1
View File
@@ -13,6 +13,7 @@
#include <filesystem>
#include <imgui.h>
#include <imgui_internal.h>
#include <limits>
#include <source_location>
#include <stdexcept>
#include <string>
@@ -357,7 +358,8 @@ void apply_save_restart() {
std::filesystem::remove_all(dir);
}
void cellular_panels(const std::filesystem::path& review) {
for (const auto& size : {std::pair{960, 640}, std::pair{1280, 800}, std::pair{640, 480}}) {
for (const auto& size :
{std::pair{960, 640}, std::pair{1280, 800}, std::pair{640, 480}, std::pair{1600, 1008}}) {
const auto [width, height] = size;
auto opened = Application::open({width, height, false, "software"});
CHECK(opened);
@@ -500,6 +502,48 @@ void cellular_panels(const std::filesystem::path& review) {
if (width >= 880)
CHECK(fits(ImGui::FindWindowByName("Field notes")) &&
disjoint(vitals, ImGui::FindWindowByName("Field notes")));
// Recording 2026-10-26 171124: "714 fg *" -> "1.54 pg *" wrapped the marker
// and pushed every later nutrient down. Check the actual table geometry,
// including the recording's 1.4 UI scale and every displayed mass unit.
auto changing_stock = diagnostics;
changing_stock.members = 1;
changing_stock.growth_per_thousand = 540;
changing_stock.growth_limit = 2;
changing_stock.reserve_energy_pj = 2'360'000;
changing_stock.reserve_matter_fg = {714, 374'000, 359'000, 300'000};
float row_top = 0, table_height = 0, value_width = 0;
for (const auto stock :
{std::uint64_t{714}, std::uint64_t{999}, std::uint64_t{1'000}, std::uint64_t{1'540},
std::uint64_t{9'999}, std::uint64_t{10'000}, std::uint64_t{999'999},
std::uint64_t{1'000'000}, std::uint64_t{999'999'999}, std::uint64_t{1'000'000'000},
std::numeric_limits<std::uint64_t>::max(), std::uint64_t{0}}) {
changing_stock.reserve_matter_fg[0] = stock;
perception.diagnostics = changing_stock;
draw();
auto* body = vitals->DC.ChildWindows[0];
const auto* table = ImGui::TableFindByID(body->GetID("matter"));
CHECK(table && table->ColumnsCount == 3 && body->ScrollMax.x == 0);
if (row_top == 0) {
row_top = table->RowPosY1;
table_height = table->OuterRect.GetHeight();
value_width = table->Columns[2].WidthGiven;
}
CHECK(table->RowPosY1 == row_top && table->OuterRect.GetHeight() == table_height);
CHECK(table->Columns[2].WidthGiven == value_width);
if (stock == std::numeric_limits<std::uint64_t>::max())
CHECK(value_width >= ImGui::CalcTextSize("18446744074 \xC2\xB5g").x);
if (!review.empty() && width == 1600 &&
(stock == 714 || stock == 1'540 ||
stock == std::numeric_limits<std::uint64_t>::max())) {
std::filesystem::create_directories(review);
CHECK(app->request_screenshot(
(review / ("cellular-stock-" + std::to_string(stock) + ".bmp")).string()));
draw();
}
}
perception.diagnostics = diagnostics;
for (int i = 0; i < 3; ++i)
draw();
// Live messages may change overflow, but never move/resize the cards or
// reflow their content width. Exercise every frame, including empty data.
struct Geometry {