Skip to content

chore: improve voip enums definitions - #41045

Merged
ggazzo merged 3 commits into
developfrom
chore/voip-enum-types
Jun 24, 2026
Merged

chore: improve voip enums definitions#41045
ggazzo merged 3 commits into
developfrom
chore/voip-enum-types

Conversation

@pierre-lehnen-rc

@pierre-lehnen-rc pierre-lehnen-rc commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

Issue(s)

Derived from CORE-2306

Steps to test or reproduce

Further comments

Review in cubic

Summary by CodeRabbit

  • Refactor
    • Standardized call and client status values by sourcing them from shared, exported lists, ensuring consistent usage across the media signaling module.
    • Updated related JSON schema enums (e.g., hangup reason, call state, client/contract state) to use the same shared value lists.
    • Adjusted module exports so the definition index now includes the shared value lists at runtime.

@dionisio-bot

dionisio-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

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

@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1808a30

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d153b1fe-f75d-47d6-a4f0-f4071540a09f

📥 Commits

Reviewing files that changed from the base of the PR and between 7e7ff5e and 7f558ce.

📒 Files selected for processing (2)
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/definition/client.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/definition/client.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check

Walkthrough

Five files in packages/media-signaling are refactored: string-literal union types for CallState, CallHangupReason, CallNotification, CallRejectedReason, CallFlag, ClientState, and ClientContractState are replaced with exported as const arrays from which the types are derived. The definition index switches to a value-inclusive re-export, and JSON schema enum constraints in hangup.ts and local-state.ts are updated to reference the shared constants.

Changes

as-const list refactor for call and client types

Layer / File(s) Summary
Convert union types to as-const lists and export
packages/media-signaling/src/definition/call/IClientMediaCall.ts, packages/media-signaling/src/definition/client.ts, packages/media-signaling/src/definition/index.ts
All five call-related and two client-related string-union types are replaced with exported as const arrays; types are derived via (typeof list)[number]. The ./client re-export in index.ts is changed from export type * to export * to expose the runtime arrays.
Replace hardcoded schema enum arrays with shared constants
packages/media-signaling/src/definition/signals/client/hangup.ts, packages/media-signaling/src/definition/signals/client/local-state.ts
Imports in both schema files are updated to pull in the new list constants, and all inline hardcoded enum: [...] arrays in clientMediaSignalHangupSchema and clientMediaSignalLocalStateSchema are replaced with references to callHangupReasonList, callStateList, clientStateList, and clientContractStateList.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: improve voip enums definitions' directly aligns with the main change, which refactors multiple enum-like type definitions into reusable const-based patterns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • CORE-2306: Request failed with status code 401

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.

@pierre-lehnen-rc pierre-lehnen-rc added the stat: QA assured Means it has been tested and approved by a company insider label Jun 22, 2026
@pierre-lehnen-rc
pierre-lehnen-rc marked this pull request as ready for review June 22, 2026 20:45

@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: 2

🧹 Nitpick comments (2)
packages/media-signaling/src/definition/call/IClientMediaCall.ts (1)

18-23: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Remove inline implementation comments from list items.

Please move these inline comments to external docs/types if needed; the current style conflicts with the repository guideline.

As per coding guidelines, **/*.{ts,tsx,js} requires: “Avoid code comments in the implementation.”

Also applies to: 29-47, 61-64, 70-79

🤖 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 `@packages/media-signaling/src/definition/call/IClientMediaCall.ts` around
lines 18 - 23, Remove all inline comments from the enum or type definition in
IClientMediaCall that currently explain each state value. The inline comments
like "trying to call with no idea if it'll reach anyone" next to 'none', and
similar comments for 'ringing', 'accepted', 'active', 'renegotiating', and
'hangup' should be deleted. If these descriptions are necessary for
documentation purposes, convert them to JSDoc comments above the enum/type
declaration instead of keeping them as inline implementation comments. Apply
this change across all affected sections mentioned in the review (lines 18-23,
29-47, 61-64, 70-79).

Source: Coding guidelines

packages/media-signaling/src/definition/client.ts (1)

2-13: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Drop inline comments inside enum value arrays.

This implementation style conflicts with the repository TS/JS guideline; move rationale to docs/types instead.

As per coding guidelines, **/*.{ts,tsx,js} requires: “Avoid code comments in the implementation.”

Also applies to: 19-23

🤖 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 `@packages/media-signaling/src/definition/client.ts` around lines 2 - 13,
Remove all inline comments that appear after each string value in the enum or
array definition in the client.ts file (such as the comments following 'none',
'pending', 'accepting', 'waiting-for-track', etc., both in the lines 2-13 range
and the also-applies-to lines 19-23). Instead, move the documentation and
rationale for each state value to a JSDoc comment block at the top of the enum
or type definition to document the entire type, which aligns with the
repository's TS/JS guideline against inline code comments in implementations.

Source: Coding guidelines

🤖 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 `@packages/media-signaling/src/definition/call/IClientMediaCall.ts`:
- Around line 17-27: Add the `as const` assertion to the end of all five array
declarations (callStateList, callHangupReasonList, callNotificationList,
callRejectedReasonList, callFlagList) to ensure their derived types are literal
unions instead of widening to string. Additionally, remove all inline comments
from the array elements as they violate the coding guideline against code
comments in TypeScript implementations, keeping only the array values
themselves.

In `@packages/media-signaling/src/definition/client.ts`:
- Around line 1-16: Add `as const` assertion to the end of the `clientStateList`
array declaration to ensure the derived `ClientState` type becomes a union of
literal string types rather than a generic string type. This will preserve
compile-time validation for state values and prevent the type from widening to
string.

---

Nitpick comments:
In `@packages/media-signaling/src/definition/call/IClientMediaCall.ts`:
- Around line 18-23: Remove all inline comments from the enum or type definition
in IClientMediaCall that currently explain each state value. The inline comments
like "trying to call with no idea if it'll reach anyone" next to 'none', and
similar comments for 'ringing', 'accepted', 'active', 'renegotiating', and
'hangup' should be deleted. If these descriptions are necessary for
documentation purposes, convert them to JSDoc comments above the enum/type
declaration instead of keeping them as inline implementation comments. Apply
this change across all affected sections mentioned in the review (lines 18-23,
29-47, 61-64, 70-79).

In `@packages/media-signaling/src/definition/client.ts`:
- Around line 2-13: Remove all inline comments that appear after each string
value in the enum or array definition in the client.ts file (such as the
comments following 'none', 'pending', 'accepting', 'waiting-for-track', etc.,
both in the lines 2-13 range and the also-applies-to lines 19-23). Instead, move
the documentation and rationale for each state value to a JSDoc comment block at
the top of the enum or type definition to document the entire type, which aligns
with the repository's TS/JS guideline against inline code comments in
implementations.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 56ccfcca-a26b-4b04-8be7-5d053d06c9ff

📥 Commits

Reviewing files that changed from the base of the PR and between ffaa115 and 7e7ff5e.

📒 Files selected for processing (5)
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/definition/client.ts
  • packages/media-signaling/src/definition/index.ts
  • packages/media-signaling/src/definition/signals/client/hangup.ts
  • packages/media-signaling/src/definition/signals/client/local-state.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/media-signaling/src/definition/signals/client/hangup.ts
  • packages/media-signaling/src/definition/index.ts
  • packages/media-signaling/src/definition/client.ts
  • packages/media-signaling/src/definition/signals/client/local-state.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
🧠 Learnings (3)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/media-signaling/src/definition/signals/client/hangup.ts
  • packages/media-signaling/src/definition/index.ts
  • packages/media-signaling/src/definition/client.ts
  • packages/media-signaling/src/definition/signals/client/local-state.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/media-signaling/src/definition/signals/client/hangup.ts
  • packages/media-signaling/src/definition/index.ts
  • packages/media-signaling/src/definition/client.ts
  • packages/media-signaling/src/definition/signals/client/local-state.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • packages/media-signaling/src/definition/signals/client/hangup.ts
  • packages/media-signaling/src/definition/index.ts
  • packages/media-signaling/src/definition/client.ts
  • packages/media-signaling/src/definition/signals/client/local-state.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
🔇 Additional comments (3)
packages/media-signaling/src/definition/index.ts (1)

5-5: LGTM!

packages/media-signaling/src/definition/signals/client/hangup.ts (1)

3-3: LGTM!

Also applies to: 33-33

packages/media-signaling/src/definition/signals/client/local-state.ts (1)

3-5: LGTM!

Also applies to: 40-45, 64-64

Comment thread packages/media-signaling/src/definition/call/IClientMediaCall.ts
Comment thread packages/media-signaling/src/definition/client.ts

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 5 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/media-signaling/src/definition/client.ts
Comment thread packages/media-signaling/src/definition/call/IClientMediaCall.ts
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.10%. Comparing base (0433f00) to head (1808a30).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #41045   +/-   ##
========================================
  Coverage    70.09%   70.10%           
========================================
  Files         3362     3362           
  Lines       129705   129705           
  Branches     22466    22459    -7     
========================================
+ Hits         90921    90930    +9     
+ Misses       35465    35454   -11     
- Partials      3319     3321    +2     
Flag Coverage Δ
e2e 59.40% <ø> (+0.10%) ⬆️
e2e-api 46.27% <ø> (-0.86%) ⬇️
unit 69.98% <ø> (ø)

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.

@pierre-lehnen-rc pierre-lehnen-rc added this to the 8.7.0 milestone Jun 23, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 23, 2026
@pierre-lehnen-rc
pierre-lehnen-rc added this pull request to the merge queue Jun 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 23, 2026
@pierre-lehnen-rc
pierre-lehnen-rc added this pull request to the merge queue Jun 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 23, 2026
@pierre-lehnen-rc
pierre-lehnen-rc added this pull request to the merge queue Jun 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 23, 2026
@pierre-lehnen-rc
pierre-lehnen-rc added this pull request to the merge queue Jun 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 24, 2026
@pierre-lehnen-rc
pierre-lehnen-rc added this pull request to the merge queue Jun 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 24, 2026
@pierre-lehnen-rc
pierre-lehnen-rc added this pull request to the merge queue Jun 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 24, 2026
@pierre-lehnen-rc
pierre-lehnen-rc added this pull request to the merge queue Jun 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 24, 2026
ggazzo pushed a commit that referenced this pull request Jun 24, 2026
@ggazzo
ggazzo disabled auto-merge June 24, 2026 21:13
@ggazzo
ggazzo merged commit 3d0aa38 into develop Jun 24, 2026
81 of 85 checks passed
@ggazzo
ggazzo deleted the chore/voip-enum-types branch June 24, 2026 21:13
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 type: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants