Skip to content

fix(nodes): refresh distance when display units change#6351

Open
CatSu-OSM wants to merge 2 commits into
meshtastic:mainfrom
CatSu-OSM:bugfix/node-distance-unit
Open

fix(nodes): refresh distance when display units change#6351
CatSu-OSM wants to merge 2 commits into
meshtastic:mainfrom
CatSu-OSM:bugfix/node-distance-unit

Conversation

@CatSu-OSM

@CatSu-OSM CatSu-OSM commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • Reformat node-list distances when the display unit state changes.
  • Refresh node-row accessibility descriptions with the new distance text.
  • Add Compose Multiplatform regression tests for the full and compact node layouts.

Root cause

The formatted distance was remembered using only the two nodes as keys. When the node-list state changed from its initial metric value to the locale-derived imperial value, Compose retained the cached kilometer string until either node refreshed.

User impact

Distances on the Nodes tab now switch to miles immediately when imperial units become active, without requiring a node refresh.

Validation

  • ./gradlew spotlessCheck detekt assembleDebug test --no-configuration-cache
  • ./gradlew :core:ui:allTests --no-configuration-cache
  • Both new metric-to-imperial Compose regression tests pass.

Repository-wide allTests was also attempted on Windows. The unrelated :core:datastore:allTests task failed because 18 existing RecentAddressesDataSourceTest cases could not rename DataStore temporary files; the failure reproduces in that module alone. The changed :core:ui module's complete allTests lifecycle passes.

Summary by CodeRabbit

  • Bug Fixes
    • Node distance text now updates immediately when switching between metric and imperial units (including compact views).
    • Accessibility distance descriptions are now kept in sync with the currently displayed distance.
  • Tests
    • Added UI coverage to verify distance text and accessibility content update correctly in both node view modes when measurement units change.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6722255b-5b0f-43fe-b4ba-d0543b624f16

📥 Commits

Reviewing files that changed from the base of the PR and between 81145f2 and a58c557.

📒 Files selected for processing (1)
  • core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/component/NodeItemDistanceUnitsTest.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/component/NodeItemDistanceUnitsTest.kt

📝 Walkthrough

Walkthrough

NodeItem and NodeItemCompact now recompute distance text when units change and accessibility descriptions when distance changes. Compose tests verify metric-to-imperial updates for both components.

Changes

Distance unit refresh

Layer / File(s) Summary
Component distance recomputation
core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/NodeItem.kt, core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/NodeItemCompact.kt
Distance strings now depend on the display unit system, while accessibility descriptions depend on the computed distance.
Distance unit change tests
core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/component/NodeItemDistanceUnitsTest.kt
Compose tests render both node item variants and verify metric text changes to imperial text when units are updated.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: refreshing node distance when display units change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CLAassistant

CLAassistant commented Jul 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added the bugfix PR tag label Jul 22, 2026
@CatSu-OSM
CatSu-OSM marked this pull request as ready for review July 22, 2026 03:47
@CatSu-OSM
CatSu-OSM marked this pull request as draft July 22, 2026 03:47
@CatSu-OSM
CatSu-OSM marked this pull request as ready for review July 22, 2026 03:48

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/component/NodeItemDistanceUnitsTest.kt (1)

71-76: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the updated accessibility description too.

These assertions only cover rendered text; add semantic content-description checks for metric removal and imperial addition so the accessibility fix cannot regress.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/component/NodeItemDistanceUnitsTest.kt`
around lines 71 - 76, Add semantic content-description assertions in the
NodeItemDistanceUnitsTest flow after switching distanceUnits to imperial: verify
the metric content description is absent and the imperial content description is
present, alongside the existing rendered-text assertions. Use the existing
metricDistance and imperialDistance values or their corresponding semantic
expectations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/component/NodeItemDistanceUnitsTest.kt`:
- Line 75: Import androidx.compose.ui.test.assertDoesNotExist in
NodeItemDistanceUnitsTest so the existing
onNodeWithText(metricDistance).assertDoesNotExist() assertion resolves and the
test compiles.

---

Nitpick comments:
In
`@core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/component/NodeItemDistanceUnitsTest.kt`:
- Around line 71-76: Add semantic content-description assertions in the
NodeItemDistanceUnitsTest flow after switching distanceUnits to imperial: verify
the metric content description is absent and the imperial content description is
present, alongside the existing rendered-text assertions. Use the existing
metricDistance and imperialDistance values or their corresponding semantic
expectations.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7779fee6-b18b-45f2-9bc9-2de92c6cc3cd

📥 Commits

Reviewing files that changed from the base of the PR and between 12a8a38 and 81145f2.

📒 Files selected for processing (3)
  • core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/NodeItem.kt
  • core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/NodeItemCompact.kt
  • core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/component/NodeItemDistanceUnitsTest.kt

@CatSu-OSM

Copy link
Copy Markdown
Author

Could a maintainer please add the ai-generated label?

@CatSu-OSM

CatSu-OSM commented Jul 22, 2026

Copy link
Copy Markdown
Author

Valid finding fixed and pushed to [PR #6351](#6351).

Added assertions confirming:

  • Metric content description disappears.
  • Imperial content description appears.
  • Both full and compact node layouts are covered.

Validation passed: Spotless, Detekt, compilation, and both focused tests. Commit: a58c557. The PR is currently ready for review, not draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants