feat(core/caesar): use new menu in prompt_backup
What changed, and why it matters
This commit is a user-interface refactor for the Trezor hardware wallet's backup prompt. It replaces a two-page flow with a scrollable frame and moves the 'skip backup' action into a context menu. There is no security vulnerability visible in the diff; it is a normal feature/UX change.
No security action required. Review as normal UI/UX refactor if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change updates the Caesar layout’s prompt_backup() implementation. It removes a custom two-page FlowPages builder and instead uses a single FormattedText with a page break, wrapped in a ScrollableFrame that supports per-page titles. The ‘skip’ action is moved from a bottom button to a menu accessed via MenuNav::ChoiceMenu. The Python side is updated to use interact_with_menu and supply a menu containing the skip action. The Rust ScrollableFrame component is extended with page_titles support (up to 2 titles) so the title updates as the user scrolls between pages. Tests are updated to match the new navigation pattern.
Changed components
core/embed/rust/src/ui/layout_caesar/component/frame.rscore/embed/rust/src/ui/layout_caesar/ui_firmware.rscore/src/trezor/ui/layouts/caesar/__init__.pytests/input_flows.pyInspect captured patch +65 / −28
### core/embed/rust/src/ui/layout_caesar/component/frame.rs
@@ -1,3 +1,5 @@
+use heapless::Vec;
+
use super::super::constant;
use super::scrollbar::SCROLLBAR_SPACE;
use super::title::Title;
@@ -102,17 +104,23 @@ where
T: Component + Paginate,
{
title: Option<Child<Title>>,
+ /// Titles of the individual pages, replacing `title` when the page changes.
+ page_titles: Vec<TString<'static>, MAX_PAGE_TITLES>,
scrollbar: ScrollBar,
content: Child<T>,
}
+/// How many pages can have their own title in `ScrollableFrame`.
+const MAX_PAGE_TITLES: usize = 2;
+
impl<T> ScrollableFrame<T>
where
T: Component + Paginate,
{
pub fn new(content: T) -> Self {
Self {
title: None,
+ page_titles: Vec::new(),
scrollbar: ScrollBar::to_be_filled_later(),
content: Child::new(content),
}
@@ -127,6 +135,13 @@ where
self
}
+ /// Each page with its own title. Pages after the last title keep it.
+ pub fn with_page_titles(mut self, titles: [TString<'static>; MAX_PAGE_TITLES]) -> Self {
+ self = self.with_title(titles[0]);
+ self.page_titles = Vec::from_iter(titles);
+ self
+ }
+
/// Showing a numeric "current/total" page counter instead of the dots.
pub fn with_numeric_page_counter(mut self) -> Self {
self.scrollbar = self.scrollbar.with_numeric();
@@ -188,6 +203,16 @@ where
if self.scrollbar.pager().current() != content_active_page {
self.scrollbar.change_page(content_active_page);
self.scrollbar.request_complete_repaint(ctx);
+ let page_title = self
+ .page_titles
+ .get(content_active_page as usize)
+ .or(self.page_titles.last());
+ if let (Some(&page_title), Some(title)) = (page_title, &mut self.title) {
+ title.mutate(ctx, |ctx, title| {
+ title.set_text(ctx, page_title);
+ title.request_complete_repaint(ctx);
+ });
+ }
}
self.title.event(ctx, event);
msg
### core/embed/rust/src/ui/layout_caesar/ui_firmware.rs
@@ -709,33 +709,25 @@ impl FirmwareUI for UICaesar {
}
fn prompt_backup() -> Result<impl LayoutMaybeTrace, Error> {
- let get_page = move |page_index| match page_index {
- 0 => {
- let btn_layout = ButtonLayout::text_none_arrow_wide(TR::buttons__skip.into());
- let btn_actions = ButtonActions::cancel_none_next();
- let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
- ops.add_text_with_font(TR::backup__new_wallet_created, fonts::FONT_NORMAL)
- .add_newline()
- .add_text_with_font(TR::backup__it_should_be_backed_up_now, fonts::FONT_NORMAL);
- let formatted = FormattedText::new(ops).vertically_centered();
- Page::new(btn_layout, btn_actions, formatted)
- .with_title(TR::words__title_success.into())
- }
- 1 => {
- let btn_layout = ButtonLayout::up_arrow_none_text(TR::buttons__back_up.into());
- let btn_actions = ButtonActions::prev_none_confirm();
- let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
- ops.add_text_with_font(TR::backup__recover_anytime, fonts::FONT_NORMAL);
- let formatted = FormattedText::new(ops).vertically_centered();
- Page::new(btn_layout, btn_actions, formatted)
- .with_title(TR::backup__title_backup_wallet.into())
- }
- _ => unreachable!(),
- };
- let pages = FlowPages::new(get_page, 2);
+ let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
+ ops.add_text_with_font(TR::backup__new_wallet_created, fonts::FONT_NORMAL)
+ .add_newline()
+ .add_text_with_font(TR::backup__it_should_be_backed_up_now, fonts::FONT_NORMAL)
+ .add_next_page()
+ .add_text_with_font(TR::backup__recover_anytime, fonts::FONT_NORMAL);
+ let formatted = FormattedText::new(ops).vertically_centered();
- let layout = RootComponent::new(Flow::new(pages));
- Ok(layout)
+ // Skipping the backup is in the context menu.
+ let content = ButtonPage::new(formatted, theme::BG)
+ .with_menu_nav(MenuNav::ChoiceMenu)
+ .with_confirm_btn(Some(ButtonDetails::text(TR::buttons__back_up.into())));
+ let frame = ScrollableFrame::new(content)
+ .with_page_titles([
+ TR::words__title_success.into(),
+ TR::backup__title_backup_wallet.into(),
+ ])
+ .with_numeric_page_counter();
+ Ok(RootComponent::new(frame))
}
fn request_bip39(
### core/src/trezor/ui/layouts/caesar/__init__.py
@@ -152,11 +152,20 @@ async def show_wallet_created_success() -> None:
async def prompt_backup() -> bool:
+ from trezor.ui.layouts.menu import Menu, MenuLeaf, interact_with_menu
+
br_name = "backup_device"
br_code = ButtonRequestType.ResetDevice
+ async def skip() -> bool:
+ return True
+
+ # skipping is in the menu
+ menu = Menu([MenuLeaf(TR.buttons__skip, skip)])
with trezorui_api.prompt_backup() as layout:
- result = await interact(layout, br_name, br_code, raise_on_cancel=None)
+ result = await interact_with_menu(
+ layout, menu, br_name, br_code, raise_on_cancel=None
+ )
if result is CONFIRMED:
return True
### tests/input_flows.py
@@ -4064,8 +4064,19 @@ def input_flow_caesar(self) -> BRGeneratorType:
yield from self.BAK.confirm_new_wallet()
yield # Skip Backup
assert TR.backup__new_wallet_created in self.text_content()
+ assert self.debug.read_layout().title() == TR.words__title_success
+ # second page and back with "Shift"
self.debug.press_right()
- self.debug.press_no()
+ layout = self.debug.read_layout()
+ assert layout.title() == TR.backup__title_backup_wallet
+ assert TR.backup__recover_anytime in layout.text_content()
+ self.debug.press_right_with_shift()
+ layout = self.debug.read_layout()
+ assert layout.title() == TR.words__title_success
+ assert TR.backup__new_wallet_created in layout.text_content()
+ # skip from the menu
+ self.debug.press_left()
+ self.debug.button_actions.navigate_to_menu_item(0)
yield # Confirm skip backup
assert TR.backup__want_to_skip in self.text_content()
self.debug.press_no()Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.