-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: debounce handle action updates #38349
Conversation
WalkthroughThe pull request introduces changes to action data handling across multiple files in the application. The modifications primarily focus on improving the management of action updates, including exporting the Changes
Suggested labels
Suggested reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
app/client/src/sagas/EvaluationsSaga.ts (3)
543-547
: Consider a more conventional interface name.Using
BUFFERED_ACTION
as an interface name is fine but slightly inconsistent with typical TypeScript naming (e.g.,BufferedAction
).You might consider renaming for clarity:
-interface BUFFERED_ACTION { +interface BufferedAction { hasDebouncedHandleUpdate: boolean; hasBufferedAction: boolean; actionDataPayloadConsolidated: actionDataPayload[]; }
550-553
: Good initialization of local state.Storing flags and consolidated payload in separate variables is clear. A possible improvement would be grouping them into a config object for better structure, but this is optional.
-let hasDebouncedHandleUpdate = false; -let hasBufferedAction = false; -let actionDataPayloadConsolidated: actionDataPayload = []; +let bufferedState = { + hasDebouncedHandleUpdate: false, + hasBufferedAction: false, + actionDataPayloadConsolidated: [] as actionDataPayload, +};
600-615
: Use optional chaining for cleaner checks.- if (actionDataPayload && actionDataPayload.length) { + if (actionDataPayload?.length) {This minor refinement can reduce complexity. Otherwise, the logic for consolidating
actionDataPayload
is sound.🧰 Tools
🪛 Biome (1.9.4)
[error] 604-604: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
app/client/src/actions/pluginActionActions.ts
(1 hunks)app/client/src/ce/actions/evaluationActionsList.ts
(1 hunks)app/client/src/sagas/ActionExecution/PluginActionSaga.ts
(0 hunks)app/client/src/sagas/EvaluationsSaga.ts
(5 hunks)
💤 Files with no reviewable changes (1)
- app/client/src/sagas/ActionExecution/PluginActionSaga.ts
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/sagas/EvaluationsSaga.ts
[error] 604-604: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (8)
app/client/src/ce/actions/evaluationActionsList.ts (1)
111-111
: Great addition!
This newly introduced UPDATE_ACTION_DATA
action type seamlessly extends the set of Redux actions that trigger evaluations. It appears well-integrated with the rest of the file.
app/client/src/actions/pluginActionActions.ts (1)
391-391
: Exporting the type is a good move!
Converting actionDataPayload
to an exported type is beneficial for reuse across multiple modules. Make sure to verify that existing references now import it correctly.
✅ Verification successful
Type is correctly imported and used across the codebase
The exported actionDataPayload
type is properly imported and used in EvaluationsSaga.ts
. All references to this type are consistent with its definition in pluginActionActions.ts
. No issues found with the type export.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify all references to actionDataPayload
rg -A 3 $'actionDataPayload'
Length of output: 5084
app/client/src/sagas/EvaluationsSaga.ts (6)
97-101
: Imports look correct and consistent!
Importing the newly exported types and existing executeJSUpdates
function aligns with the recent additions in pluginActionActions.ts
.
568-575
: Resetting variables is handled correctly.
You’re effectively clearing out the buffered state for the next cycle. This is consistent with re-initializing local variables once their usage completes.
578-580
: Consolidation fields are well-structured.
Destructuring into the return object ensures clarity for the calling code. Nicely done.
804-813
: Direct saga call for UPDATE_ACTION_DATA
.
This succinctly handles action-data updates before continuing to other logic. Looks appropriate for your architecture.
815-826
: Clear separation of non-buffered actions.
This neatly funnels non-buffered actions into the main evaluation flow. The branching logic is simple and easy to follow.
827-853
: Nicely handles buffered debounced actions.
Collecting update payloads and deferring them until a single shot is efficient. Well-structured approach to reduce repeated evaluations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/client/src/sagas/EvaluationsSaga.test.ts (2)
213-215
: Avoid redundant property initialization in multiple places if possible
Since lines 213-215 duplicate the same values as the previous block, factor them out, or use a shared utility if these are consistently repeated.
267-269
: Reassess the necessity ofactionDataPayloadConsolidated
If future logic is anticipated to populate this array, confirm that the test coverage reflects different states for this property. Otherwise, consider removing it to reduce complexity.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/client/src/sagas/EvaluationsSaga.test.ts
(4 hunks)
🔇 Additional comments (2)
app/client/src/sagas/EvaluationsSaga.test.ts (2)
193-195
: Consider verifying usage and test coverage for newly introduced properties
These properties are great additions to the buffered action state. However, ensure thorough tests confirm that actionDataPayloadConsolidated
, hasBufferedAction
, and hasDebouncedHandleUpdate
accurately reflect their intended behavior under various scenarios.
237-239
: Check for consistent updates to the hasDebouncedHandleUpdate
flag
Currently, hasDebouncedHandleUpdate
is set to false
. If this value must reflect whether a debounce occurred, consider adding logic to flip it to true
when the debounce condition is triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please add test cases for the new logic ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/client/src/sagas/EvaluationsSaga.test.ts (1)
279-386
: Great test coverage for debouncing functionality!The new tests thoroughly cover the debouncing scenarios. Consider adding one more test case:
Add a test case for error handling when invalid action data is provided:
test("should handle invalid action data gracefully during debouncing", () => { const buffer = evalQueueBuffer(); buffer.put( updateActionData([ { entityName: "widget1", // missing required fields data: { a: 1 } } ]) ); const bufferedAction = buffer.take(); expect(bufferedAction.hasBufferedAction).toBeFalsy(); expect(bufferedAction.hasDebouncedHandleUpdate).toBeTruthy(); expect(bufferedAction.actionDataPayloadConsolidated).toEqual([]); });
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/client/src/sagas/EvaluationsSaga.test.ts
(6 hunks)
🔇 Additional comments (2)
app/client/src/sagas/EvaluationsSaga.test.ts (2)
29-29
: LGTM!
The import is correctly added for testing the new action data update functionality.
194-196
: LGTM! Test coverage looks comprehensive.
The new properties for debounced action handling are consistently added across all test cases, maintaining the test coverage for both existing and new functionality.
Let's verify the test coverage:
Also applies to: 214-216, 238-240, 256-258, 271-273
✅ Verification successful
Test coverage for debounced action handling is comprehensive
The test suite thoroughly covers all scenarios for the new debouncing properties:
- Default state with empty consolidated payload
- Multiple action data updates being consolidated
- Combinations of buffered and debounced actions
- Various affected JS objects states
- Both true/false states for
hasBufferedAction
andhasDebouncedHandleUpdate
The consistent assertions across test cases validate the correct implementation of the new debouncing functionality.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if we have tests for all possible combinations of buffered actions
rg "test\(.*should.*UPDATE_ACTION_DATA.*BUFFERED_ACTION" -A 5
Length of output: 548
Script:
#!/bin/bash
# Let's check for all test cases related to buffered actions and debouncing
rg "test\(.*buffer.*action" -i app/client/src/sagas/EvaluationsSaga.test.ts -A 5
# Also check for any other test cases that might be related to action data updates
rg "test\(.*UPDATE_ACTION_DATA" app/client/src/sagas/EvaluationsSaga.test.ts -A 5
Length of output: 1565
Script:
#!/bin/bash
# Let's check the implementation of these test cases to verify coverage
rg "updateActionData.*BUFFERED_ACTION" app/client/src/sagas/EvaluationsSaga.test.ts -B 5 -A 15
# Also check the test assertions to ensure they verify the new properties
ast-grep --pattern 'expect($_).toEqual({
$$$
actionDataPayloadConsolidated: $_,
hasBufferedAction: $_,
hasDebouncedHandleUpdate: $_,
$$$
})'
Length of output: 7500
Description
Debounced handleActionUpdate actions together with bufferedActions, this has reduced the webworker scripting and LCP by about 25-30% on a windows machine.
Fixes #
Issue Number
or
Fixes
Issue URL
Warning
If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.
Automation
/ok-to-test tags="@tag.All"
🔍 Cypress test results
Warning
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12515902433
Commit: 41ec14d
Cypress dashboard.
Tags: @tag.All
Spec:
It seems like no tests ran 😔. We are not able to recognize it, please check workflow here.
Mon, 30 Dec 2024 04:30:58 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Chores