Skip to content

chore: created extension constants in shared module #3412

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nafees87n
Copy link
Contributor

@nafees87n nafees87n commented Aug 19, 2025

Summary by CodeRabbit

  • Chores
    • Introduced new shared constants to standardize internal references.
    • Expanded the shared constants index to re-export newly added entries for consistent access across the app.
    • Improves internal consistency and reduces duplication.
    • No user-facing changes in this release.

Copy link

coderabbitai bot commented Aug 19, 2025

Walkthrough

A new module shared/src/constants/extension.ts is added, defining a namespace ExtensionConstants with two string enums: StorageKeys (POPUP_CONFIG = "popup_config") and ExtensionMessages (OPEN_CURL_IMPORT_MODAL = "openCurlImportModal"). The constants barrel file shared/src/constants/index.ts is updated to re-export from "./extension", exposing these new enums through the existing constants index.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch create-extension-constants

🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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: 0

🧹 Nitpick comments (2)
shared/src/constants/extension.ts (2)

1-9: Consider avoiding namespace + runtime enums in favor of module-level as const objects

Namespaces and string enums generate extra runtime artifacts and can be unfriendly with Babel/esbuild-only pipelines. A more bundler-friendly pattern is flat module exports using as const objects + derived union types. If this is consistent with the repo’s style, consider this refactor.

Apply this diff if you want to move to flat exports:

-export namespace ExtensionConstants {
-  export enum StorageKeys {
-    POPUP_CONFIG = "popup_config",
-  }
-
-  export enum ExtensionMessages {
-    OPEN_CURL_IMPORT_MODAL = "openCurlImportModal",
-  }
-}
+export const ExtensionStorageKeys = {
+  POPUP_CONFIG: "popup_config",
+} as const;
+export type ExtensionStorageKey = typeof ExtensionStorageKeys[keyof typeof ExtensionStorageKeys];
+
+export const ExtensionMessages = {
+  OPEN_CURL_IMPORT_MODAL: "openCurlImportModal",
+} as const;
+export type ExtensionMessage = typeof ExtensionMessages[keyof typeof ExtensionMessages];

Notes:

  • Flat exports tree-shake well, avoid IIFEs generated for namespaces, and don’t rely on TS enum emit.
  • If any call sites already expect ExtensionConstants.StorageKeys shape, keep the current approach. Otherwise, adopting flat exports now will simplify future usage.

2-4: StorageKeys and ExtensionMessages conventions verified; no raw strings to replace

  • Storage key values use snake_case (e.g. "popup_config") as intended for persisted data.
  • Message identifiers use camelCase (e.g. "openCurlImportModal"), matching existing definitions in
    common/constants.js and browser-extension/common/src/constants.ts.
  • No occurrences of these raw string literals were found outside the enum definitions in
    shared/src/constants/extension.ts.
  • If you’re adding new call sites, import and reference these enums instead of hard-coding strings.

Optional: OPEN_CURL_IMPORT_MODAL is currently defined in three places—consider consolidating into a single source of truth to prevent drift.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 453813c and 634123c.

📒 Files selected for processing (2)
  • shared/src/constants/extension.ts (1 hunks)
  • shared/src/constants/index.ts (1 hunks)
🔇 Additional comments (2)
shared/src/constants/extension.ts (1)

1-9: Good extraction and centralization of extension constants

Centralizing storage keys and message names reduces stringly-typed usage and prevents drift across extension surfaces. Looks good.

shared/src/constants/index.ts (1)

1-1: LGTM: barrel re-export

Re-exporting from "./extension" cleanly surfaces these constants via the existing constants index.

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