Skip to content

feat: add generate schema button#39751

Merged
znamenskii-ilia merged 9 commits intoreleasefrom
feat/39726-generate-schema-button-2
Mar 18, 2025
Merged

feat: add generate schema button#39751
znamenskii-ilia merged 9 commits intoreleasefrom
feat/39726-generate-schema-button-2

Conversation

@znamenskii-ilia
Copy link
Contributor

@znamenskii-ilia znamenskii-ilia commented Mar 17, 2025

Description

Update JS and Plugin Action Toolbar to add new Schema generation CTA in them

https://www.figma.com/design/mVEbXXryqv2oBxMcNg8yjC/Anvil-AI?node-id=3891-34025&t=AVP3gbWu07WzPfwc-0

Fixes #39726

Automation

/ok-to-test tags="@tag.JS, @tag.Datasource"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13920663021
Commit: c0b7603
Cypress dashboard.
Tags: @tag.JS, @tag.Datasource
Spec:


Tue, 18 Mar 2025 11:30:10 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced real-time tracking of schema generation processes with clear UI indicators and error messaging.
    • Expanded actionable events to support improved feedback during schema creation for plugin actions and JavaScript functions.
  • Refactor

    • Streamlined component exports and updated import paths for enhanced organization and consistency in the editor toolbars.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2025

Walkthrough

This pull request introduces schema generation state management for both plugin actions and JavaScript functions. New Redux state properties, actions, reducers, and selectors are added to track the generation process. Additionally, export paths for related components have been updated and new constants (including error messages and a test identifier) defined. These changes prepare the codebase to handle UI interactions for triggering and monitoring schema generation.

Changes

File(s) Change Summary
app/client/src/.../pluginActionEditorSelectors.ts
app/client/src/.../pluginEditorReducer.ts
Added selector isActionSchemaGenerating and new state property isSchemaGenerating with request, success, and error handlers for plugin action schema generation.
app/client/src/.../ReduxActionConstants.tsx Introduced new action types for JS function and plugin action schema generation including request, cancelled, success, and error states.
app/client/src/.../jsPaneReducer.ts
app/client/src/.../jsPaneSelectors.ts
Extended JS pane state with isSchemaGenerating and added selectors for tracking schema generation and saving status.
app/client/src/.../messages.ts Added constant CANNOT_GENERATE_SCHEMA to provide error text for schema generation failures.
app/client/src/.../JSEditorToolbar/constants.ts
app/client/src/.../JSEditorToolbar/JSEditorToolbar.tsx
app/client/src/.../JSEditorToolbar/index.ts
app/client/src/.../PluginActionEditor/index.ts
app/client/src/.../PluginActionToolbar.tsx (both ce and ee)
Updated import paths and export statements; added a new test ID for the generate schema button; re-exported components from new locations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant Redux
    participant Selector

    User->>UI: Click "Generate Schema" button
    UI->>Redux: Dispatch GENERATE_*_REQUEST action
    Redux->>Redux: Update isSchemaGenerating state to true
    Redux-->>UI: Dispatch SUCCESS/ERROR action on completion
    UI->>Selector: Query isSchemaGenerating status
    Selector-->>UI: Return current generation status
Loading

Assessment against linked issues

Objective Addressed Explanation
#39726 Add "save" button (generate jsFunction/queries types) Redux state and test locator changes are present, but UI button code is not implemented.

Possibly related PRs

Suggested labels

skip-changelog, ok-to-test, IDE Product

Suggested reviewers

  • AmanAgarwal041
  • ayushpahwa
  • albinAppsmith

Poem

In lines of code a rhythm sings,
New schema states take flight on wings.
Redux paths now clearly pave the way,
Components and actions come out to play.
A celebration of change in digital arrays!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 33f2c98 and c0b7603.

📒 Files selected for processing (3)
  • app/client/src/ce/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx (1 hunks)
  • app/client/src/ee/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • app/client/src/ee/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/index.ts
  • app/client/src/ce/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • 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

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

@github-actions github-actions bot added the Enhancement New feature or request label Mar 17, 2025
@znamenskii-ilia
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/13900931622.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 39751.
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/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionGenerateSchema.tsx (1)

1-25: Button text doesn't match component's purpose

The component name and test ID suggest it's for generating a schema, but the button text is "Save". This inconsistency could confuse users. Consider changing the button text to "Generate Schema" or similar to better reflect its purpose.

  <Button
    data-testid={testLocators.generateSchemaJSActionTestID}
    isDisabled={props.disabled}
    isLoading={props.isLoading}
    kind="secondary"
    onClick={props.onButtonClick}
    size="sm"
  >
-   Save
+   Generate Schema
  </Button>
app/client/src/api/SchemaAPI.ts (1)

4-7: Consider using a more specific type for schema

The schema property is typed as unknown, which provides limited type safety. If the schema follows a specific structure, consider defining a more specific type or interface to improve type checking and developer experience.

app/client/src/pages/Editor/JSEditor/Form.tsx (1)

301-305: Schema generation handler implementation.

The implementation correctly dispatches the schema generation action only when a valid JS action is selected. Consider adding error handling or user feedback if no action is selected.

 const handleGenerateSchemaButtonClick = async () => {
   if (selectedJSActionOption.data?.id) {
     dispatch(generateJSFunctionSchema(selectedJSActionOption.data));
+  } else {
+    // Consider adding a toast notification or other feedback
+    // toast.info("Please select a function to generate schema");
   }
 };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3705176 and 939e29c.

📒 Files selected for processing (16)
  • app/client/src/PluginActionEditor/components/PluginActionToolbar.tsx (4 hunks)
  • app/client/src/PluginActionEditor/hooks/useHandleGenerateSchemaClick.ts (1 hunks)
  • app/client/src/PluginActionEditor/store/pluginActionEditorSelectors.ts (1 hunks)
  • app/client/src/PluginActionEditor/store/pluginEditorReducer.ts (3 hunks)
  • app/client/src/actions/generateSchemaActions.ts (1 hunks)
  • app/client/src/api/SchemaAPI.ts (1 hunks)
  • app/client/src/ce/constants/ReduxActionConstants.tsx (2 hunks)
  • app/client/src/ce/constants/messages.ts (1 hunks)
  • app/client/src/ce/sagas/index.tsx (2 hunks)
  • app/client/src/pages/Editor/JSEditor/Form.tsx (6 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx (4 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionGenerateSchema.tsx (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/constants.ts (1 hunks)
  • app/client/src/reducers/uiReducers/jsPaneReducer.ts (4 hunks)
  • app/client/src/sagas/GenerateSchemaSaga.ts (1 hunks)
  • app/client/src/selectors/jsPaneSelectors.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • 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
🔇 Additional comments (40)
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/constants.ts (1)

11-11: Test ID added for generate schema functionality.

This constant will be used to identify the generate schema button in automated tests, following the established pattern for test IDs in this codebase.

app/client/src/ce/constants/messages.ts (1)

652-652: Added error message for schema generation failure.

This message will be shown to users when schema generation fails. The message is concise and follows the established pattern of using function expressions to return message strings.

app/client/src/ce/sagas/index.tsx (1)

54-54: Added new saga for plugin action schema generation.

The schema generation saga has been properly imported and registered in the sagas array. This enables the application to handle the asynchronous operations involved in schema generation.

Also applies to: 68-68

app/client/src/PluginActionEditor/hooks/useHandleGenerateSchemaClick.ts (1)

1-18: Well-structured custom hook for handling schema generation.

This hook follows React best practices:

  • Uses useCallback to memoize the handler function
  • Properly depends on the action ID and dispatch
  • Provides a clean interface for components that need to trigger schema generation

The null coalescing operator (??) provides a fallback empty string when the action ID is undefined, preventing potential issues.

app/client/src/actions/generateSchemaActions.ts (1)

1-18: Clean implementation of Redux action creators

The action creators follow Redux best practices with descriptive names and proper payload structures. No issues found.

app/client/src/api/SchemaAPI.ts (1)

9-17: API implementation follows project patterns

The SchemaAPI class implementation is clean and follows the established API patterns in the application. The method is concise and correctly handles the schema generation request.

app/client/src/PluginActionEditor/store/pluginActionEditorSelectors.ts (1)

23-31: Well-structured schema generation selector

The implementation of the schema generation state selector follows the established pattern of other selectors in the file. It properly uses createSelector for memoization and matches the code style of the surrounding selectors.

app/client/src/selectors/jsPaneSelectors.ts (2)

26-27: New selector looks good.

The getIsGeneratingSchema selector follows the same pattern as other selectors in this file, properly accessing the schema generation state for a specific collection.


29-32: New selector implementation is correct.

The getIsJSCollectionSaving selector properly accesses the saving state for a specific JS collection with appropriate type parameters.

app/client/src/PluginActionEditor/components/PluginActionToolbar.tsx (5)

12-16: Import statements are correctly organized.

Added selectors for tracking action states: running, saving, and schema generation.


19-19: New hook import looks good.

Importing the custom hook for schema generation functionality.


30-35: Schema generation handler is properly integrated.

Added hook instantiation and state selectors for the schema generation features.


54-54: Correctly disable run button during schema generation.

The Run button is now disabled while schema generation is in progress, preventing concurrent operations that could lead to state inconsistencies.


63-72: New schema generation button looks good.

The Save button is properly added with appropriate test ID, disabled states, and loading indicator connected to the schema generation state. Button styling is consistent with existing UI components.

app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx (5)

13-14: New imports for schema generation UI components.

The JSFunctionGenerateSchema component and Flex layout component are correctly imported.


25-25: New prop for disabling schema functionality.

Added prop to control when schema generation is disabled.


28-28: Schema generation loading state prop added.

This prop will be used to show loading state on the schema generation button.


33-35: Event handler prop for schema generation.

Added prop for handling schema generation button click events.


65-81: UI structure improved with Flex layout.

Replaced div with Flex component for better alignment of action buttons and added the schema generation button. The implementation follows the same pattern as the run button with appropriate props for disabled state and loading indicators.

app/client/src/pages/Editor/JSEditor/Form.tsx (6)

33-37: New selector imports are clean and organized.

Added selectors for tracking schema generation and JS collection saving states.


64-64: New action import for schema generation.

Properly importing the generateJSFunctionSchema action.


161-166: State selectors for schema generation and saving.

Added Redux selectors to track schema generation and JS collection saving states for the current collection.


359-364: Toolbar props for schema generation.

Correctly passing the disabled states for both schema generation and run functionality. The run functionality is now disabled during schema generation to prevent concurrent operations.


368-368: Loading state passed to toolbar.

The isGeneratingSchema state is correctly passed to the toolbar to show loading indicator on the schema generation button.


377-377: Schema generation click handler passed to toolbar.

The handler for schema generation is correctly passed to the toolbar component.

app/client/src/reducers/uiReducers/jsPaneReducer.ts (6)

7-7: Import usage looks good.
You’re correctly importing both JSAction and JSCollection, which are referenced elsewhere in the reducer.


26-26: New property for tracking schema generation.
Introducing isSchemaGenerating aligns well with expectations for asynchronous actions.


36-36: Reasonable initial state.
Initializing isSchemaGenerating as an empty record is consistent with other properties.


180-195: Smooth handling of the schema generation request.
Good approach: you set isSchemaGenerating to true and safeguard the case when no collectionId is found.


196-209: Schema generation success flow.
Marking isSchemaGenerating as false upon success is consistent.


210-223: Error handling is aligned.
On errors, setting isSchemaGenerating to false prevents stale loading states.

app/client/src/sagas/GenerateSchemaSaga.ts (4)

1-15: Imports are properly organized.
All required modules are included, and there are no apparent redundancies.


16-55: Plugin action schema generation is well-structured.
The saga correctly calls the API, updates the Redux state, and handles errors.


56-96: JS function schema generation mirrors plugin logic.
Consistent approach for managing JS function actions and error handling.


98-109: Saga watchers correctly handle both plugin and JS schema requests.
Using takeLatest ensures only the latest request is processed.

app/client/src/PluginActionEditor/store/pluginEditorReducer.ts (3)

25-25: Additional property for schema generation.
isSchemaGenerating is a clear and suitable name for this state.


38-38: Empty object as an initial value is consistent.
Matches how other fields in the reducer are initialized.


146-165: Comprehensive reducers for schema request lifecycle.
You’re toggling isSchemaGenerating appropriately for request, success, and error.

app/client/src/ce/constants/ReduxActionConstants.tsx (2)

713-722: Nice addition of schema generation action types for both JS functions and plugin actions

The implementation follows the standard pattern in the codebase with request, cancelled, and success action types. This provides complete state management for the schema generation feature.


735-736: Good work adding corresponding error action types

You've correctly added error action types that match the success actions, ensuring proper error handling for both JS function and plugin action schema generation.

@github-actions github-actions bot added AI Agents Issues related to agentic solutions on Appsmith Anvil Pod Issue related to Anvil project Task A simple Todo labels Mar 17, 2025
@znamenskii-ilia znamenskii-ilia force-pushed the feat/39726-generate-schema-button-2 branch from 939e29c to 75c2a49 Compare March 17, 2025 13:51
@znamenskii-ilia
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/13901214718.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 39751.
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: 1

🧹 Nitpick comments (8)
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionGenerateSchema.tsx (1)

1-25: Clean implementation of the Schema Generation button component

This is a well-structured React component implementing the schema generation functionality. The component follows React best practices with clear props interface and proper handling of disabled and loading states.

One suggestion though - the button text "Save" might be slightly confusing considering the component and functionality are about schema generation rather than saving in the traditional sense.

Consider renaming the button text to more accurately reflect its function:

-      Save
+      Generate Schema
app/client/src/PluginActionEditor/components/PluginActionToolbar.tsx (1)

65-76: Proper implementation of the Save button with feature flag

The Save button is correctly implemented with appropriate disabled and loading states, and properly guarded by the feature flag.

Similar to the previous component, the button text "Save" might be slightly confusing since the functionality is generating a schema rather than saving.

Consider renaming the button text to better reflect its actual function:

-            Save
+            Generate Schema
app/client/src/sagas/GenerateSchemaSaga.ts (6)

1-3: Consider consistent imports.
There is a mix of @appsmith/ads and @appsmith/ads-old. Using a single import source might reduce confusion or version mismatch issues.


16-19: Add input validation checks.
Validating action.payload.id before calling SchemaAPI.generateSchema prevents unintentionally passing undefined arguments.


25-39: Handle missing schema or description fields.
If response.data does not contain schema or description, the current code may set them to undefined. Consider fallbacks.


50-53: Refine error feedback.
Displaying only "Cannot generate schema" might be too generic. Including details in the toast could help with debugging.


67-81: Consolidate repeated code.
This block duplicates the plugin action schema logic. Consider abstracting common logic for both plugin actions and JS functions.


92-95: Improve granularity in error handling.
Consider capturing specific error details from the API response to better assist debugging.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 939e29c and 75c2a49.

📒 Files selected for processing (16)
  • app/client/src/PluginActionEditor/components/PluginActionToolbar.tsx (4 hunks)
  • app/client/src/PluginActionEditor/hooks/useHandleGenerateSchemaClick.ts (1 hunks)
  • app/client/src/PluginActionEditor/store/pluginActionEditorSelectors.ts (1 hunks)
  • app/client/src/PluginActionEditor/store/pluginEditorReducer.ts (3 hunks)
  • app/client/src/actions/generateSchemaActions.ts (1 hunks)
  • app/client/src/api/SchemaAPI.ts (1 hunks)
  • app/client/src/ce/constants/ReduxActionConstants.tsx (2 hunks)
  • app/client/src/ce/constants/messages.ts (1 hunks)
  • app/client/src/ce/sagas/index.tsx (2 hunks)
  • app/client/src/pages/Editor/JSEditor/Form.tsx (6 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx (6 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionGenerateSchema.tsx (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/constants.ts (1 hunks)
  • app/client/src/reducers/uiReducers/jsPaneReducer.ts (4 hunks)
  • app/client/src/sagas/GenerateSchemaSaga.ts (1 hunks)
  • app/client/src/selectors/jsPaneSelectors.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/constants.ts
  • app/client/src/ce/constants/messages.ts
  • app/client/src/PluginActionEditor/hooks/useHandleGenerateSchemaClick.ts
  • app/client/src/api/SchemaAPI.ts
  • app/client/src/ce/sagas/index.tsx
  • app/client/src/actions/generateSchemaActions.ts
  • app/client/src/selectors/jsPaneSelectors.ts
  • app/client/src/PluginActionEditor/store/pluginActionEditorSelectors.ts
  • app/client/src/PluginActionEditor/store/pluginEditorReducer.ts
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
🔇 Additional comments (15)
app/client/src/PluginActionEditor/components/PluginActionToolbar.tsx (3)

12-20: Appropriate imports for the new functionality

The added imports correctly support the new schema generation feature with proper selectors and hooks.


31-37: Well integrated schema generation hook and state selectors

Good implementation of the schema generation functionality by adding the necessary hook and state selectors. This provides proper state management for the new feature.


56-56: Good state handling for the Run button

Correctly disabling the Run button while schema generation is in progress prevents potential conflicts between operations.

app/client/src/reducers/uiReducers/jsPaneReducer.ts (3)

26-26: Appropriate state modeling for schema generation

Adding the isSchemaGenerating property to track schema generation status per collection ID follows the established pattern in this reducer.


36-36: Proper initialization of the new state property

The new state property is correctly initialized as an empty object.


180-223: Well implemented action handlers for schema generation lifecycle

The action handlers for schema generation request, success, and error follow a consistent pattern and include proper safety checks for the collection ID. The schema generation state is correctly set and reset throughout the lifecycle of the operation.

app/client/src/pages/Editor/JSEditor/Form.tsx (6)

33-37: Appropriate import organization for state selectors

Good consolidation of related imports using object destructuring.


64-64: Well-placed action import

The import for the schema generation action is appropriately placed with other action imports.


161-166: Proper use of state selectors

Good implementation of selectors to track schema generation and collection saving state from the Redux store.


301-305: Clean implementation of schema generation handler

The schema generation handler is well-implemented with proper null checking before dispatching the action.


359-364: Good state handling for feature buttons

The disabled states for both the schema generation and run functionality buttons are correctly managed to prevent conflicts between operations.


368-378: Proper props integration with JSEditorToolbar

The JSEditorToolbar component is correctly enhanced with new props to support schema generation functionality.

app/client/src/sagas/GenerateSchemaSaga.ts (1)

56-60: Verify action.id field usage.
Ensure action.id is always set since you rely on action.id for schema generation. If missing, the saga call will fail.

app/client/src/ce/constants/ReduxActionConstants.tsx (2)

713-722: Keep naming consistent.
The newly added action types for generating schemas are clearly descriptive. Ensure usage across the codebase follows the same naming convention (e.g., “schema” vs “Schema”).


735-736: Validate error flow.
The added error types are good. Confirm that corresponding reducers or sagas handle these cases to avoid silent failures.

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/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.test.tsx (1)

26-28: Props added for schema generation feature, but no tests for this functionality.

The code correctly adds the necessary props for the schema generation feature to the defaultProps object. However, there are no tests that verify the behavior of this new functionality.

Consider adding a test case that:

  1. Verifies the schema generation button renders correctly
  2. Tests that disableGenerateSchemaFunctionality properly enables/disables the button
  3. Confirms the button shows a loading state when isGeneratingSchema is true
  4. Ensures onGenerateSchemaButtonClick is called when the button is clicked
it("handles generate schema button click correctly", () => {
  mockUseFeatureFlag.mockReturnValue(true);
  render(<JSEditorToolbar {...defaultProps} />);
  
  // Find and click the generate schema button
  const generateSchemaButton = screen.getByRole("button", { name: "Generate Schema" });
  fireEvent.click(generateSchemaButton);
  
  // Verify the click handler was called
  expect(defaultProps.onGenerateSchemaButtonClick).toHaveBeenCalled();
});

it("disables generate schema button when disableGenerateSchemaFunctionality is true", () => {
  mockUseFeatureFlag.mockReturnValue(true);
  render(<JSEditorToolbar {...defaultProps} disableGenerateSchemaFunctionality={true} />);
  
  // Verify the button is disabled
  const generateSchemaButton = screen.getByRole("button", { name: "Generate Schema" });
  expect(generateSchemaButton).toHaveAttribute("disabled");
});
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 75c2a49 and 664e013.

📒 Files selected for processing (1)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.test.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies

@znamenskii-ilia
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

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

@github-actions
Copy link

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

@hetunandu hetunandu added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Mar 18, 2025
@znamenskii-ilia znamenskii-ilia merged commit d494ca4 into release Mar 18, 2025
64 of 68 checks passed
@znamenskii-ilia znamenskii-ilia deleted the feat/39726-generate-schema-button-2 branch March 18, 2025 11:41
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
## Description

Update JS and Plugin Action Toolbar to add new Schema generation CTA in
them


https://www.figma.com/design/mVEbXXryqv2oBxMcNg8yjC/Anvil-AI?node-id=3891-34025&t=AVP3gbWu07WzPfwc-0

Fixes appsmithorg#39726

## Automation

/ok-to-test tags="@tag.JS, @tag.Datasource"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13920663021>
> Commit: c0b7603
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13920663021&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.JS, @tag.Datasource`
> Spec:
> <hr>Tue, 18 Mar 2025 11:30:10 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced real-time tracking of schema generation processes with
clear UI indicators and error messaging.
- Expanded actionable events to support improved feedback during schema
creation for plugin actions and JavaScript functions.

- **Refactor**
- Streamlined component exports and updated import paths for enhanced
organization and consistency in the editor toolbars.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Agents Issues related to agentic solutions on Appsmith Anvil Pod Issue related to Anvil project Enhancement New feature or request ok-to-test Required label for CI Task A simple Todo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "save" button

3 participants