Skip to content

Fix show temp#188

Open
fionny-darmawan wants to merge 3 commits into
bvaisvil:masterfrom
fionny-darmawan:fix-show-temp
Open

Fix show temp#188
fionny-darmawan wants to merge 3 commits into
bvaisvil:masterfrom
fionny-darmawan:fix-show-temp

Conversation

@fionny-darmawan

Copy link
Copy Markdown

Pull Request

Summary

Fix CPU title bar showing "TEMP []" when no temperature sensors are present.
The TEMP section is now fully hidden when there are no sensors.

Type of Change

  • [X] Bug fix
  • New feature / enhancement
  • Performance improvement
  • Refactor (no behavior change)
  • Documentation
  • CI / tooling

Related Issue

Closes #

Changes

  • Changed temp from a single Span to a Vec<Span> (temp_spans) that
    is conditionally populated. This returns all three spans (label, value,
    closing bracket) only when sensors exist, and an empty vec otherwise.
  • The title line is now built incrementally using extend so the TEMP
    section is completely absent when there are no sensors.

Testing

Previously, the CPU sparkline title bar would render "TEMP []" even when
no sensors were available, which looked wrong.

Platforms tested:

  • Linux
  • [X] macOS
  • Other: ___

Test steps:

  1. Ran 'cargo run'
  2. TEMP[] no longer shows when there are no sensors detected.

Performance Impact

N/A

Checklist

  • cargo clippy passes with no new warnings
  • [X] cargo test passes
  • cargo fmt applied
  • No new unwrap()/expect() without justification in a comment
  • non-obvious logic have doc comments
  • CHANGELOG updated (if user-facing change)

@bvaisvil bvaisvil self-assigned this Jun 5, 2026
Comment thread src/renderer/cpu.rs
temp,
Span::raw("]"),
];
spans.extend(temp_spans);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to check if temp_spans is empty before attempting to extend the vec

Comment thread src/renderer/cpu.rs
)),
])
]);
Line::from(spans)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see if we can't add a test for this change, see:

mod tests {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants