What changed, and why it matters
This commit restores the ability to swipe up or down to exit a QR code display screen in the Krux hardware wallet. Previously, those same up/down swipes were being used to cycle through display modes, which accidentally trapped the user on the screen. There is no security issue here; it is a straightforward user-interface bug fix.
No security action required. Treat as a normal UI/UX fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In SeedQRView.qr_view(), the inner event loop previously ran while True and consumed SWIPE_UP/SWIPE_DOWN to change display modes, preventing those gestures from reaching the outer loop’s exit logic. The patch changes the inner loop condition to while button not in (SWIPE_DOWN, SWIPE_UP), so the first vertical swipe breaks out of the inner loop and returns to the caller, restoring the intended ‘swipe to go back’ behavior. Tests are updated to use SWIPE_DOWN instead of BUTTON_TOUCH to simulate leaving the view.
Changed components
src/krux/pages/qr_view.pytests/pages/test_qr_view.pyInspect captured patch +7 / −11
diff --git a/src/krux/pages/qr_view.py b/src/krux/pages/qr_view.py
index 6c224b3..9abe9c1 100644
--- a/src/krux/pages/qr_view.py
+++ b/src/krux/pages/qr_view.py
@@ -518,7 +518,7 @@ class SeedQRView(Page):
mode = 0
while True:
button = None
- while True:
+ while button not in (SWIPE_DOWN, SWIPE_UP):
def toggle_brightness():
if self.qr_foreground == WHITE:
@@ -539,15 +539,11 @@ class SeedQRView(Page):
highlight_function(label, y_offset)
button = self.ctx.input.wait_for_button()
if transcript_tools:
- if button in (BUTTON_PAGE, SWIPE_UP, SWIPE_LEFT): # page, swipe
+ if button in (BUTTON_PAGE, SWIPE_LEFT): # page, swipe
mode += 1
mode %= 5
self.lr_index = 0
- elif button in (
- BUTTON_PAGE_PREV,
- SWIPE_DOWN,
- SWIPE_RIGHT,
- ): # page, swipe
+ elif button in (BUTTON_PAGE_PREV, SWIPE_RIGHT): # page, swipe
mode -= 1
mode %= 5
self.lr_index = 0
diff --git a/tests/pages/test_qr_view.py b/tests/pages/test_qr_view.py
index 64f5869..06c169c 100644
--- a/tests/pages/test_qr_view.py
+++ b/tests/pages/test_qr_view.py
@@ -101,7 +101,7 @@ def test_init_qr_view_background_white(amigo, mocker, mocker_theme_background_wh
def test_load_qr_no_title(mocker, amigo):
- from krux.input import BUTTON_TOUCH
+ from krux.input import SWIPE_DOWN
from krux.pages import MENU_CONTINUE
from krux.pages.qr_view import SeedQRView
@@ -116,7 +116,7 @@ def test_load_qr_no_title(mocker, amigo):
# UI methods like wait_for_button,
# draw_hcentered_text, draw_grided_qr, etc..
mocker.patch.object(qr_view, "draw_grided_qr")
- mocker.patch.object(qr_view.ctx.input, "wait_for_button", return_value=BUTTON_TOUCH)
+ mocker.patch.object(qr_view.ctx.input, "wait_for_button", return_value=SWIPE_DOWN)
mocker.patch.object(qr_view.ctx.display, "height", return_value=240)
mocker.patch.object(qr_view.ctx.display, "width", return_value=240)
mocker.patch.object(qr_view.ctx.display, "qr_offset", return_value=10)
@@ -130,7 +130,7 @@ def test_load_qr_no_title(mocker, amigo):
def test_display_qr_toggle_brightness(amigo, mocker):
- from krux.input import BUTTON_PAGE, BUTTON_TOUCH
+ from krux.input import BUTTON_PAGE, SWIPE_DOWN
from krux.pages import MENU_CONTINUE
from krux.pages.qr_view import SeedQRView
from krux.themes import DARKGREY, WHITE
@@ -143,7 +143,7 @@ def test_display_qr_toggle_brightness(amigo, mocker):
ctx.input = mocker.Mock()
ctx.input.wait_for_button.side_effect = [
BUTTON_PAGE,
- BUTTON_TOUCH,
+ SWIPE_DOWN,
]
ctx.display = mocker.Mock()
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.