Skip to content

[Bug?] 笔记本电池电量高于 85% 时触发黄色告警 #1673

Description

@Hatsune39

描述 Bug

在使用 iOS 版 ServerBox 中,通过 SSH 监控 Windows 笔记本电脑时,发现服务器状态指示灯一直显示黄色警告

复现步骤

使用 ServerBox 通过 SSH 连接 Windows 笔记本
让笔记本电池电量高于 85%
查看ServerBox状态

期望结果

电池剩余电量较高时,不应仅因为电量超过 85% 而触发黄色告警
如果需要电池告警,或许可以考虑使用独立的低电量阈值

实际结果

电池电量为 97%,服务器状态指示灯显示黄色,并出现⚠警告标识

截图

Image

设备

  • 手机系统: IOS 27
  • App版本: V1719
  • Windows系统: Windows 11

更多信息

这个小问题不影响使用,我只是出于好奇让ChatGPT分析了一下源码,AI 给出的分析如下:

在 lib/view/page/server/card/metric.dart 中,存在统一的告警阈值:
const kServerAlertPercent = 85.0;

ServerMetric.over 使用以下逻辑判断指标是否超出阈值:
bool get over =>
percent != null &&
percent! * 100 >= kServerAlertPercent;

而 serverStateDot() 会在任意监控指标触发阈值时,将状态指示灯设为黄色:

(readings ?? serverCardReadings(srv))
.all.any((m) => m.over)
? StatePalette.warn
: StatePalette.running

AI 认为,由于电池剩余电量也参与了这一判断,可能导致电池电量较高时触发告警。

相关源码:

https://github.com/lollipopkit/flutter_server_box/blob/v1.0.1719/lib/view/page/server/card/metric.dart

以上是 AI 辅助分析的结果,我没有自行调试验证源码,如果理解有误还请指正

Activity

  1. winnowl commented on Oct 9, 2026

    @winnowl

    Issue triage

    Feasibility:needs-clarification | Risk:medium

    Related code:

    • lib/view/page/server/card/metric.dart · kServerAlertPercent
    • lib/view/page/server/card/metric.dart · ServerMetric.over
    • lib/view/page/server/card/metric.dart · serverStateDot
    • lib/view/page/server/card/metric.dart · serverCardReadings

    Information needed to reproduce:

    • Can you confirm the battery reading is included in serverCardReadings for this Windows SSH connection, and share the relevant metric values if possible?
    • Does the yellow warning disappear when the battery level falls below 85%, or does it persist regardless of charge level?
    • Please share the Windows SSH metric/monitoring configuration and any relevant logs to verify which metric triggers the warning.

    Suggested labels(not applied automatically):bug, battery, windows, ssh

  2. lollipopkit commented on Oct 9, 2026

    @lollipopkit
    Owner

    感谢反馈,分析是对的。

    告警判断用的是同一条规则:占比 ≥ 85% 算超标。电池也套用了这条规则,可电量高是正常状态,所以充满电的笔记本会显示黄色。这个问题不只出现在 Windows,所有带电池的机器都有。

    已在 #1675 修复:

    • 电池只在电量 ≤ 20% 且正在放电时才告警。
    • 充电中、已充满或接着电源时,不会告警。
    • CPU、内存、磁盘等其他指标的规则不变。

    会在下一个版本中发布。

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions