Skip to content

feat: improve live telemetry dashboard - #6

Merged
ioncache merged 4 commits into
mainfrom
live-telemetry
Jul 6, 2026
Merged

ioncache merged 4 commits into
mainfrom
live-telemetry

Conversation

@ioncache

@ioncache ioncache commented Jul 5, 2026 •

Copy link
Copy Markdown
Owner

Overview

This PR moves the live telemetry dashboard onto a shared live/history chart flow, extracts the oversized App view 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

  • extract the web dashboard into focused components and supporting helpers, including the profiles card/carousel, shot details, debug drawer, and shared display utilities
  • add the synthetic live-shot model and shared chart-source flow so live telemetry and history shots reuse the same chart/details surface
  • add history replay controls, stable empty/default chart behavior, profile selection synchronization, and live-shot guards that ignore idle socket traffic
  • add warm SVG ShotLab branding for the favicon/header and remove dev-only header copy
  • expand unit/render coverage around the extracted components, live telemetry mapper, and shared chart behavior

Related Tickets and/or Pull Requests

  • Relates to the live telemetry roadmap work in docs/plans/2026-07-05-live-telemetry.md

Checklist

  • Tests added or updated
  • README and TSDoc updated if the public API changed
  • Breaking changes called out (if any)
  • Roadmap item checked off if this PR completes one

Summary by CodeRabbit

  • New Features

    • Added a richer dashboard layout with separate areas for live info, actions, profiles, shot details, history, and chart viewing.
    • Introduced profile browsing, selection, and profile imagery across the dashboard.
    • Added chart replay controls and the ability to switch between live and history views.
    • Added a socket debug panel for inspecting recent live events.
  • Bug Fixes

    • Improved loading and empty states across dashboard sections.
    • Fixed history selections and profile display so the active shot/profile stays consistent while browsing.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ioncache, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b9d49d9f-e240-4c38-89f4-dd5e3d7d2cb3

📥 Commits

Reviewing files that changed from the base of the PR and between c75349d and 9bbd699.

📒 Files selected for processing (26)
  • apps/web/src/app.test.tsx
  • apps/web/src/app.tsx
  • apps/web/src/components/DashboardAlerts.test.tsx
  • apps/web/src/components/DashboardAlerts.tsx
  • apps/web/src/components/HistoryTableCard.test.tsx
  • apps/web/src/components/HistoryTableCard.tsx
  • apps/web/src/components/LiveInfoCards.test.tsx
  • apps/web/src/components/ProfileCarousel.tsx
  • apps/web/src/components/ProfileDetails.test.tsx
  • apps/web/src/components/ProfileDetails.tsx
  • apps/web/src/components/ShotChartCard.test.tsx
  • apps/web/src/components/ShotChartCard.tsx
  • apps/web/src/components/ShotDetailsCard.test.tsx
  • apps/web/src/components/ShotDetailsCard.tsx
  • apps/web/src/lib/dashboard-display.ts
  • apps/web/src/lib/dashboard-selectors.test.ts
  • apps/web/src/lib/dashboard-selectors.ts
  • apps/web/src/lib/live-telemetry.test.ts
  • apps/web/src/lib/live-telemetry.ts
  • apps/web/src/lib/profile-display.test.ts
  • apps/web/src/lib/profile-display.ts
  • apps/web/src/lib/shot-chart.test.ts
  • apps/web/src/lib/shot-chart.ts
  • apps/web/tsconfig.json
  • docs/ROADMAP.md
  • docs/plans/2026-07-05-live-telemetry.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch live-telemetry

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ioncache ioncache changed the title feat(0): improve live telemetry dashboard feat: improve live telemetry dashboard Jul 5, 2026
@ioncache
ioncache marked this pull request as ready for review July 5, 2026 23:39

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

History/profile sync can skip the real match after profiles load
If profiles is still empty on the first pass, findProfileIdByReference(...) returns undefined but lastSyncedHistoryShotIdRef.current is still set. When listProfiles finishes and the effect reruns for the same shot, the ref guard exits early, so selectedProfileId never 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 win

Consider 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 value

Coverage gap for brewing fallback with no active reference.

Tests cover idle-manual-selection and brewing-with-reference cases, but not the brewing branch where readActiveBrewProfileReference returns undefined (no machine.profile/loaded_profile and empty lastProfile), which falls back to orderedProfiles[0] regardless of selectedProfileId. 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 value

Duplicate logic between readActiveBrewProfileReference and readLoadedProfileReference.

Both functions are identical except for the order of machine.profile/machine.loaded_profile in the first readString call. 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 value

Potential 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 an id and share the same name, React will see duplicate keys, causing incorrect reconciliation. This is an edge case given profile data likely always has an id, but worth a defensive check if id is 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 value

Hardcoded hex colors bypass MUI theming.

#355c7d, #b7b7b7, and #fffaf2 are hardcoded instead of referencing theme.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 win

Misleading zero defaults for missing metrics.

When temperature/final_weight are 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 win

Missing edge-case coverage for durationSeconds === 0.

This suite validates scaling for a positive durationSeconds but doesn't cover the durationSeconds === 0 edge case, which would have caught the readShotReplayScale inconsistency flagged in shot-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 value

Repeated per-point rescan on every animation frame.

selectShotReplayPointIndex is invoked from ShotChartCard's replay requestAnimationFrame loop and internally scans every point, calling readShotReplayElapsedMs (which itself recomputes readShotReplayScale) 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 by second) 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 value

Replay effect re-runs every animation frame.

displayedChartPointIndex is included in this effect's dependency array (line 189), but animateReplay already re-schedules itself recursively via window.requestAnimationFrame (line 177). Each setDisplayedPointIndex call 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 displayedChartPointIndex from 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 win

Loading state coupled to display label text.

isLiveCardLoading matches 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 alongside DashboardMetric (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 win

Placeholder shot ID shows literal '0' instead of an empty state.

When there's no selectedShot, shotId falls back to '0', which is displayed (and used as the title) 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 value

Potential duplicate React key if loadErrors contains repeated messages.

Using the error string itself as the key will 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 since loadErrors is 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

📥 Commits

Reviewing files that changed from the base of the PR and between c8b3836 and c75349d.

⛔ Files ignored due to path filters (3)
  • apps/web/public/icon.svg is excluded by !**/*.svg
  • apps/web/public/logo.svg is excluded by !**/*.svg
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (53)
  • apps/web/index.html
  • apps/web/package.json
  • apps/web/src/app.test.tsx
  • apps/web/src/app.tsx
  • apps/web/src/components/ActionsCard.test.tsx
  • apps/web/src/components/ActionsCard.tsx
  • apps/web/src/components/DashboardAlerts.test.tsx
  • apps/web/src/components/DashboardAlerts.tsx
  • apps/web/src/components/DashboardHeader.test.tsx
  • apps/web/src/components/DashboardHeader.tsx
  • apps/web/src/components/EmptyPanel.test.tsx
  • apps/web/src/components/EmptyPanel.tsx
  • apps/web/src/components/HistoryTableCard.test.tsx
  • apps/web/src/components/HistoryTableCard.tsx
  • apps/web/src/components/LiveInfoCards.test.tsx
  • apps/web/src/components/LiveInfoCards.tsx
  • apps/web/src/components/Metric.test.tsx
  • apps/web/src/components/Metric.tsx
  • apps/web/src/components/ProfileCarousel.test.tsx
  • apps/web/src/components/ProfileCarousel.tsx
  • apps/web/src/components/ProfileDefaultIcon.test.tsx
  • apps/web/src/components/ProfileDefaultIcon.tsx
  • apps/web/src/components/ProfileDetails.test.tsx
  • apps/web/src/components/ProfileDetails.tsx
  • apps/web/src/components/ProfilesCard.test.tsx
  • apps/web/src/components/ProfilesCard.tsx
  • apps/web/src/components/ShotChartCard.test.tsx
  • apps/web/src/components/ShotChartCard.tsx
  • apps/web/src/components/ShotDetailsCard.test.tsx
  • apps/web/src/components/ShotDetailsCard.tsx
  • apps/web/src/components/SkeletonStates.test.tsx
  • apps/web/src/components/SkeletonStates.tsx
  • apps/web/src/components/SocketDebugDrawer.test.tsx
  • apps/web/src/components/SocketDebugDrawer.tsx
  • apps/web/src/components/SourceDefaultIcon.test.tsx
  • apps/web/src/components/SourceDefaultIcon.tsx
  • apps/web/src/config.ts
  • apps/web/src/lib/create-dashboard-client.test.ts
  • apps/web/src/lib/dashboard-display.ts
  • apps/web/src/lib/dashboard-selectors.test.ts
  • apps/web/src/lib/dashboard-selectors.ts
  • apps/web/src/lib/dashboard-types.ts
  • apps/web/src/lib/live-telemetry.test.ts
  • apps/web/src/lib/live-telemetry.ts
  • apps/web/src/lib/load-dashboard-snapshot.test.ts
  • apps/web/src/lib/load-dashboard-snapshot.ts
  • apps/web/src/lib/profile-display.test.ts
  • apps/web/src/lib/profile-display.ts
  • apps/web/src/lib/shot-chart.test.ts
  • apps/web/src/lib/shot-chart.ts
  • apps/web/src/lib/socket-debug.ts
  • apps/web/tsconfig.json
  • docs/plans/2026-07-05-live-telemetry.md

Comment thread apps/web/src/app.test.tsx Resolved
Comment thread apps/web/src/lib/live-telemetry.test.ts Resolved
Comment thread apps/web/src/lib/live-telemetry.ts Resolved
Comment thread apps/web/src/lib/shot-chart.ts Resolved
Comment thread apps/web/src/lib/socket-debug.ts Resolved
@ioncache

ioncache commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ioncache
ioncache merged commit 80a0b12 into main Jul 6, 2026
3 checks passed
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.

1 participant