refactor(core/delizia): remove Header-related helpers from Frame#6995
Conversation
WalkthroughThis PR refactors the Delizia UI layout API: Frame::new now accepts a prepared Header and content; header convenience constructors/builders were moved from Frame into Header. All component modules and UI flows were updated to construct pages via Frame::new(Header::..., content) while preserving existing footer, swipe, and message-mapping behavior. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
398eed3 to
81e58be
Compare
81e58be to
110c8e5
Compare
Header-related helpers from Frame
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@core/embed/rust/src/ui/layout_delizia/component/frame.rs`:
- Around line 374-376: The title height calculation uses
header.place(bounds).height(), but Header::place only updates self.area in the
subtitle branch, so wrapped titles without subtitles report a stale/zero height;
update Header::place (or add a Header::measured_height method) to compute and
return the actual consumed height for both branches (subtitle and no-subtitle)
and ensure self.area is set when wrapping occurs, then have the frame code
derive title_height from that accurate value (still clamped with
.max(TITLE_HEIGHT)). This ensures wrapped titles update self.area and prevent
content overlap.
In `@core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs`:
- Around line 339-345: In new_confirm_action_uni avoid moving extra: change uses
of matches!(extra, ...) to matches!(&extra, ...) and switch the match to match
&extra using patterns Menu(_) and ExternalMenu (or Cancel) so you only borrow
extra; update the header construction that currently uses match extra to use
match &extra and call header.with_menu_button() / with_cancel_button() as
before, ensuring subsequent borrows like menu selection and create_confirm use
the same borrowed extra without having been moved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 58cce924-f4c4-47a7-b63d-6e94dabe3797
📒 Files selected for processing (22)
core/embed/rust/src/ui/layout_delizia/component/address_details.rscore/embed/rust/src/ui/layout_delizia/component/coinjoin_progress.rscore/embed/rust/src/ui/layout_delizia/component/frame.rscore/embed/rust/src/ui/layout_delizia/component/header.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_action.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_fido.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_firmware_update.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_homescreen.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_reset.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_set_new_code.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_summary.rscore/embed/rust/src/ui/layout_delizia/flow/continue_recovery_homepage.rscore/embed/rust/src/ui/layout_delizia/flow/prompt_backup.rscore/embed/rust/src/ui/layout_delizia/flow/receive.rscore/embed/rust/src/ui/layout_delizia/flow/request_number.rscore/embed/rust/src/ui/layout_delizia/flow/request_passphrase.rscore/embed/rust/src/ui/layout_delizia/flow/set_brightness.rscore/embed/rust/src/ui/layout_delizia/flow/show_danger.rscore/embed/rust/src/ui/layout_delizia/flow/show_share_words.rscore/embed/rust/src/ui/layout_delizia/flow/show_tutorial.rscore/embed/rust/src/ui/layout_delizia/flow/util.rscore/embed/rust/src/ui/layout_delizia/ui_firmware.rs
110c8e5 to
1597414
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs (1)
339-344:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winAvoid moving
extrabefore later borrows.
matches!(extra, ...)andmatch extraconsumeextra, but&extrais used later (Line 381/Line 400), which breaks ownership.💡 Proposed fix
- let has_external_menu = matches!(extra, ConfirmActionExtra::ExternalMenu); - let mut header = match extra { - ConfirmActionExtra::ExternalMenu => header.with_menu_button(), - ConfirmActionExtra::Menu(_) => header.with_menu_button(), - ConfirmActionExtra::Cancel => header.with_cancel_button(), + let has_external_menu = matches!(&extra, ConfirmActionExtra::ExternalMenu); + let mut header = match &extra { + ConfirmActionExtra::ExternalMenu => header.with_menu_button(), + ConfirmActionExtra::Menu(_) => header.with_menu_button(), + ConfirmActionExtra::Cancel => header.with_cancel_button(), };#!/bin/bash set -euo pipefail file="core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs" echo "== by-value use sites in new_confirm_action_uni ==" rg -n -C2 'matches!\(extra|match extra' "$file" echo echo "== later borrows of extra in same function ==" rg -n -C2 'match &extra|&extra' "$file"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs` around lines 339 - 344, The code currently consumes extra via matches!(extra, ...) and match extra, which prevents later borrows (&extra) in the same function (e.g., in new_confirm_action_uni). Change these by-value uses to borrow instead: use matches!(&extra, ConfirmActionExtra::ExternalMenu) for has_external_menu and match &extra { ConfirmActionExtra::ExternalMenu | ConfirmActionExtra::Menu(_) => header.with_menu_button(), ConfirmActionExtra::Cancel => header.with_cancel_button(), } so extra remains available for subsequent &extra borrows.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs`:
- Around line 339-344: The code currently consumes extra via matches!(extra,
...) and match extra, which prevents later borrows (&extra) in the same function
(e.g., in new_confirm_action_uni). Change these by-value uses to borrow instead:
use matches!(&extra, ConfirmActionExtra::ExternalMenu) for has_external_menu and
match &extra { ConfirmActionExtra::ExternalMenu | ConfirmActionExtra::Menu(_) =>
header.with_menu_button(), ConfirmActionExtra::Cancel =>
header.with_cancel_button(), } so extra remains available for subsequent &extra
borrows.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 63fdbc92-1e8b-4dba-a08b-06e9e2870cfc
📒 Files selected for processing (22)
core/embed/rust/src/ui/layout_delizia/component/address_details.rscore/embed/rust/src/ui/layout_delizia/component/coinjoin_progress.rscore/embed/rust/src/ui/layout_delizia/component/frame.rscore/embed/rust/src/ui/layout_delizia/component/header.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_action.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_fido.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_firmware_update.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_homescreen.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_reset.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_set_new_code.rscore/embed/rust/src/ui/layout_delizia/flow/confirm_summary.rscore/embed/rust/src/ui/layout_delizia/flow/continue_recovery_homepage.rscore/embed/rust/src/ui/layout_delizia/flow/prompt_backup.rscore/embed/rust/src/ui/layout_delizia/flow/receive.rscore/embed/rust/src/ui/layout_delizia/flow/request_number.rscore/embed/rust/src/ui/layout_delizia/flow/request_passphrase.rscore/embed/rust/src/ui/layout_delizia/flow/set_brightness.rscore/embed/rust/src/ui/layout_delizia/flow/show_danger.rscore/embed/rust/src/ui/layout_delizia/flow/show_share_words.rscore/embed/rust/src/ui/layout_delizia/flow/show_tutorial.rscore/embed/rust/src/ui/layout_delizia/flow/util.rscore/embed/rust/src/ui/layout_delizia/ui_firmware.rs
jjanku
left a comment
There was a problem hiding this comment.
Overall, it makes sense and looks good to me 👍
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
core/embed/rust/src/ui/layout_delizia/component/frame.rs (1)
112-126:⚠️ Potential issue | 🟠 Major | ⚡ Quick winKeep
has_menusynchronized with the providedHeader.After moving menu-button builders off
Frame,new()still hard-codeshas_menutofalse. Inui_debug, that means a frame can render a menu viaHeaderwhile tracing as menu-less unless every caller also remembers.with_external_menu(). Please derive this flag fromheaderhere, or keep the oldFramebridge until the migration is finished.Also applies to: 130-136
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@core/embed/rust/src/ui/layout_delizia/component/frame.rs` around lines 112 - 126, The ui_debug flags has_menu and has_flow_menu are hard-coded to false in Frame::new which can desync debug tracing from the actual Header state; update Frame::new (and the other Frame constructors around the later block) to derive these flags from the passed Header (e.g., use Header's menu/flow-menu accessor such as header.has_menu() or similar API) so has_menu and has_flow_menu reflect whether the Header provides an external menu instead of always setting them to false.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@core/embed/rust/src/ui/layout_delizia/component/frame.rs`:
- Around line 112-126: The ui_debug flags has_menu and has_flow_menu are
hard-coded to false in Frame::new which can desync debug tracing from the actual
Header state; update Frame::new (and the other Frame constructors around the
later block) to derive these flags from the passed Header (e.g., use Header's
menu/flow-menu accessor such as header.has_menu() or similar API) so has_menu
and has_flow_menu reflect whether the Header provides an external menu instead
of always setting them to false.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5038cd4e-a257-4ff4-844e-6f916d94b262
📒 Files selected for processing (1)
core/embed/rust/src/ui/layout_delizia/component/frame.rs
ce271fe to
e78a3fe
Compare




























































































































































Needed to allow dropping empty header on Delizia (similar to af8bfeb, will be used in #6651).
Also reduces
TREZOR_MODEL=T3T1 PYOPT=0 make build_firmwareflash size by 4kB = 1645056 - 1640960.