From 72f42a363ea04fff958b5fc46a48c259727b8f4d Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sat, 17 Jan 2026 10:46:11 +0800 Subject: [PATCH] chore: remove redundant sensors card and bump version to 1.22.1 - Disable sensors data collection (CPU temp already shown in CPU card) - Remove unused sensor-related functions (collectSensors, prettifyLabel, hasSensorData, renderSensorsCard) - Remove unused gopsutil/sensors import - Fix inline spinner disown call with explicit PID - Update version from 1.22.0 to 1.22.1 - Update SECURITY_AUDIT.md to match new version and date --- SECURITY_AUDIT.md | 6 +++--- cmd/status/metrics.go | 3 ++- cmd/status/metrics_battery.go | 28 ---------------------------- cmd/status/view.go | 30 ++++-------------------------- lib/core/ui.sh | 2 +- mole | 2 +- 6 files changed, 11 insertions(+), 60 deletions(-) diff --git a/SECURITY_AUDIT.md b/SECURITY_AUDIT.md index 67c3971..ebec8fc 100644 --- a/SECURITY_AUDIT.md +++ b/SECURITY_AUDIT.md @@ -2,7 +2,7 @@
-**Status:** PASSED | **Risk Level:** LOW | **Version:** 1.21.0 (2026-01-15) +**Status:** PASSED | **Risk Level:** LOW | **Version:** 1.22.1 (2026-01-17)
@@ -12,9 +12,9 @@ | Attribute | Details | |-----------|---------| -| Audit Date | January 15, 2026 | +| Audit Date | January 17, 2026 | | Audit Conclusion | **PASSED** | -| Mole Version | V1.21.0 | +| Mole Version | V1.22.0 | | Audited Branch | `main` (HEAD) | | Scope | Shell scripts, Go binaries, Configuration | | Methodology | Static analysis, Threat modeling, Code review | diff --git a/cmd/status/metrics.go b/cmd/status/metrics.go index 7617cd2..d573aa7 100644 --- a/cmd/status/metrics.go +++ b/cmd/status/metrics.go @@ -276,7 +276,8 @@ func (c *Collector) Collect() (MetricsSnapshot, error) { collect(func() (err error) { proxyStats = collectProxy(); return nil }) collect(func() (err error) { batteryStats, _ = collectBatteries(); return nil }) collect(func() (err error) { thermalStats = collectThermal(); return nil }) - collect(func() (err error) { sensorStats, _ = collectSensors(); return nil }) + // Sensors disabled - CPU temp already shown in CPU card + // collect(func() (err error) { sensorStats, _ = collectSensors(); return nil }) collect(func() (err error) { gpuStats, err = c.collectGPU(now); return }) collect(func() (err error) { // Bluetooth is slow; cache for 30s. diff --git a/cmd/status/metrics_battery.go b/cmd/status/metrics_battery.go index 4559188..c28e319 100644 --- a/cmd/status/metrics_battery.go +++ b/cmd/status/metrics_battery.go @@ -10,8 +10,6 @@ import ( "strconv" "strings" "time" - - "github.com/shirou/gopsutil/v4/sensors" ) var ( @@ -283,29 +281,3 @@ func collectThermal() ThermalStatus { return thermal } - -func collectSensors() ([]SensorReading, error) { - temps, err := sensors.SensorsTemperatures() - if err != nil { - return nil, err - } - var out []SensorReading - for _, t := range temps { - if t.Temperature <= 0 || t.Temperature > 150 { - continue - } - out = append(out, SensorReading{ - Label: prettifyLabel(t.SensorKey), - Value: t.Temperature, - Unit: "°C", - }) - } - return out, nil -} - -func prettifyLabel(key string) string { - key = strings.TrimSpace(key) - key = strings.TrimPrefix(key, "TC") - key = strings.ReplaceAll(key, "_", " ") - return key -} diff --git a/cmd/status/view.go b/cmd/status/view.go index a8a723a..2bb4f12 100644 --- a/cmd/status/view.go +++ b/cmd/status/view.go @@ -201,15 +201,6 @@ func getScoreStyle(score int) lipgloss.Style { } } -func hasSensorData(sensors []SensorReading) bool { - for _, s := range sensors { - if s.Note == "" && s.Value > 0 { - return true - } - } - return false -} - func renderCPUCard(cpu CPUStatus, thermal ThermalStatus) cardData { var lines []string @@ -411,9 +402,10 @@ func buildCards(m MetricsSnapshot, width int) []cardData { renderProcessCard(m.TopProcesses), renderNetworkCard(m.Network, m.NetworkHistory, m.Proxy, width), } - if hasSensorData(m.Sensors) { - cards = append(cards, renderSensorsCard(m.Sensors)) - } + // Sensors card disabled - redundant with CPU temp + // if hasSensorData(m.Sensors) { + // cards = append(cards, renderSensorsCard(m.Sensors)) + // } return cards } @@ -600,20 +592,6 @@ func renderBatteryCard(batts []BatteryStatus, thermal ThermalStatus) cardData { return cardData{icon: iconBattery, title: "Power", lines: lines} } -func renderSensorsCard(sensors []SensorReading) cardData { - var lines []string - for _, s := range sensors { - if s.Note != "" { - continue - } - lines = append(lines, fmt.Sprintf("%-12s %s", shorten(s.Label, 12), colorizeTemp(s.Value)+s.Unit)) - } - if len(lines) == 0 { - lines = append(lines, subtleStyle.Render("No sensors")) - } - return cardData{icon: iconSensors, title: "Sensors", lines: lines} -} - func renderCard(data cardData, width int, height int) string { titleText := data.icon + " " + data.title lineLen := max(width-lipgloss.Width(titleText)-2, 4) diff --git a/lib/core/ui.sh b/lib/core/ui.sh index cacb10b..f9a8ea0 100755 --- a/lib/core/ui.sh +++ b/lib/core/ui.sh @@ -316,7 +316,7 @@ start_inline_spinner() { exit 0 ) & INLINE_SPINNER_PID=$! - disown 2> /dev/null || true + disown "$INLINE_SPINNER_PID" 2> /dev/null || true else echo -n " ${BLUE}|${NC} $message" >&2 || true fi diff --git a/mole b/mole index 2d459b8..b249154 100755 --- a/mole +++ b/mole @@ -13,7 +13,7 @@ source "$SCRIPT_DIR/lib/core/commands.sh" trap cleanup_temp_files EXIT INT TERM # Version and update helpers -VERSION="1.22.0" +VERSION="1.22.1" MOLE_TAGLINE="Deep clean and optimize your Mac." is_touchid_configured() {