Skip to content

Conversation

@rocketchat-github-ci
Copy link
Collaborator

@rocketchat-github-ci rocketchat-github-ci commented Oct 15, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Fixed real-time monitoring showing incorrect/stale chart data by improving chart reset and update behavior.
  • Improvements

    • More robust chart lifecycle and update handling for all real-time monitoring charts, reducing rendering glitches and aborting updates when not ready.
    • Improved query timing to avoid stale results.
  • Chores

    • Bumped patch version for a core package to prepare a maintenance release.

You can see below a preview of the release change log:

7.10.2

Engine versions

  • Node: 22.16.0
  • Deno: 1.43.5
  • MongoDB: 5.0, 6.0, 7.0
  • Apps-Engine: 1.55.1

Patch Changes

@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2025

🦋 Changeset detected

Latest commit: 73aeb0c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 39 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/omni-core-ee Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 15, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Replaces local chart refs with a new reusable useChartContext hook, adds resetChart helper, adapts useUpdateChartData to accept a chart instance (not a ref), and updates multiple real-time monitoring chart components to use the new context-driven init/update flow; also adds two changeset files for a patch bump.

Changes

Cohort / File(s) Summary
Changesets
./.changeset/bump-patch-1760546047114.md, ./.changeset/rare-schools-laugh.md
Add two changeset entries indicating patch bumps for @rocket.chat/meteor with brief descriptions/notes.
Chart utilities
apps/meteor/app/livechat/client/lib/chartHandler.ts
Add resetChart<TChartType> to clear labels and dataset data and call chart.update().
Chart context hook & update util
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useChartContext.tsx, apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useUpdateChartData.ts
Add useChartContext hook to initialize/destroy Chart.js instances; change useUpdateChartData API to accept `context: TChart
Realtime chart components (context migration)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/AgentStatusChart.tsx, .../ChatDurationChart.tsx, .../ChatsChart.tsx, .../ChatsPerAgentChart.tsx, .../ChatsPerDepartmentChart.tsx, .../ResponseTimesChart.tsx
Replace manual ref-based chart lifecycle with useChartContext, add gcTime: 0 to queries, add guards for missing context, wire updates through useUpdateChartData, and for some charts call resetChart before pushing new data.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Component
  participant H as useChartContext (hook)
  participant I as init(chart)
  participant U as useUpdateChartData
  participant CH as Chart.js instance

  C->>H: provide { canvas, init, t }
  H->>I: call init(...) (async)
  I-->>H: returns CH
  H-->>C: expose CH (context)
  C->>U: call updateChartData({ context: CH, ... })
  U->>CH: update datasets / labels
  CH-->>U: update complete
  Note right of CH: resetChart may be called to clear before updates
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • scuciatto
  • ggazzo
  • aleksandernsilva

Poem

I hop on canvas, paws in code so neat,
I plant a hook and make the charts complete.
Labels cleared, datasets gleam anew,
A tiny patch, a carrot cheer—woohoo! 🥕🐰

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Release 7.10.2” succinctly and accurately captures the primary purpose of this pull request, which is to bump the project to the 7.10.2 release. It is concise, clearly indicates the version change, and enables reviewers to immediately understand the PR’s intent without extraneous detail.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch release-7.10.2

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 and usage tips.

@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.18%. Comparing base (4de0c56) to head (73aeb0c).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #37239      +/-   ##
==========================================
- Coverage   66.21%   66.18%   -0.03%     
==========================================
  Files        3289     3289              
  Lines      110356   110356              
  Branches    20911    20904       -7     
==========================================
- Hits        73070    73040      -30     
- Misses      34603    34634      +31     
+ Partials     2683     2682       -1     
Flag Coverage Δ
e2e 57.39% <ø> (-0.02%) ⬇️
unit 71.50% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kodiakhq kodiakhq bot requested review from a team as code owners October 15, 2025 18:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useUpdateChartData.ts (1)

21-31: Remove fallback initialization in useUpdateChartData to prevent orphaned charts.

The context ?? (await init(...)) in useUpdateChartData (useUpdateChartData.ts) can spin up a new Chart.js instance when data arrives before useChartContext has finished initializing, and that instance is never cleaned up. Replace the fallback with an early return on missing context:

- const chartContext = context ?? (await init(canvas, undefined, t));
+ if (!context) {
+   return;
+ }
+ const chartContext = context;
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerAgentChart.tsx (1)

17-23: Fix dataset count mismatch in init

Three dataset labels are provided, but only two data arrays are passed. Add a third array to match.

- drawLineChart(canvas, context, [t('Open'), t('Closed'), t('On_Hold_Chats')], [], [[], []], {
+ drawLineChart(canvas, context, [t('Open'), t('Closed'), t('On_Hold_Chats')], [], [[], [], []], {
♻️ Duplicate comments (1)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsChart.tsx (1)

49-50: gcTime usage note already covered

See earlier comment about ensuring TanStack Query v5 for gcTime.

🧹 Nitpick comments (4)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ResponseTimesChart.tsx (1)

86-97: Tighten effect guard and deps

Combine guards and drop unused t from deps to avoid extra renders.

-  if (!context) {
-    return;
-  }
-
-  if (!isSuccess) {
-    return;
-  }
+  if (!context || !isSuccess) {
+    return;
+  }
@@
-}, [context, reactionAvg, reactionLongest, responseAvg, responseLongest, isSuccess, t, updateChartData]);
+}, [context, reactionAvg, reactionLongest, responseAvg, responseLongest, isSuccess, updateChartData]);
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsChart.tsx (1)

67-80: Reduce unnecessary effect deps and consider batching updates

  • t isn't used in the effect body; remove from deps.
  • Optional: if updateChartData triggers a chart update each call, consider a bulk update path to avoid 4 sequential updates.
-}, [context, closed, open, queued, onhold, isSuccess, t, updateChartData]);
+}, [context, closed, open, queued, onhold, isSuccess, updateChartData]);
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerAgentChart.tsx (1)

55-67: Effect guards/reset look good; trim deps

Keep the guards and resetChart, but drop unused t from deps.

-}, [context, data, isSuccess, t, updateChartData]);
+}, [context, data, isSuccess, updateChartData]);
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerDepartmentChart.tsx (1)

55-69: Guards and reset look good; trim deps

t isn't used in the effect body; remove from deps.

-}, [context, data, isSuccess, t, updateChartData]);
+}, [context, data, isSuccess, updateChartData]);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 11e9da1 and 73aeb0c.

📒 Files selected for processing (10)
  • .changeset/rare-schools-laugh.md (1 hunks)
  • apps/meteor/app/livechat/client/lib/chartHandler.ts (1 hunks)
  • apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/AgentStatusChart.tsx (2 hunks)
  • apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatDurationChart.tsx (3 hunks)
  • apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsChart.tsx (2 hunks)
  • apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerAgentChart.tsx (2 hunks)
  • apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerDepartmentChart.tsx (2 hunks)
  • apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ResponseTimesChart.tsx (2 hunks)
  • apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useChartContext.tsx (1 hunks)
  • apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useUpdateChartData.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (8)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatDurationChart.tsx (2)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useChartContext.tsx (1)
  • useChartContext (12-44)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useUpdateChartData.ts (1)
  • useUpdateChartData (15-32)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/AgentStatusChart.tsx (2)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useChartContext.tsx (1)
  • useChartContext (12-44)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useUpdateChartData.ts (1)
  • useUpdateChartData (15-32)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ResponseTimesChart.tsx (2)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useChartContext.tsx (1)
  • useChartContext (12-44)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useUpdateChartData.ts (1)
  • useUpdateChartData (15-32)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useUpdateChartData.ts (1)
apps/meteor/app/livechat/client/lib/chartHandler.ts (1)
  • updateChart (187-211)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerAgentChart.tsx (3)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useChartContext.tsx (1)
  • useChartContext (12-44)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useUpdateChartData.ts (1)
  • useUpdateChartData (15-32)
apps/meteor/app/livechat/client/lib/chartHandler.ts (1)
  • resetChart (213-220)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useChartContext.tsx (1)
apps/meteor/app/utils/lib/i18n.ts (1)
  • t (6-6)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerDepartmentChart.tsx (3)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useChartContext.tsx (1)
  • useChartContext (12-44)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useUpdateChartData.ts (1)
  • useUpdateChartData (15-32)
apps/meteor/app/livechat/client/lib/chartHandler.ts (1)
  • resetChart (213-220)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsChart.tsx (2)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useChartContext.tsx (1)
  • useChartContext (12-44)
apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useUpdateChartData.ts (1)
  • useUpdateChartData (15-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 📦 Meteor Build - coverage
  • GitHub Check: update-pr
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (16)
.changeset/rare-schools-laugh.md (1)

1-5: LGTM!

The changeset correctly documents the patch version bump and describes the fix being delivered.

apps/meteor/app/livechat/client/lib/chartHandler.ts (1)

213-220: LGTM!

The resetChart function correctly clears all chart data by resetting labels and dataset arrays, then triggers an update. The generic implementation allows it to work with any Chart.js chart type.

apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/AgentStatusChart.tsx (3)

51-62: LGTM!

The chart context integration is correctly implemented using the new useChartContext hook, and the context is properly passed to useUpdateChartData.


65-77: LGTM!

The effect correctly guards against updates when the context is unavailable and includes context in the dependency array, ensuring the effect re-runs once the chart is initialized.


48-48: Confirm intentional use of gcTime: 0 across all real-time monitoring charts
All six charts under apps/meteor/client/views/omnichannel/realTimeMonitoring/charts disable caching by using gcTime: 0, forcing fresh data on every mount. If you need real-time accuracy but want to reduce network/server load, consider a short nonzero cache (e.g. gcTime: 1000).

apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/useChartContext.tsx (1)

12-44: LGTM!

The hook correctly manages the chart lifecycle with proper async initialization and cleanup. The unmounted flag at line 17 prevents race conditions by ensuring chart destruction and preventing state updates if the component unmounts during async initialization.

apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatDurationChart.tsx (3)

60-71: LGTM!

The chart context integration follows the same correct pattern as AgentStatusChart, properly using useChartContext to manage the chart lifecycle and passing the context to useUpdateChartData.


83-93: LGTM!

The effect correctly guards against updates when the context is unavailable and includes context in the dependency array, ensuring proper synchronization with the chart lifecycle.


57-57: Verify the need for disabling query caching.

Similar to AgentStatusChart, setting gcTime: 0 disables query caching. Ensure this is intentional and consistent with real-time monitoring requirements across all chart components.

apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ResponseTimesChart.tsx (2)

73-77: Context-based chart lifecycle: LGTM

Good migration to useChartContext and passing context into useUpdateChartData.

Also applies to: 79-85


70-70: gcTime is correct with TanStack Query v5
Project uses @tanstack/[email protected], so gcTime is a valid option; no update required.

apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsChart.tsx (1)

52-56: Hook migration: LGTM

Correct use of useChartContext and passing context into useUpdateChartData.

Also applies to: 58-63

apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerAgentChart.tsx (2)

42-46: Hook integration: LGTM

Good use of useChartContext and passing context into useUpdateChartData.

Also applies to: 48-53


38-40: Confirm select safely strips only success and yields agent entries
The endpoint returns a plain object mapping agent IDs to their { open, closed, onhold? } metrics (no extra metadata keys), so using

select: ({ success: _, ...data }) => Object.entries(data)

correctly removes only success.
(Note: runtime shape omits onhold when zero, despite TS typing.)

apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerDepartmentChart.tsx (2)

12-15: Reset integration: LGTM

Importing and using resetChart aligns with the new flow.


42-46: Hook integration: LGTM

Correct use of useChartContext and useUpdateChartData with context.

Also applies to: 48-53

@rocketchat-github-ci rocketchat-github-ci merged commit 73aeb0c into master Oct 15, 2025
53 checks passed
@rocketchat-github-ci rocketchat-github-ci deleted the release-7.10.2 branch October 15, 2025 22:38
@coderabbitai coderabbitai bot mentioned this pull request Nov 14, 2025
@coderabbitai coderabbitai bot mentioned this pull request Dec 8, 2025
@coderabbitai coderabbitai bot mentioned this pull request Dec 19, 2025
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