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

feat: dedupe incremental mutations for mobile replay #19974

Merged
merged 15 commits into from
Jan 26, 2024

Conversation

pauldambra
Copy link
Member

  • we don't want to diff in the mobile SDK to send granular updates
  • so mutations are either: "removes", "adds", or "updates"
  • updates need to be converted to a remove and then an add
  • since, we're removing we need to send the entire child nodes so that when we add the children are present
  • since, we're sending the entire child node tree we can see the same node more than once
  • so we need to de-dupe those nodes

looking at the suspect recordings this still isn't quite right but is already an improvement...

e.g. here where the image button was incorrectly below the text area it is now above it

Screenshot 2024-01-25 at 22 54 56

@@ -19,10 +20,10 @@ function spacerDiv(idSequence: Generator<number>): serializedNodeWithId {
/**
* tricky: we need to accept children because that's the interface of converters, but we don't use them
*/
export function makeStatusBar(wireframe: wireframeStatusBar, _children: serializedNodeWithId[], timestamp: number, idSequence: Generator<number>): serializedNodeWithId {
const clockId = idSequence.next().value;
export function makeStatusBar(wireframe: wireframeStatusBar, _children: serializedNodeWithId[], context: ConversionContext): ConversionResult<serializedNodeWithId> {
Copy link
Member Author

Choose a reason for hiding this comment

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

this signature change is the meat of what has gone into the PR

we now needed to pass multiple parameters around, and rely on that state persisting through chained calls

it was getting messy and confusing

so I pulled out the concept of the conversion having a context, and the steps in the conversion returning a result.

the context can be passed along through the results

this also opens up isolating the id generation, and will make it easier to split this big file up a little

@@ -0,0 +1,25 @@
import {MobileStyles} from "../mobile.types";

export interface ConversionResult<T> {
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: reading through this now... sometimes I say transform and sometimes I saw convert but they're the same thing 🤦

Copy link
Contributor

github-actions bot commented Jan 25, 2024

Size Change: 0 B

Total Size: 2.21 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 2.21 MB

compressed-size-action

@pauldambra pauldambra requested a review from a team January 26, 2024 09:19
Copy link
Contributor

@daibhin daibhin left a comment

Choose a reason for hiding this comment

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

Looks good, left a couple of comments but nothing blocking. One thing I don't think I fully understood was the screenshot in the description. Maybe a before / after would have helped because I expected to see duplicates of one component that since this change now correctly renders one.

attributes: inputAttributes(wireframe),
id: wireframe.id,
childNodes: [
...// TODO this won't work once we're editing the context
Copy link
Contributor

Choose a reason for hiding this comment

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

Just commenting to make sure you didn't miss this

Copy link
Member Author

Choose a reason for hiding this comment

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

commenting here for the thread

One thing I don't think I fully understood was the screenshot in the description.

Sorry, yep, the "image" button was below the text area before because the mutations were applying multiple times but not an equal amount of multiple times so the order was changed. I didn't have a screenshot to hand 🙈

@@ -77,8 +77,9 @@ function* ids(): Generator<number> {
}
}

// TODO this is shared for the lifetime of the page, so a very, very long-lived session could exhaust the ids
const idSequence = ids()
// TODO this is shared for the lifetime of the page,
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, only if you squint 🙈

@pauldambra
Copy link
Member Author

i'm going to merge this, since it's already better, and then follow-up with improvements

@pauldambra pauldambra merged commit 0fdb1e0 into master Jan 26, 2024
79 checks passed
@pauldambra pauldambra deleted the feat/dedupe-update-tree branch January 26, 2024 16:14
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.

2 participants