Repository navigation
feat: improve live telemetry dashboard - #6
Conversation
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (26)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 9
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/app.tsx (1)
499-522: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winHistory/profile sync can skip the real match after profiles load
Ifprofilesis still empty on the first pass,findProfileIdByReference(...)returnsundefinedbutlastSyncedHistoryShotIdRef.currentis still set. WhenlistProfilesfinishes and the effect reruns for the same shot, the ref guard exits early, soselectedProfileIdnever gets populated. Only mark the shot as synced after a profile match is found, or once profiles are actually available.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/app.tsx` around lines 499 - 522, The history/profile sync logic in the effect that uses findProfileIdByReference and lastSyncedHistoryShotIdRef.current is marking a shot as synced too early, which prevents a later profile load from setting selectedProfileId. Update that effect so the sync ref is only set after a matching profile is found, or after profiles are actually available, and keep the guard in place only for already-processed matches. Use the existing selectedProfileId, profiles, and lastSyncedHistoryShotIdRef flow to ensure the effect can rerun for the same shot once listProfiles completes.
🧹 Nitpick comments (12)
apps/web/src/lib/dashboard-display.ts (1)
30-36: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winConsider rounding displayed grams/seconds.
Raw numeric interpolation can render long floating-point tails (e.g. sensor-derived weights) in the UI.
♻️ Proposed rounding
export function formatGrams(value: number | null): string { - return value === null ? 'Unavailable' : `${value} g`; + return value === null ? 'Unavailable' : `${value.toFixed(1)} g`; } export function formatSeconds(value: number | null): string { - return value === null ? 'Unavailable' : `${value} s`; + return value === null ? 'Unavailable' : `${value.toFixed(1)} s`; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/lib/dashboard-display.ts` around lines 30 - 36, The display helpers formatGrams and formatSeconds currently interpolate raw numbers directly, which can expose long floating-point tails in the UI. Update these functions to round or otherwise limit precision before appending the unit, while still returning Unavailable for null values, so the rendered strings stay concise and readable.apps/web/src/lib/profile-display.test.ts (1)
1-49: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCoverage gap for brewing fallback with no active reference.
Tests cover idle-manual-selection and brewing-with-reference cases, but not the brewing branch where
readActiveBrewProfileReferencereturnsundefined(nomachine.profile/loaded_profileand emptylastProfile), which falls back toorderedProfiles[0]regardless ofselectedProfileId. Worth a test to lock in that behavior explicitly.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/lib/profile-display.test.ts` around lines 1 - 49, Add a test in profile-display.test.ts to cover the brewing fallback path in selectProfileBrowserState when readActiveBrewProfileReference yields no reference (no machine.profile, no loaded_profile, and empty lastProfile). Verify that the brewing branch falls back to orderedProfiles[0] and that this happens regardless of selectedProfileId, so the behavior is locked in explicitly.apps/web/src/lib/profile-display.ts (1)
142-162: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicate logic between
readActiveBrewProfileReferenceandreadLoadedProfileReference.Both functions are identical except for the order of
machine.profile/machine.loaded_profilein the firstreadStringcall. Consider consolidating into a single helper parameterized by priority order to avoid drift if the fallback chain changes later.♻️ Proposed consolidation
-function readActiveBrewProfileReference( - machine: JsonObject, - lastProfile: LastProfileResponse, -): string | undefined { - return ( - readString(machine.profile, machine.loaded_profile) ?? - readProfileId(lastProfile.profile) ?? - readString(lastProfile.profile?.name) - ); -} - -function readLoadedProfileReference( - machine: JsonObject, - lastProfile: LastProfileResponse, -): string | undefined { - return ( - readString(machine.loaded_profile, machine.profile) ?? - readProfileId(lastProfile.profile) ?? - readString(lastProfile.profile?.name) - ); -} +function readProfileReference( + machine: JsonObject, + lastProfile: LastProfileResponse, + priority: 'brewing' | 'loaded', +): string | undefined { + const primary = + priority === 'brewing' + ? readString(machine.profile, machine.loaded_profile) + : readString(machine.loaded_profile, machine.profile); + + return ( + primary ?? + readProfileId(lastProfile.profile) ?? + readString(lastProfile.profile?.name) + ); +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/lib/profile-display.ts` around lines 142 - 162, `readActiveBrewProfileReference` and `readLoadedProfileReference` duplicate the same fallback chain with only the first `readString` argument order differing, so consolidate them into one shared helper in `profile-display.ts` that accepts the preferred machine field order as a parameter. Update both call sites to use the helper with the appropriate priority (`machine.profile` first for active, `machine.loaded_profile` first for loaded) and keep the shared fallback logic with `readProfileId` and `readString(lastProfile.profile?.name)` in one place to prevent future drift.apps/web/src/components/ProfileCarousel.tsx (1)
137-144: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valuePotential duplicate React keys when profile has no id/name mismatch across list.
profileId = readProfileId(profile) ?? readProfileName(profile)falls back to name for the key. If two profiles lack anidand share the samename, React will see duplicate keys, causing incorrect reconciliation. This is an edge case given profile data likely always has anid, but worth a defensive check ifidis ever optional in practice.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/components/ProfileCarousel.tsx` around lines 137 - 144, The `ProfileCarousel` list item key logic can produce duplicate React keys when `readProfileId(profile)` is missing and multiple profiles share the same `readProfileName(profile)`. Update the `props.profiles.map(...)` block so `SwiperSlide` always gets a truly unique key, preferably by using a stable id from the profile data and only falling back to a disambiguated value if needed. Keep the change local to `ProfileCarousel.tsx` and use the existing `readProfileId`, `readProfileName`, and `SwiperSlide` symbols to adjust the key generation defensively.apps/web/src/components/ProfileDefaultIcon.tsx (1)
13-25: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueHardcoded hex colors bypass MUI theming.
#355c7d,#b7b7b7, and#fffaf2are hardcoded instead of referencingtheme.palette. This will look inconsistent under dark mode or if the app's theme changes.♻️ Proposed refactor
- backgroundColor: props.active ? '`#355c7d`' : '`#b7b7b7`', + backgroundColor: props.active ? 'primary.main' : 'action.disabled', - color: '`#fffaf2`', + color: 'primary.contrastText',🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/components/ProfileDefaultIcon.tsx` around lines 13 - 25, Replace the hardcoded hex values in ProfileDefaultIcon’s sx styling with theme-aware palette references so the component follows MUI theming and adapts correctly to dark mode and future theme changes. Update the ProfileDefaultIcon component’s backgroundColor and color logic to use theme.palette values (or a theme-based lookup) instead of `#355c7d`, `#b7b7b7`, and `#fffaf2`, keeping the active/inactive behavior intact.apps/web/src/components/ProfileDetails.tsx (1)
14-17: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winMisleading zero defaults for missing metrics.
When
temperature/final_weightare undefined (e.g. no profile selected, or a profile that simply omits these fields), the UI shows "0 C" / "0 g" — indistinguishable from an actual zero reading. Consider a placeholder like "—" or "Not set" instead.💡 Proposed fix
- <Metric - label="Temperature" - value={temperature === undefined ? '0 C' : `${temperature} C`} - /> - <Metric - label="Yield" - value={finalWeight === undefined ? '0 g' : `${finalWeight} g`} - /> + <Metric + label="Temperature" + value={temperature === undefined ? '—' : `${temperature} C`} + /> + <Metric + label="Yield" + value={finalWeight === undefined ? '—' : `${finalWeight} g`} + />Also applies to: 38-44
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/components/ProfileDetails.tsx` around lines 14 - 17, The ProfileDetails component is defaulting missing temperature/final_weight values to zero, which makes undefined data look like a real reading. Update the temperature and finalWeight handling in ProfileDetails so undefined/null values render a clear placeholder such as “—” or “Not set” instead of “0 C”/“0 g”, and apply the same fallback consistently anywhere these metrics are displayed in the component.apps/web/src/lib/shot-chart.test.ts (1)
109-135: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winMissing edge-case coverage for
durationSeconds === 0.This suite validates scaling for a positive
durationSecondsbut doesn't cover thedurationSeconds === 0edge case, which would have caught thereadShotReplayScaleinconsistency flagged inshot-chart.ts(Lines 194-213).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/lib/shot-chart.test.ts` around lines 109 - 135, Add an edge-case test in the replay timing helpers suite to cover a shot whose durationSeconds is 0, using readShotReplayDurationMs, readShotReplayElapsedMs, and selectShotReplayPointIndex to verify the zero-duration behavior. Locate the existing describe('replay timing helpers') block in shot-chart.test.ts and extend it with a minimal zero-duration DashboardShot fixture so the readShotReplayScale path is exercised consistently with shot-chart.ts.apps/web/src/lib/shot-chart.ts (1)
139-161: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueRepeated per-point rescan on every animation frame.
selectShotReplayPointIndexis invoked fromShotChartCard's replayrequestAnimationFrameloop and internally scans every point, callingreadShotReplayElapsedMs(which itself recomputesreadShotReplayScale) for each one. For shots with many sampled points this repeats redundant work up to 60 times/sec. Consider precomputing the scale once and/or using a binary search (points are monotonically ordered bysecond) since correctness isn't at risk for typical shot lengths — this is purely an efficiency improvement.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/lib/shot-chart.ts` around lines 139 - 161, selectShotReplayPointIndex currently rescans every point and recomputes elapsed values on each animation frame, so optimize the hot path in shot-chart.ts. Update selectShotReplayPointIndex to avoid per-point repeated readShotReplayScale/readShotReplayElapsedMs work by precomputing the replay scale once and using a faster lookup strategy, preferably a binary search over shot.points because the points are ordered by second. Keep the same return behavior for ShotChartCard’s replay loop and preserve the fallback to selectShotPointIndex when replayDurationMs is non-positive.apps/web/src/components/ShotChartCard.tsx (1)
137-193: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueReplay effect re-runs every animation frame.
displayedChartPointIndexis included in this effect's dependency array (line 189), butanimateReplayalready re-schedules itself recursively viawindow.requestAnimationFrame(line 177). EachsetDisplayedPointIndexcall therefore re-renders the component, which tears down and restarts this effect (canceling the self-scheduled frame and issuing a new one) on every tick. This still works because React's commit happens well before the next paint, but it's a redundant scheduling cycle per frame during the entire replay duration.Consider dropping
displayedChartPointIndexfrom the dependency array (it's only used to seed the closure, not to drive re-scheduling) so the RAF loop is purely self-perpetuating.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/components/ShotChartCard.tsx` around lines 137 - 193, The replay RAF loop in ShotChartCard is being restarted on every frame because displayedChartPointIndex is part of the useEffect dependency array even though animateReplay already self-schedules with requestAnimationFrame. Remove displayedChartPointIndex from the dependencies in the ShotChartCard effect so the replay loop stays continuous without canceling and recreating the animation frame each tick.apps/web/src/components/LiveInfoCards.tsx (1)
56-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLoading state coupled to display label text.
isLiveCardLoadingmatches on the exact card label string ('Temperature','Machine status','Weight','Last loaded profile'). Any copy change to these labels silently breaks the loading-state mapping with no compile-time warning. Consider passing a stable key/id alongsideDashboardMetric(or a dedicated map) instead of matching on user-facing text.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/components/LiveInfoCards.tsx` around lines 56 - 67, The loading logic in isLiveCardLoading is tied to user-facing label strings, so copy changes can silently break it. Update LiveInfoCards to use a stable metric key/id from DashboardMetric (or a dedicated label-to-state map) and switch the loading lookup to that key instead of matching on 'Temperature', 'Machine status', 'Weight', or 'Last loaded profile'. Ensure the card rendering path passes the stable identifier into isLiveCardLoading so the mapping remains resilient to display text changes.apps/web/src/components/ShotDetailsCard.tsx (1)
38-38: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winPlaceholder shot ID shows literal
'0'instead of an empty state.When there's no
selectedShot,shotIdfalls back to'0', which is displayed (and used as thetitle) even though the copy button is disabled. This reads as a real (and misleading) shot ID rather than an empty state.💬 Proposed fix
- const shotId = props.selectedShot?.id ?? '0'; + const shotId = props.selectedShot?.id ?? '—';🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/components/ShotDetailsCard.tsx` at line 38, The ShotDetailsCard fallback for shotId is using a literal "0", which makes the empty state look like a real shot ID. Update the shotId assignment in ShotDetailsCard so it stays empty when props.selectedShot is missing, and ensure the rendered title and any related display logic treat that empty state correctly while keeping the copy button disabled.apps/web/src/components/DashboardAlerts.tsx (1)
17-21: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePotential duplicate React key if
loadErrorscontains repeated messages.Using the error string itself as the
keywill collide if two load errors have identical text (e.g., two failed sections with the same message), causing React key warnings/misrendering. Consider keying by index sinceloadErrorsis an append-only, non-reorderable list.♻️ Proposed fix
- {props.loadErrors.map((error) => ( - <Alert key={error} severity="warning"> + {props.loadErrors.map((error, index) => ( + <Alert key={`${index}-${error}`} severity="warning"> {error} </Alert> ))}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/components/DashboardAlerts.tsx` around lines 17 - 21, The DashboardAlerts list currently uses the error message itself as the React key, which can collide when loadErrors contains duplicate text. Update the map in DashboardAlerts to use a stable unique key such as the array index (appropriate here since the list is append-only and not reordered), while keeping the Alert rendering unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/src/app.test.tsx`:
- Around line 227-248: The image accessible name assertion in app.test.tsx does
not match what ShotDetailsCard renders. Update either the test expectation
around the getByRole('img', { name: ... }) call or the alt text in
ShotDetailsCard so they use the same selected profile image naming, keeping the
Bright Filter history/profile image checks consistent with the rendered
accessible name.
In `@apps/web/src/components/HistoryTableCard.test.tsx`:
- Around line 7-16: The `shot` fixture used by `HistoryTableCard` is missing the
required `source` field from `DashboardShot`, so update that test fixture to
include a valid source value. Make the change in the `shot` object defined in
`HistoryTableCard.test.tsx`, keeping the rest of the fixture shape aligned with
`DashboardShot` so the component receives a complete mock.
In `@apps/web/src/components/HistoryTableCard.tsx`:
- Around line 56-91: The `TableRow` in `HistoryTableCard` is clickable but not
keyboard accessible, and its selected state is only visual. Update the row
rendering to make the row focusable and operable via keyboard by adding the
appropriate accessibility props/handlers on `TableRow` and wiring selection
through `props.onSelectShot`. Also ensure the selected row exposes
`aria-selected` (the `selected` prop alone is not enough) so screen readers can
announce the active history shot.
In `@apps/web/src/components/ProfileCarousel.tsx`:
- Line 38: Update the loop gating in ProfileCarousel so Swiper only enables
looping when there are at least 4 profiles, not 3. Adjust the canLoop condition
in the component that builds the Swiper props to use a stricter profile count
threshold, and keep the loop, slideToLoop, and related swiper settings aligned
with that check so behavior stays reliable.
In `@apps/web/src/components/ShotChartCard.tsx`:
- Around line 61-69: In ShotChartCard’s useEffect, don’t cache a concrete point
index for live shots because live telemetry keeps extending the same shot id and
the chart can get stuck on an old length. Update the logic around props.shot,
selectShotPointIndex, and setDisplayedPointIndex so that when props.shot?.source
is 'live' you leave displayedPointIndex undefined, and only call
selectShotPointIndex(shot) to pin history shots. Keep the existing reset
behavior for hoveredPointIndex, replay state, and
replayStartedAtRef/replayStartElapsedMsRef unchanged.
In `@apps/web/src/lib/live-telemetry.test.ts`:
- Around line 45-84: The test in applyLiveSocketEvent is not asserting the
intended behavior because the first status payload never enters the brewing
path, so liveShot remains undefined. Update the brewingState setup to include
the fields that readIsBrewingStatus expects (such as extracting/state) so
patchLiveShotFromStatusEvent actually creates a live shot, then keep the later
idle status assertion to verify the existing liveShot is preserved.
In `@apps/web/src/lib/live-telemetry.ts`:
- Around line 286-392: `patchLiveShotProfile` is passing no status into
`resolveLiveProfile`, so `profileId` keeps falling back to the stale
`liveShot.profileId` during a real profile switch. Update `resolveLiveProfile`
so the `id` resolution has the same fallback behavior as `image` when `status`
is undefined, using the fresh `lastProfile.profile.id` instead of always
preserving the old `liveShot.profileId`. Keep the fix localized to
`patchLiveShotProfile` and `resolveLiveProfile` so genuine profile-change events
update `profileId` consistently with `name` and `image`.
In `@apps/web/src/lib/shot-chart.ts`:
- Around line 194-213: The readShotReplayScale helper is still treating zero or
negative durationSeconds as valid, which can produce a scale of 0 and break
replay point selection. Update readShotReplayScale in shot-chart.ts to mirror
readShotReplayDurationMs by returning 1 whenever shot.durationSeconds is null,
undefined, or <= 0, then keep the existing recorded span validation and ratio
calculation for only positive durations.
In `@apps/web/src/lib/socket-debug.ts`:
- Around line 94-112: The buildDebugSocketSessionSnapshot function uses
Array.prototype.toSorted, which is not available with the web app’s current
TypeScript lib settings. Update the groups ordering in
buildDebugSocketSessionSnapshot to use a non-ES2023-compatible approach such as
sorting a copied array, or alternatively adjust the web app tsconfig lib to
include ES2023 if that is the intended target.
---
Outside diff comments:
In `@apps/web/src/app.tsx`:
- Around line 499-522: The history/profile sync logic in the effect that uses
findProfileIdByReference and lastSyncedHistoryShotIdRef.current is marking a
shot as synced too early, which prevents a later profile load from setting
selectedProfileId. Update that effect so the sync ref is only set after a
matching profile is found, or after profiles are actually available, and keep
the guard in place only for already-processed matches. Use the existing
selectedProfileId, profiles, and lastSyncedHistoryShotIdRef flow to ensure the
effect can rerun for the same shot once listProfiles completes.
---
Nitpick comments:
In `@apps/web/src/components/DashboardAlerts.tsx`:
- Around line 17-21: The DashboardAlerts list currently uses the error message
itself as the React key, which can collide when loadErrors contains duplicate
text. Update the map in DashboardAlerts to use a stable unique key such as the
array index (appropriate here since the list is append-only and not reordered),
while keeping the Alert rendering unchanged.
In `@apps/web/src/components/LiveInfoCards.tsx`:
- Around line 56-67: The loading logic in isLiveCardLoading is tied to
user-facing label strings, so copy changes can silently break it. Update
LiveInfoCards to use a stable metric key/id from DashboardMetric (or a dedicated
label-to-state map) and switch the loading lookup to that key instead of
matching on 'Temperature', 'Machine status', 'Weight', or 'Last loaded profile'.
Ensure the card rendering path passes the stable identifier into
isLiveCardLoading so the mapping remains resilient to display text changes.
In `@apps/web/src/components/ProfileCarousel.tsx`:
- Around line 137-144: The `ProfileCarousel` list item key logic can produce
duplicate React keys when `readProfileId(profile)` is missing and multiple
profiles share the same `readProfileName(profile)`. Update the
`props.profiles.map(...)` block so `SwiperSlide` always gets a truly unique key,
preferably by using a stable id from the profile data and only falling back to a
disambiguated value if needed. Keep the change local to `ProfileCarousel.tsx`
and use the existing `readProfileId`, `readProfileName`, and `SwiperSlide`
symbols to adjust the key generation defensively.
In `@apps/web/src/components/ProfileDefaultIcon.tsx`:
- Around line 13-25: Replace the hardcoded hex values in ProfileDefaultIcon’s sx
styling with theme-aware palette references so the component follows MUI theming
and adapts correctly to dark mode and future theme changes. Update the
ProfileDefaultIcon component’s backgroundColor and color logic to use
theme.palette values (or a theme-based lookup) instead of `#355c7d`, `#b7b7b7`, and
`#fffaf2`, keeping the active/inactive behavior intact.
In `@apps/web/src/components/ProfileDetails.tsx`:
- Around line 14-17: The ProfileDetails component is defaulting missing
temperature/final_weight values to zero, which makes undefined data look like a
real reading. Update the temperature and finalWeight handling in ProfileDetails
so undefined/null values render a clear placeholder such as “—” or “Not set”
instead of “0 C”/“0 g”, and apply the same fallback consistently anywhere these
metrics are displayed in the component.
In `@apps/web/src/components/ShotChartCard.tsx`:
- Around line 137-193: The replay RAF loop in ShotChartCard is being restarted
on every frame because displayedChartPointIndex is part of the useEffect
dependency array even though animateReplay already self-schedules with
requestAnimationFrame. Remove displayedChartPointIndex from the dependencies in
the ShotChartCard effect so the replay loop stays continuous without canceling
and recreating the animation frame each tick.
In `@apps/web/src/components/ShotDetailsCard.tsx`:
- Line 38: The ShotDetailsCard fallback for shotId is using a literal "0", which
makes the empty state look like a real shot ID. Update the shotId assignment in
ShotDetailsCard so it stays empty when props.selectedShot is missing, and ensure
the rendered title and any related display logic treat that empty state
correctly while keeping the copy button disabled.
In `@apps/web/src/lib/dashboard-display.ts`:
- Around line 30-36: The display helpers formatGrams and formatSeconds currently
interpolate raw numbers directly, which can expose long floating-point tails in
the UI. Update these functions to round or otherwise limit precision before
appending the unit, while still returning Unavailable for null values, so the
rendered strings stay concise and readable.
In `@apps/web/src/lib/profile-display.test.ts`:
- Around line 1-49: Add a test in profile-display.test.ts to cover the brewing
fallback path in selectProfileBrowserState when readActiveBrewProfileReference
yields no reference (no machine.profile, no loaded_profile, and empty
lastProfile). Verify that the brewing branch falls back to orderedProfiles[0]
and that this happens regardless of selectedProfileId, so the behavior is locked
in explicitly.
In `@apps/web/src/lib/profile-display.ts`:
- Around line 142-162: `readActiveBrewProfileReference` and
`readLoadedProfileReference` duplicate the same fallback chain with only the
first `readString` argument order differing, so consolidate them into one shared
helper in `profile-display.ts` that accepts the preferred machine field order as
a parameter. Update both call sites to use the helper with the appropriate
priority (`machine.profile` first for active, `machine.loaded_profile` first for
loaded) and keep the shared fallback logic with `readProfileId` and
`readString(lastProfile.profile?.name)` in one place to prevent future drift.
In `@apps/web/src/lib/shot-chart.test.ts`:
- Around line 109-135: Add an edge-case test in the replay timing helpers suite
to cover a shot whose durationSeconds is 0, using readShotReplayDurationMs,
readShotReplayElapsedMs, and selectShotReplayPointIndex to verify the
zero-duration behavior. Locate the existing describe('replay timing helpers')
block in shot-chart.test.ts and extend it with a minimal zero-duration
DashboardShot fixture so the readShotReplayScale path is exercised consistently
with shot-chart.ts.
In `@apps/web/src/lib/shot-chart.ts`:
- Around line 139-161: selectShotReplayPointIndex currently rescans every point
and recomputes elapsed values on each animation frame, so optimize the hot path
in shot-chart.ts. Update selectShotReplayPointIndex to avoid per-point repeated
readShotReplayScale/readShotReplayElapsedMs work by precomputing the replay
scale once and using a faster lookup strategy, preferably a binary search over
shot.points because the points are ordered by second. Keep the same return
behavior for ShotChartCard’s replay loop and preserve the fallback to
selectShotPointIndex when replayDurationMs is non-positive.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 46469bca-c9a1-4a5f-b3b8-1f2ea1798cc4
⛔ Files ignored due to path filters (3)
apps/web/public/icon.svgis excluded by!**/*.svgapps/web/public/logo.svgis excluded by!**/*.svgyarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (53)
apps/web/index.htmlapps/web/package.jsonapps/web/src/app.test.tsxapps/web/src/app.tsxapps/web/src/components/ActionsCard.test.tsxapps/web/src/components/ActionsCard.tsxapps/web/src/components/DashboardAlerts.test.tsxapps/web/src/components/DashboardAlerts.tsxapps/web/src/components/DashboardHeader.test.tsxapps/web/src/components/DashboardHeader.tsxapps/web/src/components/EmptyPanel.test.tsxapps/web/src/components/EmptyPanel.tsxapps/web/src/components/HistoryTableCard.test.tsxapps/web/src/components/HistoryTableCard.tsxapps/web/src/components/LiveInfoCards.test.tsxapps/web/src/components/LiveInfoCards.tsxapps/web/src/components/Metric.test.tsxapps/web/src/components/Metric.tsxapps/web/src/components/ProfileCarousel.test.tsxapps/web/src/components/ProfileCarousel.tsxapps/web/src/components/ProfileDefaultIcon.test.tsxapps/web/src/components/ProfileDefaultIcon.tsxapps/web/src/components/ProfileDetails.test.tsxapps/web/src/components/ProfileDetails.tsxapps/web/src/components/ProfilesCard.test.tsxapps/web/src/components/ProfilesCard.tsxapps/web/src/components/ShotChartCard.test.tsxapps/web/src/components/ShotChartCard.tsxapps/web/src/components/ShotDetailsCard.test.tsxapps/web/src/components/ShotDetailsCard.tsxapps/web/src/components/SkeletonStates.test.tsxapps/web/src/components/SkeletonStates.tsxapps/web/src/components/SocketDebugDrawer.test.tsxapps/web/src/components/SocketDebugDrawer.tsxapps/web/src/components/SourceDefaultIcon.test.tsxapps/web/src/components/SourceDefaultIcon.tsxapps/web/src/config.tsapps/web/src/lib/create-dashboard-client.test.tsapps/web/src/lib/dashboard-display.tsapps/web/src/lib/dashboard-selectors.test.tsapps/web/src/lib/dashboard-selectors.tsapps/web/src/lib/dashboard-types.tsapps/web/src/lib/live-telemetry.test.tsapps/web/src/lib/live-telemetry.tsapps/web/src/lib/load-dashboard-snapshot.test.tsapps/web/src/lib/load-dashboard-snapshot.tsapps/web/src/lib/profile-display.test.tsapps/web/src/lib/profile-display.tsapps/web/src/lib/shot-chart.test.tsapps/web/src/lib/shot-chart.tsapps/web/src/lib/socket-debug.tsapps/web/tsconfig.jsondocs/plans/2026-07-05-live-telemetry.md
|
@CodeRabbit review |
✅ Action performedReview finished.
|
Overview
This PR moves the live telemetry dashboard onto a shared live/history chart flow, extracts the oversized
Appview into focused components, and adds the first round of live-shot UX work so the branch can be reviewed before the remaining live wiring is finished.Details
Related Tickets and/or Pull Requests
docs/plans/2026-07-05-live-telemetry.mdChecklist
Summary by CodeRabbit
New Features
Bug Fixes