Skip to content

feat(charts): More charts ui/ux tweaks#4520

Merged
jamesarich merged 15 commits into
meshtastic:mainfrom
jamesarich:fix/charts
Feb 10, 2026
Merged

feat(charts): More charts ui/ux tweaks#4520
jamesarich merged 15 commits into
meshtastic:mainfrom
jamesarich:fix/charts

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

This pull request introduces a significant refactor and feature enhancement to the metrics screens, particularly focusing on time frame selection and filtering, code simplification, and improved data handling for environment metrics. The changes standardize the way metrics are filtered by time, add user controls for selecting time frames, and clean up the codebase by removing unnecessary logic and improving data validity checks.

Key improvements include:

Time Frame Selection & Filtering

  • Added new string resources for various time frames (e.g., "1H", "1M", "All") to strings.xml to support user-friendly time frame selection in the UI. [1] [2]
  • Introduced a TimeFrameSelector composable and integrated it into both DeviceMetricsScreen and EnvironmentMetricsScreen, allowing users to filter metrics by selectable time frames. [1] [2]
  • Updated data filtering logic in DeviceMetricsScreen and EnvironmentMetricsScreen to only display metrics within the selected time frame, using the new timeFrame and availableTimeFrames state. [1] [2]

Codebase Simplification & Cleanup

  • Refactored EnvironmentMetricsScreen to use the shared BaseMetricScreen and removed a significant amount of redundant or boilerplate Compose code, streamlining the UI logic.
  • Removed unused imports and unnecessary local state/logic from EnvironmentMetrics.kt for better maintainability.

Data Handling & Validity

  • Improved handling of invalid or missing soil moisture and IAQ values by filtering out Int.MIN_VALUE (previously only filtered zero), ensuring charts and stats do not display nonsensical data. [1] [2] [3]
  • Added a validity check for environment metrics in the Telemetry model to ensure only valid data is considered for display and analysis.

Chart Formatting Enhancements

  • Improved date/time formatting for chart axes: for spans under two weeks, the date and time are now shown on separate lines for better readability; removed unused formatter. [1] [2]

Minor Fixes

  • Fixed a variable naming inconsistency in VoltageCurrentDisplay for clarity.

These changes collectively enhance the user experience by making metric data more navigable and relevant, while also improving code maintainability and correctness.

addresses #4496 , addresses #4439

…values

Adds a 10% padding to the top and bottom of the Y-axis on the device, power, signal, and pax counter charts to prevent the graph line from touching the edges.

Additionally, filters out invalid `Int.MIN_VALUE` readings for `soil_moisture` and `iaq` from environment metrics to prevent crashes.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit introduces a time frame filter to all the node metrics screens (Device, Environment, Power, Signal, and Pax).

A `TimeFrame` enum has been created to define the available filter options: 1 hour, 24 hours, and 7 days. A `SlidingSelector` component is used in the UI to allow users to switch between these time frames.

The view model now holds the selected time frame state, and the data displayed in both the charts and lists on each metrics screen is filtered accordingly.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Replaces the custom `SlidingSelector` with a new `TimeFrameSelector` composable based on Material 3's `SingleChoiceSegmentedButtonRow`. This refactor is applied across all metrics screens (Device, Environment, Pax, Power, and Signal).

Additionally, an "All" time frame option has been added to display all historical metrics data.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit refactors the time frame selector in the metrics screens to only display time frames that are relevant to the available data.

Key changes include:
- A new `oldestTimestampSeconds` function in `MetricsState` to find the earliest data point across all metric types.
- The `TimeFrame` enum now includes `TWO_WEEKS` and `ONE_MONTH` options and has a new `isAvailable` method to check if a time frame is relevant based on the oldest data.
- `MetricsViewModel` now exposes an `availableTimeFrames` state flow, which filters the time frames based on the available data history.
- The `TimeFrameSelector` composable is updated to accept and display only the `availableTimeFrames`. If only one option is available, the selector is hidden.
- All metric screens (`Device`, `Environment`, `Power`, `Signal`, `Pax`) are updated to use the new `availableTimeFrames` state.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
- Refactors the x-axis date/time formatting for charts to use a newline for date and time when the visible span is between 2 and 14 days. This improves label readability in the graphs.
- Updates the logic for determining available time frames (`availableTimeFrames`) to consider both node and environmental metrics, ensuring the full range of data is accounted for.
- Modifies the `hasValidSignal` check to use a logical OR (`||`) for `rx_snr` and `rx_rssi`, allowing packets with at least one of these values to be considered valid.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Removes the unused `Y_AXIS_WEIGHT` constant from several metrics chart files.

Also, adds `@Suppress` annotations for `MagicNumber` and `CyclomaticComplexMethod` to clean up warnings and improve code formatting in various places.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit refactors the Power, Environment, and PAX metrics screens to use a new `BaseMetricScreen` composable. This change abstracts away common boilerplate code for the screen layout, state management, and user interactions, resulting in cleaner and more maintainable UI components.

Key changes:
- Introduced `BaseMetricScreen` to handle the generic layout including the app bar, time frame selector, and adaptive chart/list view.
- Migrated shared UI logic for chart point selection, list scrolling, and data fetching requests into the base implementation.
- Refactored `PowerMetricsScreen`, `EnvironmentMetricsScreen`, and `PaxMetricsScreen` to use `BaseMetricScreen`, significantly reducing their code size.
- Centralized PAX log decoding logic into `MetricsViewModel`.
- Optimized telemetry data filtering and processing by moving it into `MetricsViewModel` and exposing it through `StateFlows`.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit introduces several changes to improve code quality and remove obsolete functionality.

- In `PowerMetrics.kt`, the `copy` function call now uses a named argument (`alpha = 1f`) for better readability.
- The `MetricsViewModel` has been refactored to remove unused functions (`tracerouteMapAvailability`, `requestUserInfo`), properties (`environmentState`), and imports.
- Null-safe calls (`?: 0`) have been removed where the type is non-nullable, simplifying the code.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
The `BaseMetricScreen` composable has been refactored to remove its direct dependency on `MetricsViewModel`. State and event handlers are now passed in as parameters, making the component more reusable and easier to test.

This change involved:
- Removing the `viewModel` parameter from `BaseMetricScreen`.
- Passing `nodeName`, `snackbarHostState`, and an `onRequestTelemetry` lambda as new parameters.
- Moving the `LaunchedEffect` for handling snackbar feedback from `BaseMetricScreen` into each of the individual metric screen composables (`DeviceMetrics`, `SignalMetrics`, `PowerMetrics`, etc.).
- Updating the call sites in each metric screen to provide the required state and callbacks to the refactored `BaseMetricScreen`.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Adds unit tests for the `BaseMetricScreen` composable to verify its behavior.

-   Tests that the title, node name, and placeholder content are displayed correctly.
-   Adds a test to confirm that the refresh button's callback is triggered on click.
-   A `testTag` has been added to the refresh button to facilitate testing.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 10, 2026 20:30
@github-actions github-actions Bot added the bugfix PR tag label Feb 10, 2026
@jamesarich jamesarich enabled auto-merge February 10, 2026 20:31

This comment was marked as outdated.

Copilot AI 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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

…cs/MetricsViewModel.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@codecov

codecov Bot commented Feb 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 6.89655% with 108 lines in your changes missing coverage. Please review.
✅ Project coverage is 14.44%. Comparing base (fe5d7d6) to head (bb45e73).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...eshtastic/feature/node/metrics/MetricsViewModel.kt 0.00% 72 Missing ⚠️
...lin/org/meshtastic/feature/node/model/TimeFrame.kt 0.00% 15 Missing ⚠️
...rg/meshtastic/feature/node/metrics/CommonCharts.kt 0.00% 8 Missing ⚠️
.../org/meshtastic/feature/node/model/MetricsState.kt 0.00% 8 Missing ⚠️
...ic/feature/node/metrics/EnvironmentMetricsState.kt 20.00% 2 Missing and 2 partials ⚠️
...meshtastic/feature/node/metrics/BaseMetricChart.kt 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4520      +/-   ##
==========================================
+ Coverage   11.23%   14.44%   +3.20%     
==========================================
  Files         424      424              
  Lines       14432    14521      +89     
  Branches     2397     2410      +13     
==========================================
+ Hits         1621     2097     +476     
+ Misses      12515    12121     -394     
- Partials      296      303       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Pass LazyListState to the metrics list composables.
This enables scrolling the list to the corresponding item when a point is selected on the chart.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@jamesarich jamesarich enabled auto-merge February 10, 2026 23:02
@jamesarich jamesarich added this pull request to the merge queue Feb 10, 2026
Merged via the queue into meshtastic:main with commit d252fde Feb 10, 2026
8 checks passed
@jamesarich jamesarich deleted the fix/charts branch February 10, 2026 23:15
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