Skip to content

fix(ui): wrap the Edit header buttons instead of letting Reset cover HDR - #2804

Merged
aiongg merged 1 commit into
storytold:mainfrom
Enthendor:edit-header-reset-wrap
Oct 31, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
Enthendor:edit-header-reset-wrap

Conversation

@Enthendor

@Enthendor Enthendor commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Edit panel: Reset no longer covers HDR in longer languages

Noticed while reviewing the German catalog (#2800). In the Edit header, Reset was laid out right-to-left in whatever width Auto, B&W and HDR left. With a longer label it drew on top of HDR. In German at the default panel width only "HD" was visible.

The new test measured how widespread this was:

  • At the default width (222 pt inside the 270 pt panel), Reset covered HDR in 11 of the 18 languages.
  • At some width between the narrowest panel and 400 pt, it happened in 16 of 18; only the two Chinese catalogs were never affected.
  • In Polish at the narrowest panel, HDR itself also ran past the edge.

Change

  • header_buttons (in panels/edit.rs) plans the row before drawing it. A button that doesn't fit starts the next row, and Reset stays right-aligned on whichever row it lands.
  • When everything fits, the layout is unchanged (English from the default width up).
  • widgets::text_button_size gives a text_button's width ahead of drawing. text_button uses the same formula, so the plan and the drawn row always agree.

Tests

  • New edit_header_buttons_do_not_overlap_in_any_language, checked for every Locale::ALL at widths 200, 222, 260 and 400 pt:
    • no two buttons intersect
    • none runs past the edge
    • Reset is right-aligned
    • German wraps at 222 pt
    • English keeps one row from 222 pt up
  • cargo clippy -p lightcraft-ui-egui --all-targets -D warnings clean.
  • cargo test -p lightcraft-ui-egui: 1389 passed. The 6 tests_model_setup failures also occur without this change: my local build "cannot run denoise models".
  • Headless snapshots (lightcraft-cli snapshot --demo, de/en/it) checked by eye:
    • German and Italian: Reset sits on a second row, right-aligned.
    • English: unchanged.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Edit panel action buttons now arrange themselves to fit the available space across different window widths and locales.
    • Reset remains right-aligned when it fits alongside other actions, or appears right-aligned on its own row.
    • Button spacing is checked to prevent overlap and ensure controls stay within the panel.

Reset was laid out right-to-left in whatever width Auto, B&W and HDR left, so a long label drew over HDR:
German Zurücksetzen in the default panel, and 16 of the 18 languages at some panel width. A button that
doesn't fit now starts the next row; Reset stays right-aligned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between c414ef0 and d0670de.

Files selected for processing: 2
  • crates/ui-egui/src/panels/edit.rs
  • crates/ui-egui/src/widgets.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

The Edit header now arranges Auto, B&W, HDR, and Reset based on available width. A public widget function measures translated button labels, and a layout test checks button positions across locales and panel widths.

Changes: Edit header layout

Layer / File(s) Summary
Button width measurement
crates/ui-egui/src/widgets.rs
text_button uses a shared width formula. The new public text_button_size function measures translated labels using the button font and text color.
Edit header action layout
crates/ui-egui/src/panels/edit.rs
The header lays out Auto, B&W, and HDR in rows. Reset shares the last row when it fits; otherwise, it occupies a right-aligned row. Existing action handling remains in place. A test checks layout across locales and widths.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: claude

Merge Risk: Minimal · up to d0670

The Edit header buttons wrap without an identified overlap or edge-overflow issue. The change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: wrapping the Edit header buttons to prevent Reset from covering HDR.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source review at d0670de (base main 5194cc2). I read the whole diff: panels/edit.rs, widgets.rs and the new test.

I found no functional defect. The row planning is right: used after the loop is the width of the last row, so reset_on_last correctly decides whether Reset shares that row or gets its own; text_button_size and text_button share text_button_width, so the planned and drawn widths agree; the click flags are set once per frame; and the test measures all four buttons across every locale at 200, 222, 260 and 400 pt, checking edge overrun, pairwise overlap and Reset's right alignment.

One small thing to fix while you are in the file: the new HeaderClicks struct was inserted between the existing doc comment /// The Reset button's tooltip with the reset shortcut ... (issue #1751). and fn reset_tip. That line now documents HeaderClicks (above its own doc line) and reset_tip has lost its doc. Move the new items above that comment.

Not verified: the test needs the font and headless harness, which I did not run. The PR conflicts with main, so CI has not run on it and I cannot approve it. Please rebase onto current main; once it is mergeable and CI has run on the merged head, I will re-check and approve if it is green.

@aiongg
aiongg merged commit d43059b into storytold:main Oct 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants