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: Opening response pane by default on query creation and for page load queries #37245

Merged
merged 6 commits into from
Nov 8, 2024

Conversation

ankitakinger
Copy link
Contributor

@ankitakinger ankitakinger commented Nov 5, 2024

Description

Opening response pane by default on query creation and for page load queries

Fixes #37216

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/11723600626
Commit: 98db89c
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Thu, 07 Nov 2024 13:48:18 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced the PluginActionResponse component for improved functionality and dynamic response handling.
    • Introduced a new state variable to manage response tab visibility on initial load.
    • Added logic to automatically open the response and schema tabs based on action responses.
  • Bug Fixes

    • Improved control flow and error handling for displaying responses based on action success.

Copy link
Contributor

coderabbitai bot commented Nov 5, 2024

Walkthrough

The PluginActionResponse component has been updated to improve its functionality. Key changes include the addition of new hooks and utility functions, the introduction of a state variable to control the visibility of the response tab on initial load, and multiple useEffect hooks to manage tab visibility based on action responses. These modifications enhance the component's control flow and error handling, allowing for dynamic responses depending on the state of the action and its response.

Changes

File Change Summary
app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx Expanded imports to include additional hooks and utility functions; added state variable for tab visibility; implemented multiple useEffect hooks for managing tab display based on action responses.

Assessment against linked issues

Objective Addressed Explanation
Open response pane by default (37216)

Possibly related PRs

Suggested reviewers

  • hetunandu

🎉 In the realm of code, where logic flows,
A response pane opens, as everyone knows.
With hooks and states, the tabs now gleam,
Dynamic and bright, like a coder's dream!
So here’s to the changes, both clever and neat,
In the world of plugins, we can’t be beat! 🚀


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 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 IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Task A simple Todo labels Nov 5, 2024
@ankitakinger
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Nov 5, 2024
Copy link

github-actions bot commented Nov 5, 2024

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between db713e9 and c596aeb.

📒 Files selected for processing (1)
  • app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx (2 hunks)
🧰 Additional context used
🪛 Biome
app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx

[error] 76-76: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

🔇 Additional comments (8)
app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx (8)

11-14: New imports are appropriate

The added imports are necessary and correctly included.


18-18: Destructuring from usePluginActionContext

Correctly retrieves action, actionResponse, and plugin from the context.


21-23: Initialization of plugin-related variables

Variables pluginRequireDatasource and showSchema are properly initialized using the plugin data.


30-31: State variable for response visibility

showResponseOnFirstLoad state is correctly initialized to manage response tab visibility.


33-35: Retrieval of response display format

responseDisplayFormat is appropriately obtained from actionResponseDisplayDataFormats.


38-55: Opening response tab on initial load

The useEffect hook correctly opens the response tab when conditions are met.


62-71: Opening schema tab when applicable

The useEffect hook properly handles opening the schema tab based on showSchema and selectedTab.


75-79: Resetting response visibility flag on action change

Resets showResponseOnFirstLoad when a new action is detected to ensure consistent behavior.

🧰 Tools
🪛 Biome

[error] 76-76: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

Copy link

github-actions bot commented Nov 5, 2024

Deploy-Preview-URL: https://ce-37245.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

🧹 Outside diff range and nitpick comments (1)
app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx (1)

30-60: Consider simplifying response visibility conditions

The useEffect contains multiple conditions that could be extracted into a helper function for better readability and maintainability.

Consider refactoring like this:

+ const shouldShowResponseOnLoad = () => {
+   return responseDisplayFormat?.title &&
+          actionResponse?.isExecutionSuccess &&
+          !showResponseOnFirstLoad;
+ };

  useEffect(() => {
-   if (
-     responseDisplayFormat &&
-     !!responseDisplayFormat?.title &&
-     actionResponse &&
-     actionResponse.isExecutionSuccess &&
-     !showResponseOnFirstLoad
-   ) {
+   if (shouldShowResponseOnLoad()) {
      dispatch(
        setPluginActionEditorDebuggerState({
          open: true,
          selectedTab: DEBUGGER_TAB_KEYS.RESPONSE_TAB,
        }),
      );
      setShowResponseOnFirstLoad(true);
    }
  }, [responseDisplayFormat, actionResponse, showResponseOnFirstLoad, dispatch]);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c596aeb and 55c2332.

📒 Files selected for processing (1)
  • app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx (2 hunks)
🔇 Additional comments (4)
app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx (4)

Line range hint 1-14: LGTM: Import statements are well-organized

The new imports for hooks and utilities are properly structured and necessary for the component's functionality.


62-71: LGTM: Schema tab handling is well-implemented

The logic for showing the schema tab when appropriate is clear and the dependencies are correctly specified.


73-79: LGTM: Action ID change handling meets requirements

The implementation correctly handles multiple page load queries by resetting the response visibility state when the action changes.


36-60: Verify performance impact of automatic response pane opening

While the implementation meets the requirements, we should verify that automatically opening the response pane doesn't impact performance, especially with multiple page load queries.

Consider implementing a debounce mechanism if multiple state updates occur in quick succession during page load.

@ankitakinger
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@ankitakinger ankitakinger added the ok-to-test Required label for CI label Nov 5, 2024
Copy link

github-actions bot commented Nov 5, 2024

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

Copy link

github-actions bot commented Nov 5, 2024

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

Comment on lines 41 to 42
responseDisplayFormat &&
!!responseDisplayFormat?.title &&
Copy link
Member

Choose a reason for hiding this comment

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

Are these needed? Would they be available when the action has a failed response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is required and basically works only when the response is a success. This is how it works in the normal flow as well.

@ankitakinger
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Nov 7, 2024

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

Copy link

github-actions bot commented Nov 7, 2024

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

@ankitakinger
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Nov 7, 2024

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

🧹 Outside diff range and nitpick comments (1)
app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx (1)

33-55: Simplify conditions and improve naming.

The useEffect implementation is good, but there are a few improvements that could be made:

- if (
-   !!responseDisplayFormat?.title &&
-   actionResponse?.isExecutionSuccess
- ) {
+ if (
+   responseDisplayFormat?.title &&
+   actionResponse?.isExecutionSuccess
+ ) {

Also, consider extracting the condition into a descriptive variable for better readability:

const shouldOpenResponseTab = responseDisplayFormat?.title && actionResponse?.isExecutionSuccess;
if (shouldOpenResponseTab) {
  // ... existing code
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cb31dd4 and 98db89c.

📒 Files selected for processing (1)
  • app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx (2 hunks)
🔇 Additional comments (3)
app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx (3)

Line range hint 1-24: LGTM! Clean implementation of context and utility imports.

The new imports and context usage are well-organized and properly implement the required functionality.


57-69: LGTM! Well-implemented schema tab logic.

The schema tab auto-opening logic is clean and follows best practices with proper dependency tracking.


33-69: Verify response pane behavior for all query scenarios.

The implementation looks good but let's verify it handles all cases:

Also, please verify that this works correctly for:

  1. New query creation
  2. Page load queries
  3. Manual query execution
✅ Verification successful

Based on the analysis of the codebase, I can now provide a final response:

Response tab behavior implementation is correct and comprehensive

The implementation correctly handles all query execution scenarios:

  • Page load queries: Opens response tab when execution is successful and response format is available
  • Schema tab: Opens when no tab is selected and schema is available
  • Error cases: Handled through separate error tab logic in PluginActionSaga
  • Manual execution: Response tab state managed through action execution saga

The changes are well-integrated with the existing debugger tab system and follow the established patterns for tab management.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other places where response pane visibility might be controlled
rg -l "setPluginActionEditorDebuggerState.*open.*true" --type ts

Length of output: 282


Script:

#!/bin/bash
# Let's check the implementation in QueryDebuggerTabs.tsx
rg -A 10 "setPluginActionEditorDebuggerState.*open.*true" app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx

# Also check ApiResponseView.tsx
rg -A 10 "setPluginActionEditorDebuggerState.*open.*true" app/client/src/components/editorComponents/ApiResponseView.tsx

# Let's also check if there are any other debugger tab related constants
rg "DEBUGGER_TAB_KEYS" --type ts

Length of output: 9831


Script:

#!/bin/bash
# Let's check how response tab is handled during action execution
rg -A 10 "executePluginAction|runAction.*setPluginActionEditorDebuggerState" --type ts

# Also check if there are any error cases that might affect response tab
rg -A 5 "actionResponse.*isExecutionSuccess.*false" --type ts

Length of output: 17403

Copy link

github-actions bot commented Nov 7, 2024

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

@ankitakinger ankitakinger merged commit 5e89aa0 into release Nov 8, 2024
43 checks passed
@ankitakinger ankitakinger deleted the chore/show-response-pane-open branch November 8, 2024 05:40
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
…e load queries (appsmithorg#37245)

## Description

Opening response pane by default on query creation and for page load
queries

Fixes [appsmithorg#37216](appsmithorg#37216)

## Automation

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

### 🔍 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/11723600626>
> Commit: 98db89c
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11723600626&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Thu, 07 Nov 2024 13:48:18 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**
- Enhanced the `PluginActionResponse` component for improved
functionality and dynamic response handling.
- Introduced a new state variable to manage response tab visibility on
initial load.
- Added logic to automatically open the response and schema tabs based
on action responses.

- **Bug Fixes**
- Improved control flow and error handling for displaying responses
based on action success.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ankita Kinger <[email protected]>
@coderabbitai coderabbitai bot mentioned this pull request Dec 30, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Open response pane by default
2 participants