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

feat: add jsfunction resp viz #39697

Merged
merged 1 commit into from
Mar 12, 2025
Merged

Conversation

znamenskii-ilia
Copy link
Contributor

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

Description

Screenshot 2025-03-12 at 15 49 20

Fixes #39684

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13814379506
Commit: 6718758
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Wed, 12 Mar 2025 15:32:41 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced an "AI Response Visualizer" tab that displays enhanced visualizations of AI responses when advanced functionality is enabled.
  • Refactor

    • Improved the visualization configuration for a more flexible and consistent display.
    • Streamlined prompt input to support seamless submission via the Enter key, enhancing the overall user experience.

Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

Walkthrough

The changes update the visualization workflow in the Plugin Action Editor and enhance response rendering in the JSResponseView. In the Visualization component, the old properties have been replaced with new ones, refactoring how visualization data and responses are handled. In the PromptInput component, the form wrapper has been removed and submission now triggers on the Enter key, simplifying the flow. Additionally, the JSResponseView now conditionally introduces an "AI Response Visualizer" tab when function calling is enabled, integrating the Visualization component accordingly.

Changes

Files Change Summary
app/client/src/PluginActionEditor/.../Visualization.tsx, app/client/src/PluginActionEditor/.../Visualization/components/PromptInput.tsx Refactored the Visualization component: removed action/actionResponse props and introduced entityId, visualizationElements, and response; updated prop destructuring and hook calls. Modified PromptInput to remove a styled form, triggering submission on Enter and linking the button’s click directly to the submission logic.
app/client/src/.../JSResponseView.tsx Added a conditional tab for function calling visualization. A new selector checks if function calling is enabled and, if so, the "AI Response Visualizer" tab is rendered with the appropriate Visualization component integration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PromptInput
    participant EditorForm

    User->>PromptInput: Types input and presses Enter
    PromptInput-->>PromptInput: Detect Enter key press
    PromptInput->>EditorForm: Trigger onSubmit event
    EditorForm-->>User: Submit input data
Loading
sequenceDiagram
    participant User
    participant JSResponseView
    participant FunctionChecker as getReleaseFnCallingEnabled
    participant VisualizationComponent

    User->>JSResponseView: Open response tabs
    JSResponseView->>FunctionChecker: Check if function calling enabled
    FunctionChecker-->>JSResponseView: Return enabled status
    alt Function Calling Enabled
        JSResponseView->>VisualizationComponent: Render "AI Response Visualizer" with props
    else Not Enabled
        JSResponseView->>VisualizationComponent: Render standard response view
    end
    VisualizationComponent-->>User: Display appropriate tab
Loading

Suggested labels

Enhancement, IDE Product, Task, Platform Administration Pod, ok-to-test

Suggested reviewers

  • AmanAgarwal041
  • ayushpahwa
  • ankitakinger
  • albinAppsmith

Poem

Code transforms with a silent glow,
Old structures fade as new winds blow.
Inputs submit with a rhythmic key,
Visual tabs now dance for all to see.
In streamlined flows, our efforts grow 🚀
A celebration of logic in a vibrant show!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @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 AI Agents Issues related to agentic solutions on Appsmith Anvil Pod Issue related to Anvil project Task A simple Todo Enhancement New feature or request labels Mar 12, 2025
actionResponse?: ActionResponse;
entityId: string;
visualizationElements?: VisualizationElements;
response?: string | Record<string, unknown>[];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made it more generic so it can be used with actions and jsfunctions

@znamenskii-ilia znamenskii-ilia added the ok-to-test Required label for CI label Mar 12, 2025
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/components/editorComponents/JSResponseView.tsx (1)

271-271: Don't forget to update dependencies array

The dependencies array for the useMemo hook doesn't include isFnCallingEnabled which is now used in the tab creation logic.

- }, [JSResponseTab, errorCount, ideType, ideViewMode]);
+ }, [JSResponseTab, errorCount, ideType, ideViewMode, isFnCallingEnabled]);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dddc6f1 and 6718758.

📒 Files selected for processing (3)
  • app/client/src/PluginActionEditor/components/PluginActionResponse/components/Visualization/Visualization.tsx (1 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionResponse/components/Visualization/components/PromptInput.tsx (3 hunks)
  • app/client/src/components/editorComponents/JSResponseView.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: build
  • 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
🔇 Additional comments (11)
app/client/src/PluginActionEditor/components/PluginActionResponse/components/Visualization/components/PromptInput.tsx (3)

16-17: Good improvement with form removal

The comment clearly explains why the form was removed - preventing nested forms which can cause submission issues. This simplifies the component structure and avoids potential DOM validation errors.


21-25: Good implementation of keyboard-based submission

Adding the Enter key handler provides a better user experience by allowing keyboard submission, which is a standard pattern for input fields. The implementation is clean and focused.


35-35: Simplified click handler

Direct connection to the onSubmit function is cleaner than the previous implementation. This change aligns with the form removal and simplifies the control flow.

app/client/src/components/editorComponents/JSResponseView.tsx (4)

45-46: New imports support the visualization feature

These imports correctly bring in the necessary selector for feature flag checking and the Visualization component that will be conditionally rendered in the new tab.


217-217: Feature flag usage is appropriate

Using a feature flag selector is the right approach for controlling access to the new functionality. This enables gradual rollout and testing of the visualization feature.


222-242: Well-structured conditional tab addition

The implementation correctly:

  1. Creates a base tabs array with the standard response tab
  2. Conditionally adds the visualization tab based on the feature flag
  3. Passes appropriate props from the current function to the Visualization component

This approach maintains backward compatibility while cleanly introducing the new functionality.


244-246: Clean tabs construction

Using the spread operator to combine the response tabs with other tabs is a clean approach that supports the conditional addition of the visualization tab.

app/client/src/PluginActionEditor/components/PluginActionResponse/components/Visualization/Visualization.tsx (4)

2-3: Good addition of error handling and type import

Adding the ErrorBoundary from Sentry will provide graceful failure handling for visualization rendering issues. The specific type import for VisualizationElements improves type safety.


13-17: Props interface is now more focused

The props interface has been improved by:

  1. Using a direct entityId string instead of requiring the full action object
  2. Making the visualization elements and response optional and more specifically typed
  3. Supporting both string and structured data responses

This makes the component more reusable and less coupled to specific data structures.


22-28: Simpler props usage

The component now directly uses the specific props needed rather than extracting values from action objects. This simplifies the code and makes the data flow more explicit.


97-106: ErrorBoundary implementation adds robustness

The visualization rendering is now wrapped in an ErrorBoundary component, which will prevent the entire UI from crashing if there's an issue with the visualization. The fallback message is clear and actionable for users.

@znamenskii-ilia znamenskii-ilia merged commit ae2f2b7 into release Mar 12, 2025
49 checks passed
@znamenskii-ilia znamenskii-ilia deleted the feat/39684-jsfunction-resp-viz branch March 12, 2025 15:43
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.

Visualize jsFunctions response
2 participants