Skip to content

chore: remove redundant klona used by the reactive action flow #41089

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

Merged
merged 1 commit into from
Jul 7, 2025

Conversation

vsvamsi1
Copy link
Contributor

@vsvamsi1 vsvamsi1 commented Jul 7, 2025

Description

Removed redundant klona used by the reactive action flow.

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

Tip

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


Mon, 07 Jul 2025 11:54:41 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Refactor

    • Simplified evaluation logic by removing redundant parameters related to previous evaluation tree snapshots across evaluation and trigger handling processes.
    • Streamlined method signatures and internal calls for improved maintainability.
  • Tests

    • Updated test cases to align with refactored function signatures, removing unnecessary arguments without affecting test coverage or outcomes.

@vsvamsi1 vsvamsi1 requested a review from ApekshaBhosale as a code owner July 7, 2025 10:38
Copy link
Contributor

coderabbitai bot commented Jul 7, 2025

Walkthrough

This change removes the usage and passing of the old evaluation tree (oldEvalTree or evalTree) and its cloning from evaluation functions, handlers, and tests. Function signatures and internal calls are updated to use internal state accessors instead. No other logic, control flow, or test assertions are modified.

Changes

File(s) Change Summary
.../tests/evaluation.test.ts
.../dataTreeEvaluator.test.ts
Removed redundant passing of evalTree as argument in evalAndValidateSubTree calls in tests.
.../evalTreeWithChanges.test.ts Removed empty object literal argument from calls to evaluation functions in tests.
.../evalTreeWithChanges.ts Eliminated all references to oldEvalTree and its cloning; updated function signatures accordingly.
.../handlers/evalTree.ts
.../handlers/evalTrigger.ts
Removed import and use of klona for cloning; stopped passing old tree to evaluation functions.
.../common/DataTreeEvaluator/index.ts Removed oldEvalTree parameter from key methods; now uses internal state accessors for old values.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant DataTreeEvaluator

    Caller->>DataTreeEvaluator: evalAndValidateSubTree(evaluationOrder, configTree, unevalUpdates, metaWidgetIds)
    DataTreeEvaluator->>DataTreeEvaluator: getPrevState()
    DataTreeEvaluator-->>Caller: {evalMetaUpdates, staleMetaIds, contextTree, executeReactiveActions}
Loading

Possibly related PRs

Suggested labels

skip-changelog, ok-to-test

Suggested reviewers

  • rajatagrawal
  • dvj1988

Poem

Old trees retired, their clones set free,
No more klona, no oldEvalTree!
Function calls now slim and neat,
With signatures that can’t be beat.
The codebase lighter, tests still run—
Refactor’s done, efficiency won!
🌳✨

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@vsvamsi1 vsvamsi1 requested review from ankitakinger and sneha122 July 7, 2025 10:38
@vsvamsi1 vsvamsi1 added the ok-to-test Required label for CI label Jul 7, 2025
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jul 7, 2025
@vsvamsi1 vsvamsi1 self-assigned this Jul 7, 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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2af8ef3 and ac67b38.

📒 Files selected for processing (7)
  • app/client/src/workers/Evaluation/__tests__/evaluation.test.ts (0 hunks)
  • app/client/src/workers/Evaluation/evalTreeWithChanges.test.ts (0 hunks)
  • app/client/src/workers/Evaluation/evalTreeWithChanges.ts (0 hunks)
  • app/client/src/workers/Evaluation/handlers/evalTree.ts (0 hunks)
  • app/client/src/workers/Evaluation/handlers/evalTrigger.ts (0 hunks)
  • app/client/src/workers/common/DataTreeEvaluator/dataTreeEvaluator.test.ts (0 hunks)
  • app/client/src/workers/common/DataTreeEvaluator/index.ts (1 hunks)
💤 Files with no reviewable changes (6)
  • app/client/src/workers/Evaluation/handlers/evalTree.ts
  • app/client/src/workers/Evaluation/evalTreeWithChanges.test.ts
  • app/client/src/workers/common/DataTreeEvaluator/dataTreeEvaluator.test.ts
  • app/client/src/workers/Evaluation/tests/evaluation.test.ts
  • app/client/src/workers/Evaluation/handlers/evalTrigger.ts
  • app/client/src/workers/Evaluation/evalTreeWithChanges.ts
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: appsmithorg/appsmith#0
File: .cursor/rules/index.mdc:0-0
Timestamp: 2025-06-23T12:22:10.042Z
Learning: Pull request titles in the Appsmith codebase should follow the Conventional Commits specification, using the format 'type(scope): description' with valid types such as feat, fix, docs, style, refactor, perf, test, build, ci, chore, and revert.
Learnt from: ashit-rath
PR: appsmithorg/appsmith#33809
File: app/client/src/workers/Evaluation/evaluate.ts:31-31
Timestamp: 2024-07-26T21:12:57.228Z
Learning: User prefers to handle extensive changes like improving type safety by replacing `any` with more specific types in a separate PR to manage the scope effectively.
Learnt from: Aishwarya-U-R
PR: appsmithorg/appsmith#29405
File: app/client/cypress/e2e/Regression/ClientSide/Binding/TableV2_Widget_API_Pagination_spec.js:37-41
Timestamp: 2024-10-08T15:32:39.374Z
Learning: The pull request titled "test: Cypress | Replace static with Dynamic waits - Part 1" is part of a phased approach where only certain test specifications are targeted for static wait removal in the initial phase. Future phases will address additional specs.
Learnt from: Aishwarya-U-R
PR: appsmithorg/appsmith#29405
File: app/client/cypress/e2e/Regression/ClientSide/Binding/TableV2_Widget_API_Pagination_spec.js:37-41
Timestamp: 2024-07-26T21:12:57.228Z
Learning: The pull request titled "test: Cypress | Replace static with Dynamic waits - Part 1" is part of a phased approach where only certain test specifications are targeted for static wait removal in the initial phase. Future phases will address additional specs.
Learnt from: sneha122
PR: appsmithorg/appsmith#30012
File: app/client/src/pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx:679-682
Timestamp: 2024-10-08T15:32:34.115Z
Learning: The user `sneha122` has confirmed the resolution of the feedback regarding the redundancy of `|| false` in the `_.get` expression within the `RestAPIDatasourceForm.tsx` file.
Learnt from: sneha122
PR: appsmithorg/appsmith#30012
File: app/client/src/pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx:679-682
Timestamp: 2024-07-26T21:12:57.228Z
Learning: The user `sneha122` has confirmed the resolution of the feedback regarding the redundancy of `|| false` in the `_.get` expression within the `RestAPIDatasourceForm.tsx` file.
Learnt from: saiprabhu-dandanayak
PR: appsmithorg/appsmith#33911
File: app/client/src/api/TemplatesApi.ts:0-0
Timestamp: 2024-10-08T15:32:39.374Z
Learning: User saiprabhu-dandanayak has confirmed the removal of the `any` type in the TypeScript code for better type safety in the `TemplatesApi.ts` file.
Learnt from: saiprabhu-dandanayak
PR: appsmithorg/appsmith#33911
File: app/client/src/api/TemplatesApi.ts:0-0
Timestamp: 2024-07-26T21:12:57.228Z
Learning: User saiprabhu-dandanayak has confirmed the removal of the `any` type in the TypeScript code for better type safety in the `TemplatesApi.ts` file.
Learnt from: ashit-rath
PR: appsmithorg/appsmith#37912
File: app/client/src/git/components/QuickActions/helpers.ts:22-25
Timestamp: 2024-12-03T10:13:43.282Z
Learning: In `app/client/src/git/components/QuickActions/helpers.ts`, the unnecessary `@ts-ignore` comments will be removed in future PRs.
Learnt from: brayn003
PR: appsmithorg/appsmith#40462
File: app/client/src/instrumentation/index.ts:0-0
Timestamp: 2025-04-29T09:12:14.552Z
Learning: Only comment on files that are directly related to the PR's objectives, even if other files appear in the diff. For PR #40462, the focus is on the import override feature for artifacts, not on instrumentation or telemetry files.
Learnt from: AmanAgarwal041
PR: appsmithorg/appsmith#36539
File: app/client/src/workers/Evaluation/handlers/jsLibrary.ts:329-329
Timestamp: 2024-09-25T18:58:34.275Z
Learning: In `app/client/src/workers/Evaluation/handlers/jsLibrary.ts`, when removing keys from `self`, use `delete` to completely remove the property, as assigning `undefined` leaves the key in the object and can affect subsequent difference checks.
Learnt from: AmanAgarwal041
PR: appsmithorg/appsmith#36539
File: app/client/src/workers/Evaluation/handlers/jsLibrary.ts:329-329
Timestamp: 2024-10-08T15:32:39.374Z
Learning: In `app/client/src/workers/Evaluation/handlers/jsLibrary.ts`, when removing keys from `self`, use `delete` to completely remove the property, as assigning `undefined` leaves the key in the object and can affect subsequent difference checks.
Learnt from: ashit-rath
PR: appsmithorg/appsmith#33809
File: app/client/src/workers/common/DataTreeEvaluator/test.ts:196-196
Timestamp: 2024-07-26T21:12:57.228Z
Learning: In test cases within `DataTreeEvaluator/test.ts`, type safety is not a priority, and using `any` is acceptable for flexibility as per user ashit-rath.
Learnt from: ashit-rath
PR: appsmithorg/appsmith#33809
File: app/client/src/workers/common/DataTreeEvaluator/test.ts:196-196
Timestamp: 2024-10-08T15:32:34.115Z
Learning: In test cases within `DataTreeEvaluator/test.ts`, type safety is not a priority, and using `any` is acceptable for flexibility as per user ashit-rath.
app/client/src/workers/common/DataTreeEvaluator/index.ts (11)
Learnt from: AmanAgarwal041
PR: appsmithorg/appsmith#36539
File: app/client/src/workers/Evaluation/handlers/jsLibrary.ts:329-329
Timestamp: 2024-10-08T15:32:39.374Z
Learning: In `app/client/src/workers/Evaluation/handlers/jsLibrary.ts`, when removing keys from `self`, use `delete` to completely remove the property, as assigning `undefined` leaves the key in the object and can affect subsequent difference checks.
Learnt from: AmanAgarwal041
PR: appsmithorg/appsmith#36539
File: app/client/src/workers/Evaluation/handlers/jsLibrary.ts:329-329
Timestamp: 2024-09-25T18:58:34.275Z
Learning: In `app/client/src/workers/Evaluation/handlers/jsLibrary.ts`, when removing keys from `self`, use `delete` to completely remove the property, as assigning `undefined` leaves the key in the object and can affect subsequent difference checks.
Learnt from: ashit-rath
PR: appsmithorg/appsmith#33809
File: app/client/src/workers/common/DataTreeEvaluator/test.ts:196-196
Timestamp: 2024-07-26T21:12:57.228Z
Learning: In test cases within `DataTreeEvaluator/test.ts`, type safety is not a priority, and using `any` is acceptable for flexibility as per user ashit-rath.
Learnt from: ashit-rath
PR: appsmithorg/appsmith#33809
File: app/client/src/workers/common/DataTreeEvaluator/test.ts:196-196
Timestamp: 2024-10-08T15:32:34.115Z
Learning: In test cases within `DataTreeEvaluator/test.ts`, type safety is not a priority, and using `any` is acceptable for flexibility as per user ashit-rath.
Learnt from: saiprabhu-dandanayak
PR: appsmithorg/appsmith#33911
File: app/client/src/api/TemplatesApi.ts:0-0
Timestamp: 2024-10-08T15:32:39.374Z
Learning: User saiprabhu-dandanayak has confirmed the removal of the `any` type in the TypeScript code for better type safety in the `TemplatesApi.ts` file.
Learnt from: saiprabhu-dandanayak
PR: appsmithorg/appsmith#33911
File: app/client/src/api/TemplatesApi.ts:0-0
Timestamp: 2024-07-26T21:12:57.228Z
Learning: User saiprabhu-dandanayak has confirmed the removal of the `any` type in the TypeScript code for better type safety in the `TemplatesApi.ts` file.
Learnt from: sharat87
PR: appsmithorg/appsmith#37715
File: app/client/packages/rts/src/ctl/backup/BackupState.ts:4-11
Timestamp: 2024-11-28T07:23:54.455Z
Learning: In the `BackupState` class in `app/client/packages/rts/src/ctl/backup/BackupState.ts`, validation for `backupRootPath` and `archivePath` properties is unnecessary because users don't have influence over these values.
Learnt from: ashit-rath
PR: appsmithorg/appsmith#37912
File: app/client/src/git/components/QuickActions/helpers.ts:22-25
Timestamp: 2024-12-03T10:13:43.282Z
Learning: In `app/client/src/git/components/QuickActions/helpers.ts`, the unnecessary `@ts-ignore` comments will be removed in future PRs.
Learnt from: riodeuno
PR: appsmithorg/appsmith#33070
File: app/client/src/layoutSystems/anvil/integrations/sagas/anvilWidgetSelectionSaga.ts:94-103
Timestamp: 2024-07-26T21:12:57.228Z
Learning: The `getErrorPropertyPath` function in `anvilWidgetSelectionSaga.ts` includes a temporary fix to handle cases where no errors are found by returning an empty string. This is planned to be removed in the future.
Learnt from: riodeuno
PR: appsmithorg/appsmith#33070
File: app/client/src/layoutSystems/anvil/integrations/sagas/anvilWidgetSelectionSaga.ts:94-103
Timestamp: 2024-10-08T15:32:34.115Z
Learning: The `getErrorPropertyPath` function in `anvilWidgetSelectionSaga.ts` includes a temporary fix to handle cases where no errors are found by returning an empty string. This is planned to be removed in the future.
Learnt from: ankitakinger
PR: appsmithorg/appsmith#29573
File: app/client/src/pages/Editor/Explorer/Entity/EntityProperties.tsx:46-65
Timestamp: 2024-07-26T21:12:57.228Z
Learning: The use of `any` for the `entityProperties` parameter in the `getJSActionBindings` function within `EntityProperties.tsx` is intentional and should not be suggested for refactoring to improve type safety.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build

Comment on lines 1319 to 1324
if (!propertyPath) continue;

// Get old value from oldEvalTree for comparison
const oldValue = get(oldEvalTree, fullPropertyPath);
const oldValue = get(this.getPrevState(), fullPropertyPath);

switch (entityType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

prevState is compared by reference – risk of always-equal matches

oldValue now comes from this.getPrevState(), but setPrevState() stores the incoming object without cloning.
Because the same object reference can later be mutated in-place during evaluation, oldValue !== parsedValue may never register, silently skipping valuechanged updates and downstream reactive flows.

-  setPrevState(state: any) {
-    this.prevState = state;
+  setPrevState(state: DataTree) {
+    // deep-clone to break shared references
+    this.prevState = klonaJSON(state);
   }

Confirm every caller of setPrevState passes the tree before any mutation and that it is invoked on every evaluation cycle; otherwise comparisons here will be unreliable.
Failing to fix this can cause widgets/actions to miss updates, leading to stale UI and hard-to-debug reactive bugs.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In app/client/src/workers/common/DataTreeEvaluator/index.ts around lines 1319 to
1324, the oldValue is obtained from this.getPrevState(), but setPrevState()
stores the state object by reference without cloning, causing mutations to
affect both current and previous states and making comparisons unreliable. To
fix this, ensure that setPrevState() clones the incoming state object deeply
before storing it, so that oldValue reflects an immutable snapshot of the
previous state and value change comparisons work correctly.

@vsvamsi1 vsvamsi1 merged commit b2bab20 into release Jul 7, 2025
88 checks passed
@vsvamsi1 vsvamsi1 deleted the test81 branch July 7, 2025 12:00
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants