-
Notifications
You must be signed in to change notification settings - Fork 275
Add Ch Util, TX airtime and uptime to Device Info panel #1010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,7 @@ import type { DeviceMetrics } from "./types.ts"; | |||||||||||||||||||
| import { Avatar } from "./UI/Avatar.tsx"; | ||||||||||||||||||||
| import { Button } from "./UI/Button.tsx"; | ||||||||||||||||||||
| import { Subtle } from "./UI/Typography/Subtle.tsx"; | ||||||||||||||||||||
| import { Uptime } from "./generic/Uptime.tsx"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| interface DeviceInfoPanelProps { | ||||||||||||||||||||
| isCollapsed: boolean; | ||||||||||||||||||||
|
|
@@ -62,7 +63,7 @@ export const DeviceInfoPanel = ({ | |||||||||||||||||||
| }: DeviceInfoPanelProps) => { | ||||||||||||||||||||
| const { t } = useTranslation(); | ||||||||||||||||||||
| const navigate = useNavigate({ from: "/" }); | ||||||||||||||||||||
| const { batteryLevel, voltage } = deviceMetrics; | ||||||||||||||||||||
| const { batteryLevel, voltage, channelUtilization, airUtilTx, uptimeSeconds} = deviceMetrics; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const getStatusColor = (status?: ConnectionStatus): string => { | ||||||||||||||||||||
| if (!status) { | ||||||||||||||||||||
|
|
@@ -117,6 +118,32 @@ export const DeviceInfoPanel = ({ | |||||||||||||||||||
| icon: CpuIcon, | ||||||||||||||||||||
| value: firmwareVersion ?? t("unknown.notAvailable", "N/A"), | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| id: "channelUtil", | ||||||||||||||||||||
| label: t("sidebar.deviceInfo.channelUtil.title"), | ||||||||||||||||||||
| value: | ||||||||||||||||||||
| channelUtilization !== undefined | ||||||||||||||||||||
| ? `${(channelUtilization).toFixed(1)}%` | ||||||||||||||||||||
|
Comment on lines
+125
to
+126
|
||||||||||||||||||||
| channelUtilization !== undefined | |
| ? `${(channelUtilization).toFixed(1)}%` | |
| typeof channelUtilization === "number" | |
| ? `${channelUtilization.toFixed(1)}%` |
Copilot
AI
Apr 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
airUtilTx is typed as number | null | undefined, but this check only excludes undefined. If it is null, calling .toFixed(1) will throw at runtime. Guard with typeof airUtilTx === "number" (or airUtilTx != null) before formatting.
| airUtilTx !== undefined | |
| ? `${(airUtilTx).toFixed(1)}%` | |
| typeof airUtilTx === "number" | |
| ? `${airUtilTx.toFixed(1)}%` |
Copilot
AI
Apr 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uptimeSeconds is typed as number | null | undefined, but this only checks !== undefined. If uptimeSeconds is null, it will be passed to <Uptime seconds={...} /> (expects a number) and can break formatting/rendering. Also, InfoDisplayItem.value is typed as string | number | null, but this branch assigns a React element; either render uptime as a string or widen the value type to React.ReactNode (and ensure the render path supports it).
| value: | |
| uptimeSeconds !== undefined ? ( | |
| <Uptime seconds={uptimeSeconds} /> | |
| ) : ( | |
| "N/A" | |
| ) | |
| customComponent: | |
| uptimeSeconds != null ? <Uptime seconds={uptimeSeconds} /> : undefined, | |
| value: uptimeSeconds != null ? null : "N/A", |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| export type DeviceMetrics = { | ||
| batteryLevel?: number | null; | ||
| voltage?: number | null; | ||
| channelUtilization?: number | null; | ||
| airUtilTx?: number | null; | ||
| uptimeSeconds?: number | null; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,8 +41,14 @@ export const subscribeAll = ( | |
| } | ||
| }); | ||
|
|
||
| connection.events.onTelemetryPacket.subscribe(() => { | ||
| // device.setMetrics(telemetryPacket); | ||
| connection.events.onTelemetryPacket.subscribe((packet) => { | ||
| const metrics = packet.data.variant.value; | ||
| const existing = nodeDB.getNode(packet.from); | ||
| nodeDB.addNode({ | ||
| ...(existing ?? {}), | ||
| num: packet.from, | ||
| deviceMetrics: { ...metrics }, | ||
| }); | ||
|
Comment on lines
+44
to
+51
|
||
| }); | ||
|
|
||
| connection.events.onDeviceStatus.subscribe((status) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New
sidebar.deviceInfo.*UI labels were added only toen/ui.json. Other locales’ui.jsonfiles don’t contain these keys, so non-English UIs will likely display the raw i18n key. Either add the corresponding entries to the other localeui.jsonfiles or provide default/fallback strings in thet(...)calls for these new labels.