Conversation
…ethod [no changelog]
Similar to `reset_device.layout` containing wordlist-related layouts. [no changelog]
Will be used for N4W1 layouts. [no changelog]
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis pull request refactors recovery device handler logic and enhances debug and layout systems. The recovery handler implementation is moved from Sequence DiagramsequenceDiagram
participant N4W1Ctx as N4W1Context
participant Rx as rx Channel
participant Layout as UI Layout
participant Menu as confirm_with_menu
N4W1Ctx->>N4W1Ctx: confirm_connect() called
N4W1Ctx->>Layout: Create Layout with async task
Layout->>N4W1Ctx: Run connect() task
N4W1Ctx->>Rx: await first value
Rx->>N4W1Ctx: DebugLinkN4W1Response(value=None)
N4W1Ctx->>N4W1Ctx: Assert connection notification
N4W1Ctx->>Layout: Emit CONFIRMED message
Layout->>Menu: Run confirm_with_menu with Layout
Menu->>Layout: Return with external menu
Layout->>N4W1Ctx: Complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 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 |
de9efb2 to
ac4c601
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/core.yml:
- Line 130: Add the N4W1 environment variable to the core_firmware and
core_emu_arm job definitions using the same conditional expression used in
core_emu: set N4W1: ${{ matrix.type == 'debuglink' && '1' || '0' }} so the build
system (SConscript.firmware and SConscript.unix) receives the flag when
PYOPT=='0' and debuglink variants exercise N4W1 plumbing; mirror the exact
expression already present in the core_emu job.
In `@core/src/apps/management/recovery_device/layout.py`:
- Around line 281-289: The debug log in choose_handler currently warns for any
method not equal to BackupMethod.Display, which incorrectly flags method None
(used by recovery_homescreen -> recovery_process) as unsupported; update the
conditional in choose_handler to only warn when __debug__ is true and method is
not None and method is not BackupMethod.Display (put __debug__ first to
short-circuit in non-debug builds) so None is treated as the valid sentinel and
no warning is emitted; keep returning _DisplayHandler unchanged.
🪄 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: 0b690685-3495-4fb5-a919-e62ace8d98e8
📒 Files selected for processing (6)
.github/workflows/core.ymlcore/src/apps/debug/n4w1_mock.pycore/src/apps/management/recovery_device/homescreen.pycore/src/apps/management/recovery_device/layout.pycore/src/apps/management/reset_device/layout.pycore/src/trezor/ui/layouts/menu.py
| async def choose_handler(method: BackupMethod | None) -> type[RecoveryHandler]: | ||
| from trezor.enums import BackupMethod | ||
|
|
||
| if method is not BackupMethod.Display and __debug__: | ||
| from trezor import log | ||
|
|
||
| log.warning(__name__, "Unsupported backup method: %s", method) | ||
|
|
||
| return _DisplayHandler |
There was a problem hiding this comment.
Suppress the unsupported-method warning for method is None as well.
recovery_homescreen() calls recovery_process(None), so the common recovery path reaches choose_handler(None). With the current condition, debug builds will log "Unsupported backup method: None" on every ordinary recovery, even though None is the sentinel reserved for the future interactive-selection flow (analogous to choose_backup_method() in reset_device/layout.py) and is not an "unsupported" value.
Based on learnings: "method=None passed to choose_backup_method() is intentionally distinct from BackupMethod.Display. … It should NOT be treated as equivalent to BackupMethod.Display, and debug-mode unsupported-method warnings should be suppressed for None (as well as for BackupMethod.Display)."
🛠 Proposed fix
async def choose_handler(method: BackupMethod | None) -> type[RecoveryHandler]:
from trezor.enums import BackupMethod
- if method is not BackupMethod.Display and __debug__:
+ if __debug__ and method is not None and method is not BackupMethod.Display:
from trezor import log
log.warning(__name__, "Unsupported backup method: %s", method)
return _DisplayHandler(Also slightly cheaper: __debug__ is a compile-time constant, so placing it first lets the rest short-circuit out entirely in non-debug builds.)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@core/src/apps/management/recovery_device/layout.py` around lines 281 - 289,
The debug log in choose_handler currently warns for any method not equal to
BackupMethod.Display, which incorrectly flags method None (used by
recovery_homescreen -> recovery_process) as unsupported; update the conditional
in choose_handler to only warn when __debug__ is true and method is not None and
method is not BackupMethod.Display (put __debug__ first to short-circuit in
non-debug builds) so None is treated as the valid sentinel and no warning is
emitted; keep returning _DisplayHandler unchanged.
"Hold the tag" layout should wait for tap event. Data read/write should be done later (using a different "progress" layout). [no changelog]
ac4c601 to
1df8713
Compare




























































































































































The commits below should not change current FW behavior.
N4W1 support will be introduced in #6799.