PromucFlow_constructor/app/client/src/workers/Evaluation/evalTreeWithChanges.ts

175 lines
5.1 KiB
TypeScript
Raw Normal View History

feat: JSObject variable as a state (JSObject variable mutation) (#19926) Fixes #19653 Fixes #14568 Fixes #17199 Fixes #14989 In this PR, we introduce a new feature in JSObject where the `variables` are now state and widgets are reactive to the change in the variable value. - It means that `JSObject.myVar1 = "Hello world"` would show `Hello world` where ever a binding `{{JSObject.myVar1}}` is used. Further changes - JSObject run functionality, executes all the functions in async evaluation. - `executeSyncJS` flow is removed - `resolvedFunctions` state is moved to JSCollection class. - unEval JSObject value i.e., currentJSCollectionState is moved to JSCollection class. - `evalTreeWithChanges` is introduced - A new flow to trigger evaluation from the worker and send the updated dataTree to mainThread. - This would open up a new possibility of features in evaluation mentioned [here](https://www.notion.so/appsmith/RFC-Dependent-Property-in-Widgets-f3b29ad652b549dd8c49189f48dbbc4b) - Introduction of `updateDataTreeHandler` to accept new dataTree from the worker. ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Jest Test - `Mutation.test.ts` - `JSVariableProxy.test.ts` - `removeProxy.test.ts` ### Cypress test - Mutation with - numbers - array - object - map - set ### Test Plan - https://github.com/appsmithorg/TestSmith/issues/2186 ### Issues raised during DP testing - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1453275688 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1478975487 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1482929425 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1486611858 Co-authored-by: Rimil Dey <rimildeyjsr@gmail.com> Co-authored-by: Rimil Dey <rimil@appsmith.com> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
2023-04-07 07:41:36 +00:00
import { dataTreeEvaluator } from "./handlers/evalTree";
import type { EvalMetaUpdates } from "@appsmith/workers/common/DataTreeEvaluator/types";
import { makeEntityConfigsAsObjProperties } from "@appsmith/workers/Evaluation/dataTreeUtils";
chore: Add evalTreeWithDiff to evalWorkerAction (#34403) ## Description These changes add evalTreeWithDiff to evalWorkerAction. Using this method it will be possible to send the unevalTree and configTree updates from mainThread to trigger evaluation. - This will skip diffing complete unEvaltree ### Next steps after this PR - [ ] Rename EvalTreeWithChanges to evalTreeWithDiff - [ ] Generate Diff instead of updatedValuePaths for the current evalTreeWithChanges references. - [ ] Handle evalTreeWithDiff for - [ ] JSObject updates - [ ] updateDependencyMap Fixes # ## Automation /test js ### :mag: 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/9684706533> > Commit: 3de988af5da9900f4e589a008d28296d05d17f25 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9684706533&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced widget evaluation logic and improved handling of dynamic bindings and dependencies. - **Bug Fixes** - Corrected type handling in various evaluation functions to improve stability and accuracy. - **Tests** - Updated test cases for widget property setters to include additional tags for better categorization. - **Refactor** - Streamlined function signatures and improved type safety across evaluation utilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-27 06:38:53 +00:00
import type {
EvalTreeResponseData,
EvalWorkerSyncRequest,
UpdateTreeResponse,
} from "./types";
feat: JSObject variable as a state (JSObject variable mutation) (#19926) Fixes #19653 Fixes #14568 Fixes #17199 Fixes #14989 In this PR, we introduce a new feature in JSObject where the `variables` are now state and widgets are reactive to the change in the variable value. - It means that `JSObject.myVar1 = "Hello world"` would show `Hello world` where ever a binding `{{JSObject.myVar1}}` is used. Further changes - JSObject run functionality, executes all the functions in async evaluation. - `executeSyncJS` flow is removed - `resolvedFunctions` state is moved to JSCollection class. - unEval JSObject value i.e., currentJSCollectionState is moved to JSCollection class. - `evalTreeWithChanges` is introduced - A new flow to trigger evaluation from the worker and send the updated dataTree to mainThread. - This would open up a new possibility of features in evaluation mentioned [here](https://www.notion.so/appsmith/RFC-Dependent-Property-in-Widgets-f3b29ad652b549dd8c49189f48dbbc4b) - Introduction of `updateDataTreeHandler` to accept new dataTree from the worker. ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Jest Test - `Mutation.test.ts` - `JSVariableProxy.test.ts` - `removeProxy.test.ts` ### Cypress test - Mutation with - numbers - array - object - map - set ### Test Plan - https://github.com/appsmithorg/TestSmith/issues/2186 ### Issues raised during DP testing - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1453275688 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1478975487 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1482929425 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1486611858 Co-authored-by: Rimil Dey <rimildeyjsr@gmail.com> Co-authored-by: Rimil Dey <rimil@appsmith.com> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
2023-04-07 07:41:36 +00:00
import { MessageType, sendMessage } from "utils/MessageUtil";
import { MAIN_THREAD_ACTION } from "@appsmith/workers/Evaluation/evalWorkerActions";
import type { UpdateDataTreeMessageData } from "sagas/EvalWorkerActionSagas";
feat: constrained diff between states (#31847) ## Description We are constraining the diff between the old dataTree and the newDataTree to its only affected nodes. The affected nodes list is the evalOrder, unevalUpdates and updatedValuePaths (which represents localStorage and setter updates). Through limiting the diff to the affected node list this should help in reducing the diff computation latency and overall improve the performance of each evaluation cycle. We are also cleaning up code related to compressing and decompressing updates since we deprecated that functionality. Fixes #31272 ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!IMPORTANT] > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/8447023192> > Commit: `cb925afbb99577947fbc7233a35e4454223b402a` > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8447023192&attempt=2" target="_blank">Click here!</a> > All cypress tests have passed 🎉🎉🎉 <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new logic for handling widget state updates efficiently. - Enhanced evaluation logic to support optimized diff updates and serialization. - Improved data tree generation for error handling and evaluation order. - **Bug Fixes** - Addressed issues in generating optimized updates for large collections and handling `undefined` values. - Fixed Cypress tests in the "PgAdmin Clone App" spec for more reliable interaction with UI elements. - **Refactor** - Simplified the logic for widget state cleanup and evaluation paths handling. - Removed unused variables and functions related to widget meta properties and evaluation paths. - **Tests** - Added new spec file `PgAdmin_spec.js` to Cypress limited tests for client-side regression testing. - **Chores** - Updated type imports across various files to reflect changes in evaluation logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-03-27 09:07:46 +00:00
import {
generateOptimisedUpdatesAndSetPrevState,
getNewDataTreeUpdates,
uniqueOrderUpdatePaths,
} from "./helpers";
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
import type { DataTreeDiff } from "@appsmith/workers/Evaluation/evaluationUtils";
chore: Add evalTreeWithDiff to evalWorkerAction (#34403) ## Description These changes add evalTreeWithDiff to evalWorkerAction. Using this method it will be possible to send the unevalTree and configTree updates from mainThread to trigger evaluation. - This will skip diffing complete unEvaltree ### Next steps after this PR - [ ] Rename EvalTreeWithChanges to evalTreeWithDiff - [ ] Generate Diff instead of updatedValuePaths for the current evalTreeWithChanges references. - [ ] Handle evalTreeWithDiff for - [ ] JSObject updates - [ ] updateDependencyMap Fixes # ## Automation /test js ### :mag: 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/9684706533> > Commit: 3de988af5da9900f4e589a008d28296d05d17f25 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9684706533&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced widget evaluation logic and improved handling of dynamic bindings and dependencies. - **Bug Fixes** - Corrected type handling in various evaluation functions to improve stability and accuracy. - **Tests** - Updated test cases for widget property setters to include additional tags for better categorization. - **Refactor** - Streamlined function signatures and improved type safety across evaluation utilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-27 06:38:53 +00:00
import type DataTreeEvaluator from "workers/common/DataTreeEvaluator";
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
const getDefaultEvalResponse = (): EvalTreeResponseData => ({
updates: "[]",
dependencies: {},
errors: [],
evalMetaUpdates: [],
evaluationOrder: [],
jsUpdates: {},
logs: [],
unEvalUpdates: [],
isCreateFirstTree: false,
staleMetaIds: [],
removedPaths: [],
isNewWidgetAdded: false,
undefinedEvalValuesMap: {},
jsVarsCreatedEvent: [],
});
feat: JSObject variable as a state (JSObject variable mutation) (#19926) Fixes #19653 Fixes #14568 Fixes #17199 Fixes #14989 In this PR, we introduce a new feature in JSObject where the `variables` are now state and widgets are reactive to the change in the variable value. - It means that `JSObject.myVar1 = "Hello world"` would show `Hello world` where ever a binding `{{JSObject.myVar1}}` is used. Further changes - JSObject run functionality, executes all the functions in async evaluation. - `executeSyncJS` flow is removed - `resolvedFunctions` state is moved to JSCollection class. - unEval JSObject value i.e., currentJSCollectionState is moved to JSCollection class. - `evalTreeWithChanges` is introduced - A new flow to trigger evaluation from the worker and send the updated dataTree to mainThread. - This would open up a new possibility of features in evaluation mentioned [here](https://www.notion.so/appsmith/RFC-Dependent-Property-in-Widgets-f3b29ad652b549dd8c49189f48dbbc4b) - Introduction of `updateDataTreeHandler` to accept new dataTree from the worker. ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Jest Test - `Mutation.test.ts` - `JSVariableProxy.test.ts` - `removeProxy.test.ts` ### Cypress test - Mutation with - numbers - array - object - map - set ### Test Plan - https://github.com/appsmithorg/TestSmith/issues/2186 ### Issues raised during DP testing - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1453275688 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1478975487 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1482929425 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1486611858 Co-authored-by: Rimil Dey <rimildeyjsr@gmail.com> Co-authored-by: Rimil Dey <rimil@appsmith.com> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
2023-04-07 07:41:36 +00:00
feat: widget property setters (#23441) ## Description - This PR adds setter methods to update widget property programmatically. Example:- `Input1.setText("setter methods are cool!");` Docs link : https://docs.appsmith.com/reference/widgets For any selected widget check the `Methods` section #### PR fixes following issue(s) Fixes #### Type of change - New feature (non-breaking change which adds functionality) ## Testing > #### How Has This Been Tested? - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan https://github.com/appsmithorg/TestSmith/issues/2409 #### Issues raised during DP testing - [x] [Errors are not logged in the debugger](https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1564017346) separate GitHub issue https://github.com/appsmithorg/appsmith/issues/24609 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1564155545 ( `setVisibility("false")` ) - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1580525843 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1576582825 - Blocker for testing - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1577956441 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1577930108 - Not a issue (lint error query) - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1593471791 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1591440488 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1586747864 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1596738201 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1598541537 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1611413076 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1612621567 - [ ] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1619654507 - [ ] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1621256722 > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [x] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [x] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Rishabh Rathod <rishabh.rathod@appsmith.com>
2023-07-08 14:07:26 +00:00
export function evalTreeWithChanges(
chore: Add evalTreeWithDiff to evalWorkerAction (#34403) ## Description These changes add evalTreeWithDiff to evalWorkerAction. Using this method it will be possible to send the unevalTree and configTree updates from mainThread to trigger evaluation. - This will skip diffing complete unEvaltree ### Next steps after this PR - [ ] Rename EvalTreeWithChanges to evalTreeWithDiff - [ ] Generate Diff instead of updatedValuePaths for the current evalTreeWithChanges references. - [ ] Handle evalTreeWithDiff for - [ ] JSObject updates - [ ] updateDependencyMap Fixes # ## Automation /test js ### :mag: 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/9684706533> > Commit: 3de988af5da9900f4e589a008d28296d05d17f25 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9684706533&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced widget evaluation logic and improved handling of dynamic bindings and dependencies. - **Bug Fixes** - Corrected type handling in various evaluation functions to improve stability and accuracy. - **Tests** - Updated test cases for widget property setters to include additional tags for better categorization. - **Refactor** - Streamlined function signatures and improved type safety across evaluation utilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-27 06:38:53 +00:00
request: EvalWorkerSyncRequest<{
metaUpdates?: EvalMetaUpdates;
updatedValuePaths: string[][];
}>,
feat: widget property setters (#23441) ## Description - This PR adds setter methods to update widget property programmatically. Example:- `Input1.setText("setter methods are cool!");` Docs link : https://docs.appsmith.com/reference/widgets For any selected widget check the `Methods` section #### PR fixes following issue(s) Fixes #### Type of change - New feature (non-breaking change which adds functionality) ## Testing > #### How Has This Been Tested? - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan https://github.com/appsmithorg/TestSmith/issues/2409 #### Issues raised during DP testing - [x] [Errors are not logged in the debugger](https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1564017346) separate GitHub issue https://github.com/appsmithorg/appsmith/issues/24609 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1564155545 ( `setVisibility("false")` ) - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1580525843 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1576582825 - Blocker for testing - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1577956441 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1577930108 - Not a issue (lint error query) - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1593471791 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1591440488 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1586747864 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1596738201 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1598541537 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1611413076 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1612621567 - [ ] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1619654507 - [ ] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1621256722 > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [x] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [x] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Rishabh Rathod <rishabh.rathod@appsmith.com>
2023-07-08 14:07:26 +00:00
) {
chore: Add evalTreeWithDiff to evalWorkerAction (#34403) ## Description These changes add evalTreeWithDiff to evalWorkerAction. Using this method it will be possible to send the unevalTree and configTree updates from mainThread to trigger evaluation. - This will skip diffing complete unEvaltree ### Next steps after this PR - [ ] Rename EvalTreeWithChanges to evalTreeWithDiff - [ ] Generate Diff instead of updatedValuePaths for the current evalTreeWithChanges references. - [ ] Handle evalTreeWithDiff for - [ ] JSObject updates - [ ] updateDependencyMap Fixes # ## Automation /test js ### :mag: 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/9684706533> > Commit: 3de988af5da9900f4e589a008d28296d05d17f25 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9684706533&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced widget evaluation logic and improved handling of dynamic bindings and dependencies. - **Bug Fixes** - Corrected type handling in various evaluation functions to improve stability and accuracy. - **Tests** - Updated test cases for widget property setters to include additional tags for better categorization. - **Refactor** - Streamlined function signatures and improved type safety across evaluation utilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-27 06:38:53 +00:00
const { data } = request;
const { metaUpdates = [], updatedValuePaths } = data;
const pathsToSkipFromEval = updatedValuePaths.map((path) => path.join("."));
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
let setupUpdateTreeResponse = {} as UpdateTreeResponse;
feat: JSObject variable as a state (JSObject variable mutation) (#19926) Fixes #19653 Fixes #14568 Fixes #17199 Fixes #14989 In this PR, we introduce a new feature in JSObject where the `variables` are now state and widgets are reactive to the change in the variable value. - It means that `JSObject.myVar1 = "Hello world"` would show `Hello world` where ever a binding `{{JSObject.myVar1}}` is used. Further changes - JSObject run functionality, executes all the functions in async evaluation. - `executeSyncJS` flow is removed - `resolvedFunctions` state is moved to JSCollection class. - unEval JSObject value i.e., currentJSCollectionState is moved to JSCollection class. - `evalTreeWithChanges` is introduced - A new flow to trigger evaluation from the worker and send the updated dataTree to mainThread. - This would open up a new possibility of features in evaluation mentioned [here](https://www.notion.so/appsmith/RFC-Dependent-Property-in-Widgets-f3b29ad652b549dd8c49189f48dbbc4b) - Introduction of `updateDataTreeHandler` to accept new dataTree from the worker. ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Jest Test - `Mutation.test.ts` - `JSVariableProxy.test.ts` - `removeProxy.test.ts` ### Cypress test - Mutation with - numbers - array - object - map - set ### Test Plan - https://github.com/appsmithorg/TestSmith/issues/2186 ### Issues raised during DP testing - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1453275688 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1478975487 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1482929425 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1486611858 Co-authored-by: Rimil Dey <rimildeyjsr@gmail.com> Co-authored-by: Rimil Dey <rimil@appsmith.com> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
2023-04-07 07:41:36 +00:00
if (dataTreeEvaluator) {
chore: Add evalTreeWithDiff to evalWorkerAction (#34403) ## Description These changes add evalTreeWithDiff to evalWorkerAction. Using this method it will be possible to send the unevalTree and configTree updates from mainThread to trigger evaluation. - This will skip diffing complete unEvaltree ### Next steps after this PR - [ ] Rename EvalTreeWithChanges to evalTreeWithDiff - [ ] Generate Diff instead of updatedValuePaths for the current evalTreeWithChanges references. - [ ] Handle evalTreeWithDiff for - [ ] JSObject updates - [ ] updateDependencyMap Fixes # ## Automation /test js ### :mag: 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/9684706533> > Commit: 3de988af5da9900f4e589a008d28296d05d17f25 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9684706533&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced widget evaluation logic and improved handling of dynamic bindings and dependencies. - **Bug Fixes** - Corrected type handling in various evaluation functions to improve stability and accuracy. - **Tests** - Updated test cases for widget property setters to include additional tags for better categorization. - **Refactor** - Streamlined function signatures and improved type safety across evaluation utilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-27 06:38:53 +00:00
setupUpdateTreeResponse = dataTreeEvaluator.setupUpdateTreeWithDifferences(
updatedValuePaths,
pathsToSkipFromEval,
);
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
}
feat: JSObject variable as a state (JSObject variable mutation) (#19926) Fixes #19653 Fixes #14568 Fixes #17199 Fixes #14989 In this PR, we introduce a new feature in JSObject where the `variables` are now state and widgets are reactive to the change in the variable value. - It means that `JSObject.myVar1 = "Hello world"` would show `Hello world` where ever a binding `{{JSObject.myVar1}}` is used. Further changes - JSObject run functionality, executes all the functions in async evaluation. - `executeSyncJS` flow is removed - `resolvedFunctions` state is moved to JSCollection class. - unEval JSObject value i.e., currentJSCollectionState is moved to JSCollection class. - `evalTreeWithChanges` is introduced - A new flow to trigger evaluation from the worker and send the updated dataTree to mainThread. - This would open up a new possibility of features in evaluation mentioned [here](https://www.notion.so/appsmith/RFC-Dependent-Property-in-Widgets-f3b29ad652b549dd8c49189f48dbbc4b) - Introduction of `updateDataTreeHandler` to accept new dataTree from the worker. ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Jest Test - `Mutation.test.ts` - `JSVariableProxy.test.ts` - `removeProxy.test.ts` ### Cypress test - Mutation with - numbers - array - object - map - set ### Test Plan - https://github.com/appsmithorg/TestSmith/issues/2186 ### Issues raised during DP testing - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1453275688 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1478975487 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1482929425 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1486611858 Co-authored-by: Rimil Dey <rimildeyjsr@gmail.com> Co-authored-by: Rimil Dey <rimil@appsmith.com> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
2023-04-07 07:41:36 +00:00
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
evaluateAndPushResponse(
dataTreeEvaluator,
setupUpdateTreeResponse,
metaUpdates,
chore: Add evalTreeWithDiff to evalWorkerAction (#34403) ## Description These changes add evalTreeWithDiff to evalWorkerAction. Using this method it will be possible to send the unevalTree and configTree updates from mainThread to trigger evaluation. - This will skip diffing complete unEvaltree ### Next steps after this PR - [ ] Rename EvalTreeWithChanges to evalTreeWithDiff - [ ] Generate Diff instead of updatedValuePaths for the current evalTreeWithChanges references. - [ ] Handle evalTreeWithDiff for - [ ] JSObject updates - [ ] updateDependencyMap Fixes # ## Automation /test js ### :mag: 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/9684706533> > Commit: 3de988af5da9900f4e589a008d28296d05d17f25 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9684706533&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced widget evaluation logic and improved handling of dynamic bindings and dependencies. - **Bug Fixes** - Corrected type handling in various evaluation functions to improve stability and accuracy. - **Tests** - Updated test cases for widget property setters to include additional tags for better categorization. - **Refactor** - Streamlined function signatures and improved type safety across evaluation utilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-27 06:38:53 +00:00
pathsToSkipFromEval,
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
);
}
feat: widget property setters (#23441) ## Description - This PR adds setter methods to update widget property programmatically. Example:- `Input1.setText("setter methods are cool!");` Docs link : https://docs.appsmith.com/reference/widgets For any selected widget check the `Methods` section #### PR fixes following issue(s) Fixes #### Type of change - New feature (non-breaking change which adds functionality) ## Testing > #### How Has This Been Tested? - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan https://github.com/appsmithorg/TestSmith/issues/2409 #### Issues raised during DP testing - [x] [Errors are not logged in the debugger](https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1564017346) separate GitHub issue https://github.com/appsmithorg/appsmith/issues/24609 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1564155545 ( `setVisibility("false")` ) - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1580525843 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1576582825 - Blocker for testing - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1577956441 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1577930108 - Not a issue (lint error query) - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1593471791 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1591440488 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1586747864 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1596738201 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1598541537 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1611413076 - [x] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1612621567 - [ ] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1619654507 - [ ] https://github.com/appsmithorg/appsmith/pull/23441#issuecomment-1621256722 > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [x] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [x] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Rishabh Rathod <rishabh.rathod@appsmith.com>
2023-07-08 14:07:26 +00:00
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
export const getAffectedNodesInTheDataTree = (
unEvalUpdates: DataTreeDiff[],
evalOrder: string[],
) => {
feat: constrained diff between states (#31847) ## Description We are constraining the diff between the old dataTree and the newDataTree to its only affected nodes. The affected nodes list is the evalOrder, unevalUpdates and updatedValuePaths (which represents localStorage and setter updates). Through limiting the diff to the affected node list this should help in reducing the diff computation latency and overall improve the performance of each evaluation cycle. We are also cleaning up code related to compressing and decompressing updates since we deprecated that functionality. Fixes #31272 ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!IMPORTANT] > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/8447023192> > Commit: `cb925afbb99577947fbc7233a35e4454223b402a` > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8447023192&attempt=2" target="_blank">Click here!</a> > All cypress tests have passed 🎉🎉🎉 <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new logic for handling widget state updates efficiently. - Enhanced evaluation logic to support optimized diff updates and serialization. - Improved data tree generation for error handling and evaluation order. - **Bug Fixes** - Addressed issues in generating optimized updates for large collections and handling `undefined` values. - Fixed Cypress tests in the "PgAdmin Clone App" spec for more reliable interaction with UI elements. - **Refactor** - Simplified the logic for widget state cleanup and evaluation paths handling. - Removed unused variables and functions related to widget meta properties and evaluation paths. - **Tests** - Added new spec file `PgAdmin_spec.js` to Cypress limited tests for client-side regression testing. - **Chores** - Updated type imports across various files to reflect changes in evaluation logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-03-27 09:07:46 +00:00
const allUnevalUpdates = unEvalUpdates.map(
(update) => update.payload.propertyPath,
);
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
// merge unevalUpdate paths and evalOrder paths
return uniqueOrderUpdatePaths([...allUnevalUpdates, ...evalOrder]);
};
feat: constrained diff between states (#31847) ## Description We are constraining the diff between the old dataTree and the newDataTree to its only affected nodes. The affected nodes list is the evalOrder, unevalUpdates and updatedValuePaths (which represents localStorage and setter updates). Through limiting the diff to the affected node list this should help in reducing the diff computation latency and overall improve the performance of each evaluation cycle. We are also cleaning up code related to compressing and decompressing updates since we deprecated that functionality. Fixes #31272 ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!IMPORTANT] > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/8447023192> > Commit: `cb925afbb99577947fbc7233a35e4454223b402a` > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8447023192&attempt=2" target="_blank">Click here!</a> > All cypress tests have passed 🎉🎉🎉 <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new logic for handling widget state updates efficiently. - Enhanced evaluation logic to support optimized diff updates and serialization. - Improved data tree generation for error handling and evaluation order. - **Bug Fixes** - Addressed issues in generating optimized updates for large collections and handling `undefined` values. - Fixed Cypress tests in the "PgAdmin Clone App" spec for more reliable interaction with UI elements. - **Refactor** - Simplified the logic for widget state cleanup and evaluation paths handling. - Removed unused variables and functions related to widget meta properties and evaluation paths. - **Tests** - Added new spec file `PgAdmin_spec.js` to Cypress limited tests for client-side regression testing. - **Chores** - Updated type imports across various files to reflect changes in evaluation logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-03-27 09:07:46 +00:00
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
export const evaluateAndPushResponse = (
dataTreeEvaluator: DataTreeEvaluator | undefined,
setupUpdateTreeResponse: UpdateTreeResponse,
metaUpdates: EvalMetaUpdates,
additionalPathsAddedAsUpdates: string[],
) => {
const response = evaluateAndGenerateResponse(
dataTreeEvaluator,
setupUpdateTreeResponse,
metaUpdates,
additionalPathsAddedAsUpdates,
);
return pushResponseToMainThread(response);
};
export const evaluateAndGenerateResponse = (
dataTreeEvaluator: DataTreeEvaluator | undefined,
setupUpdateTreeResponse: UpdateTreeResponse,
metaUpdates: EvalMetaUpdates,
additionalPathsAddedAsUpdates: string[],
): UpdateDataTreeMessageData => {
// generate default response first and later add updates to it
const defaultResponse = getDefaultEvalResponse();
if (!dataTreeEvaluator) {
const updates = generateOptimisedUpdatesAndSetPrevState(
{},
dataTreeEvaluator,
[],
);
defaultResponse.updates = updates;
defaultResponse.evalMetaUpdates = [...(metaUpdates || [])];
return {
workerResponse: defaultResponse,
unevalTree: {},
};
}
const { evalOrder, jsUpdates, unEvalUpdates } = setupUpdateTreeResponse;
defaultResponse.evaluationOrder = evalOrder;
defaultResponse.unEvalUpdates = unEvalUpdates;
defaultResponse.jsUpdates = jsUpdates;
const updateResponse = dataTreeEvaluator.evalAndValidateSubTree(
evalOrder,
dataTreeEvaluator.oldConfigTree,
unEvalUpdates,
);
const dataTree = makeEntityConfigsAsObjProperties(
dataTreeEvaluator.evalTree,
{
evalProps: dataTreeEvaluator.evalProps,
},
);
/** Make sure evalMetaUpdates is sanitized to prevent postMessage failure */
defaultResponse.evalMetaUpdates = JSON.parse(
JSON.stringify([...(metaUpdates || []), ...updateResponse.evalMetaUpdates]),
);
defaultResponse.staleMetaIds = updateResponse.staleMetaIds;
const unevalTree = dataTreeEvaluator.getOldUnevalTree();
// when additional paths are required to be added as updates, we extract the updates from the data tree using these paths.
const additionalUpdates = getNewDataTreeUpdates(
additionalPathsAddedAsUpdates,
feat: constrained diff between states (#31847) ## Description We are constraining the diff between the old dataTree and the newDataTree to its only affected nodes. The affected nodes list is the evalOrder, unevalUpdates and updatedValuePaths (which represents localStorage and setter updates). Through limiting the diff to the affected node list this should help in reducing the diff computation latency and overall improve the performance of each evaluation cycle. We are also cleaning up code related to compressing and decompressing updates since we deprecated that functionality. Fixes #31272 ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!IMPORTANT] > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/8447023192> > Commit: `cb925afbb99577947fbc7233a35e4454223b402a` > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8447023192&attempt=2" target="_blank">Click here!</a> > All cypress tests have passed 🎉🎉🎉 <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new logic for handling widget state updates efficiently. - Enhanced evaluation logic to support optimized diff updates and serialization. - Improved data tree generation for error handling and evaluation order. - **Bug Fixes** - Addressed issues in generating optimized updates for large collections and handling `undefined` values. - Fixed Cypress tests in the "PgAdmin Clone App" spec for more reliable interaction with UI elements. - **Refactor** - Simplified the logic for widget state cleanup and evaluation paths handling. - Removed unused variables and functions related to widget meta properties and evaluation paths. - **Tests** - Added new spec file `PgAdmin_spec.js` to Cypress limited tests for client-side regression testing. - **Chores** - Updated type imports across various files to reflect changes in evaluation logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-03-27 09:07:46 +00:00
dataTree,
);
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
// the affected paths is a combination of the eval order and the uneval updates
// we use this collection to limit the diff between the old and new data tree
const affectedNodePaths = getAffectedNodesInTheDataTree(
unEvalUpdates,
evalOrder,
);
feat: JSObject variable as a state (JSObject variable mutation) (#19926) Fixes #19653 Fixes #14568 Fixes #17199 Fixes #14989 In this PR, we introduce a new feature in JSObject where the `variables` are now state and widgets are reactive to the change in the variable value. - It means that `JSObject.myVar1 = "Hello world"` would show `Hello world` where ever a binding `{{JSObject.myVar1}}` is used. Further changes - JSObject run functionality, executes all the functions in async evaluation. - `executeSyncJS` flow is removed - `resolvedFunctions` state is moved to JSCollection class. - unEval JSObject value i.e., currentJSCollectionState is moved to JSCollection class. - `evalTreeWithChanges` is introduced - A new flow to trigger evaluation from the worker and send the updated dataTree to mainThread. - This would open up a new possibility of features in evaluation mentioned [here](https://www.notion.so/appsmith/RFC-Dependent-Property-in-Widgets-f3b29ad652b549dd8c49189f48dbbc4b) - Introduction of `updateDataTreeHandler` to accept new dataTree from the worker. ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Jest Test - `Mutation.test.ts` - `JSVariableProxy.test.ts` - `removeProxy.test.ts` ### Cypress test - Mutation with - numbers - array - object - map - set ### Test Plan - https://github.com/appsmithorg/TestSmith/issues/2186 ### Issues raised during DP testing - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1453275688 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1478975487 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1482929425 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1486611858 Co-authored-by: Rimil Dey <rimildeyjsr@gmail.com> Co-authored-by: Rimil Dey <rimil@appsmith.com> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
2023-04-07 07:41:36 +00:00
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
defaultResponse.updates = generateOptimisedUpdatesAndSetPrevState(
feat: JSObject variable as a state (JSObject variable mutation) (#19926) Fixes #19653 Fixes #14568 Fixes #17199 Fixes #14989 In this PR, we introduce a new feature in JSObject where the `variables` are now state and widgets are reactive to the change in the variable value. - It means that `JSObject.myVar1 = "Hello world"` would show `Hello world` where ever a binding `{{JSObject.myVar1}}` is used. Further changes - JSObject run functionality, executes all the functions in async evaluation. - `executeSyncJS` flow is removed - `resolvedFunctions` state is moved to JSCollection class. - unEval JSObject value i.e., currentJSCollectionState is moved to JSCollection class. - `evalTreeWithChanges` is introduced - A new flow to trigger evaluation from the worker and send the updated dataTree to mainThread. - This would open up a new possibility of features in evaluation mentioned [here](https://www.notion.so/appsmith/RFC-Dependent-Property-in-Widgets-f3b29ad652b549dd8c49189f48dbbc4b) - Introduction of `updateDataTreeHandler` to accept new dataTree from the worker. ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Jest Test - `Mutation.test.ts` - `JSVariableProxy.test.ts` - `removeProxy.test.ts` ### Cypress test - Mutation with - numbers - array - object - map - set ### Test Plan - https://github.com/appsmithorg/TestSmith/issues/2186 ### Issues raised during DP testing - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1453275688 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1478975487 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1482929425 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1486611858 Co-authored-by: Rimil Dey <rimildeyjsr@gmail.com> Co-authored-by: Rimil Dey <rimil@appsmith.com> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
2023-04-07 07:41:36 +00:00
dataTree,
chore: send diff updates from worker (#24933) ## Description - Optimisation around evaluation updates to the state - Updates generation logic moved from main thread to worker thread - The diff between previous state and next state is less exacting to limit the number of updates - Logic to compress similar updates to reduce the diff updates sent from worker thread to main thread - Memoisation fixes and some selector optimisation for improved performance. #### PR fixes following issue(s) Fixes #24866 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-08-16 05:34:32 +00:00
dataTreeEvaluator,
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
affectedNodePaths,
additionalUpdates,
chore: send diff updates from worker (#24933) ## Description - Optimisation around evaluation updates to the state - Updates generation logic moved from main thread to worker thread - The diff between previous state and next state is less exacting to limit the number of updates - Logic to compress similar updates to reduce the diff updates sent from worker thread to main thread - Memoisation fixes and some selector optimisation for improved performance. #### PR fixes following issue(s) Fixes #24866 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-08-16 05:34:32 +00:00
);
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
dataTreeEvaluator.undefinedEvalValuesMap =
dataTreeEvaluator.undefinedEvalValuesMap || {};
feat: constrained diff between states (#31847) ## Description We are constraining the diff between the old dataTree and the newDataTree to its only affected nodes. The affected nodes list is the evalOrder, unevalUpdates and updatedValuePaths (which represents localStorage and setter updates). Through limiting the diff to the affected node list this should help in reducing the diff computation latency and overall improve the performance of each evaluation cycle. We are also cleaning up code related to compressing and decompressing updates since we deprecated that functionality. Fixes #31272 ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!IMPORTANT] > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/8447023192> > Commit: `cb925afbb99577947fbc7233a35e4454223b402a` > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8447023192&attempt=2" target="_blank">Click here!</a> > All cypress tests have passed 🎉🎉🎉 <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new logic for handling widget state updates efficiently. - Enhanced evaluation logic to support optimized diff updates and serialization. - Improved data tree generation for error handling and evaluation order. - **Bug Fixes** - Addressed issues in generating optimized updates for large collections and handling `undefined` values. - Fixed Cypress tests in the "PgAdmin Clone App" spec for more reliable interaction with UI elements. - **Refactor** - Simplified the logic for widget state cleanup and evaluation paths handling. - Removed unused variables and functions related to widget meta properties and evaluation paths. - **Tests** - Added new spec file `PgAdmin_spec.js` to Cypress limited tests for client-side regression testing. - **Chores** - Updated type imports across various files to reflect changes in evaluation logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-03-27 09:07:46 +00:00
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
return {
workerResponse: defaultResponse,
fix: Prevent evalTree and configTree from being undefined (#23374) ## Description This PR prevents evalTree and configTree from being undefined values. #### PR fixes following issue(s) Fixes #23283 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing Nil #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-05-22 06:17:23 +00:00
unevalTree,
feat: JSObject variable as a state (JSObject variable mutation) (#19926) Fixes #19653 Fixes #14568 Fixes #17199 Fixes #14989 In this PR, we introduce a new feature in JSObject where the `variables` are now state and widgets are reactive to the change in the variable value. - It means that `JSObject.myVar1 = "Hello world"` would show `Hello world` where ever a binding `{{JSObject.myVar1}}` is used. Further changes - JSObject run functionality, executes all the functions in async evaluation. - `executeSyncJS` flow is removed - `resolvedFunctions` state is moved to JSCollection class. - unEval JSObject value i.e., currentJSCollectionState is moved to JSCollection class. - `evalTreeWithChanges` is introduced - A new flow to trigger evaluation from the worker and send the updated dataTree to mainThread. - This would open up a new possibility of features in evaluation mentioned [here](https://www.notion.so/appsmith/RFC-Dependent-Property-in-Widgets-f3b29ad652b549dd8c49189f48dbbc4b) - Introduction of `updateDataTreeHandler` to accept new dataTree from the worker. ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Jest Test - `Mutation.test.ts` - `JSVariableProxy.test.ts` - `removeProxy.test.ts` ### Cypress test - Mutation with - numbers - array - object - map - set ### Test Plan - https://github.com/appsmithorg/TestSmith/issues/2186 ### Issues raised during DP testing - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1453275688 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1478975487 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1482929425 - https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1486611858 Co-authored-by: Rimil Dey <rimildeyjsr@gmail.com> Co-authored-by: Rimil Dey <rimil@appsmith.com> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
2023-04-07 07:41:36 +00:00
};
fix: evalTrigger mutation fix (#34106) ## Description This fixes a gap in our evaluation flow where we were not sending evaluation updates during an evaluation in the evalTrigger. We have resolved that by sending updates in the evalTrigger, also we have created a separate function called evaluateAndGenerateWebWorkerResponse which unifies the logic between sending updates in evalTrigger as well as evalTreeWithChanges. We have added several unit test cases in this PR to test the evaluation flow. Fixes #33823 > [!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" ### :mag: 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/9558723818> > Commit: 8b7bc93e3d1a8ce93c722a94c8846f9359d40686 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9558723818&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `` <!-- 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 - **Refactor** - Improved the evaluation and update process for data tree structures with new helper functions and interfaces. - Enhanced error handling with optional chaining in `setPrevState` function. - **New Features** - Introduced `evaluateAndPushResponse`, `evaluateAndGenerateResponse`, and `getAffectedNodesInTheDataTree` functions for better data tree evaluation and updates. - Added `UpdateTreeResponse` interface for structured update responses. - **Bug Fixes** - Adjusted error handling in the evaluation process to ensure robustness. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-18 09:45:24 +00:00
};
chore: Add evalTreeWithDiff to evalWorkerAction (#34403) ## Description These changes add evalTreeWithDiff to evalWorkerAction. Using this method it will be possible to send the unevalTree and configTree updates from mainThread to trigger evaluation. - This will skip diffing complete unEvaltree ### Next steps after this PR - [ ] Rename EvalTreeWithChanges to evalTreeWithDiff - [ ] Generate Diff instead of updatedValuePaths for the current evalTreeWithChanges references. - [ ] Handle evalTreeWithDiff for - [ ] JSObject updates - [ ] updateDependencyMap Fixes # ## Automation /test js ### :mag: 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/9684706533> > Commit: 3de988af5da9900f4e589a008d28296d05d17f25 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9684706533&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced widget evaluation logic and improved handling of dynamic bindings and dependencies. - **Bug Fixes** - Corrected type handling in various evaluation functions to improve stability and accuracy. - **Tests** - Updated test cases for widget property setters to include additional tags for better categorization. - **Refactor** - Streamlined function signatures and improved type safety across evaluation utilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-27 06:38:53 +00:00
export const pushResponseToMainThread = (data: UpdateDataTreeMessageData) => {
sendMessage.call(self, {
messageType: MessageType.DEFAULT,
body: {
data,
method: MAIN_THREAD_ACTION.UPDATE_DATATREE,
},
});
};