Title: SettingsActivity: render ui_options label instead of raw pref value by bitcoin3us · Pull Request #137 · MicroPythonOS/MicroPythonOS · GitHub
Open Graph Title: SettingsActivity: render ui_options label instead of raw pref value by bitcoin3us · Pull Request #137 · MicroPythonOS/MicroPythonOS
X Title: SettingsActivity: render ui_options label instead of raw pref value by bitcoin3us · Pull Request #137 · MicroPythonOS/MicroPythonOS
Description: Summary Settings rows with ui: "radiobuttons" (or "dropdown") render the raw stored pref value in the secondary text beneath the title. So a row with: {"title": "Hero Image", "key": "hero_image", "ui": "radiobuttons", "ui_options": [("Lightning Piggy", "lightningpiggy"), ("Lightning Penguin", "lightningpenguin"), ("None", "none")]} …displays "lightningpiggy" (internal value, no space) in the row, even though the picker activity itself correctly shows "Lightning Piggy" on the radio button. The label-to-value mapping only ever existed inside the picker; the list-view row had no access to it. Same gap on the post-save path — when the user picks an option, the framework writes new_value directly to the value_label, so even a freshly-saved row reverts to "lightningpiggy". Fix Adds a small helper in settings_activity.py: def _value_label_for(setting, stored_value): ui_options = setting.get("ui_options") if ui_options: for label, value in ui_options: if value == stored_value: return label return stored_value Routed through in two places: settings_activity.py list-view render — instead of value_text = stored_value, use value_text = _value_label_for(setting, stored_value). Default-value branch also routed through. setting_activity.py post-save — instead of value_label.set_text(new_value), look up the label from ui_options first. Case Before After ui_options matches stored value "lightningpiggy" "Lightning Piggy" No ui_options (textarea, etc.) raw value raw value (unchanged) Stored value not in current ui_options (stale pref) raw value raw value (visible, recoverable, not collapsed to "(not set)") default_value rendered with "(defaults to X)" raw default_value mapped label Tests tests/test_settings_activity_label_mapping.py — 6 unit tests in one class on the new helper: Matched value returns label Unmatched value passes through (recoverable display for stale prefs) No ui_options passes through (textarea / freeform settings unaffected) Empty ui_options list passes through None value passes through (defensive — caller handles "(not set)" elsewhere) First-match-wins precedence with duplicate values (documents behavior) $ bash tests/unittest.sh tests/test_settings_activity_label_mapping.py Ran 6 tests OK Motivating case in the wild LightningPiggyApp PR #26 (multi-wallet) adds a per-slot Hero Image setting with values "lightningpiggy" / "lightningpenguin" / "none". Without this framework fix, the Customise menu showed those raw values with no space ("lightningpiggy" instead of "Lightning Piggy"). I shipped a local closure-callback workaround there as a stopgap; once this PR lands, that workaround can come out and the row will be consistent on both initial display and post-save. Hardware verification (this commit unchanged — verification done on existing tree) Captured on a live device running multi-wallet LP with the unpatched (frozen) framework, then with the patched framework injected via exec(src, mpos.ui.settings_activity.__dict__) at the REPL. Before — lightningpiggy raw value visible in the Hero Image row of Customise → exactly the bug this PR fixes: ┌──────────────────────────────────────┐ │ Balance Denomination │ │ ₿ symbol │ ├──────────────────────────────────────┤ │ Hero Image │ │ lightningpiggy ← raw │ ├──────────────────────────────────────┤ │ Theme │ │ Dark │ └──────────────────────────────────────┘ After (label re-rendered with _value_label_for applied to the live widget): ┌──────────────────────────────────────┐ │ Balance Denomination │ │ ₿ symbol │ ├──────────────────────────────────────┤ │ Hero Image │ │ Lightning Piggy ← mapped │ ├──────────────────────────────────────┤ │ Theme │ │ Dark │ └──────────────────────────────────────┘ PNG screenshots: /tmp/lp_customise_before_137.png and /tmp/lp_customise_after_137_simulated.png on the development host — see follow-up comment for the verification log. Test plan All 6 unit tests pass on desktop No regression in existing settings rows that have no ui_options (textarea / freeform) — verified by the "passes through" tests Visual smoke-test on device: Lightning Piggy's Customise → Hero Image row currently shows raw "lightningpiggy" with the frozen framework, switches to "Lightning Piggy" after the patched _value_label_for is applied to the same widget (see screenshots in the verification comment below) Confirm-once-released: the simulated-after screenshot exercises the same code path that the framework patch will run (label.set_text(_value_label_for(...))); a single end-to-end "open Customise on a fresh boot of firmware that includes this PR" check will tick once #137 is in a release build 🤖 Generated with Claude Code
Open Graph Description: Summary Settings rows with ui: "radiobuttons" (or "dropdown") render the raw stored pref value in the secondary text beneath the title. So a row with: {"title": "...
X Description: Summary Settings rows with ui: "radiobuttons" (or "dropdown") render the raw stored pref value in the secondary text beneath the title. So a row with: {"...
Opengraph URL: https://github.com/MicroPythonOS/MicroPythonOS/pull/137
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:ef03453d-7854-21f3-18e2-f2f3ebcafc0a |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D7B8:25305:B376D9:10160DF:6A4E4795 |
| html-safe-nonce | 36000e43489a0cf453d88f1a8f7aebe74efd7420e23542a8f2be5001cc3f3026 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0I4OjI1MzA1OkIzNzZEOToxMDE2MERGOjZBNEU0Nzk1IiwidmlzaXRvcl9pZCI6IjIyOTkzNDQ2ODY4MjM2NTUzMTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 55acb69d8b9ae5011b3fa9fc3d9627bddc41a18678975445f51b7a8425e37780 |
| hovercard-subject-tag | pull_request:3677237317 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/MicroPythonOS/MicroPythonOS/pull/137/files |
| twitter:image | https://avatars.githubusercontent.com/u/115934595?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/115934595?s=400&v=4 |
| og:image:alt | Summary Settings rows with ui: "radiobuttons" (or "dropdown") render the raw stored pref value in the secondary text beneath the title. So a row with: {"title": "... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/MicroPythonOS/MicroPythonOS git https://github.com/MicroPythonOS/MicroPythonOS.git |
| octolytics-dimension-user_id | 213598128 |
| octolytics-dimension-user_login | MicroPythonOS |
| octolytics-dimension-repository_id | 975472483 |
| octolytics-dimension-repository_nwo | MicroPythonOS/MicroPythonOS |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 975472483 |
| octolytics-dimension-repository_network_root_nwo | MicroPythonOS/MicroPythonOS |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e8506f6d0538364886e3f0153c154c410965e70d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width