refactor(core): drop header if title unset
What changed, and why it matters
This is a user-interface cleanup change for Trezor hardware wallets. It lets the 'show_warning' screen accept 'None' for the title, which means 'hide the header entirely', instead of using an empty string to mean the same thing. It is a refactor with no changelog and no apparent security relevance.
No security action required. Treat as a normal UI refactor during code review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit changes the ‘title’ parameter of the FirmwareUI::show_warning method from a required TString to an Option
Changed components
core/embed/rust/src/ui/api/firmware_micropython.rscore/embed/rust/src/ui/layout_bolt/ui_firmware.rscore/embed/rust/src/ui/layout_caesar/ui_firmware.rscore/embed/rust/src/ui/layout_delizia/ui_firmware.rscore/embed/rust/src/ui/layout_eckhart/ui_firmware.rscore/embed/rust/src/ui/ui_firmware.rscore/mocks/generated/trezorui_api.pyiInspect captured patch +29 / −27
diff --git a/core/embed/rust/src/ui/api/firmware_micropython.rs b/core/embed/rust/src/ui/api/firmware_micropython.rs
index 8fe667ef..6c30bc26 100644
--- a/core/embed/rust/src/ui/api/firmware_micropython.rs
+++ b/core/embed/rust/src/ui/api/firmware_micropython.rs
@@ -1274,7 +1274,7 @@ extern "C" fn new_show_wait_text(message: Obj) -> Obj {
extern "C" fn new_show_warning(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
- let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
+ let title: Option<TString> = kwargs.get(Qstr::MP_QSTR_title)?.try_into_option()?;
let button: TString = kwargs.get(Qstr::MP_QSTR_button)?.try_into()?;
let value: TString = kwargs.get_or(Qstr::MP_QSTR_value, "".into())?;
let description: TString = kwargs.get_or(Qstr::MP_QSTR_description, "".into())?;
@@ -2155,7 +2155,7 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// def show_warning(
/// *,
- /// title: str,
+ /// title: str | None,
/// button: str,
/// value: str = "",
/// description: str = "",
diff --git a/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs b/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs
index 3f554687..3bf2b78e 100644
--- a/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs
+++ b/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs
@@ -1271,7 +1271,7 @@ impl FirmwareUI for UIBolt {
}
fn show_warning(
- title: TString<'static>,
+ title: Option<TString<'static>>,
button: TString<'static>,
value: TString<'static>,
description: TString<'static>,
@@ -1286,7 +1286,7 @@ impl FirmwareUI for UIBolt {
theme::BG,
);
new_show_modal(
- title,
+ title.unwrap_or(TString::empty()),
value,
description,
(!button.is_empty()).then_some(button),
diff --git a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs
index cb624e65..de882e2b 100644
--- a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs
+++ b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs
@@ -1366,7 +1366,7 @@ impl FirmwareUI for UICaesar {
}
fn show_warning(
- _title: TString<'static>,
+ _title: Option<TString<'static>>,
button: TString<'static>,
value: TString<'static>,
description: TString<'static>,
diff --git a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
index d4acf9d8..058fa9eb 100644
--- a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
+++ b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
@@ -1233,7 +1233,7 @@ impl FirmwareUI for UIDelizia {
}
fn show_warning(
- title: TString<'static>,
+ title: Option<TString<'static>>,
button: TString<'static>,
value: TString<'static>,
description: TString<'static>,
@@ -1253,20 +1253,23 @@ impl FirmwareUI for UIDelizia {
.into_paragraphs(),
);
- let frame = if title.is_empty() {
- if danger {
- // Disallow showing "dangerous" warning with no header.
- return Err(Error::ValueError(c"Non-empty title is required"));
+ let frame = match title {
+ None => {
+ if danger {
+ // Disallow showing "dangerous" warning with no header.
+ return Err(Error::ValueError(c"Non-empty title is required"));
+ }
+ Frame::content(content)
+ }
+ Some(title) => {
+ let header = Header::left_aligned(title);
+ let header = if danger {
+ header.with_danger_icon()
+ } else {
+ header.with_warning_low_icon()
+ };
+ Frame::with_header(header, content)
}
- Frame::content(content)
- } else {
- let header = Header::left_aligned(title);
- let header = if danger {
- header.with_danger_icon()
- } else {
- header.with_warning_low_icon()
- };
- Frame::with_header(header, content)
};
let frame = if danger {
frame.with_tap_footer(action)
diff --git a/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs b/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs
index c4b58be6..0252b100 100644
--- a/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs
+++ b/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs
@@ -1546,7 +1546,7 @@ impl FirmwareUI for UIEckhart {
}
fn show_warning(
- title: TString<'static>,
+ title: Option<TString<'static>>,
button: TString<'static>,
value: TString<'static>,
description: TString<'static>,
@@ -1575,14 +1575,13 @@ impl FirmwareUI for UIEckhart {
ActionBar::new_single(Button::with_text(button))
};
let screen = TextScreen::new(paragraphs).with_action_bar(action_bar);
- let screen = if title.is_empty() {
- screen
- } else {
- screen.with_header(
+ let screen = match title {
+ None => screen,
+ Some(title) => screen.with_header(
Header::new(title)
.with_icon(theme::ICON_INFO, color)
.with_text_style(style),
- )
+ ),
};
let layout = LayoutObj::new(screen)?;
Ok(layout)
diff --git a/core/embed/rust/src/ui/ui_firmware.rs b/core/embed/rust/src/ui/ui_firmware.rs
index 56f65467..c48bb160 100644
--- a/core/embed/rust/src/ui/ui_firmware.rs
+++ b/core/embed/rust/src/ui/ui_firmware.rs
@@ -464,7 +464,7 @@ pub trait FirmwareUI {
fn show_wait_text(text: TString<'static>) -> Result<impl LayoutMaybeTrace, Error>;
fn show_warning(
- title: TString<'static>,
+ title: Option<TString<'static>>,
button: TString<'static>,
value: TString<'static>,
description: TString<'static>,
diff --git a/core/mocks/generated/trezorui_api.pyi b/core/mocks/generated/trezorui_api.pyi
index 7ae02f53..90f2ae54 100644
--- a/core/mocks/generated/trezorui_api.pyi
+++ b/core/mocks/generated/trezorui_api.pyi
@@ -834,7 +834,7 @@ def show_wait_text(message: str, /) -> LayoutObj[None]:
# rust/src/ui/api/firmware_micropython.rs
def show_warning(
*,
- title: str,
+ title: str | None,
button: str,
value: str = "",
description: str = "",
Why this scored 12/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.