Skip to content

fix: refine tray widget GPU temperature metric#1444

Merged
shm11C3 merged 3 commits into
developfrom
fix/tray-widget-gpu-temp
May 3, 2026
Merged

fix: refine tray widget GPU temperature metric#1444
shm11C3 merged 3 commits into
developfrom
fix/tray-widget-gpu-temp

Conversation

@shm11C3

@shm11C3 shm11C3 commented May 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Rename the tray widget temperature metric key from temp to gpu-temp across frontend and backend tray code.
  • Rename the user-facing tray widget temperature label to GPU temperature / GPU温度.
  • Hide the GPU temperature metric from tray widget settings on macOS, where GPU temperature is not available.

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.json
  • npx vitest run src/features/settings/components/general/TrayWidgetSettings.test.tsx src/features/tray/TrayWidgetFlyout.test.tsx
  • cargo test -p hardware_visualizer tray::widget
  • cargo fmt -p hardware_visualizer --check

Summary by CodeRabbit

  • New Features

    • Platform-aware tray metrics: OS-specific availability (macOS hides GPU temperature control).
  • Bug Fixes

    • Temperature metric clarified as GPU temperature, preserves legacy settings/keys, and ensures GPU temperature values, labels and unit formatting display consistently.
  • Documentation

    • Updated English and Japanese labels to show "GPU temperature" in the UI.
  • Tests

    • Updated tests and UI specs to reflect the GPU temperature metric, legacy migration, ordering/visibility rules, and platform-specific behavior.

@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: c16927dd-60ca-4bfc-b028-3653f58e056a

📥 Commits

Reviewing files that changed from the base of the PR and between 22f8ca7 and babb764.

📒 Files selected for processing (2)
  • src/features/settings/components/general/TrayWidgetSettings.test.tsx
  • src/features/settings/components/general/TrayWidgetSettings.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/features/settings/components/general/TrayWidgetSettings.tsx

📝 Walkthrough

Walkthrough

Tray metric Temp was renamed to GpuTemp and enum serialization changed to kebab-case with a serde alias for legacy "temp". GPU-temperature availability is now platform-aware (hidden on macOS). Backend collection, classification, formatting, frontend wiring, i18n keys, and tests were updated to use GpuTemp/gpu-temp.

Changes

Metric Rename and OS-Aware Availability

Layer / File(s) Summary
Data Shape / Consts
src-tauri/src/tray/widget.rs, src/features/settings/components/general/TrayWidgetSettings.tsx
TrayMetric variant renamed TempGpuTemp; #[serde(rename_all = "kebab-case")] applied; GpuTemp accepts legacy alias temp; CONFIGURABLE_METRICS and defaults updated to include "gpu-temp"; macOS unavailable list defined.
Core Implementation (Backend)
src-tauri/src/tray/widget.rs
Metric collection uses TrayMetric::GpuTemp and reads GPU temperature via hottest_temperature_celsius(...); classification, icon metadata, tooltip label, and value formatting branches updated to GpuTemp.
Core Implementation (Frontend Settings)
src/features/settings/components/general/TrayWidgetSettings.tsx
normalizeSettings, normalizeMetricOrder, normalizeVisibleMetrics signatures extended to accept unavailableMetrics; normalization maps legacy persisted "temp""gpu-temp" and filters out unavailable metrics (platform-aware via platform()).
UI Wiring
src/features/tray/TrayWidgetFlyout.tsx, src/features/settings/components/general/TrayWidgetSettings.test.tsx
Icon mapping and emitted metric keys switched to "gpu-temp"; settings UI hides GPU-temp controls on macOS; drag/reorder and visibility persistence updated to use "gpu-temp".
Translations
src/lang/en.json, src/lang/ja.json
i18n keys changed from tempgpu-temp for flyout and settings labels (English and Japanese).
Tests
src-tauri/src/tray/widget.rs tests, src/features/settings/components/general/TrayWidgetSettings.test.tsx, src/features/tray/TrayWidgetFlyout.test.tsx
Unit and component tests updated to expect GpuTemp/gpu-temp; legacy store deserialization tests accept legacy "temp" via alias and assert normalized results; added macOS-specific UI test verifying GPU temperature control hidden.

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"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

Hopping through code with a cheerful thump,
GPU temps now labeled with a tidy bump.
"gpu-temp" hums clear in flyout and test,
macOS keeps it hidden when that is best.
A rabbit-approved tweak — quick, neat, and plump! 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: refining the tray widget GPU temperature metric naming and behavior.
Description check ✅ Passed The description covers the key objectives, includes validation steps, but is missing explicit checklist items (self-review, linting/formatting confirmation, test confirmation, warnings check).
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tray-widget-gpu-temp

Review rate limit: 3/5 reviews remaining, refill in 20 minutes and 32 seconds.

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

@github-actions github-actions Bot added bug Something isn't working frontend hardviz_tauri labels May 3, 2026
@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 97.28% (🎯 60%) 1182 / 1215
🔵 Statements 96.81% (🎯 60%) 1246 / 1287
🔵 Functions 96.74% (🎯 60%) 297 / 307
🔵 Branches 90.54% (🎯 60%) 431 / 476
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/features/settings/components/general/TrayWidgetSettings.tsx 97.72% 94.44% 100% 97.72%
src/features/tray/TrayWidgetFlyout.tsx 91.66% 83.33% 92.3% 91.42%
Generated in workflow #2890 for commit babb764 by the Vitest Coverage Report Action

@shm11C3 shm11C3 marked this pull request as ready for review May 3, 2026 16:12
Copilot AI review requested due to automatic review settings May 3, 2026 16:12
@shm11C3 shm11C3 enabled auto-merge (squash) May 3, 2026 16:12
@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Rust Tauri Coverage Report

Coverage Details
Filename                                     Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
_tests/commands/background_image_test.rs          39                 0   100.00%           6                 0   100.00%          21                 0   100.00%           0                 0         -
_tests/commands/settings_test.rs                 219                 0   100.00%          18                 0   100.00%         162                 0   100.00%           0                 0         -
adapters/tray.rs                                 152               152     0.00%          15                15     0.00%         104               104     0.00%           0                 0         -
adapters/window.rs                               254                69    72.83%          21                 8    61.90%         195                47    75.90%           0                 0         -
app/startup.rs                                   188                87    53.72%          10                 3    70.00%         114                58    49.12%           0                 0         -
commands/background_image.rs                      22                 7    68.18%          11                 5    54.55%          19                 7    63.16%           0                 0         -
commands/hardware.rs                              62                62     0.00%          20                20     0.00%          68                68     0.00%           0                 0         -
commands/settings.rs                             578               578     0.00%         102               102     0.00%         497               497     0.00%           0                 0         -
commands/system.rs                                21                21     0.00%          10                10     0.00%          20                20     0.00%           0                 0         -
commands/ui.rs                                    17                17     0.00%           2                 2     0.00%          13                13     0.00%           0                 0         -
commands/updater.rs                               97                97     0.00%          15                15     0.00%          66                66     0.00%           0                 0         -
enums/error.rs                                   115                10    91.30%           9                 1    88.89%          99                10    89.90%           0                 0         -
enums/hardware.rs                                194                 7    96.39%          16                 1    93.75%         120                 6    95.00%           0                 0         -
enums/settings.rs                                425                16    96.24%          26                 2    92.31%         289                10    96.54%           0                 0         -
infrastructure/database/migration.rs              66                 1    98.48%          10                 0   100.00%          86                 0   100.00%           0                 0         -
lib.rs                                           216               216     0.00%           5                 5     0.00%         138               138     0.00%           0                 0         -
lifecycle.rs                                     227               178    21.59%          29                25    13.79%         160               137    14.37%           0                 0         -
main.rs                                            3                 3     0.00%           1                 1     0.00%           3                 3     0.00%           0                 0         -
models/hardware.rs                               375                83    77.87%          31                12    61.29%         275               100    63.64%           0                 0         -
models/hardware_archive.rs                         8                 0   100.00%           2                 0   100.00%          10                 0   100.00%           0                 0         -
models/settings.rs                               283                 0   100.00%          16                 0   100.00%         246                 0   100.00%           0                 0         -
services/background_image_service.rs             165                96    41.82%          16                10    37.50%          93                59    36.56%           0                 0         -
services/gpu_service.rs                           56                56     0.00%          11                11     0.00%          43                43     0.00%           0                 0         -
services/hardware_service.rs                      85                85     0.00%           4                 4     0.00%          51                51     0.00%           0                 0         -
services/language_service.rs                     101                 0   100.00%          18                 0   100.00%          57                 0   100.00%           0                 0         -
services/memory_service.rs                        12                12     0.00%           3                 3     0.00%           7                 7     0.00%           0                 0         -
services/motherboard_service.rs                   12                12     0.00%           3                 3     0.00%           7                 7     0.00%           0                 0         -
services/network_service.rs                       14                14     0.00%           1                 1     0.00%           8                 8     0.00%           0                 0         -
services/settings_service.rs                     321               143    55.45%          31                13    58.06%         269               130    51.67%           0                 0         -
services/system_service.rs                        22                22     0.00%           2                 2     0.00%          12                12     0.00%           0                 0         -
services/ui_service.rs                            45                45     0.00%           8                 8     0.00%          36                36     0.00%           0                 0         -
tray/surface/mod.rs                                8                 8     0.00%           2                 2     0.00%           5                 5     0.00%           0                 0         -
tray/surface/tauri_surface.rs                     80                80     0.00%           6                 6     0.00%          48                48     0.00%           0                 0         -
tray/widget.rs                                   562                28    95.02%          50                 3    94.00%         505                26    94.85%           0                 0         -
utils/color.rs                                    66                 1    98.48%           4                 0   100.00%          26                 0   100.00%           0                 0         -
utils/file.rs                                    224                 5    97.77%          14                 0   100.00%         144                 4    97.22%           0                 0         -
utils/formatter.rs                                55                 0   100.00%           5                 0   100.00%          39                 0   100.00%           0                 0         -
utils/logger.rs                                   71                71     0.00%           1                 1     0.00%          38                38     0.00%           0                 0         -
utils/tauri.rs                                   138                 0   100.00%          17                 0   100.00%          82                 0   100.00%           0                 0         -
workers/mod.rs                                    40                40     0.00%           2                 2     0.00%          24                24     0.00%           0                 0         -
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                           5638              2322    58.82%         573               296    48.34%        4199              1782    57.56%           0                 0         -

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

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.

Comment thread src-tauri/src/tray/widget.rs
Comment thread src/features/settings/components/general/TrayWidgetSettings.tsx
Comment thread src-tauri/src/tray/widget.rs

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between cf835bb and 0f91fc8.

📒 Files selected for processing (7)
  • src-tauri/src/tray/widget.rs
  • src/features/settings/components/general/TrayWidgetSettings.test.tsx
  • src/features/settings/components/general/TrayWidgetSettings.tsx
  • src/features/tray/TrayWidgetFlyout.test.tsx
  • src/features/tray/TrayWidgetFlyout.tsx
  • src/lang/en.json
  • src/lang/ja.json

Comment thread src-tauri/src/tray/widget.rs
Comment thread src-tauri/src/tray/widget.rs
@shm11C3 shm11C3 merged commit e097ecd into develop May 3, 2026
30 checks passed
@shm11C3 shm11C3 deleted the fix/tray-widget-gpu-temp branch May 3, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working frontend hardviz_tauri

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants