fix(node): disambiguate signal-log packet keys - #6492
Merged
Conversation
The Signal Metrics screen keyed its LazyColumn packet rows off MeshPacket.id alone. That id is unique only per originating node, and a retransmitted packet is stored once per reception, so real duplicates reach the list and Compose throws a fatal IllegalArgumentException. Confirmed in the field on 2.8.0 across several builds. The sibling LocalStatsEntry already disambiguated with its source-list index; PacketEntry now does the same. Also lifts the list building out of the composable into buildSignalLog() and widens SignalLogEntry to internal, so the keys can be tested at all — a duplicate here is a crash, not a cosmetic glitch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthroughSignal metrics now use a shared helper to merge telemetry and packet samples, sort entries newest-first, and generate collision-free list keys. Tests cover repeated IDs, signed IDs, shared timestamps, and ordering. ChangesSignal log handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
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 |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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
`@feature/node/src/commonTest/kotlin/org/meshtastic/feature/node/metrics/SignalLogKeyTest.kt`:
- Around line 39-46: Update the test `a negative packet id is not conflated with
its positive twin` so it verifies packet ID encoding independently of packet
index: build each signed-ID packet in a separate single-item `buildSignalLog`
call, or assert the exact expected signed keys. Ensure the assertion fails if
key generation ignores or normalizes the packet ID.
🪄 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: 8557c8e1-3ef5-4b44-9c51-4d7dfae6aa2b
📒 Files selected for processing (2)
feature/node/src/commonMain/kotlin/org/meshtastic/feature/node/metrics/SignalMetrics.ktfeature/node/src/commonTest/kotlin/org/meshtastic/feature/node/metrics/SignalLogKeyTest.kt
Both packets sat at different indices, so the assertion passed even if key generation dropped or normalised the id. Each id now gets its own single-item log at index 0 and the exact key is asserted, so the id is the only thing that can separate them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The Signal Metrics screen crashed for real users on 2.8.0: its
LazyColumnkeyed packet rows offMeshPacket.idalone, but that id is unique only per originating node and a retransmitted packet is stored once per reception, so genuine duplicates reach the list and Compose throws a fatalIllegalArgumentException. Observed on several 2.8.0 builds, on real devices with normal interaction.🐛 Bug Fixes
SignalLogEntry.PacketEntrynow carries its source-list index and keys off"packet_<id>_<index>". The siblingLocalStatsEntryalready disambiguated this way — packets were simply missed.🛠️ Refactoring & Architecture
SignalMetricsScreenintointernal fun buildSignalLog(...), and widenedSignalLogEntryfromprivatetointernal. The keys had no test coverage because the type was file-private, and a duplicate key here is a crash rather than a cosmetic glitch — this makes the invariant testable.Testing Performed
New
feature/node/src/commonTest/.../SignalLogKeyTest.kt(commonMain logic, so it runs on every KMP target):repeated packet ids still produce distinct keys— the shape that actually crasheda negative packet id is not conflated with its positive twin— packet ids are signed in the proto. Asserts the exact key with each id at index 0, so the index cannot be what separates them (strengthened after review feedback)local stats and packets sharing a timestamp do not collide— cross-type key safetyentries are ordered newest first across both types— guards the ordering the extraction preservesFull local baseline green:
spotlessApply spotlessCheck detekt assembleDebug test allTests.No UI appearance change — this only affects item identity, so there is nothing visual to capture.
Summary by CodeRabbit
Bug Fixes
Tests