perf(node): add stable keys and contentType to telemetry chart lists#5869
Merged
Conversation
The metrics chart screens rendered their log lists with bare
`itemsIndexed(data) { ... }` — no `key` and no `contentType`. Without a
stable key, Compose falls back to positional identity, so inserting or
reordering a row (new telemetry arrives at the top) forces a full
re-layout of the list and defeats `animateItem`.
Give each list a stable item key and a constant `contentType`:
- DeviceMetrics (both lists), AirQualityMetrics, PowerMetrics,
EnvironmentMetrics: key on `telemetry.time`.
- PositionLogScreens: key on `position.time`.
- PaxMetrics: key on the `MeshLog.uuid` primary key rather than
`received_date`, which isn't guaranteed unique.
- SignalMetrics: the list is heterogeneous (LocalStatsEntry vs
PacketEntry), where a bare timestamp could collide across subtypes.
Added type-prefixed `key`/`contentType` members to the SignalLogEntry
sealed interface ("local_stats_<time>" vs "packet_<id>").
- ScannedQrCodeDialog: keyed on the channel slot index (the identity
already used for selection state); the bigger win is `contentType`
since that LazyColumn interleaves several item types.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
📄 Docs staleness check — advisoryThis PR modifies user-facing UI source files but does not update any page under
Changed source files: What to check:
New page checklist (if adding a new doc page):
If this PR does not require a doc update (e.g., internal refactor, bug fix, test change), add the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The telemetry/log lists in the node metrics screens rendered with bare
itemsIndexed(data) { ... }— nokeyand nocontentType. Without a stable key, Compose uses positional identity, so when a row is inserted or reordered (new telemetry arrives at the top of these time-sorted lists) the whole list is re-laid-out andanimateItemcan't run. This adds stable identities and content types so only the affected rows recompose.🛠️ Changes
itemsIndexedin the metrics screens:DeviceMetrics(both lists),AirQualityMetrics,PowerMetrics,EnvironmentMetrics→ key ontelemetry.time.PositionLogScreens→ key onposition.time.PaxMetrics→ key on theMeshLog.uuidprimary key (notreceived_date, which isn't guaranteed unique).ScannedQrCodeDialog→ key on the channel slot index (the identity already used for selection state).contentTypeadded to each list so Compose can pool/reuse compositions per type. This matters most in the heterogeneousLazyColumns (ScannedQrCodeDialoginterleaves description text, channel rows, LoRa-change blocks, and buttons;SignalMetricsmixes two card types).SignalMetricsheterogeneous list: itsLazyColumnholds bothLocalStatsEntryandPacketEntry, where a bare timestamp could collide across the two subtypes. Added type-prefixedkey/contentTypemembers to theSignalLogEntrysealed interface ("local_stats_<time>"vs"packet_<meshPacket.id>") so keys stay collision-free and the two card layouts get distinct content types.TracerouteLogandHostMetricsLogalready had keys and were left untouched.Note for reviewers
The timestamp-based keys assume
timeis unique within each list. This matches the screens' existing selection logic, which already treatstimeas each card's identity (telemetry.time.toDouble() == selectedX) — so duplicate timestamps would already have broken selection highlighting, independent of this change.Testing Performed
./gradlew spotlessApply spotlessCheck detekt assembleDebug— all pass../gradlew :feature:node:allTests— all pass (JVM unit tests; iOS simulator compilation succeeds).No test changes were required — this is a list-rendering/identity change with no behavioral surface in the existing unit tests.