Skip to content

Conversation

@lucas-a-pelegrino
Copy link
Member

@lucas-a-pelegrino lucas-a-pelegrino commented Sep 9, 2025

Proposed changes (including videos or screenshots)

This PR adds a deprecation warning to livechat:getRoutingConfig, and adds a new endpoint that replaces the deprecated method with the livechat/config/routing path.

Issue(s)

CTZ-56

Steps to test or reproduce

Further comments

Tests will be implemented on this task

Summary by CodeRabbit

  • New Features
    • Added an authenticated REST API endpoint to retrieve Livechat routing settings.
  • Refactor
    • Migrated Livechat routing configuration retrieval from a legacy method to the new REST API for improved consistency.
  • Bug Fixes
    • Show user-facing error toasts when routing config retrieval or subscription setup fails.
  • Chores
    • Display a deprecation warning for the legacy Livechat routing method and bumped related package patch versions.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Sep 9, 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 Sep 9, 2025

🦋 Changeset detected

Latest commit: 7ea8769

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/rest-typings Patch
@rocket.chat/api-client Patch
@rocket.chat/core-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/http-router Patch
@rocket.chat/models 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/stream-hub-service Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/core-typings Patch
@rocket.chat/apps Patch
@rocket.chat/freeswitch Patch
@rocket.chat/model-typings Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker 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

@lucas-a-pelegrino lucas-a-pelegrino changed the title chore! Adds deprecation warning on livechat:getRoutingConfig & adds new endpoint to replace it chore!: Adds deprecation warning on livechat:getRoutingConfig & adds new endpoint to replace it Sep 9, 2025
@codecov
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.56%. Comparing base (a89f0e5) to head (7ea8769).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #36897      +/-   ##
===========================================
+ Coverage    66.54%   66.56%   +0.02%     
===========================================
  Files         3344     3344              
  Lines       114626   114629       +3     
  Branches     21090    21251     +161     
===========================================
+ Hits         76273    76303      +30     
+ Misses       35666    35620      -46     
- Partials      2687     2706      +19     
Flag Coverage Δ
e2e 57.70% <83.33%> (-0.01%) ⬇️
unit 71.21% <ø> (-0.01%) ⬇️

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.

@lucas-a-pelegrino lucas-a-pelegrino changed the title chore!: Adds deprecation warning on livechat:getRoutingConfig & adds new endpoint to replace it chore: Adds deprecation warning on livechat:getRoutingConfig & adds new endpoint to replace it Sep 10, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 10, 2025

Walkthrough

Adds GET /v1/livechat/config/routing and AJV typings; client code switches from the Meteor method to the new REST endpoint; the legacy Meteor method logs a deprecation warning; a changeset bumps patch versions.

Changes

Cohort / File(s) Summary
New REST endpoint & typings
apps/meteor/app/livechat/server/api/v1/config.ts, packages/rest-typings/src/v1/omnichannel.ts
Adds GET livechat/config/routing (auth required) returning { config }. Introduces GETLivechatConfigRoutingSchema and GETLivechatConfigRouting validator and augments public REST typings.
Client migrations to REST
apps/meteor/app/livechat/client/lib/stream/queueManager.ts, apps/meteor/client/providers/OmnichannelProvider.tsx
Replaces calls to the Meteor method with REST usage (sdk.rest.get('/v1/livechat/config/routing') and useEndpoint('GET','/v1/livechat/config/routing')), adapts to { config } response shape; queueManager adds try/catch and dispatchToastMessage on errors.
Method deprecation
apps/meteor/app/livechat/server/methods/getRoutingConfig.ts
Emits deprecation log via methodDeprecationLogger.method('livechat:getRoutingConfig', '8.0.0', 'v1/livechat/config/routing') before returning the existing config.
Versioning / changeset
.changeset/itchy-news-design.md
Adds changeset bumping patch versions and documents new endpoint and deprecation.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as Client (Web/App)
  participant REST as REST API (/v1/livechat/config/routing)
  participant Router as RoutingManager

  Note over Client,REST: New flow — client fetches routing config via REST
  Client->>REST: GET /v1/livechat/config/routing
  REST->>Router: RoutingManager.getConfig()
  Router-->>REST: OmichannelRoutingConfig | undefined
  REST-->>Client: 200 { success: true, config }
  Note over Client: Client uses config (e.g., config.autoAssignAgent)
Loading
sequenceDiagram
  autonumber
  participant Client as Client (Legacy)
  participant Method as Meteor Method
  participant Logger as DeprecationLogger
  participant Router as RoutingManager

  Note over Client,Method: Legacy method is deprecated but still returns config
  Client->>Method: call livechat:getRoutingConfig
  Method->>Logger: method('livechat:getRoutingConfig','8.0.0','v1/livechat/config/routing')
  Method->>Router: RoutingManager.getConfig()
  Router-->>Method: OmichannelRoutingConfig | undefined
  Method-->>Client: OmichannelRoutingConfig | undefined
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely reflects the primary changes described in the PR: it adds a deprecation warning for livechat:getRoutingConfig and introduces a new replacement endpoint (livechat/config/routing), matching the raw file summaries and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

I thump my paws—new routes appear,
A tidy path for configs clear.
The old burrow signs “this way’s past,”
REST trails hop forward, quick and fast.
Patch bumps sing; the queues align—🐇✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/v7/CTZ-56

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

@lucas-a-pelegrino lucas-a-pelegrino changed the title chore: Adds deprecation warning on livechat:getRoutingConfig & adds new endpoint to replace it chore: Adds deprecation warning on livechat:getRoutingConfig with new endpoint to replace it Sep 10, 2025
@lucas-a-pelegrino lucas-a-pelegrino added this to the 7.11.0 milestone Sep 10, 2025
@lucas-a-pelegrino lucas-a-pelegrino marked this pull request as ready for review September 10, 2025 19:15
@lucas-a-pelegrino lucas-a-pelegrino requested review from a team as code owners September 10, 2025 19:15
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

🧹 Nitpick comments (5)
apps/meteor/app/livechat/server/methods/getRoutingConfig.ts (1)

17-17: Use absolute path in deprecation hint.

Prefer including a leading slash to match REST paths consistently.

- methodDeprecationLogger.method('livechat:getRoutingConfig', '8.0.0', 'v1/livechat/config/routing');
+ methodDeprecationLogger.method('livechat:getRoutingConfig', '8.0.0', '/v1/livechat/config/routing');
packages/rest-typings/src/v1/omnichannel.ts (1)

2141-2147: Align schema with runtime shape (avoid null if undefined is used).

Server returns undefined (and JSON omits the key). Marking config as nullable allows null, which diverges from the TS generic { config: OmichannelRoutingConfig | undefined }. Remove nullable: true here.

-        config: {
-            type: 'object',
-            nullable: true,
-            properties: {
+        config: {
+            type: 'object',
+            properties: {
apps/meteor/app/livechat/server/api/v1/config.ts (1)

44-57: Guard against missing routing method to avoid 500s.

RoutingManager.getConfig() can throw when no method is set. Consider catching and returning { config: undefined } to keep clients simple.

- async function action() {
-   const config = RoutingManager.getConfig();
-   return API.v1.success({ config });
- },
+ async function action() {
+   try {
+     const config = RoutingManager.getConfig();
+     return API.v1.success({ config });
+   } catch {
+     return API.v1.success({ config: undefined });
+   }
+ },
.changeset/itchy-news-design.md (1)

6-6: Tighten wording and include HTTP verb.

Clearer, concise phrasing.

-Adds deprecation warning on `livechat:getRoutingConfig`, as well as it adds new endpoint to replace it; `livechat/config/routing`
+Deprecates `livechat:getRoutingConfig` and introduces the replacement endpoint: `GET /v1/livechat/config/routing`.
apps/meteor/app/livechat/client/lib/stream/queueManager.ts (1)

121-126: Handle fetch failures to avoid subscribing when config is unavailable.

If the request fails (e.g., 401/timeout), we currently proceed and subscribe. Safer to bail out.

-  const { config } = await sdk.rest.get('/v1/livechat/config/routing');
-  if (config?.autoAssignAgent) {
-    return;
-  }
+  try {
+    const { config } = await sdk.rest.get('/v1/livechat/config/routing');
+    if (config?.autoAssignAgent) {
+      return;
+    }
+  } catch {
+    return;
+  }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6876409 and 8dfbc73.

📒 Files selected for processing (6)
  • .changeset/itchy-news-design.md (1 hunks)
  • apps/meteor/app/livechat/client/lib/stream/queueManager.ts (1 hunks)
  • apps/meteor/app/livechat/server/api/v1/config.ts (2 hunks)
  • apps/meteor/app/livechat/server/methods/getRoutingConfig.ts (2 hunks)
  • apps/meteor/client/providers/OmnichannelProvider.tsx (3 hunks)
  • packages/rest-typings/src/v1/omnichannel.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
apps/meteor/app/livechat/client/lib/stream/queueManager.ts (1)
apps/meteor/app/utils/client/lib/SDKClient.ts (1)
  • sdk (271-271)
apps/meteor/app/livechat/server/api/v1/config.ts (4)
packages/rest-typings/src/v1/omnichannel.ts (1)
  • GETLivechatConfigRouting (2176-2176)
apps/meteor/app/livechat/server/lib/RoutingManager.ts (1)
  • RoutingManager (73-346)
apps/meteor/app/api/server/ApiClass.ts (1)
  • ExtractRoutesFromAPI (71-75)
packages/rest-typings/src/index.ts (1)
  • Endpoints (52-100)
apps/meteor/client/providers/OmnichannelProvider.tsx (1)
packages/ui-contexts/src/index.ts (1)
  • useEndpoint (32-32)
🔇 Additional comments (2)
apps/meteor/app/livechat/server/api/v1/config.ts (1)

59-64: Typings hookup LGTM.

Extending Endpoints via ExtractRoutesFromAPI is correct and keeps client typings in sync.

apps/meteor/client/providers/OmnichannelProvider.tsx (1)

110-114: REST switch and state update look good.

Using useEndpoint('GET', '/v1/livechat/config/routing') with guarded setRouteConfig(config) is correct; error path is handled.

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

♻️ Duplicate comments (1)
apps/meteor/app/livechat/client/lib/stream/queueManager.ts (1)

123-154: Nice improvement: initial request is now handled with try/catch and user feedback

This addresses the earlier concern about request failures by surfacing a toast and propagating the error. 👍

🧹 Nitpick comments (6)
apps/meteor/app/livechat/client/lib/stream/queueManager.ts (6)

7-7: Normalize error toast payload to avoid “[object Object]” and improve UX

Ensure the toast message is always a string; otherwise users may see a generic object printout.

-		dispatchToastMessage({ type: 'error', message: error });
+		const message = error instanceof Error ? error.message : String(error);
+		dispatchToastMessage({ type: 'error', message });

Also applies to: 151-154


104-110: Duplicate global-listener cleanup (removeGlobalListener and globalCleanup) — call only once

addGlobalListener returns removeGlobalListener, and the cleanup currently calls both removeGlobalListener() and globalCleanup?.(). Drop one to avoid double stop and potential no-op warnings in the SDK.

 		return () => {
 			useLivechatInquiryStore.getState().discardAll();
-			removeGlobalListener();
 			cleanAgentListener?.();
 			cleanDepartmentListeners?.();
 			globalCleanup?.();
 			departments.clear();
 			computation.stop();
 		};

Also applies to: 142-150


136-141: Avoid async Tracker.autorun; catch fetch errors inside to prevent unhandled rejections

Tracker doesn’t await async callbacks. Refactor to a sync autorun that spawns the promise and handles errors locally.

-		const computation = Tracker.autorun(async () => {
-			const inquiriesFromAPI = await getInquiriesFromAPI();
-
-			await updateInquiries(inquiriesFromAPI);
-		});
+		const computation = Tracker.autorun(() => {
+			void getInquiriesFromAPI()
+				.then((inquiriesFromAPI) => updateInquiries(inquiriesFromAPI))
+				.catch((e) => dispatchToastMessage({ type: 'error', message: e instanceof Error ? e.message : String(e) }));
+		});

123-128: Type the REST response for compile-time safety

Leverage REST typings so refactors to the endpoint shape are caught at build time.

+import type { GETLivechatConfigRouting } from '@rocket.chat/rest-typings';-		const { config } = await sdk.rest.get('/v1/livechat/config/routing');
+		const { config } = await sdk.rest.get<GETLivechatConfigRouting>('/v1/livechat/config/routing');

125-127: Return a no-op cleanup when auto-assign is enabled to keep API symmetry

Callers always receive a function, simplifying upstream logic (even though optional chaining is used).

-		if (config?.autoAssignAgent) {
-			return;
-		}
+		if (config?.autoAssignAgent) {
+			return () => {};
+		}

78-81: Avoid shadowing ‘departments’ identifier for readability

The parameter name in addListenerForeachDepartment shadows the module-level departments Set. Rename for clarity.

-const addListenerForeachDepartment = (departments: ILivechatDepartment['_id'][] = []) => {
-	const cleanupFunctions = departments.map((department) => appendListenerToDepartment(department));
+const addListenerForeachDepartment = (departmentIds: ILivechatDepartment['_id'][] = []) => {
+	const cleanupFunctions = departmentIds.map((departmentId) => appendListenerToDepartment(departmentId));

Also applies to: 129-135

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8dfbc73 and 4af41c0.

📒 Files selected for processing (1)
  • apps/meteor/app/livechat/client/lib/stream/queueManager.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/meteor/app/livechat/client/lib/stream/queueManager.ts (3)
apps/meteor/app/utils/client/lib/SDKClient.ts (1)
  • sdk (271-271)
apps/meteor/client/hooks/useLivechatInquiryStore.ts (1)
  • useLivechatInquiryStore (6-42)
apps/meteor/client/lib/toast.ts (1)
  • dispatchToastMessage (22-25)
⏰ 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). (21)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 7.0 (4/4) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 5.0 (1/4) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 7.0 (1/4) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 7.0 (3/4) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 5.0 (2/4) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 5.0 (2/5) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 5.0 (3/5) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 7.0 (2/4) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 5.0 (4/5) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 5.0 (3/4) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 5.0 (4/4) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 5.0 (5/5) - Alpine (Official)
  • GitHub Check: 🔨 Test API (EE) / MongoDB 5.0 (1/1) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 5.0 (1/5) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 7.0 [legacy watchers] (2/5) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 7.0 [legacy watchers] (5/5) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 7.0 [legacy watchers] (3/5) - Alpine (Official)
  • GitHub Check: 🔨 Test API (CE) / MongoDB 5.0 (1/1) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 7.0 [legacy watchers] (1/5) - Alpine (Official)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 7.0 [legacy watchers] (4/5) - Alpine (Official)
  • GitHub Check: 🔨 Test API (CE) / MongoDB 7.0 (1/1) - Alpine (Official)

Copy link
Contributor

@aleksandernsilva aleksandernsilva left a comment

Choose a reason for hiding this comment

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

[FE] LGTM

@lucas-a-pelegrino lucas-a-pelegrino added stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider labels Sep 11, 2025
@kodiakhq kodiakhq bot merged commit 00611ac into develop Sep 12, 2025
70 of 72 checks passed
@kodiakhq kodiakhq bot deleted the chore/v7/CTZ-56 branch September 12, 2025 01:27
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.

5 participants