Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

render component on toolbar badge click, add Mocksi icons #151

Merged
merged 4 commits into from
Aug 21, 2024

Conversation

fitzk
Copy link
Contributor

@fitzk fitzk commented Aug 21, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced user interaction by allowing the extension to respond directly when the toolbar icon is clicked.
    • Improved control flow for mounting the React component in the extension.
  • Bug Fixes

    • Streamlined message handling logic for better performance and responsiveness.
  • Style

    • Updated icons for the extension to align with new branding.
  • Chores

    • Removed unnecessary development icons from the production build process.

@fitzk fitzk requested a review from elg0nz August 21, 2024 19:47
Copy link

coderabbitai bot commented Aug 21, 2024

Warning

Rate limit exceeded

@fitzk has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 57 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 9a75706 and 5526ce1.

Walkthrough

Walkthrough

The recent updates to the "Mocksi Lite: Next" application include significant changes to the manifest files, a streamlined background script, and refined content rendering logic for improved user interaction. The action icon functionality has been removed, simplifying the extension's UI and enhancing its responsiveness. Additionally, the updates reflect a rebranding effort with new icon assets, while also consolidating message handling to improve performance and maintainability.

Changes

Files Change Summary
apps/mocksi-lite-next/manifest.dev.json Removed "action" key and its properties, simplifying the manifest structure.
apps/mocksi-lite-next/manifest.json Updated icon filenames for rebranding and removed reference to "contentStyle.css" from content_scripts.
apps/mocksi-lite-next/src/pages/background/index.ts Added listener for chrome.action.onClicked, simplified existing message listeners, improved logging.
apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx Introduced message listener to conditionally mount Iframe, consolidated message handling for styling.
apps/mocksi-lite-next/vite.config.ts Removed stripDevIcons function, eliminating the conditional stripping of development icons from production builds.

Poem

In a world of code where rabbits play,
Changes hop along, brightening the day.
Icons refreshed, a brand new start,
With each clever tweak, we craft an art.
So let’s leap with joy, let’s make it clear,
For Mocksi Lite shines, a gem we hold dear! 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

@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, codebase verification and nitpick comments (1)
apps/mocksi-lite-next/src/pages/background/index.ts (1)

4-9: Improve the error message for clarity.

The error message could be more descriptive to aid debugging.

Use this diff to improve the message:

 console.log("No tab found, could not mount extension");
+console.log("Ensure that the toolbar icon is clicked while a tab is active.");
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 89061ce and 9a75706.

Files ignored due to path filters (6)
  • apps/mocksi-lite-next/public/dev-icon-128.png is excluded by !**/*.png
  • apps/mocksi-lite-next/public/dev-icon-32.png is excluded by !**/*.png
  • apps/mocksi-lite-next/public/icon-128.png is excluded by !**/*.png
  • apps/mocksi-lite-next/public/icon-32.png is excluded by !**/*.png
  • apps/mocksi-lite-next/public/mocksi-icon.png is excluded by !**/*.png
  • apps/mocksi-lite-next/public/mocksi-logo.png is excluded by !**/*.png
Files selected for processing (5)
  • apps/mocksi-lite-next/manifest.dev.json (1 hunks)
  • apps/mocksi-lite-next/manifest.json (4 hunks)
  • apps/mocksi-lite-next/src/pages/background/index.ts (1 hunks)
  • apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx (1 hunks)
  • apps/mocksi-lite-next/vite.config.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • apps/mocksi-lite-next/manifest.dev.json
Additional context used
Biome
apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx

[error] 1-2: Expected a statement but instead found '<<<<<<< HEAD
======='.

Expected a statement here.

(parse)


[error] 4-5: Expected a statement but instead found '>>>>>>> origin/main'.

Expected a statement here.

(parse)

Additional comments not posted (10)
apps/mocksi-lite-next/src/pages/background/index.ts (1)

11-16: LGTM!

The chrome.runtime.onMessage event listener is correctly implemented and logs the received message appropriately.

apps/mocksi-lite-next/manifest.json (3)

4-4: LGTM!

The update to the default_icon is consistent with the rebranding effort.


25-25: LGTM!

The update to the icons entry is consistent with the rebranding effort.


44-44: LGTM!

The update to web_accessible_resources is consistent with the icon filename changes.

apps/mocksi-lite-next/vite.config.ts (1)

Line range hint 1-41: Verify the impact of removing stripDevIcons.

The removal of stripDevIcons may lead to development icons being included in the production build. Ensure this aligns with the intended build process.

Run the following script to verify if development icons are present in the production build:

apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx (5)

8-13: LGTM!

The creation and appending of the root div is correctly implemented.


14-104: LGTM!

The message listener and mounting logic are well-implemented, ensuring the component is only mounted once.


21-85: LGTM!

The Iframe component and message handling logic are clear and efficient.


68-88: LGTM!

The use of createPortal to render the iframe is appropriate and correctly implemented.


97-101: LGTM!

The error handling and logging are correctly implemented.

Comment on lines 22 to 27
console.log("Received message from external:", request);
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs[0].id) {
chrome.tabs.sendMessage(tabs[0].id, { message: request.message });
}
});
Copy link

@coderabbitai coderabbitai bot Aug 21, 2024

Choose a reason for hiding this comment

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

Add error handling for no active tab found.

Consider handling the case where no active tab is found to prevent potential issues.

Use this diff to add error handling:

 chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
   if (tabs[0].id) {
     chrome.tabs.sendMessage(tabs[0].id, { message: request.message });
+  } else {
+    console.log("No active tab found, could not send message");
   }
 });
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
console.log("Received message from external:", request);
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs[0].id) {
chrome.tabs.sendMessage(tabs[0].id, { message: request.message });
}
});
console.log("Received message from external:", request);
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs[0].id) {
chrome.tabs.sendMessage(tabs[0].id, { message: request.message });
} else {
console.log("No active tab found, could not send message");
}
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elg0nz I added this

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@fitzk fitzk changed the title open render component on toolbar badge click, add Mocksi icons render component on toolbar badge click, add Mocksi icons Aug 21, 2024
Copy link
Contributor

@elg0nz elg0nz left a comment

Choose a reason for hiding this comment

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

Nice!

@fitzk fitzk merged commit 2cf462b into main Aug 21, 2024
3 checks passed
@fitzk fitzk deleted the MOC-202_content-script-badge branch August 21, 2024 19:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants