Skip to content

fix(devices): clarify offline alert and heartbeat stale states#166

Open
mislayming wants to merge 2 commits into
ongridio:mainfrom
mislayming:codex/device-status-semantics
Open

fix(devices): clarify offline alert and heartbeat stale states#166
mislayming wants to merge 2 commits into
ongridio:mainfrom
mislayming:codex/device-status-semantics

Conversation

@mislayming

@mislayming mislayming commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a derived device presence helper that prioritizes unresolved device_offline alerts over tunnel status.
  • Show separate Offline alert and Heartbeat stale states on the Devices page so operators do not see a misleading plain Online state while Alerts reports the device offline.
  • Add focused unit coverage for alert priority and heartbeat staleness.

Validation

  • cd web && npm run test -- deviceStatus.test.ts
  • cd web && npm run typecheck
  • cd web && npm run build
  • cd web && npx eslint src/lib/deviceStatus.ts src/lib/deviceStatus.test.ts src/pages/Edges.tsx --ext ts,tsx --report-unused-disable-directives passes with 0 errors and 1 existing warning in Edges.tsx.
  • cd web && npm run lint still fails on pre-existing unrelated repo issues such as src/api/chat.ts, src/components/ChatInput.tsx, src/components/MessageBubble.tsx, src/pages/DeviceShell.tsx, and src/pages/SkillRun.tsx.

Author confirmation

  • I have read and agree to the project contribution guide in CONTRIBUTING.md.

@mislayming
mislayming marked this pull request as ready for review July 7, 2026 11:21
@mislayming
mislayming requested a review from singchia as a code owner July 7, 2026 11:21
@singchia

Copy link
Copy Markdown
Contributor

这个方向可以:把 Device offline alert、心跳超时、tunnel 在线状态区分开,确实能减少设备页和告警页互相打架的感觉。

但这个 PR 需要先 rebase / 重做一下。我们最近已经调整过设备列表页面,现在列表是 Device-first:页面主数据来自 /devices,Edge 只是挂在 Device 下面的 hostEdge/agent 连接信息。#166 现在还是按旧的 Edge row 模型改 web/src/pages/Edges.tsx,所以会和 main 上的设备列表冲突,也容易把 Device/Edge 语义又混回去。

建议改法:

  • 状态列基于 Device 行来判断:device.online / device.last_seen_at 是设备状态基准;
  • hostEdge.status 只表示 Edge tunnel/agent 连接状态,不要再当成设备在线状态;
  • device_offline 未恢复告警可以覆盖显示成 Offline alert,但要覆盖 open / acknowledged / silenced,不能只看 open;
  • 不要只拉前 100 条 incident,否则告警多时设备状态会漏。

另外这是 UI 行为调整,后续类似 PR 麻烦带上涉及页面的截图,至少包括设备列表状态列的 before/after。这个改动用户一眼就会看到,截图能让 review 更快判断文案、颜色、状态优先级是不是对。

@singchia

Copy link
Copy Markdown
Contributor

Reviewed. I would not merge this as-is.

The branch is now dirty against main and edits the old Devices/Edges page surface. Since main has moved further toward a Device-first list and Edge-operation wording, this will conflict with the current UI model. Please rebase and update the implementation against the current page, then include screenshots for the affected Devices states: normal online, stale heartbeat, and offline alert.

The status helper idea is still useful; it just needs to land on the current UI baseline.

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