Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(MultiplyingArchitecture): Avoid setting stale edits #1419

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

lordrip
Copy link
Member

@lordrip lordrip commented Sep 9, 2024

Context

Currently, an MA edit lifecycle looks like the following:

  1. The Kaoto editor makes an edit and notifies the MA.
  2. After a quiet period (debounce), MA processes the edit and sends it back to the Kaoto editor.
  3. If the content is the same, this last call is ignored by Kaoto, as the editor content is the same, so there's no need to recreate the UI. If the contrary, the current state gets discarded and the UI is regenerated with the incoming content.

This process opens the case for an edit happening a few milliseconds before the MA sends the content back, meaning that at this stage, the Kaoto content has changed but is receiving stale content, causing the UI to be regenerated with the stale content.

Changes

The fix for this situation is to implement a hash for each content and validate whether the incoming content is stale or not.

This PR also takes the opportunity to bring a couple of missing tests for the existing MA functionality.

fix: #1376
fix: https://issues.redhat.com/projects/KTO/issues/KTO-452

Currently, an MA edit lifecycle looks like the following:

1. The Kaoto editor makes an edit and notifies the MA.
2. After a quiet period (debounce), MA process the edit and sends it
   back to the Kaoto editor.
3. If the content is the same, this last call is ignored by Kaoto, as
   the editor content is exactly the same, so there's no need to
recreate the UI. If the contrary, the current state gets discarded and
the UI is regenerated with the incoming content.

This process opens the case for an edit happening a few milliseconds
before the MA sending the content back, meaning that at this stage, the
Kaoto content has changed but is receiving a stale content, causing for
the UI to be regenerated with the stale content.

The fix for this situation is to implement a hash for each content and
validate whether the incoming content is stale or not.

fix: KaotoIO#1376
fix: https://issues.redhat.com/projects/KTO/issues/KTO-452
Copy link

sonarcloud bot commented Sep 9, 2024

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 95.74468% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@e6c5ed7). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...es/ui/src/multiplying-architecture/KaotoBridge.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1419   +/-   ##
=======================================
  Coverage        ?   67.52%           
  Complexity      ?       25           
=======================================
  Files           ?      266           
  Lines           ?     7600           
  Branches        ?     1520           
=======================================
  Hits            ?     5132           
  Misses          ?     2465           
  Partials        ?        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@apupier apupier left a comment

Choose a reason for hiding this comment

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

tested locally manually in VS Code with auto-save using a delay, working fine

@lordrip lordrip merged commit e8354d0 into KaotoIO:main Sep 10, 2024
12 checks passed
@lordrip lordrip deleted the fix/typing-closes-configform branch September 10, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typing characters during auto save causes force closing of the configuration panel and losing input characters
3 participants