Repository navigation
feat(ui): surface frzWater tank level and sensHealth cover disconnects #877
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a2ba0df
feat(health): count frzWater and sensHealth in the live stream inspector
ng 721b774
feat(ui): show the frzWater tank level and sensHealth cover disconnects
ng 2896f34
Merge remote-tracking branch 'origin/dev' into feat/frzwater-sensheal…
ng dd64646
fix(ui): type frzWater flags as firmware ints and show tank, priming …
ng 6dc20bc
test(dashboard): cover the DAC water-level fallback in the attention …
ng 1bba8a5
fix(ui): keep sensHealth and frzWater subscribed outside System and w…
ng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,27 @@ | ||
| 'use client' | ||
|
|
||
| import { attentionItems } from '@/src/components/diagnostics/dashboardLogic' | ||
| import { attentionItems, disconnectedCovers } from '@/src/components/diagnostics/dashboardLogic' | ||
| import { useNowMinute } from '@/src/components/Schedule/CurveChart' | ||
| import { useSensorFrame, useSensorSubscription } from '@/src/hooks/useSensorStream' | ||
| import { trpc } from '@/src/utils/trpc' | ||
| import { footerStatus } from './footerStatus' | ||
|
|
||
| /** | ||
| * The pod's health as the navigation shows it: failing system checks plus the | ||
| * System Dashboard's attention items. Shared by the sidebar footer and the | ||
| * phone tab bar's System dot. | ||
| * phone tab bar's System dot. Cover health comes from the sensor stream's | ||
| * sensHealth frames (newer cover firmware; older pods never send one). | ||
| */ | ||
| export function usePodHealth() { | ||
| const status = trpc.device.getStatus.useQuery({}, { staleTime: 10_000, refetchInterval: 30_000 }) | ||
| const health = trpc.health.system.useQuery({}, { staleTime: 10_000, refetchInterval: 30_000 }) | ||
| const maintenance = trpc.health.maintenance.useQuery({}, { staleTime: 30_000, refetchInterval: 60_000 }) | ||
| const water = trpc.waterLevel.getLatest.useQuery({}, { staleTime: 10_000, refetchInterval: 30_000 }) | ||
| useSensorSubscription({ sensors: ['sensHealth'] }) | ||
| const sensHealth = useSensorFrame('sensHealth') | ||
| const nowMinute = useNowMinute() | ||
| const attention = nowMinute == null | ||
| ? [] | ||
| : attentionItems(maintenance.data, water.data?.level ?? status.data?.waterLevel, nowMinute * 60_000) | ||
| : attentionItems(maintenance.data, water.data?.level ?? status.data?.waterLevel, nowMinute * 60_000, [], disconnectedCovers(sensHealth)) | ||
| return { footer: footerStatus(health.data, attention), podVersion: status.data?.podVersion } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { ALL_SENSOR_TYPES } from '@/src/hooks/useSensorStream' | ||
| import { STREAM_GROUPS, fmtSeen, groupForType } from '../streamGroups' | ||
|
|
||
| describe('groupForType', () => { | ||
| it('puts the firmware water and cover-health frames in Freezer and Presence', () => { | ||
| expect(groupForType('frzWater')).toBe('freezer') | ||
| expect(groupForType('sensHealth')).toBe('presence') | ||
| }) | ||
|
|
||
| it('keeps the existing mappings', () => { | ||
| expect(groupForType('frzHealth')).toBe('freezer') | ||
| expect(groupForType('capSense2')).toBe('presence') | ||
| expect(groupForType('lps')).toBe('piezo') | ||
| expect(groupForType('deviceStatus')).toBe('status') | ||
| }) | ||
|
|
||
| it('returns undefined for types outside every group', () => { | ||
| expect(groupForType('nope')).toBeUndefined() | ||
| }) | ||
|
|
||
| it('assigns every streamed sensor type to exactly one group', () => { | ||
| for (const type of ALL_SENSOR_TYPES) { | ||
| expect(STREAM_GROUPS.filter(g => g.types.includes(type)), type).toHaveLength(1) | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| describe('fmtSeen', () => { | ||
| it('compacts ages', () => { | ||
| expect(fmtSeen(null)).toBe('—') | ||
| expect(fmtSeen(1_234)).toBe('1.2s') | ||
| expect(fmtSeen(12_400)).toBe('12s') | ||
| expect(fmtSeen(4 * 60_000 + 5_000)).toBe('4m') | ||
| expect(fmtSeen(2 * 3_600_000)).toBe('2h') | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.