fix: refine tray widget GPU temperature metric#1444
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughTray metric ChangesMetric Rename and OS-Aware Availability
Sequence Diagram(s)sequenceDiagram
actor User
participant UI as Frontend UI (Settings / Flyout)
participant TS as Settings Normalizer
participant Platform as OS Plugin
participant Backend as Tauri Rust (tray/widget)
User->>UI: change settings / open flyout
UI->>TS: normalizeSettings(persisted, unavailableMetrics)
TS->>Platform: platform()
Platform-->>TS: "macos" / "windows"
TS-->>UI: normalized metricOrder / visibleMetrics
UI->>Backend: persist/send metric selection ("gpu-temp")
Backend->>Backend: collect_samples() uses TrayMetric::GpuTemp -> hottest_temperature_celsius()
Backend-->>UI: emit tray frame with metric "gpu-temp" and formatted value
UI->>UI: render icon/label using i18n key "gpu-temp"
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 3/5 reviews remaining, refill in 20 minutes and 32 seconds. Comment |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
Rust Tauri Coverage ReportCoverage Details |
There was a problem hiding this comment.
Pull request overview
This PR refines the tray widget’s GPU temperature metric by renaming the serialized/frontend metric key from temp to gpu-temp, updating the displayed label to “GPU temperature”, and hiding that metric from macOS tray widget settings where the metric is unavailable. It fits into the tray/settings/i18n parts of the codebase that coordinate persisted widget settings, tray rendering, and localized UI labels.
Changes:
- Renamed the tray widget GPU temperature metric key and related labels across frontend UI, tests, and Rust tray widget code.
- Added macOS-specific filtering in tray widget settings so GPU temperature is not shown as a configurable metric there.
- Updated frontend and backend tests to reflect the renamed metric identifier and revised labels.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/lang/ja.json |
Renames Japanese tray widget/flyout temperature labels to the new gpu-temp key. |
src/lang/en.json |
Renames English tray widget/flyout temperature labels to the new gpu-temp key. |
src/features/tray/TrayWidgetFlyout.tsx |
Updates flyout metric typing/icon mapping to use gpu-temp. |
src/features/tray/TrayWidgetFlyout.test.tsx |
Adjusts flyout tests for the renamed metric key and label. |
src/features/settings/components/general/TrayWidgetSettings.tsx |
Renames the metric in persisted settings logic and hides it on macOS. |
src/features/settings/components/general/TrayWidgetSettings.test.tsx |
Updates settings normalization/rendering tests for gpu-temp and macOS filtering. |
src-tauri/src/tray/widget.rs |
Renames the backend tray metric enum/labels and updates tray widget normalization/tests. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src-tauri/src/tray/widget.rs`:
- Around line 12-13: The backend still lists TrayMetric::GpuTemp in
CONFIGURABLE_METRICS and in the normalization/defaults path causing macOS to
persist an unavailable metric; remove or conditionally exclude
TrayMetric::GpuTemp on macOS by wrapping its inclusion with #[cfg(not(target_os
= "macos"))] (or add per-OS arrays using #[cfg(target_os = "...")]) so
CONFIGURABLE_METRICS and any normalization/default logic that builds the
persisted metrics list do not include GpuTemp on macOS; update any places that
reference CONFIGURABLE_METRICS or the normalization function (e.g., the
defaults/normalization routine that prunes metrics before collect_samples()) to
use the new OS-conditioned set.
- Around line 16-20: The TrayMetric enum's GpuTemp variant won't deserialize
legacy stores that used "temp" because only kebab-case ("gpu-temp") is accepted;
add #[serde(alias = "temp")] to the GpuTemp variant in the TrayMetric enum so
both "temp" and "gpu-temp" deserialize, and add a regression test that
deserializes an old store JSON containing "temp" entries in metric_order and
visible_metrics to ensure future renames don't break deserialization (reference
the TrayMetric enum and the GpuTemp variant in your changes and test).
🪄 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.yml
Review profile: CHILL
Plan: Pro
Run ID: 93339676-fc0e-4792-8318-f941a1c90c16
📒 Files selected for processing (7)
src-tauri/src/tray/widget.rssrc/features/settings/components/general/TrayWidgetSettings.test.tsxsrc/features/settings/components/general/TrayWidgetSettings.tsxsrc/features/tray/TrayWidgetFlyout.test.tsxsrc/features/tray/TrayWidgetFlyout.tsxsrc/lang/en.jsonsrc/lang/ja.json
Summary
temptogpu-tempacross frontend and backend tray code.GPU temperature/GPU温度.Validation
npx biome check src/features/settings/components/general/TrayWidgetSettings.tsx src/features/settings/components/general/TrayWidgetSettings.test.tsx src/features/tray/TrayWidgetFlyout.tsx src/features/tray/TrayWidgetFlyout.test.tsx src/lang/en.json src/lang/ja.jsonnpx vitest run src/features/settings/components/general/TrayWidgetSettings.test.tsx src/features/tray/TrayWidgetFlyout.test.tsxcargo test -p hardware_visualizer tray::widgetcargo fmt -p hardware_visualizer --checkSummary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests