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

chore: add rollup config for wds #39397

Open
wants to merge 6 commits into
base: release
Choose a base branch
from

Conversation

jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Feb 21, 2025

/ok-to-test tags="@tag.Sanity"

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Upgraded browserslist dependency for improved browser compatibility.
    • Enhanced module support and packaging for design system components, including new build scripts and dependencies.
    • Introduced a streamlined bundling configuration for improved build efficiency and support for ES modules.
    • Updated Jest configuration to use ES Module syntax for exports.
    • Refactored hotkey management, transitioning from components to custom hooks for better integration and maintainability.
    • Converted GlobalHotKeys from class-based to functional component using React hooks for improved performance and clarity.
    • Removed the HotKeysView component to simplify hotkey management.
    • Wrapped GlobalHotKeys with HotkeysProvider for enhanced context and functionality.

Important

🟣 🟣 🟣 Your tests are running.
Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/13521660461
Commit: 4287ae7
Workflow: PR Automation test suite
Tags: @tag.Sanity
Spec: ``


Tue, 25 Feb 2025 12:52:54 UTC

@jsartisan jsartisan requested a review from KelvinOm as a code owner February 21, 2025 10:25
Copy link
Contributor

coderabbitai bot commented Feb 21, 2025

Walkthrough

This pull request updates dependency versions in one package configuration and enhances the design system widget package. The changes include upgrading the browserslist dependency in the main client package and adding new properties, scripts, and dependencies in the design system widget’s package. Additionally, a new Rollup configuration file has been introduced to define the build process with various plugins for handling JavaScript, TypeScript, and CSS files.

Changes

File(s) Change Summary
app/client/package.json Updated browserslist dependency from ^4.18.1 to ^4.24.4 and resolution from 4.20.3 to 4.24.4.
app/client/packages/design-system/widgets/package.json Added "type": "module", introduced "files": ["build"] property, and a new "build:package" script. Multiple new dev dependencies (Babel presets, Rollup plugins, etc.) and a peer dependency for react-dom were also added.
app/client/packages/design-system/widgets/rollup.config.js Introduced a new Rollup configuration file with input set to src/index.ts, output to the build directory, enabled source maps, and configured external dependencies with several plugins to manage the build process.
app/client/packages/design-system/widgets/jest.config.js Updated export syntax from CommonJS (module.exports) to ES Module (export default).
app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHotKeys.tsx Refactored GlobalSearchHotKeys from class-based to functional component, utilizing hooks for hotkey management.
app/client/src/git/components/HotKeys/HotKeysView.tsx Removed HotKeysView component, which managed a hotkey for git commit modal.
app/client/src/git/components/HotKeys/index.tsx Refactored HotKeys component to useHotKeys custom hook, replacing component-based approach with hook-based approach.
app/client/src/git/components/HotKeys/useHotKeysView.ts Introduced useHotKeysView custom hook for managing keyboard shortcuts related to Git operations, including a new interface for props.
app/client/src/git/index.ts Added export for useHotKeys hook and removed export for GitHotKeys.
app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx Refactored GlobalHotKeys from class-based to functional component, utilizing hooks for state management and dispatching actions, and streamlined hotkey rendering logic.
app/client/src/pages/Editor/GlobalHotKeys/index.tsx Wrapped GlobalHotKeys component with HotkeysProvider from @blueprintjs/core library, enhancing context for hotkeys.

Suggested labels

Task, Enhancement, Packages Pod

Suggested reviewers

  • sagar-qa007
  • ApekshaBhosale
  • ankitakinger

Poem

In the realm of code where updates gleam,
Dependencies rise like a well-tuned dream.
Scripts awaken with a build anew,
Rollup whirls magic through each plugin's cue.
With every change, our code sings bright—
Happy builds in days and nights!
🚀✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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

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

🧹 Nitpick comments (1)
app/client/packages/design-system/widgets/rollup.config.js (1)

29-38: Consider adding minification for production build.

The output configuration looks good, but consider adding terser for production builds to optimize bundle size.

 output: {
   file: path.resolve(BUILD_DIR, "bundle.js"),
   format: "esm",
   sourcemap: true,
   inlineDynamicImports: true,
+  plugins: [
+    process.env.NODE_ENV === 'production' && terser()
+  ].filter(Boolean),
   globals: {
     react: "React",
     "react-dom": "ReactDOM",
   },
 },
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2fce726 and e7261cc.

⛔ Files ignored due to path filters (1)
  • app/client/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • app/client/package.json (1 hunks)
  • app/client/packages/design-system/widgets/package.json (2 hunks)
  • app/client/packages/design-system/widgets/rollup.config.js (1 hunks)
  • app/client/packages/design-system/widgets/src/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/package.json
🔇 Additional comments (4)
app/client/packages/design-system/widgets/package.json (2)

3-3: Version bump from 1.0.0 to 1.0.6 seems large for build config changes.

Consider using a smaller version increment (e.g., 1.0.1) since this change only adds build configuration.


41-64: LGTM! Dependencies are well organized and versions are up to date.

The build tooling dependencies are properly configured with specific versions.

app/client/packages/design-system/widgets/rollup.config.js (1)

79-85: LGTM! TypeScript configuration is properly set up.

The TypeScript plugin is well configured with declaration files and proper output directories.

app/client/packages/design-system/widgets/src/index.ts (1)

44-44: LGTM! Theming utilities are properly exported.

The theming utilities are correctly exported from the package.

@@ -34,12 +39,31 @@
"usehooks-ts": "*"
},
"devDependencies": {
"@babel/core": "^7.23.9",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have a conflict with package versions. The build (yarn start) does not work with these versions. We have to use the same package versions that are currently used in the app.

Снимок экрана 2025-02-24 в 11 19 23

@@ -423,4 +423,4 @@
"@types/react": "^17.0.2",
"postcss": "8.4.31"
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

After installing the dependencies, the GIT shows 3 modified files, could you check and fix it?

Снимок экрана 2025-02-24 в 11 21 23

@@ -4,12 +4,17 @@
"main": "src/index.ts",
"author": "Valera Melnikov <[email protected]>, Pawan Kumar <[email protected]>",
"license": "MIT",
"type": "module",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to check if this affects the current work of the package in the main app.

@jsartisan jsartisan force-pushed the chore/add-rollup-config-for-wds branch from 8b05e28 to a3fe76c Compare February 25, 2025 04:41
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: 1

🧹 Nitpick comments (3)
app/client/packages/design-system/widgets/rollup.config.js (3)

27-38: Output configuration needs UMD/CJS consideration.

While ESM is good for modern environments, consider adding UMD or CJS format outputs for broader compatibility.

Consider adding multiple output formats to support different environments:

  output: {
-   file: path.resolve(BUILD_DIR, "bundle.js"),
-   format: "esm",
+   dir: BUILD_DIR,
+   formats: ["esm", "cjs"],
+   entryFileNames: "bundle.[format].js",
    sourcemap: true,
    inlineDynamicImports: true,
    globals: {
      react: "React",
      "react-dom": "ReactDOM",
    },
  },

42-48: Environment variables are hardcoded to production.

The current configuration always sets NODE_ENV and REACT_APP_ENV to "production", which may not be suitable for development builds.

Consider making the environment configurable:

  replace({
    preventAssignment: true,
    values: {
-     "process.env.NODE_ENV": JSON.stringify("production"),
-     "process.env.REACT_APP_ENV": JSON.stringify("production"),
+     "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "production"),
+     "process.env.REACT_APP_ENV": JSON.stringify(process.env.REACT_APP_ENV || "production"),
    },
  }),

27-93: Overall Rollup configuration is solid.

The configuration is comprehensive and should work well for building the widget package. Consider adding package.json entries for "main", "module", and "types" to point to the generated files.

In your package.json, make sure to add:

{
  "main": "build/bundle.js",
  "module": "build/bundle.js",
  "types": "build/index.d.ts",
  "files": ["build"]
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7261cc and a3fe76c.

⛔ Files ignored due to path filters (1)
  • app/client/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • app/client/package.json (3 hunks)
  • app/client/packages/design-system/widgets/package.json (2 hunks)
  • app/client/packages/design-system/widgets/rollup.config.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/client/package.json
  • app/client/packages/design-system/widgets/package.json
🔇 Additional comments (9)
app/client/packages/design-system/widgets/rollup.config.js (9)

1-4: Module imports look good.

The necessary path and URL modules are properly imported, along with Rollup's defineConfig.


6-11: PostCSS plugins are correctly imported.

Good selection of PostCSS plugins for handling nesting, imports, variables, and other CSS features.


12-13: Proper ESM file path handling.

The code correctly uses fileURLToPath with import.meta.url to get the current file's path in an ESM context.


15-21: Rollup plugins imports are appropriate.

All necessary plugins for handling JSON, resolving modules, transpiling TypeScript, and processing CSS are imported.


23-25: Constants defined clearly.

BUILD_DIR and EXTERNALS are well-defined constants that improve readability and maintainability.


55-66: Babel configuration is well-defined.

The Babel configuration is comprehensive with proper presets for React and TypeScript.


67-78: PostCSS setup is appropriate.

The PostCSS configuration with CSS modules and the selected plugins should handle most modern CSS needs.


86-91: Module resolution configuration is good.

The resolve plugin is properly configured with correct extensions and browser settings.


49-54:

❓ Verification inconclusive

CommonJS configuration might need adjustment.

The requireReturnsDefault: "preferred" setting can cause issues with some CommonJS modules.


🏁 Script executed:

#!/bin/bash
# Check if there are CommonJS dependencies that might have issues with this setting
grep -r "module.exports" ./node_modules --include="*.js" | head -n 5

Length of output: 116


Action Required: Verify CommonJS Plugin Configuration

The configuration in app/client/packages/design-system/widgets/rollup.config.js (lines 49–54) uses requireReturnsDefault: "preferred", which may cause issues with CommonJS modules lacking default exports. However, our automated script couldn’t verify this because the node_modules directory wasn’t found in the repository.

  • Next Steps:
    • Manually Verify: Please run the build and tests in an environment with dependencies installed to confirm that no CommonJS modules are misbehaving due to this setting.
    • Adjust if Needed: If issues occur, consider modifying the requireReturnsDefault setting.

Comment on lines +79 to +85
typescript({
tsconfig: "./tsconfig.json",
declaration: true,
declarationDir: path.resolve(BUILD_DIR),
rootDir: "src",
outDir: path.resolve(BUILD_DIR),
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify TypeScript configuration exists.

Make sure the referenced tsconfig.json exists and has compatible settings.


🏁 Script executed:

#!/bin/bash
# Check if tsconfig.json exists and has compatible settings
if [ -f "./tsconfig.json" ]; then
  echo "tsconfig.json exists"
  grep -E "\"jsx\":|\"jsxFactory\":|\"target\":|\"module\":" ./tsconfig.json
else
  echo "tsconfig.json does not exist"
fi

Length of output: 95


Action Required: Update the TypeScript configuration reference.

The rollup configuration references ./tsconfig.json (lines 79–85), but our check confirms that this file does not exist in the repo root. Please add the missing tsconfig.json with the necessary settings (such as "jsx", "target", "module", etc.) or update the reference path to point to the correct location.

@jsartisan jsartisan force-pushed the chore/add-rollup-config-for-wds branch from a3fe76c to 4909464 Compare February 25, 2025 07:20
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

🧹 Nitpick comments (1)
app/client/packages/design-system/widgets/package.json (1)

15-16: Review new build script for package creation.
The new "build:package" script cleans the build directory and then runs Rollup. For better cross-platform compatibility (especially on Windows), consider using a tool like rimraf (e.g., "rimraf build && rollup -c rollup.config.js") instead of rm -rf.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3fe76c and 4909464.

⛔ Files ignored due to path filters (1)
  • app/client/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • app/client/package.json (2 hunks)
  • app/client/packages/design-system/widgets/package.json (2 hunks)
  • app/client/packages/design-system/widgets/rollup.config.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/client/package.json
  • app/client/packages/design-system/widgets/rollup.config.js
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
  • GitHub Check: chromatic-deployment
🔇 Additional comments (4)
app/client/packages/design-system/widgets/package.json (4)

7-7: Ensure ES module compatibility with "type": "module".
The addition of "type": "module" signals that the package is intended to be used as an ES module. Please verify that all scripts and dependencies (including the new Rollup configuration) are compatible with ESM, and that no CommonJS modules cause runtime issues.


8-10: Confirm inclusion of build artifacts via "files".
Adding the "files": ["build"] property helps ensure that only the built assets are published. Make sure that the build process reliably generates the build folder before publishing the package.


42-65: Validate new devDependencies for build process enhancement.
Numerous new devDependencies (Babel presets, Rollup plugins, and related tools) have been added to support the recent build improvements. Please ensure these versions are compatible with the rest of the monorepo and do not conflict with existing dependency versions—as highlighted in previous feedback.


66-69: Validate peerDependencies for React compatibility.
The updated peer dependencies for "react" and "react-dom" should be consistent with the versions used by consuming projects. Double-check that these ranges meet the needs of both current and legacy consumers to avoid version mismatches.

@jsartisan jsartisan added the ok-to-test Required label for CI label Feb 25, 2025
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Feb 25, 2025
@jsartisan
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/13517960615.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 39397.
recreate: .

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

🧹 Nitpick comments (3)
app/client/packages/design-system/widgets/rollup.config.js (3)

1-3: Redundant path import.

You're importing both the full path module and the dirname function separately, but dirname is already available in the full path module.

import path from "path";
-import { dirname } from "path";
import { fileURLToPath } from "url";

Then update line 13 to use:

const __dirname = path.dirname(__filename);

27-38: Define input and output paths as constants.

Consider extracting the input and output paths as constants at the top of the file for better maintainability.

const BUILD_DIR = path.resolve(__dirname, "build");
+const INPUT_FILE = path.resolve(__dirname, "src/index.ts");
+const OUTPUT_FILE = path.resolve(BUILD_DIR, "bundle.js");

const EXTERNALS = ["react", "react-dom"];

export default defineConfig({
-  input: path.resolve(__dirname, "src/index.ts"),
+  input: INPUT_FILE,
  output: {
-    file: path.resolve(BUILD_DIR, "bundle.js"),
+    file: OUTPUT_FILE,
    format: "esm",
    sourcemap: true,
    inlineDynamicImports: true,
    globals: {
      react: "React",
      "react-dom": "ReactDOM",
    },
  },

42-48: Make environment configuration more flexible.

Currently, environment values are hardcoded to "production". Consider making this configurable based on the build environment.

replace({
  preventAssignment: true,
  values: {
-    "process.env.NODE_ENV": JSON.stringify("production"),
-    "process.env.REACT_APP_ENV": JSON.stringify("production"),
+    "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "production"),
+    "process.env.REACT_APP_ENV": JSON.stringify(process.env.REACT_APP_ENV || "production"),
  },
}),
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c5dfb9 and c51e46d.

📒 Files selected for processing (2)
  • app/client/packages/design-system/widgets/jest.config.js (1 hunks)
  • app/client/packages/design-system/widgets/rollup.config.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (5)
app/client/packages/design-system/widgets/jest.config.js (1)

3-3: Updated export syntax to ES Module format.

This change from CommonJS module.exports to ES Module export default aligns with the project's move to ES modules.

app/client/packages/design-system/widgets/rollup.config.js (4)

79-85: Update the TypeScript configuration reference.

The rollup configuration references ./tsconfig.json, but this file might not exist at the expected location according to previous reviews.

#!/bin/bash
# Check if tsconfig.json exists at specified locations
if [ -f "./tsconfig.json" ]; then
  echo "tsconfig.json exists at repo root"
elif [ -f "./app/client/packages/design-system/widgets/tsconfig.json" ]; then
  echo "tsconfig.json exists in the widgets directory"
  echo "Consider updating the reference to: tsconfig: path.resolve(__dirname, 'tsconfig.json')"
else
  echo "tsconfig.json not found in expected locations"
  echo "Searching for any tsconfig.json files in the design system directory:"
  fd -t f "tsconfig.json" ./app/client/packages/design-system
fi

67-78: The PostCSS configuration is well-structured.

Good use of PostCSS plugins for nesting, imports, variables, and other CSS enhancements.


55-66: Well-configured Babel setup for React and TypeScript.

The Babel configuration correctly handles JavaScript and TypeScript files with appropriate presets.


86-91: Good node-resolve configuration.

The resolve plugin is properly configured to handle JS/TS extensions and deduplicate external dependencies.

Copy link

Deploy-Preview-URL: https://ce-39397.dp.appsmith.com

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

🧹 Nitpick comments (3)
app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx (3)

140-156: Leverage optional chaining for clarity.
To simplify checks on selectedWidgets, consider using optional chaining. This also aligns with the static analysis hint.

-  const multipleWidgetsSelected = selectedWidgets && selectedWidgets.length;
+  const multipleWidgetsSelected = selectedWidgets?.length;
🧰 Tools
🪛 Biome (1.9.4)

[error] 141-141: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


178-391: Hotkeys array is extensive but effective.

  1. Each key combo is well-labeled and grouped for discoverability.
  2. Consider extracting repeated patterns (e.g. stopPropagationIfWidgetSelected) into shared helpers if it grows further.

350-353: Revisit the label "Cut Widgets for grouping."
The label doesn’t fully match the actual action (groupSelectedWidget). Consider updating it for clarity.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c51e46d and 488d615.

📒 Files selected for processing (6)
  • app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHotKeys.tsx (1 hunks)
  • app/client/src/git/components/HotKeys/HotKeysView.tsx (0 hunks)
  • app/client/src/git/components/HotKeys/index.tsx (1 hunks)
  • app/client/src/git/components/HotKeys/useHotKeysView.ts (1 hunks)
  • app/client/src/git/index.ts (1 hunks)
  • app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx (4 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/git/components/HotKeys/HotKeysView.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx

[error] 141-141: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (12)
app/client/src/git/index.ts (1)

5-5:

❓ Verification inconclusive

API change: GitHotKeys component replaced with useHotKeys hook

This change replaces the component-based approach with a hook-based approach, which aligns with modern React patterns but may affect consuming components.


🏁 Script executed:

#!/bin/bash
# Check for usages of the removed GitHotKeys component
rg "GitHotKeys" --type ts --type tsx

Length of output: 64


Please run the above script to manually verify that there are no remaining references to GitHotKeys in the codebase.


🏁 Script executed:

[run_scripts]
#!/bin/bash
# Search for any references to the removed GitHotKeys component in TypeScript files (.ts and .tsx)
rg "GitHotKeys" -g "*.ts" -g "*.tsx"

Length of output: 367


Action: Verify and Clarify the Import Alias Usage

The API change to replace the old GitHotKeys component with the new hook (useHotKeys) is in place via the export in app/client/src/git/index.ts. However, in
app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx the hook is imported as an alias—useHotKeys as useGitHotKeys—and then invoked. This aliasing may introduce confusion, so please confirm that:

  • The alias useGitHotKeys is intentionally retained for backward compatibility or clarity.
  • No consuming components are mistakenly treating the alias as if it were still a component.

If the alias is not needed or causes ambiguity, consider updating it to match the hook’s naming convention (e.g., using useHotKeys directly).

app/client/src/git/components/HotKeys/index.tsx (1)

1-8: Good refactoring to hook-based approach

Converting the HotKeys component to a useHotKeys hook follows modern React best practices and improves composability.

app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHotKeys.tsx (1)

2-2:

❓ Verification inconclusive

Verify hotkey functionality after HotkeysTarget removal

The HotkeysTarget decorator has been removed from the import, but the component still renders Hotkeys manually. Ensure that hotkey functionality still works as expected.


🏁 Script executed:

#!/bin/bash
# Check if this component is still being used and how it's being initialized
rg "GlobalSearchHotKeys" --type tsx -A 3

Length of output: 68


Hotkey Functionality Check – Verify Post HotkeysTarget Removal

Please ensure that the manual hotkeys behavior is still working after removing the HotkeysTarget decorator. It appears that our previous search for usages of the GlobalSearchHotKeys component using rg --type tsx failed due to an unrecognized file type. To verify its usage, please run the following updated script:

#!/bin/bash
# Search for usages of GlobalSearchHotKeys in TSX files using glob pattern matching
rg "GlobalSearchHotKeys" -g '*.tsx' -A 3
  • Confirm that this component is correctly integrated into the application and instantiated.
  • Manually test the hotkey functionality to ensure it behaves as expected.
app/client/src/git/components/HotKeys/useHotKeysView.ts (1)

5-22: Well-implemented hook for Git hotkeys

The hook is properly implemented with useCallback for the handler and returns the necessary hotkey configuration. Good use of proper typing with the interface.

app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx (8)

1-3: Imports look solid.
These imports correctly utilize React hooks and TypeScript types.


9-14: Aliased imports seem consistent.
Renaming imported actions with an underscore avoids naming collisions and keeps the code clear.


38-43: New imports for preview mode and git hotkeys.
Bringing in these hooks and selectors fits the revised architecture, though ensure you keep usage consistent and tested.


45-53: Interface definition is straightforward.
Defining explicit types for props promotes clarity and scalability.


55-69: Functional component approach looks good.
The transition to hooks for GlobalHotKeys is neat, and using useDispatch, useSelector, and context ensures clear separation of concerns.


71-129: Callbacks for dispatch actions are well-defined.
Each callback is neatly wrapped with useCallback; make sure you're mindful of any dependencies that might need to be added to the dep arrays in future updates.


158-174: Omnibar logic is intuitive.
Your hotkey handler properly prevents default actions and adjusts global search categories, ensuring a smooth user experience.


393-398: Final rendering with useHotkeys is clean.
Registering hotkeys via useHotkeys(hotkeys) and returning children in a simple wrapper keeps things lightweight.

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

🧹 Nitpick comments (2)
app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx (2)

139-139: Use optional chaining for better readability.

The current check can be simplified using optional chaining.

-    const multipleWidgetsSelected = selectedWidgets && selectedWidgets.length;
+    const multipleWidgetsSelected = selectedWidgets?.length;
🧰 Tools
🪛 Biome (1.9.4)

[error] 139-139: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


56-394: Consider breaking down this large component into smaller hooks.

While the refactoring to a functional component is excellent, this component still has many responsibilities. Consider extracting some of the logic into custom hooks for better maintainability.

For example:

  • A hook for widget selection-related hotkeys
  • A hook for navigation-related hotkeys
  • A hook for action execution hotkeys
🧰 Tools
🪛 Biome (1.9.4)

[error] 139-139: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 488d615 and 1bef3ac.

📒 Files selected for processing (1)
  • app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx (4 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx

[error] 139-139: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: storybook-tests
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
🔇 Additional comments (5)
app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx (5)

1-49: Good work on modernizing imports and function naming.

The refactoring to use React hooks and improved naming conventions with underscore prefixes for imported actions helps distinguish them from local functions.


50-68: Clean component conversion from class to functional.

The Props interface is well-defined, and the component properly uses hooks for state access. Good job extracting the state selectors.


69-127: Well-structured action dispatchers with proper memoization.

Each dispatch function is correctly wrapped in useCallback with appropriate dependencies, preventing unnecessary re-creation of functions on re-renders.


173-389: Clean hotkey configuration with conditional rendering.

The approach of using a conditional array for hotkeys based on application state is clean and maintainable. Good integration with Git hotkeys when enabled.


390-396: Simplified component rendering with Blueprint's useHotkeys hook.

The rendering is appropriately simplified, letting the Blueprint library handle the hotkey registration under the hood.

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

🔭 Outside diff range comments (1)
app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx (1)

56-394: 🛠️ Refactor suggestion

Refactored Keyboard Shortcut Logic.

The new functional approach effectively consolidates hotkey handling. However, one improvement stands out from the static analysis:

  • Lines 138-139: Replace explicit checks with optional chaining for clarity and safety:
- const multipleWidgetsSelected = selectedWidgets && selectedWidgets.length;
+ const multipleWidgetsSelected = selectedWidgets?.length;
🧰 Tools
🪛 Biome (1.9.4)

[error] 139-139: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🧹 Nitpick comments (2)
app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHotKeys.tsx (1)

18-72: Great functional refactor.

Switching to a functional component with useHotkeys improves clarity and alignment with modern React. However, the explicit cast to any in document.activeElement as any (line 49) may mask potential type issues.

Consider assigning a more precise type or leveraging optional chaining:

- const activeElement = document.activeElement as any;
+ const activeElement = document.activeElement as HTMLElement | null;
app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx (1)

9-14: Naming consistency check.

Renaming deleteSelectedWidget to _deleteSelectedWidget might reduce clarity if the underscore prefix isn't a standard in your codebase. Consider keeping naming consistent across actions.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1bef3ac and 4287ae7.

📒 Files selected for processing (3)
  • app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHotKeys.tsx (2 hunks)
  • app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx (4 hunks)
  • app/client/src/pages/Editor/GlobalHotKeys/index.tsx (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx

[error] 139-139: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (5)
app/client/src/pages/Editor/GlobalHotKeys/index.tsx (2)

5-5: Confirm Blueprint dependencies.

This new import for HotkeysProvider relies on Blueprint; please verify that the required version is pinned and compatible with the rest of the dependencies.


15-23: Nicely integrated hotkeys context.

Wrapping GlobalHotKeys inside HotkeysProvider centralizes hotkey handling and aligns with recommended patterns in Blueprint.

app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHotKeys.tsx (1)

2-2: Validate Blueprint usage.

Ensure the installed @blueprintjs/core version supports useHotkeys and HotkeyConfig to avoid runtime errors.

app/client/src/pages/Editor/GlobalHotKeys/GlobalHotKeys.tsx (2)

1-3: Functional conversion looks good.

Reviewing the new imports and hook-based approach, everything appears well-organized. Good job transitioning to useDispatch and useSelector.


45-55: Interfaces and new imports.

These lines define props and introduce additional selectors and hooks. It all seems correct and coherent with the overall Redux usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants