Skip to content

Conversation

@KevLehman
Copy link
Member

@KevLehman KevLehman commented Apr 7, 2025

This pull request addresses a critical issue in the Rocket.Chat Omnichannel feature, specifically the evaluation of maximum simultaneous chat limits for agents. The changes focus on refining the logic to ensure accurate enforcement of chat limits at various levels, including agent, global, and department-specific limits.

Key changes include:

  1. Introduction of a New Helper Function: A new function, isAgentWithinChatLimits, has been introduced to replace the previous getMaxNumberSimultaneousChat function. This function evaluates whether an agent can accept more chats based on the configured limits, considering agent, department, and global constraints. This refactor aims to improve the robustness and clarity of the limit evaluation process.

  2. Refactoring of MongoDB Queries: The logic for constructing MongoDB query filters has been simplified. The previous nested $or/$and structure has been replaced with a more linear approach, enhancing readability and maintainability. Additionally, the aggregation pipeline in the getUnavailableAgents method has been optimized for better performance and robustness.

  3. Enhancements to Method Signatures: The getAgentAndAmountOngoingChats method in the IUsersModel interface has been updated to include an optional departmentId parameter. This change allows for the retrieval of department-specific chat counts, providing more granular control over chat limit evaluations.

  4. Refactoring of Livechat Hooks: The logic within the beforeJoinRoom and checkAgentBeforeTakeInquiry hooks has been refactored to utilize the new helper function. This change streamlines the process of checking chat limits before agents join rooms or take inquiries, ensuring consistent application of the new logic.

  5. Changeset Addition: A changeset file has been added to document the fix and the new logic for applying maximum simultaneous chat limits, ensuring that these changes are tracked and communicated effectively.

Overall, this pull request enhances the accuracy and efficiency of chat limit evaluations in the Rocket.Chat Omnichannel feature, providing a more reliable experience for agents and administrators.

CTZ-50
[CTZ-31]

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Apr 7, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Apr 7, 2025

🦋 Changeset detected

Latest commit: 3f11f01

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

This PR includes changesets to release 36 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/model-typings Patch
@rocket.chat/models Patch
@rocket.chat/apps 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/omnichannel-services Patch
rocketchat-services Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/presence Patch
@rocket.chat/network-broker Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration 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

@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2025

PR Preview Action v1.6.1

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-35722/

Built to branch gh-pages at 2025-04-16 19:58 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov
Copy link

codecov bot commented Apr 8, 2025

Codecov Report

Attention: Patch coverage is 99.15254% with 1 line in your changes missing coverage. Please review.

Project coverage is 60.95%. Comparing base (00b75e3) to head (3f11f01).
Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #35722      +/-   ##
===========================================
- Coverage    60.96%   60.95%   -0.02%     
===========================================
  Files         2952     2956       +4     
  Lines        70308    70574     +266     
  Branches     16137    16215      +78     
===========================================
+ Hits         42866    43019     +153     
- Misses       24495    24606     +111     
- Partials      2947     2949       +2     
Flag Coverage Δ
e2e 57.64% <ø> (-0.01%) ⬇️
e2e-api 35.81% <ø> (ø)
unit 75.30% <99.15%> (-0.19%) ⬇️

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.

@KevLehman KevLehman marked this pull request as ready for review April 8, 2025 17:43
@KevLehman KevLehman requested review from a team as code owners April 8, 2025 17:43
@KevLehman KevLehman added this to the 7.6.0 milestone Apr 9, 2025
@jessicaschelly
Copy link
Member

Can you add a description and the steps to reproduce?

@renatobecker renatobecker added the stat: QA assured Means it has been tested and approved by a company insider label Apr 16, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Apr 16, 2025
sampaiodiego
sampaiodiego previously approved these changes Apr 16, 2025
@kody-ai
Copy link

kody-ai bot commented Apr 16, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Apr 16, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Apr 16, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Apr 16, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Apr 16, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@KevLehman KevLehman requested a review from sampaiodiego April 16, 2025 19:39
@kody-ai
Copy link

kody-ai bot commented Apr 16, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@sampaiodiego sampaiodiego merged commit 5f11fea into develop Apr 16, 2025
45 of 48 checks passed
@sampaiodiego sampaiodiego deleted the fix/chat-limits branch April 16, 2025 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants