Skip to content

Conversation

@marcin-bazyl
Copy link
Collaborator

@marcin-bazyl marcin-bazyl commented May 15, 2025

Fixed it so that vscode can now jump to function definitions.

Make sure to tick the "hide whitespace" box when looking at the diff

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 15, 2025

📝 Walkthrough

Walkthrough

The code refactors the SelfUtils object from a mutable structure with separately assigned methods to a consolidated object literal where all methods are defined inline. Multiple utility functions within SelfUtils were updated to include explicit error handling and improved parameter validation. Several methods were enhanced to provide more robust null checks and to return null or specific values when expected data is missing. New methods were added, such as getSipUrl, and existing methods were updated to refine state comparison logic, particularly for media status and user state transitions. The overall structure and error handling of the module were improved without changing its core functionality.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
(node:23087) [DEP0169] DeprecationWarning: url.parse() behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for url.parse() vulnerabilities.
(Use node --trace-deprecation ... to show where the warning was created)
warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
warning [email protected]: Glob versions prior to v9 are no longer supported
warning intern > [email protected]: Glob versions prior to v9 are no longer supported
warning intern > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jasmine > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > jest-cli > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning [email protected]: 16.1.1
warning sinon > @sinonjs/samsam > [email protected]: This package is deprecated. Use the optional chaining (?.) operator instead.
warning wd > [email protected]: request has been deprecated, see request/request#3142
warning wd > [email protected]: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.

(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
warning wd > request > [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
warning wd > archiver > [email protected]: Glob versions prior to v9 are no longer supported
warning wd > request > [email protected]: this library is no longer supported
warning wd > archiver > archiver-utils > [email protected]: Glob versions prior to v9 are no longer supported
warning @babel/cli > [email protected]: Glob versions prior to v9 are no longer supported
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
warning @babel/polyfill > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @babel/runtime-corejs2 > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning babel-plugin-lodash > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-3a001053-0d4d-448d-b060-9d36bbad6c8a > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning workspace-aggregator-3a001053-0d4d-448d-b060-9d36bbad6c8a > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-3a001053-0d4d-448d-b060-9d36bbad6c8a > [email protected]: 16.1.1
warning workspace-aggregator-3a001053-0d4d-448d-b060-9d36bbad6c8a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning workspace-aggregator-3a001053-0d4d-448d-b060-9d36bbad6c8a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning workspace-aggregator-3a001053-0d4d-448d-b060-9d36bbad6c8a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning workspace-aggregator-3a001053-0d4d-448d-b060-9d36bbad6c8a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning workspace-aggregator-3a001053-0d4d-448d-b060-9d36bbad6c8a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning workspace-aggregator-3a001053-0d4d-448d-b060-9d36bbad6c8a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning workspace-aggregator-3a001053-0d4d-448d-b060-9d36bbad6c8a > @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
[2/4] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version "^14 || ^16 || ^17 || ^18 || ^19". Got "24.0.2"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@aws-amplify-us-east-2
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-4272.d3m3l2kee0btzx.amplifyapp.com

@marcin-bazyl marcin-bazyl force-pushed the selfutils-small-refactor branch from 8815a27 to 024b0c0 Compare May 15, 2025 16:36
@marcin-bazyl marcin-bazyl marked this pull request as ready for review May 15, 2025 16:41
@marcin-bazyl marcin-bazyl requested review from a team as code owners May 15, 2025 16:41
@marcin-bazyl marcin-bazyl added the validated If the pull request is validated for automation. label May 15, 2025
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: 3

🧹 Nitpick comments (3)
packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts (3)

216-229: Leverage optional chaining to simplify getLastModified

The current verbose guard blocks readability and prompted a Biome lint warning.
It can be reduced to one safe line without changing behaviour:

-    if (
-      !self ||
-      !self.controls ||
-      !self.controls.audio ||
-      !self.controls.audio.meta ||
-      !self.controls.audio.meta.lastModified
-    ) {
-      return null;
-    }
-
-    return self.controls.audio.meta.lastModified;
+    return self?.controls?.audio?.meta?.lastModified ?? null;

The same pattern applies to getModifiedBy.


380-390: Doc-block promises an error that the code never throws

The comment states @throws {Error} if changed self was undefined, yet isDeviceObserving simply returns a boolean thanks to short-circuit evaluation and never raises. Either drop the @throws line or add the explicit check/throw for consistency with sibling helpers (isUserAdmitted, etc.).

- * @throws {Error} if changed self was undefined
+ * @remarks does not throw; returns `false` when `changedSelf` is undefined

168-176: Optional: simplify nested null checks in isMediaInactive

The explicit multi-line guard is correct but verbose and was flagged by Biome.
You can replace it with optional chaining without changing semantics:

-      previous &&
-      previous.joinedWith &&
-      previous.joinedWith.mediaSessions &&
-      current &&
-      current.joinedWith &&
-      current.joinedWith.mediaSessions
+      previous?.joinedWith?.mediaSessions &&
+      current?.joinedWith?.mediaSessions

(Not critical, but keeps the codebase concise and passes the linter.)

🧰 Tools
🪛 Biome (1.9.4)

[error] 170-172: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 727e691 and 024b0c0.

📒 Files selected for processing (1)
  • packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts

[error] 170-172: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Initialize Project
  • GitHub Check: AWS Amplify Console Web Preview

Copy link
Collaborator

@chrisadubois chrisadubois left a comment

Choose a reason for hiding this comment

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

this is a great improvement

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 (2)
packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts (2)

81-82: Prevent potential TypeError when accessing layouts[0].type

The current implementation doesn't check if layouts array is empty before accessing the first element, which can cause a runtime error.

Apply this change:

-  getLayout: (self) =>
-    Array.isArray(self?.controls?.layouts) ? self.controls.layouts[0].type : undefined,
+  getLayout: (self) => {
+    const layouts = self?.controls?.layouts;
+    return Array.isArray(layouts) && layouts.length > 0 ? layouts[0].type : undefined;
+  },

29-32: ⚠️ Potential issue

Add array check for self.devices to prevent runtime errors

The parse method accesses properties of self.devices without first verifying it's an array, which could cause runtime errors if devices is undefined or not an array (e.g. during unit tests or with malformed payloads).

Apply this change:

  parse: (self: any, deviceId: string) => {
    if (self) {
-      const joinedWith = self.devices.find((device) => deviceId === device.url);
-      const pstnDevices = self.devices.filter((device) => PSTN_DEVICE_TYPE === device.deviceType);
+      const devices = Array.isArray(self.devices) ? self.devices : [];
+      const joinedWith = devices.find((device) => deviceId === device.url);
+      const pstnDevices = devices.filter((device) => PSTN_DEVICE_TYPE === device.deviceType);
🧹 Nitpick comments (3)
packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts (3)

27-27: Update JSDoc return type

The JSDoc comment incorrectly states the return type is {undefined} when the function actually returns an object or null.

- * @returns {undefined}
+ * @returns {Object|null}

169-176: Simplify conditional with optional chaining

The complex condition checking for existence of properties could be simplified using optional chaining for better readability.

  if (
-    previous &&
-    previous.joinedWith &&
-    previous.joinedWith.mediaSessions &&
-    current &&
-    current.joinedWith &&
-    current.joinedWith.mediaSessions
+    previous?.joinedWith?.mediaSessions &&
+    current?.joinedWith?.mediaSessions
  ) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 170-172: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


522-526: Add explicit length check for the array

When checking for breakout replaces, consider adding an explicit length check to avoid accessing an empty array.

  if (self && Array.isArray(self.devices)) {
    const joinedDevice = self.devices.find((device) => deviceId === device.url);
-    if (Array.isArray(joinedDevice?.replaces)) {
+    if (Array.isArray(joinedDevice?.replaces) && joinedDevice.replaces.length > 0) {
      return joinedDevice.replaces[0]?.breakoutMoveId;
    }
  }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 024b0c0 and f92bec7.

📒 Files selected for processing (1)
  • packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts

[error] 170-172: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build Packages
  • GitHub Check: AWS Amplify Console Web Preview
🔇 Additional comments (6)
packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts (6)

249-252: Fixed previous issue with null-guard logic in getSelfIdentity

Great job fixing the null-guard logic by using the correct logical OR operator. This now correctly returns null when either self or self.person is missing.


97-139: Improved structure in getSelves method

The refactored structure with consistent formatting for computing updates makes the code more maintainable and easier to read. The transition to an object literal with defined methods has also improved the organization overall.


492-499: New getSipUrl method implements robust partner handling

The new method correctly extracts SIP URLs conditionally based on partner and call type, with appropriate fallback to the provided sipUri when needed.


168-214: Enhanced media inactivity detection

This implementation now correctly checks multiple media types (audio, video, share) individually for inactive state transitions. The check for direction !== MEDIA_STATE.inactive is particularly important to prevent false positives.

🧰 Tools
🪛 Biome (1.9.4)

[error] 170-172: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


437-449: Robust check for muted status changes

Added logic to avoid false positives when the user mutes themselves and to prevent sending unnecessary unmute notifications on meeting join. This is a valuable improvement.


22-73: Well-structured object literal refactoring

Excellent job converting to an object literal structure. This refactoring makes the code more maintainable and enables VSCode to correctly jump to function definitions as intended by the PR.

@marcin-bazyl marcin-bazyl merged commit 80e80da into webex:next May 19, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validated If the pull request is validated for automation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants