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

fix: remove redundant eval trigger #36433

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

Conversation

rishabhrathod01
Copy link
Contributor

@rishabhrathod01 rishabhrathod01 commented Sep 19, 2024

Description

Fixes #36237

Automation

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

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10965434213
Commit: ba66e4e
Cypress dashboard.
Tags: @tag.All
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/Git/GitSync/GitSyncedApps_spec.js
  2. cypress/e2e/Regression/ClientSide/Workspace/ShareAppTests_Spec.ts
List of identified flaky tests.
Fri, 20 Sep 2024 21:03:00 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Improved handling of page loading states by removing unnecessary parameters, simplifying the fetch and setup processes for published pages.
    • Introduced new functions to enhance code organization and maintainability in page fetching operations.
  • Bug Fixes

    • Resolved issues related to redundant logic and parameters in the page fetching saga.
  • Refactor

    • Streamlined the control flow in the PageSagas for better readability and performance.
  • Tests

    • Updated tests to reflect the removal of the firstLoad property from action payloads.

Copy link
Contributor

coderabbitai bot commented Sep 19, 2024

Walkthrough

The recent changes involve the removal of the firstLoad property from several action payloads and functions related to fetching and setting up published pages. This adjustment simplifies the code structure and enhances the readability of the sagas by introducing new generator functions for handling page layout and post-fetch operations. The AppViewer component has also been streamlined by eliminating unnecessary setup calls, focusing solely on fetching page resources. Overall, these modifications aim to improve the organization and clarity of the codebase.

Changes

File Change Summary
app/client/src/actions/pageActions.tsx Removed firstLoad property from FetchPublishedPageActionPayload and SetupPublishedPageActionPayload interfaces and corresponding default parameters in fetchPublishedPageAction and setupPublishedPage functions.
app/client/src/ce/sagas/PageSagas.tsx Refactored sagas by extracting logic into new functions updateCanvasLayout and postFetchedPublishedPage. Adjusted fetchPublishedPageSaga to streamline control flow, removing firstLoad from destructured payload.
app/client/src/ce/sagas/tests/PageSaga.test.ts Removed firstLoad from the payload in two instances when invoking fetchPublishedPageAction.
app/client/src/pages/AppViewer/index.tsx Removed setupPublishedPage from dispatch calls, focusing on fetching resources with fetchPublishedPageResourcesAction only.

Assessment against linked issues

Objective Addressed Explanation
Avoid triggering evaluations multiple times on page switch (Issue #36237) The changes simplify the fetching logic, but it’s unclear if they directly resolve the evaluation issue.

Possibly related PRs

  • fix: loading state for pull #36363: The changes in this PR involve modifications to the loading state management for Git operations, which may relate to the overall handling of application state and loading indicators, similar to the changes made in the main PR regarding the removal of the firstLoad property.

Suggested reviewers

  • sagar-qa007
  • ankitakinger

Poem

In code we weave a tale so bright,
Removing flags to bring forth light.
With sagas neat and functions clear,
Our pages dance, no need to fear.
So let us cheer for changes made,
A simpler path, no plans delayed! 🎉


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 087b59f and ba66e4e.

Files selected for processing (1)
  • app/client/src/ce/sagas/PageSagas.tsx (5 hunks)
Additional comments not posted (2)
app/client/src/ce/sagas/PageSagas.tsx (2)

328-342: Excellent work on the updateCanvasLayout function! 👏

This function nicely encapsulates the necessary steps to update the canvas layout after fetching a page. By waiting for the widget config to load, resizing the main canvas, updating the canvas layout, and generating a data structure for dynamic height computation, you've ensured that the canvas is properly updated and optimized for the new page. Keep up the great work! 🌟


344-362: Great job on the postFetchedPublishedPage function! 🎉

This function does a fantastic job of centralizing the post-fetch operations for a published page. By clearing existing caches, setting URL params, updating the canvas layout, and updating the current page state, you've ensured that all the necessary housekeeping tasks and state updates are performed consistently. This improves code organization and reduces duplication. Well done! 👍


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 the Bug Something isn't working label Sep 19, 2024
@github-actions github-actions bot added Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Query & JS Pod Issues related to the query & JS Pod Release labels Sep 19, 2024
@rishabhrathod01 rishabhrathod01 self-assigned this Sep 19, 2024
@rishabhrathod01 rishabhrathod01 added the ok-to-test Required label for CI label Sep 19, 2024
@rishabhrathod01 rishabhrathod01 marked this pull request as ready for review September 19, 2024 22:14
@rishabhrathod01 rishabhrathod01 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Sep 19, 2024
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: 2

Outside diff range and nitpick comments (1)
app/client/src/pages/AppViewer/index.tsx (1)

Alright, class, gather 'round! We've got some interesting results from our experiment. It looks like our setupPublishedPage function is still present in various parts of our codebase. Let's break down our findings:

Attention, developer! Our investigation reveals that setupPublishedPage is still alive and kicking in our codebase.

Here's what we've discovered:

  • setupPublishedPage appears in multiple files, including:
    1. app/client/src/entities/Engine/AppViewerEngine.ts
    2. app/client/src/actions/pageActions.tsx
    3. app/client/src/ce/sagas/PageSagas.tsx
  • There's also a related saga called setupPublishedPageSaga.
  • Our test files (PageSaga.test.ts) are importing and using setupPublishedPageSaga.

Now, class, here's your homework assignment:

  1. Carefully review these occurrences to ensure your changes don't introduce any unintended side effects.
  2. Double-check if the removal of the setupPublishedPage dispatch in the file we initially reviewed was intentional.
  3. Consider whether the other occurrences of setupPublishedPage should be updated to maintain consistency across the codebase.

Remember, in software development, just like in science, every change can have ripple effects. It's crucial to understand the full scope of our actions!

Analysis chain

Line range hint 91-94: Great job simplifying the page resource fetching logic!

Removing the dispatch of setupPublishedPage action and only dispatching fetchPublishedPageResourcesAction with the basePageId argument streamlines the code and aligns with the PR objective of eliminating redundant evaluation triggers. This change enhances code clarity and maintainability.

To ensure this change doesn't introduce any unintended consequences, please run the following script to verify that setupPublishedPage is no longer used in the codebase:


Class, it seems we've encountered a small hiccup in our investigation. Our previous attempt to search for setupPublishedPage didn't quite work as expected. But don't worry! In the spirit of scientific inquiry, we're going to try a different approach. Let's modify our experiment and run it again.

Now, class, let's run this improved experiment and see what results we get. Remember, in science, it's all about refining our methods until we get the answers we're looking for!

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `setupPublishedPage` is no longer used in the codebase.

# Test: Search for occurrences of `setupPublishedPage`. Expect: No occurrences found.
rg --type typescript $'setupPublishedPage'

Length of output: 76


Script:

#!/bin/bash
# Description: Verify that `setupPublishedPage` is no longer used in the codebase.

# Test 1: Search for occurrences of `setupPublishedPage` in .ts and .tsx files
echo "Searching for 'setupPublishedPage' in .ts and .tsx files:"
rg 'setupPublishedPage' --glob '*.{ts,tsx}'

# Test 2: Search for potential imports of setupPublishedPage
echo "Searching for potential imports of 'setupPublishedPage':"
rg 'import.*setupPublishedPage' --glob '*.{ts,tsx}'

Length of output: 1296

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3bc73f5 and 0a18cfe.

Files selected for processing (5)
  • app/client/src/actions/pageActions.tsx (0 hunks)
  • app/client/src/ce/sagas/PageSagas.tsx (4 hunks)
  • app/client/src/ce/sagas/tests/PageSaga.test.ts (0 hunks)
  • app/client/src/entities/Engine/AppViewerEngine.ts (1 hunks)
  • app/client/src/pages/AppViewer/index.tsx (1 hunks)
Files not reviewed due to no reviewable changes (2)
  • app/client/src/actions/pageActions.tsx
  • app/client/src/ce/sagas/tests/PageSaga.test.ts
Additional comments not posted (2)
app/client/src/entities/Engine/AppViewerEngine.ts (1)

108-108: Excellent work simplifying the setupPublishedPage call!

Class, I must commend the developer for streamlining the invocation of the setupPublishedPage function. By eliminating the superfluous third argument, you have not only made the code more concise but also improved its readability. This change demonstrates a keen eye for detail and a commitment to writing clean, efficient code. Well done!

app/client/src/pages/AppViewer/index.tsx (1)

31-31: Excellent work importing the necessary action!

The fetchPublishedPageResourcesAction is imported correctly from the actions/pageActions module. This follows the best practice of placing import statements at the top of the file. Well done!

app/client/src/ce/sagas/PageSagas.tsx Show resolved Hide resolved
const canvasWidgetsPayload = getCanvasWidgetsPayload(response);

// resize main canvas
resizePublishedMainCanvasToLowestWidget(canvasWidgetsPayload.widgets);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remember to use 'yield' when calling functions inside generator functions

In the updateCanvasLayout generator function, the call to resizePublishedMainCanvasToLowestWidget should be yielded to properly handle side effects within the generator.

Apply this diff to fix the issue:

-  resizePublishedMainCanvasToLowestWidget(canvasWidgetsPayload.widgets);
+  yield call(resizePublishedMainCanvasToLowestWidget, canvasWidgetsPayload.widgets);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
resizePublishedMainCanvasToLowestWidget(canvasWidgetsPayload.widgets);
yield call(resizePublishedMainCanvasToLowestWidget, canvasWidgetsPayload.widgets);

@rishabhrathod01 rishabhrathod01 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Sep 19, 2024
@rishabhrathod01
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Query & JS Pod Issues related to the query & JS Pod Release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Eval getting triggered twice on page switch in deployed mode
1 participant