Skip to content

chore: apply updates back to the prevState#40184

Closed
vsvamsi1 wants to merge 2 commits intoreleasefrom
test74
Closed

chore: apply updates back to the prevState#40184
vsvamsi1 wants to merge 2 commits intoreleasefrom
test74

Conversation

@vsvamsi1
Copy link
Contributor

@vsvamsi1 vsvamsi1 commented Apr 9, 2025

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

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

🔍 Cypress test results

Caution

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

  1. cypress/e2e/Regression/ClientSide/Widgets/JSONForm/JSONForm_FieldChange_spec.js
List of identified flaky tests.
Wed, 09 Apr 2025 16:57:28 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced the application’s update process to deliver more consistent and reliable performance during iterative changes.
    • Improved error handling now captures and applies state differences more efficiently.
  • Refactor

    • Streamlined the logic for processing dynamic updates, ensuring smoother and more robust state management during active usage.

@vsvamsi1 vsvamsi1 added the ok-to-test Required label for CI label Apr 9, 2025
@vsvamsi1 vsvamsi1 requested a review from ApekshaBhosale as a code owner April 9, 2025 06:46
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 9, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request refactors the evaluation process for the data tree. It introduces an isUpdateCycle flag and leverages the mutative library’s create function to generate a draft state for updates. The evalTree function and related helpers now handle state updates and error tracking more explicitly. Additionally, a new method in the data tree evaluator is added to perform optimized state updates based on whether the evaluation is part of an update cycle.

Changes

File(s) Summary
app/.../handlers/evalTree.ts, app/.../helpers.ts Introduced an isUpdateCycle flag, replaced the previous state construction with a mutative draft using create, updated update generation functions to return raw diffs and handle errors, and modified function signatures to conditionally process state updates.
app/.../DataTreeEvaluator/index.ts Integrated the isUpdateCycle flag into the evaluation flow and added a new method generateOptimisedUpdatesAndSetPrevState to apply updates directly to the previous state based on the evaluation cycle status.

Sequence Diagram(s)

sequenceDiagram
    participant ET as evalTree
    participant H as Helpers
    participant D as DataTreeEvaluator

    ET->>ET: Initialize isUpdateCycle = false
    ET->>ET: Evaluate data tree properties
    alt Update cycle detected
        ET->>ET: Set isUpdateCycle = true
        ET->>H: Create draft state with `create`
        H-->>ET: Return serialised updates & raw diffs
        ET->>H: Call generateOptimisedUpdatesAndSetPrevState(isUpdateCycle)
        H-->>ET: Return updated previous state
    end
    ET->>D: Update data tree meta and state
    D-->>ET: Return final updated state
    ET->>ET: Reset isUpdateCycle = false
Loading

Possibly related PRs

Suggested labels

skip-changelog, Needs Triaging

Suggested reviewers

  • rajatagrawal
  • dvj1988

Poem

In the realm of code where changes gleam,
A flag is born to mark the stream.
With drafts of state and updates clear,
The tree evolves with every gear.
Code flows on like a joyous rhyme—
A fresh update cycle, sublime!
🚀✨


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

@vsvamsi1 vsvamsi1 marked this pull request as draft April 9, 2025 06:46
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Apr 9, 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/workers/Evaluation/helpers.ts (1)

457-463: New block updating prevState immutably.
Using create provides a simpler way to patch the draft. Consider performance implications if data trees are large.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between af2f442 and 32a8052.

📒 Files selected for processing (3)
  • app/client/src/workers/Evaluation/handlers/evalTree.ts (6 hunks)
  • app/client/src/workers/Evaluation/helpers.ts (5 hunks)
  • app/client/src/workers/common/DataTreeEvaluator/index.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • 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-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (14)
app/client/src/workers/Evaluation/handlers/evalTree.ts (6)

4-4: Fine import addition.
No issues with adding set from lodash.


35-35: Validate library support.
create from mutative is introduced. Verify that compatibility and licensing align with project requirements.


95-95: Descriptive variable naming.
Establishing isUpdateCycle to track evaluation cycles is clear and self-documenting.


194-194: Confirm resetting logic.
Setting isUpdateCycle = true here works, but ensure cleanup or reset occurs reliably to avoid confusion in subsequent calls.


248-257: Verify entity existence before assignment.
When creating a new draft, confirm that draft[entityName] is never undefined; otherwise, set may throw if the entity is missing.


346-346: Proper cleanup.
Resetting isUpdateCycle to false ensures the next cycle isn't incorrectly marked as an update.

app/client/src/workers/common/DataTreeEvaluator/index.ts (3)

1134-1136: Succinct introduction of update-cycle awareness.
Declaring isUpdateCycle = !isFirstTree; is a straightforward way to distinguish initial vs. subsequent evaluations.


1428-1436: Clean invocation of state-updating method.
Passing isUpdateCycle into generateOptimisedUpdatesAndSetPrevState cleanly segregates first-tree and update-cycle logic.


1967-2011: Check for missing or invalid paths in meta updates.
The new generateOptimisedUpdatesAndSetPrevState method updates previous state based on metaPropertyPath and widgetId. Ensure these fields are valid to avoid unexpected undefined assignments.

app/client/src/workers/Evaluation/helpers.ts (5)

4-4: Helpful addition of applyChange.
No concerns with importing applyChange and diff for deeper functionality.


10-10: Validate usage of create.
As with other files, confirm environment and licensing considerations for mutative.


403-403: Clearer typing.
Declaring updates: Diff<DataTree, DataTree>[] clarifies return expectations and offers improved type safety.


445-445: Optional parameter usage.
isUpdateCycle?: boolean is a convenient solution, but confirm call sites handle the undefined case correctly.


464-467: Straightforward fallback.
Retaining existing behavior when isUpdateCycle is false is unobjectionable and maintains clarity.

@vsvamsi1
Copy link
Contributor Author

vsvamsi1 commented Apr 9, 2025

/build-deploy-preview skip-tests=true

@github-actions
Copy link

github-actions bot commented Apr 9, 2025

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

@github-actions
Copy link

github-actions bot commented Apr 9, 2025

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

@vsvamsi1
Copy link
Contributor Author

vsvamsi1 commented Apr 9, 2025

/build-deploy-preview skip-tests=true

@github-actions
Copy link

github-actions bot commented Apr 9, 2025

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

@github-actions
Copy link

github-actions bot commented Apr 9, 2025

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

@vsvamsi1
Copy link
Contributor Author

vsvamsi1 commented Apr 9, 2025

/build-deploy-preview env=release

@github-actions
Copy link

github-actions bot commented Apr 9, 2025

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

@github-actions
Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Apr 17, 2025
@github-actions
Copy link

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Apr 24, 2025
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 Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant