Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentiment analyser playtime 24 #4024

Open
wants to merge 9 commits into
base: next
Choose a base branch
from

Conversation

rishigupta1606
Copy link

@rishigupta1606 rishigupta1606 commented Dec 10, 2024

COMPLETES #< INSERT LINK TO ISSUE >

This pull request addresses

< DESCRIBE THE CONTEXT OF THE ISSUE >

by making the following changes

< DESCRIBE YOUR CHANGES >

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

I certified that

  • I have read and followed contributing guidelines

  • I discussed changes with code owners prior to submitting this pull request

  • I have not skipped any automated checks

  • All existing and new tests passed

  • I have updated the documentation accordingly


Make sure to have followed the contributing guidelines before submitting.

Summary by CodeRabbit

  • New Features

    • Introduced sentiment analysis capabilities during meetings.
    • Added a new "Sentiment Analyser" section with visual feedback components.
  • Bug Fixes

    • Enhanced error handling for call setup and media negotiation processes.
  • Documentation

    • Updated HTML structure for improved user interface clarity, including simplification of participant section.
  • Style

    • Added new CSS classes and styles for sentiment analysis components and progress tracking.

Copy link

coderabbitai bot commented Dec 10, 2024

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.

warning eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > inflight@1.0.6: 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 > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning glob@7.2.3: Glob versions prior to v9 are no longer supported
warning intern > glob@7.1.7: Glob versions prior to v9 are no longer supported
warning intern > glob > inflight@1.0.6: 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 > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-config > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning mocha > glob@7.2.0: Glob versions prior to v9 are no longer supported
warning mocha > glob > inflight@1.0.6: 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 sinon@9.2.4: 16.1.1
warning wd > archiver > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning wd > q@1.5.1: 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@2.88.0: request has been deprecated, see request/request#3142
warning wd > archiver > archiver-utils > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning wd > request > uuid@3.4.0: 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 > request > har-validator@5.1.5: this library is no longer supported
warning @babel/cli > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning @babel/plugin-proposal-async-generator-functions@7.20.7: 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/plugin-proposal-class-properties@7.18.6: 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/plugin-proposal-export-namespace-from@7.18.9: 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/plugin-proposal-nullish-coalescing-operator@7.18.6: 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/plugin-proposal-object-rest-spread@7.20.7: 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/plugin-proposal-optional-chaining@7.21.0: 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/polyfill@7.12.1: 🚨 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 > core-js@2.6.12: 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 > core-js@2.6.12: 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 > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-d8b9c5f0-a1dd-40a9-a4c3-682fdd19c709 > eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning workspace-aggregator-d8b9c5f0-a1dd-40a9-a4c3-682fdd19c709 > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-d8b9c5f0-a1dd-40a9-a4c3-682fdd19c709 > sinon@9.2.4: 16.1.1
warning workspace-aggregator-d8b9c5f0-a1dd-40a9-a4c3-682fdd19c709 > @babel/plugin-proposal-async-generator-functions@7.20.7: 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-d8b9c5f0-a1dd-40a9-a4c3-682fdd19c709 > @babel/plugin-proposal-class-properties@7.18.6: 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-d8b9c5f0-a1dd-40a9-a4c3-682fdd19c709 > @babel/plugin-proposal-export-namespace-from@7.18.9: 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-d8b9c5f0-a1dd-40a9-a4c3-682fdd19c709 > @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: 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-d8b9c5f0-a1dd-40a9-a4c3-682fdd19c709 > @babel/plugin-proposal-object-rest-spread@7.20.7: 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-d8b9c5f0-a1dd-40a9-a4c3-682fdd19c709 > @babel/plugin-proposal-optional-chaining@7.21.0: 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-d8b9c5f0-a1dd-40a9-a4c3-682fdd19c709 > @babel/polyfill@7.12.1: 🚨 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.
error eslint-plugin-jsdoc@40.3.0: The engine "node" is incompatible with this module. Expected version "^14 || ^16 || ^17 || ^18 || ^19". Got "22.9.0"
error Found incompatible module.

Walkthrough

The changes introduce significant enhancements to the functionality of a browser plugin for meetings, focusing on transcription and sentiment analysis features. The app.js file has been updated to process captions and analyze sentiment, while the HTML structure in index.html has been modified to streamline the UI and include a new sentiment analysis section. Additionally, the CSS file has been updated with new styles for sentiment-related components. Changes to the call.ts file improve call state management and error handling, enhancing the overall reliability of the calling features.

Changes

File Path Change Summary
docs/samples/browser-plugin-meetings/app.js - Modified caption handling to include sentiment analysis.
- Added functions: getSentimentScore, getShowScore, updateNeedle, updateCommulativeScore, updateLinearBar.
docs/samples/browser-plugin-meetings/index.html - Simplified section header from "Participants, Breakout Sessions, and Events published" to "Participants".
- Added new section "Sentiment Analyser".
- Commented out content related to "Breakout Sessions" and "Events Published".
docs/samples/browser-plugin-meetings/style.css - Introduced new CSS classes for sentiment analysis: .sentiment, .box-sentiment, .progress-container, .progress-bar, and color states.
- Defined styles for speedometer component.
packages/calling/src/CallingClient/calling/call.ts - Updated Call class constructor for better media negotiation management.
- Refined call state machine definitions and error handling.
- Enhanced logging and metrics collection for disconnection reasons.

Suggested reviewers

  • marcin-bazyl
  • jor-row
  • adhmenon

🐰 In the meadow where we play,
New features bloom, bright as day.
Sentiments rise, and bars align,
Captions flow, oh how they shine!
With calls that connect, and errors that flee,
Hooray for the changes, let’s hop with glee! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Experiment)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

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

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

@rishigupta1606 rishigupta1606 marked this pull request as ready for review December 10, 2024 15:24
@rishigupta1606 rishigupta1606 requested review from a team as code owners December 10, 2024 15:24
Copy link

@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

🧹 Outside diff range and nitpick comments (4)
docs/samples/browser-plugin-meetings/app.js (2)

1233-1238: Correct the spelling of 'commulative' to 'cumulative'

The term 'commulative' is misspelled. It should be 'cumulative' to accurately reflect the function's purpose and maintain consistency.

Apply this diff to fix the spelling errors:

-function updateCommulativeScore(scores, value) {
+function updateCumulativeScore(scores, value) {
   scores.push(value);
   const total = scores.reduce((acc, value) => acc + value, 0);
-  const commulativeScore =  total / scores.length;
-  return commulativeScore;
+  const cumulativeScore = total / scores.length;
+  return cumulativeScore;
 }

 // Update the function call
-updateLinearBar(updateCommulativeScore(scores, value));
+updateLinearBar(updateCumulativeScore(scores, value));

1243-1246: Standardize variable naming: 'yellowGreenbLENDwidth' should be 'yellowGreenBlendWidth'

The variable name yellowGreenbLENDwidth has inconsistent casing. Rename it to yellowGreenBlendWidth for consistency and readability.

Apply this diff to fix the variable name:

-let yellowGreenbLENDwidth = 0;
+let yellowGreenBlendWidth = 0;

   // Update all occurrences
-  yellowGreenbLENDwidth = 10;
+  yellowGreenBlendWidth = 10;

   // Update the DOM manipulation
-  document.getElementById('yellowGreenbLENDwidth').style.width = `${yellowGreenbLENDwidth}%`;
+  document.getElementById('yellowGreenBlendWidth').style.width = `${yellowGreenBlendWidth}%`;
docs/samples/browser-plugin-meetings/style.css (1)

539-541: Standardize class name: '.yellowGreenbLENDwidth' should be '.yellowGreenBlendWidth'

The class name .yellowGreenbLENDwidth has inconsistent casing. Rename it to .yellowGreenBlendWidth to maintain consistency with the JavaScript variable names and improve readability.

Apply this diff to fix the class name:

-.yellowGreenbLENDwidth {
+.yellowGreenBlendWidth {
   background: linear-gradient(to right, yellow, green);
 }

Ensure to update all references to this class in the HTML and JavaScript code.

docs/samples/browser-plugin-meetings/index.html (1)

Line range hint 703-723: Consider removing commented-out code for 'Breakout Sessions' and 'Events Published'

The sections for 'Breakout Sessions' and 'Events Published' are commented out. If these features are no longer needed, consider removing the commented-out code to keep the codebase clean and maintainable.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d545259 and 23affcb.

⛔ Files ignored due to path filters (1)
  • docs/samples/browser-plugin-meetings/speedometer1.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • docs/samples/browser-plugin-meetings/app.js (2 hunks)
  • docs/samples/browser-plugin-meetings/index.html (9 hunks)
  • docs/samples/browser-plugin-meetings/style.css (1 hunks)
  • packages/calling/src/CallingClient/calling/call.ts (1 hunks)
🔇 Additional comments (1)
packages/calling/src/CallingClient/calling/call.ts (1)

233-235: LGTM!

Initializing mobiusUrl, receivedRoapOKSeq, and mediaNegotiationCompleted in the constructor enhances the call management process and ensures proper media negotiation handling.

Comment on lines +1156 to +1167
let currentRead = 0;

for (i=currentRead; i< payload.captions.length ; i++) {
let isSpeakerHost = payload.captions[i].speaker.speakerId === meeting.hostId;

currentRead = currentRead +1;

if(payload.captions[i].isFinal === true && isSpeakerHost !== true ) {
getSentimentScore(payload.captions[i].text);
}
}

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the for loop by declaring 'i' and adding an increment expression

The variable i is not declared, which will result in a reference error or the creation of a global variable. Additionally, the for loop lacks an increment expression, leading to a potential infinite loop. Incrementing currentRead inside the loop does not affect the loop variable i.

Apply this diff to fix the issues:

-let currentRead = 0;

-for (i=currentRead; i< payload.captions.length ; i++) {
+for (let i = 0; i < payload.captions.length; i++) {

-  currentRead = currentRead +1; 

   let isSpeakerHost = payload.captions[i].speaker.speakerId === meeting.hostId;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let currentRead = 0;
for (i=currentRead; i< payload.captions.length ; i++) {
let isSpeakerHost = payload.captions[i].speaker.speakerId === meeting.hostId;
currentRead = currentRead +1;
if(payload.captions[i].isFinal === true && isSpeakerHost !== true ) {
getSentimentScore(payload.captions[i].text);
}
}
for (let i = 0; i < payload.captions.length; i++) {
let isSpeakerHost = payload.captions[i].speaker.speakerId === meeting.hostId;
if(payload.captions[i].isFinal === true && isSpeakerHost !== true ) {
getSentimentScore(payload.captions[i].text);
}
}

Comment on lines +1195 to +1208
if (xhr.status >= 200 && xhr.status < 300) {
const response = JSON.parse(this.responseText);

console.log(`Playtime: Score: ${response[0].score} Label: ${response[0].label}`);

let value = getShowScore(response[0].label, response[0].score);

updateNeedle(value);

updateLinearBar(updateCommulativeScore(scores,value));
} else {
console.error('Error in request:', xhr.status, xhr.statusText);
}
};
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for JSON parsing

Parsing this.responseText without error handling may throw an exception if the response is not valid JSON. Wrap the JSON.parse call in a try-catch block to handle parsing errors gracefully.

Apply this diff to handle JSON parsing errors:

  xhr.onload = function() {
    if (xhr.status >= 200 && xhr.status < 300) {
+     try {
        const response = JSON.parse(this.responseText);

        console.log(`Playtime: Score: ${response[0].score} Label: ${response[0].label}`);

        let value = getShowScore(response[0].label, response[0].score);

        updateNeedle(value);

        updateLinearBar(updateCommulativeScore(scores, value));
+     } catch (e) {
+       console.error('Failed to parse JSON response:', e);
+     }
    } else {
      console.error('Error in request:', xhr.status, xhr.statusText);
    }
  };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (xhr.status >= 200 && xhr.status < 300) {
const response = JSON.parse(this.responseText);
console.log(`Playtime: Score: ${response[0].score} Label: ${response[0].label}`);
let value = getShowScore(response[0].label, response[0].score);
updateNeedle(value);
updateLinearBar(updateCommulativeScore(scores,value));
} else {
console.error('Error in request:', xhr.status, xhr.statusText);
}
};
if (xhr.status >= 200 && xhr.status < 300) {
try {
const response = JSON.parse(this.responseText);
console.log(`Playtime: Score: ${response[0].score} Label: ${response[0].label}`);
let value = getShowScore(response[0].label, response[0].score);
updateNeedle(value);
updateLinearBar(updateCommulativeScore(scores,value));
} catch (e) {
console.error('Failed to parse JSON response:', e);
}
} else {
console.error('Error in request:', xhr.status, xhr.statusText);
}
};

Comment on lines +1183 to +1213
let xhr = new XMLHttpRequest();
let scores = [];

xhr.open("POST", "http://localhost:8080/analyze-sentiment");

xhr.setRequestHeader("Content-Type", "application/json");

console.log('Playtime: Transcript Sent:', transcriptText);

xhr.send(JSON.stringify({ transcript: transcriptText }));

xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
const response = JSON.parse(this.responseText);

console.log(`Playtime: Score: ${response[0].score} Label: ${response[0].label}`);

let value = getShowScore(response[0].label, response[0].score);

updateNeedle(value);

updateLinearBar(updateCommulativeScore(scores,value));
} else {
console.error('Error in request:', xhr.status, xhr.statusText);
}
};

xhr.onerror = function() {
console.error('Request failed');
};
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Declare the 'scores' array outside the 'getSentimentScore' function to accumulate values

The scores array is reinitialized every time getSentimentScore is called, which prevents it from accumulating values across multiple calls. To correctly compute the cumulative score, declare scores outside the function.

Apply this diff to fix the issue:

-function getSentimentScore(transcriptText) {
-  let xhr = new XMLHttpRequest();
-  let scores = [];
+let scores = [];
+
+function getSentimentScore(transcriptText) {
+  let xhr = new XMLHttpRequest();

    // Rest of the code...
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let xhr = new XMLHttpRequest();
let scores = [];
xhr.open("POST", "http://localhost:8080/analyze-sentiment");
xhr.setRequestHeader("Content-Type", "application/json");
console.log('Playtime: Transcript Sent:', transcriptText);
xhr.send(JSON.stringify({ transcript: transcriptText }));
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
const response = JSON.parse(this.responseText);
console.log(`Playtime: Score: ${response[0].score} Label: ${response[0].label}`);
let value = getShowScore(response[0].label, response[0].score);
updateNeedle(value);
updateLinearBar(updateCommulativeScore(scores,value));
} else {
console.error('Error in request:', xhr.status, xhr.statusText);
}
};
xhr.onerror = function() {
console.error('Request failed');
};
}
let scores = [];
function getSentimentScore(transcriptText) {
let xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:8080/analyze-sentiment");
xhr.setRequestHeader("Content-Type", "application/json");
console.log('Playtime: Transcript Sent:', transcriptText);
xhr.send(JSON.stringify({ transcript: transcriptText }));
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
const response = JSON.parse(this.responseText);
console.log(`Playtime: Score: ${response[0].score} Label: ${response[0].label}`);
let value = getShowScore(response[0].label, response[0].score);
updateNeedle(value);
updateLinearBar(updateCommulativeScore(scores,value));
} else {
console.error('Error in request:', xhr.status, xhr.statusText);
}
};
xhr.onerror = function() {
console.error('Request failed');
};
}

Copy link

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

🧹 Outside diff range and nitpick comments (2)
docs/samples/browser-plugin-meetings/style.css (2)

458-466: Remove commented code and improve margin handling

The .box-sentiment class contains:

  • Commented out background-color that should be removed
  • Hard-coded margin values that could affect responsiveness

Suggested improvements:

 .box-sentiment {
   display: flex;
   justify-content: center;
   align-items: center;
   flex-direction: column;
-  margin-bottom: 50px;
-  margin-left: 70px;
+  margin: clamp(1rem, 3vw, 3rem);
-  /* background-color: #982e2e; */
 }

469-478: Maintain consistent styling with box-sentiment

The .progress-container has similar issues to .box-sentiment:

  • Contains unnecessary commented code
  • Uses hard-coded margin values

Suggested improvements for consistency:

 .progress-container {
   display: flex;
   justify-content: left;
   text-align: center;
   align-items: center;
   flex-direction: column;
-  margin-bottom: 77px;
-  margin-left: 40px;
+  margin: clamp(1rem, 3vw, 3rem);
-  /* background-color: #c0d646; */
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 23affcb and 9a34a9e.

📒 Files selected for processing (1)
  • docs/samples/browser-plugin-meetings/style.css (1 hunks)
🔇 Additional comments (1)
docs/samples/browser-plugin-meetings/style.css (1)

480-502: ⚠️ Potential issue

Improve speedometer image handling and scaling

Several concerns with the speedometer implementation:

  1. The background image path is relative and might break when deployed
  2. Fixed dimensions could affect scalability
  3. Needle positioning uses fixed percentages

Suggested improvements:

 #speedometer {
-  width: 25rem;
-  height: 19rem;
+  width: min(25rem, 90vw);
+  aspect-ratio: 25/19;
   background-image: url("speedometer1.png");
   background-size: 100%, 100%;
   background-repeat: no-repeat;
   position: relative;
 }

 #needle {
-  width: 3.3px;
-  height: 80px;
+  width: calc(0.33% + 2px);
+  height: 40%;
   border: 1.5px solid white;
   border-radius: 5px;
   background-color: rgb(248, 243, 243);
   position: absolute;
   top: 28%;
   left: 48%;
   z-index: 111;
   transform-origin: bottom;
   transform: rotate(-135deg);
   transition: 1s;
 }

Also, consider using an SVG instead of a background image for better scaling and performance.

Let's verify the image path:

Comment on lines +450 to +456
display: flex;
/* justify-content: space-between; */
gap: 150px;
align-items: center;
height: 31rem;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider improving responsive design

The .sentiment class has potential responsiveness issues:

  • Fixed height (31rem) might not work well on different screen sizes
  • Hard-coded gap (150px) could break layout on mobile devices

Consider this more responsive approach:

 .sentiment {
   display: flex;
-  /* justify-content: space-between; */
-  gap: 150px; 
+  gap: clamp(1rem, 5vw, 150px);
   align-items: center;
-  height: 31rem;
+  min-height: 31rem;
+  flex-wrap: wrap;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.sentiment {
display: flex;
/* justify-content: space-between; */
gap: 150px;
align-items: center;
height: 31rem;
}
.sentiment {
display: flex;
gap: clamp(1rem, 5vw, 150px);
align-items: center;
min-height: 31rem;
flex-wrap: wrap;
}

Comment on lines +504 to +541
.progress-bar {
width: 21rem;
height: 5rem;
border: 2px solid black;
border-radius: 10px;
display: flex;
overflow: hidden;
position: relative;
}

.red, .yellow, .green, .redYellowBlendWidth, .yellowGreenbLENDwidth {
height: 100%;
transition: width 0.5s ease;
position: left;
top: 0;
bottom: 0;
}

.red {
background-color: red;
}

.yellow {
background-color: yellow;
}

.green {
background-color: green;
}

.redYellowBlendWidth {
/* background-color: rgb(215, 146, 43); */
background: linear-gradient(to right, red, yellow);
}

.yellowGreenbLENDwidth {
background: linear-gradient(to right, yellow, green);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix CSS issues and naming consistency

Several issues in the progress bar implementation:

  1. Fixed dimensions affect responsiveness
  2. Invalid CSS property position: left
  3. Inconsistent class naming (bLEND vs Blend)

Apply these fixes:

 .progress-bar {
-  width: 21rem;
+  width: min(21rem, 90vw);
   height: 5rem;
   border: 2px solid black;
   border-radius: 10px;
   display: flex;
   overflow: hidden;
   position: relative;
 }

 .red, .yellow, .green, .redYellowBlendWidth, .yellowGreenbLENDwidth {
   height: 100%;
   transition: width 0.5s ease;
-  position: left;
+  position: relative;
   top: 0;
   bottom: 0;
 }

-.yellowGreenbLENDwidth {
+.yellowGreenBlendWidth {
   background: linear-gradient(to right, yellow, green);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.progress-bar {
width: 21rem;
height: 5rem;
border: 2px solid black;
border-radius: 10px;
display: flex;
overflow: hidden;
position: relative;
}
.red, .yellow, .green, .redYellowBlendWidth, .yellowGreenbLENDwidth {
height: 100%;
transition: width 0.5s ease;
position: left;
top: 0;
bottom: 0;
}
.red {
background-color: red;
}
.yellow {
background-color: yellow;
}
.green {
background-color: green;
}
.redYellowBlendWidth {
/* background-color: rgb(215, 146, 43); */
background: linear-gradient(to right, red, yellow);
}
.yellowGreenbLENDwidth {
background: linear-gradient(to right, yellow, green);
}
.progress-bar {
width: min(21rem, 90vw);
height: 5rem;
border: 2px solid black;
border-radius: 10px;
display: flex;
overflow: hidden;
position: relative;
}
.red, .yellow, .green, .redYellowBlendWidth, .yellowGreenbLENDwidth {
height: 100%;
transition: width 0.5s ease;
position: relative;
top: 0;
bottom: 0;
}
.red {
background-color: red;
}
.yellow {
background-color: yellow;
}
.green {
background-color: green;
}
.redYellowBlendWidth {
/* background-color: rgb(215, 146, 43); */
background: linear-gradient(to right, red, yellow);
}
.yellowGreenBlendWidth {
background: linear-gradient(to right, yellow, green);
}

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.

1 participant