Repository navigation
render: keep text input values and cursors within their fields - #4875
Conversation
|
Holding review: upstream PR #4873 is not yet approved. This stacked PR will be re-evaluated once the upstream lands an approval label. |
Perf gateHead host slug: perf comparison: 9557153 → 5c0d419-cibaseline: host calibration
thresholds: regress ≥ 10%, improve ≥ 5% voxel cull effectiveness
frame timing (ms)
GPU frame timing (ms; separate from stage samples)
GPU stage timing (avg ms per sampled invocation)
top CPU systems by avg ms (head)
|
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
246.854 → 256.667 (+4.0%) |
| RENDER | ComputeLightVolume |
33.089 → 33.986 (+2.7%) |
| RENDER | CanvasToFramebuffer |
17.303 → 17.112 (-1.1%) |
| RENDER | BakeSunShadowMap |
9.493 → 10.353 (+9.1%) |
| RENDER | ComputeSunShadow |
7.826 → 7.693 (-1.7%) |
| UPDATE | PropagateTransform |
4.444 → 5.101 (+14.8%) ⚠ |
| UPDATE | FogRevealEval |
4.251 → 4.227 (-0.6%) |
| RENDER | ComputeVoxelAO |
3.994 → 3.906 (-2.2%) |
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1029.388 → 1026.794 (-0.3%) |
| RENDER | ComputeLightVolume |
29.437 → 29.616 (+0.6%) |
| RENDER | ComputeSunShadow |
21.807 → 21.386 (-1.9%) |
| RENDER | CanvasToFramebuffer |
16.427 → 15.955 (-2.9%) |
| RENDER | ComputeVoxelAO |
9.553 → 9.501 (-0.5%) |
| RENDER | BakeSunShadowMap |
8.723 → 8.569 (-1.8%) |
| RENDER | LightingToTrixel |
8.431 → 8.232 (-2.4%) |
| UPDATE | PropagateTransform |
4.525 → 4.642 (+2.6%) |
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
291.808 → 289.361 (-0.8%) |
| RENDER | ComputeSunShadow |
57.890 → 55.146 (-4.7%) |
| RENDER | LightingToTrixel |
37.677 → 35.811 (-5.0%) |
| RENDER | ComputeLightVolume |
32.943 → 32.782 (-0.5%) |
| RENDER | BakeSunShadowMap |
23.010 → 22.632 (-1.6%) |
| RENDER | CanvasToFramebuffer |
17.714 → 17.431 (-1.6%) |
| RENDER | FogToTrixel |
7.272 → 7.142 (-1.8%) |
| UPDATE | PropagateTransform |
6.270 → 6.124 (-2.3%) |
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1463.424 → 1457.780 (-0.4%) |
| RENDER | ComputeLightVolume |
29.476 → 28.862 (-2.1%) |
| RENDER | ComputeSunShadow |
19.108 → 18.210 (-4.7%) |
| RENDER | CanvasToFramebuffer |
16.257 → 16.258 (+0.0%) |
| RENDER | BakeSunShadowMap |
8.716 → 8.658 (-0.7%) |
| RENDER | ComputeVoxelAO |
7.771 → 7.712 (-0.8%) |
| RENDER | LightingToTrixel |
6.805 → 6.618 (-2.7%) |
| UPDATE | PropagateTransform |
6.350 → 6.192 (-2.5%) |
Perf gateHead host slug: perf comparison: a990fd6 → 44922b2-cibaseline: host calibration
thresholds: regress ≥ 10%, improve ≥ 5% voxel cull effectiveness
frame timing (ms)
GPU frame timing (ms; separate from stage samples)
GPU stage timing (avg ms per sampled invocation)
top CPU systems by avg ms (head)
|
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
240.443 → 246.132 (+2.4%) |
| RENDER | ComputeSunShadow |
31.232 → 32.703 (+4.7%) |
| RENDER | ComputeLightVolume |
29.633 → 30.160 (+1.8%) |
| RENDER | LightingToTrixel |
18.523 → 19.711 (+6.4%) |
| RENDER | CanvasToFramebuffer |
15.822 → 16.152 (+2.1%) |
| RENDER | BakeSunShadowMap |
1.167 → 9.806 (+740.3%) ⚠ |
| UPDATE | PropagateTransform |
4.949 → 4.983 (+0.7%) |
| RENDER | FogToTrixel |
4.669 → 4.802 (+2.8%) |
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1218.093 → 1221.796 (+0.3%) |
| RENDER | ComputeLightVolume |
25.504 → 26.134 (+2.5%) |
| RENDER | CanvasToFramebuffer |
14.310 → 14.616 (+2.1%) |
| RENDER | ComputeSunShadow |
9.793 → 13.401 (+36.8%) ⚠ |
| RENDER | BakeSunShadowMap |
0.198 → 6.158 (+3010.1%) ⚠ |
| RENDER | ComputeVoxelAO |
5.222 → 5.375 (+2.9%) |
| UPDATE | PropagateTransform |
4.911 → 5.013 (+2.1%) |
| RENDER | LightingToTrixel |
4.476 → 4.691 (+4.8%) |
unmatched cells
only in head: target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1, target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1
Perf gateHead host slug: perf comparison: 9557153 → 44922b2-cibaseline: host calibration
thresholds: regress ≥ 10%, improve ≥ 5% voxel cull effectiveness
frame timing (ms)
GPU frame timing (ms; separate from stage samples)
GPU stage timing (avg ms per sampled invocation)
top CPU systems by avg ms (head)
|
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
246.854 → 256.241 (+3.8%) |
| RENDER | ComputeLightVolume |
33.089 → 35.029 (+5.9%) |
| RENDER | CanvasToFramebuffer |
17.303 → 17.251 (-0.3%) |
| RENDER | BakeSunShadowMap |
9.493 → 10.434 (+9.9%) |
| RENDER | ComputeSunShadow |
7.826 → 7.864 (+0.5%) |
| UPDATE | PropagateTransform |
4.444 → 5.090 (+14.5%) ⚠ |
| UPDATE | FogRevealEval |
4.251 → 4.250 (-0.0%) |
| RENDER | ComputeVoxelAO |
3.994 → 4.037 (+1.1%) |
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1029.388 → 1030.023 (+0.1%) |
| RENDER | ComputeLightVolume |
29.437 → 29.537 (+0.3%) |
| RENDER | ComputeSunShadow |
21.807 → 21.825 (+0.1%) |
| RENDER | CanvasToFramebuffer |
16.427 → 16.221 (-1.3%) |
| RENDER | ComputeVoxelAO |
9.553 → 9.481 (-0.8%) |
| RENDER | BakeSunShadowMap |
8.723 → 8.825 (+1.2%) |
| RENDER | LightingToTrixel |
8.431 → 8.301 (-1.5%) |
| UPDATE | PropagateTransform |
4.525 → 4.621 (+2.1%) |
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
291.808 → 293.638 (+0.6%) |
| RENDER | ComputeSunShadow |
57.890 → 56.509 (-2.4%) |
| RENDER | LightingToTrixel |
37.677 → 35.954 (-4.6%) |
| RENDER | ComputeLightVolume |
32.943 → 32.539 (-1.2%) |
| RENDER | BakeSunShadowMap |
23.010 → 23.423 (+1.8%) |
| RENDER | CanvasToFramebuffer |
17.714 → 17.545 (-1.0%) |
| RENDER | FogToTrixel |
7.272 → 7.292 (+0.3%) |
| UPDATE | PropagateTransform |
6.270 → 6.094 (-2.8%) |
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1463.424 → 1460.135 (-0.2%) |
| RENDER | ComputeLightVolume |
29.476 → 28.720 (-2.6%) |
| RENDER | ComputeSunShadow |
19.108 → 18.265 (-4.4%) |
| RENDER | CanvasToFramebuffer |
16.257 → 16.410 (+0.9%) |
| RENDER | BakeSunShadowMap |
8.716 → 8.704 (-0.1%) |
| RENDER | ComputeVoxelAO |
7.771 → 7.854 (+1.1%) |
| RENDER | LightingToTrixel |
6.805 → 6.859 (+0.8%) |
| UPDATE | PropagateTransform |
6.350 → 6.142 (-3.3%) |
jakildev
left a comment
There was a problem hiding this comment.
Review — render: keep text input values and cursors within their fields
Verdict: approve
Stacked on #4873 (now fleet:approved; the fleet:awaiting-upstream-review gate is cleared). Reviewing the child diff only — the upstream is approved separately. Head aac17f007, mergeable: MERGEABLE, CLEAN.
Big picture. Text-input values longer than the field now render through a window that follows the insertion point, the cursor is placed relative to that window, and the stored text_ / cursorPos_ are never touched. This is the fix the PR describes for the component-overrides field. The approach is sound: one pure function (textInputViewport) is the single copy of the placement formula, and the renderer (system_widget_render_text_input.hpp) and the layout audit (gui_layout_audit.hpp:289 via textInputText) both read it. That keeps the audit measuring what the renderer draws, as widget_text_layout.hpp's header comment requires. No scroll state and no serialized field is added, so kSaveVersion is not in play.
Checked by hand (widget_text_layout.hpp:227-262):
inset <= width/2, soinnerWidth >= 0.cursorWidth <= innerWidth, socapacity >= 0. Thesubstr(first, capacity)start is<= lengthin every branch, so it can't throwout_of_range, including thecapacity == 0case.cursor - first <= capacityin all three clamp branches (lower clamp, centered, upper clamp). The cursor's right edge is at mostinset + innerWidth, so it stays inside the field, and the last glyph's right edge is inside it too.- For normal widths
inset == padding*2, so the unfocused and short-value layout is identical to before. The old hard-codedcursorX = min(...)clamp is replaced by containment by construction. - No other reader of
cursorPos_assumes the window starts at character 0. Click handling doesn't map x to a cursor position, so the scrolled window can't desync a click. Keyboard handling insystem_widget_apply_text_input.hppworks on the value, not on screen columns. TextRun::text_is astring_viewinto the component'stext_. That lifetime contract is unchanged ("caller owns it as long as the run is queued"), and the view is queued the same frame it is built.
CI. Every check on the head completed green: linux-build, format-check, header-checks, comment-refs, whitespace, instruction-size, closes-lint, no-plan-files, perf-gate, gate, changes. fleet-tests and swap-approval-label are SKIPPED, with no run on this head. The perf-gate comments flag BakeSunShadowMap / ComputeSunShadow on the xeon host. That is not this PR: the diff touches no sun or shadow code, and the gate says its baseline is the stacked base branch's unmerged changes. Inherited / unrelated.
Tests. The two new GuiLayoutAudit cases cover:
- cursor at the end, middle and start, plus negative and over-length cursors;
- empty, short, and 0/1/10/18-px-wide fields;
- containment of both glyphs and cursor;
- value preservation.
I recomputed the expected values: inset 8, inner width 34, capacity 4, cursor x = 18 + 4·8 = 50 at the end. They match. The tests exercise the real renderer's placement function, so I have no gap to raise.
Nits (follow-up)
widget_text_layout.hpp:236— Reserving cursor width while unfocused is deliberate and documented. It differs fromnumberFieldText, which reserves only whileediting_(line 195). A one-line note on why the text input diverges would help the next reader.- Behavior question for the next UI pass, not blocking: an unfocused long value now shows its suffix, because
cursorPos_sits at the end aftersetTextInputValue. For path/name-like fields the head may read better when unfocused. The PR body discloses this, and Home brings the head back.
Praise
- Folding the cursor placement into the same function as the text window makes drift between the glyphs and the cursor impossible, and the zero/narrow-width degeneracies are handled by clamps rather than special cases.
Test plan the author should run before merge
- Nothing further — the PR body's evidence (52/52 GUI suites, 11/11 motion_preview assertions, zero layout findings, clean exits) matches the diff.
Escalation: none. Safe for merge.
🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)
Opus recheck not required.
Display a cursor-following substring without changing the complete value. Share the calculation with layout auditing and retain keyboard editing behavior. Cover cursor positions, small fields, glyph containment and value preservation.
aac17f0 to
f3950b5
Compare
|
New commits pushed after fleet approval. Re-tagging |
Perf gateHead host slug: perf comparison: bb78d69 → 188b5ff-cibaseline: host calibration
thresholds: regress ≥ 10%, improve ≥ 5% voxel cull effectiveness
frame timing (ms)
GPU frame timing (ms; separate from stage samples)
GPU stage timing (avg ms per sampled invocation)
top CPU systems by avg ms (head)
|
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
259.823 → 261.822 (+0.8%) |
| RENDER | ComputeLightVolume |
37.661 → 38.805 (+3.0%) |
| RENDER | CanvasToFramebuffer |
18.125 → 18.753 (+3.5%) |
| RENDER | BakeSunShadowMap |
0.238 → 10.376 (+4259.7%) ⚠ |
| RENDER | ComputeSunShadow |
6.157 → 7.859 (+27.6%) ⚠ |
| UPDATE | PropagateTransform |
4.992 → 5.160 (+3.4%) |
| RENDER | LightingToTrixel |
3.820 → 4.067 (+6.5%) |
| UPDATE | FogRevealEval |
3.808 → 3.976 (+4.4%) |
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1043.404 → 1054.197 (+1.0%) |
| RENDER | ComputeLightVolume |
31.649 → 32.672 (+3.2%) |
| RENDER | ComputeSunShadow |
16.333 → 20.840 (+27.6%) ⚠ |
| RENDER | CanvasToFramebuffer |
16.630 → 17.350 (+4.3%) |
| RENDER | ComputeVoxelAO |
9.193 → 9.408 (+2.3%) |
| RENDER | LightingToTrixel |
7.758 → 8.655 (+11.6%) ⚠ |
| RENDER | BakeSunShadowMap |
0.236 → 8.625 (+3554.7%) ⚠ |
| UPDATE | PropagateTransform |
4.765 → 4.899 (+2.8%) |
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
290.184 → 296.094 (+2.0%) |
| RENDER | ComputeSunShadow |
51.563 → 56.295 (+9.2%) |
| RENDER | ComputeLightVolume |
35.815 → 37.543 (+4.8%) |
| RENDER | LightingToTrixel |
33.295 → 35.313 (+6.1%) |
| RENDER | BakeSunShadowMap |
3.645 → 22.465 (+516.3%) ⚠ |
| RENDER | CanvasToFramebuffer |
18.265 → 18.426 (+0.9%) |
| RENDER | FogToTrixel |
6.954 → 7.064 (+1.6%) |
| UPDATE | PropagateTransform |
6.821 → 6.984 (+2.4%) |
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1475.114 → 1490.392 (+1.0%) |
| RENDER | ComputeLightVolume |
31.550 → 33.377 (+5.8%) |
| RENDER | ComputeSunShadow |
12.076 → 18.100 (+49.9%) ⚠ |
| RENDER | CanvasToFramebuffer |
16.579 → 17.245 (+4.0%) |
| RENDER | BakeSunShadowMap |
0.237 → 8.835 (+3627.8%) ⚠ |
| RENDER | ComputeVoxelAO |
7.600 → 7.643 (+0.6%) |
| RENDER | LightingToTrixel |
6.207 → 7.028 (+13.2%) ⚠ |
| UPDATE | PropagateTransform |
6.704 → 6.853 (+2.2%) |
jakildev
left a comment
There was a problem hiding this comment.
Review — render: keep text input values and cursors within their fields
Verdict: approve
Stacked on #4873 (cross-author, fleet:approved). Reviewing the child diff only; approval assumes #4873 lands first. The PR has no Closes #N, so there is no acceptance grading.
The PR does what its description says. A single pure function, textInputViewport, now owns both the visible substring and the cursor rect. The renderer and the layout audit read it, so the audit still measures the text the renderer draws (via the textInputText wrapper). The stored value and cursorPos_ are untouched, so there is no serialization change and no kSaveVersion impact.
What I checked
- Window math, traced by hand.
inset <= width/2makesinnerWidth >= 0, andcursorWidth = min(cw, innerWidth)makescapacity >= 0.first = clamp(cursor - capacity/2, 0, max(0, length - capacity))always gives0 <= cursor - first <= capacity.- So the cursor stays inside the field when
cursor == length, whenlength < capacity, and for zero, one, or tiny widths. substr(first, capacity)hasfirst <= length, so it cannot throw.
- Lifetime.
TextRun::text_is astring_viewoftextInput.text_. It is queued in the same tick call, before any edit, and the struct already documents "views a string the caller owns for as long as the run is queued". - Cursor behaviour. Cursor X, Y, and the end-of-text clamp match the old formula (
pos.x + 2*padding,(h - glyphH)/2) for fields that fit. - Consumers.
cursorPos_is only written bysystem_widget_apply_text_input.hppand the serializer. There is no click-to-caret mapping that would disagree with the scrolled window. The audit call site (gui_layout_audit.hpp:289) still goes throughtextInputText. - ECS and style.
- The per-entity tick is unchanged: no
getComponent, no allocation, andstring_viewslicing only. - Math goes through
IRMath. - New names follow the conventions.
- The new comment states an invariant rather than history.
- The per-entity tick is unchanged: no
- Tests.
- The two new
GuiLayoutAuditcases cover cursor at the end, in the middle, at the start, below zero, and past the end. - They also cover empty, short, and narrow fields (widths 0, 1, 10, 18).
- They assert glyph and cursor containment and that the complete value is unchanged.
- I traced the expected numbers (e.g. cursor X 18 / 34 / 50 for a 50-wide field with an 8px inset) and they follow from the code.
- The two new
- Checks on the head.
linux-build,format-check,header-checks,comment-refs,instruction-size,whitespace,closes-lint,perf-gateandgateare green.fleet-testswas skipped (no scripts touched). - What I did not run. I did not build or run the tests or the editor workflow myself. The 52/52 GUI suite and the 11/11 editor workflow are the author's macOS runs; CI
linux-buildis the only build I rely on.
Nits (follow-up)
widget_text_layout.hpp:259—textInputTextis now a one-line wrapper. Its only callers are the layout audit and the older audit test (gui_layout_audit_test.cpp:449). Fine to keep; fold the callers ontotextInputViewportnext time one of those files is touched.- PR body — it discloses that a long unfocused value shows its suffix when the insertion point is at the end. If that reads badly in the editor, an unfocused-shows-prefix rule is a one-line follow-up, but it is a product call and not a defect here.
Praise
- Putting the window computation in the shared layout header removes the formula that the renderer and the audit each carried a copy of. The audit stays a true measurement of what is drawn.
Test plan the author should run before merge
- Windows/OpenGL smoke is already tracked via
fleet:needs-windows-smoke(a post-merge ledger entry, not a gate).
Escalation: none. Safe for merge.
🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)
Opus recheck not required.
Summary
Keep long single-line widget values inside their fields while preserving the complete editable value. A shared viewport calculation follows the insertion point, and the renderer places the cursor relative to the displayed substring. Layout auditing uses the same text calculation.
Validation
Scope
This fixes the component-overrides field exposed by the editor workflow and applies to shared text-input widgets. Existing click-to-focus and keyboard Home/End/Left/Right behavior remains; it does not add selection, clipboard editing, or a native text control.
The viewport is computed from the existing insertion position; no stored scroll state or serialized component changes are introduced. Long unfocused values can show their suffix when the insertion point is at the end. Home/End and arrow keys reveal the rest.
Screenshots
Same neutral combined-stack fixture after returning from preview, native macOS/Metal at 3200×1800, yaw 0, zoom 4, subdivisions 4. The paired pixel difference is confined to the component-value row (1034,938)–(2054,960); the remainder is identical. These are combined-stack captures, not isolated builds of this PR. PNGs are used because this editor has no auto-record wiring.
Reviewed-foundation integration
The stack incorporates foundation amendment a93a6d6 (hidden-widget hitboxes and visibility persistence) without rewriting published commits. IRVoxelEditor rebuilt at combined-stack head 598b23b. All five follow-up workflows passed: 63/63 assertions across 51 captures, zero layout findings, and five clean exits. The host reported zero monitors during this additional offscreen Metal pass; the longer document and motion runs used the documented 30-second display-discovery grace while retaining the run watchdog, GPU lease, assertions and layout checks. Earlier display-guard terminations are not counted as passes. The earlier unit runs and screenshots remain scoped as described above.