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(tree): Include list of properties that changed in nodeChanged event #22043

Closed
wants to merge 21 commits into from

Conversation

alexvy86
Copy link
Contributor

@alexvy86 alexvy86 commented Jul 26, 2024

Description

This adds a payload to the nodeChanged event in simple-tree, where we specify the names of the properties of the node that changed and caused the event to fire.

TODO (in this PR)

  • Check how this behaves for array nodes and map nodes
  • Implement translation from stored keys to view keys

Reviewer Guidance

The review process is outlined on this wiki page.

AB#8399

@alexvy86 alexvy86 requested review from a team as code owners July 26, 2024 23:24
Copy link

changeset-bot bot commented Jul 26, 2024

🦋 Changeset detected

Latest commit: 135659d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 157 packages
Name Type
fluid-framework Major
@fluidframework/tree Major
@fluid-example/presence-tracker Major
@fluid-example/inventory-app Major
@fluid-example/app-integration-external-controller Major
@fluid-example/shared-tree-demo Major
@fluid-example/bundle-size-tests Major
@fluid-example/tree-comparison Major
@fluid-example/bubblebench-shared-tree Major
@fluid-internal/tablebench Major
@fluid-example/tree-shim Major
@fluid-experimental/property-shared-tree-interop Major
@fluid-experimental/tree Major
@fluid-experimental/tree-react-api Major
@fluidframework/fluid-telemetry Major
@fluidframework/azure-client Major
@fluidframework/azure-end-to-end-tests Major
@fluid-internal/functional-tests Major
@fluid-private/test-end-to-end-tests Major
@fluidframework/devtools-core Major
@fluid-example/devtools-example Major
@fluid-example/bubblebench-common Major
@fluid-example/bubblebench-experimental-tree Major
@fluid-internal/devtools-browser-extension Major
@fluid-internal/devtools-view Major
@fluidframework/devtools Major
@fluid-example/bubblebench-baseline Major
@fluid-example/bubblebench-ot Major
@fluid-example/attributable-map Major
@fluid-example/collaborative-textarea Major
@fluid-example/contact-collection Major
@fluid-example/data-object-grid Major
@fluid-example/task-selection Major
@fluid-example/odspsnapshotfetch-perftestapp Major
@fluid-example/app-insights-logger Major
@fluid-example/canvas Major
@fluid-example/clicker Major
@fluid-example/codemirror Major
@fluid-example/diceroller Major
@fluid-example/monaco Major
@fluid-example/multiview-constellation-model Major
@fluid-example/multiview-constellation-view Major
@fluid-example/multiview-container Major
@fluid-example/multiview-coordinate-model Major
@fluid-example/multiview-coordinate-interface Major
@fluid-example/multiview-plot-coordinate-view Major
@fluid-example/multiview-slider-coordinate-view Major
@fluid-example/multiview-triangle-view Major
@fluid-example/prosemirror Major
@fluid-example/smde Major
@fluid-example/table-document Major
@fluid-example/todo Major
@fluid-example/webflow Major
@fluid-example/app-integration-external-data Major
@fluid-example/example-utils Major
@fluid-example/webpack-fluid-loader Major
@fluid-example/app-integration-live-schema-upgrade Major
@fluid-example/version-migration-same-container Major
@fluid-example/app-integration-schema-upgrade Major
@fluid-example/app-integration-container-views Major
@fluid-example/app-integration-external-views Major
@fluid-example/view-framework-sampler Major
@fluid-example/property-inspector Major
@fluid-example/schemas Major
@fluid-experimental/azure-scenario-runner Major
@fluid-experimental/property-binder Major
@fluid-experimental/property-changeset Major
@fluid-experimental/property-common Major
@fluid-experimental/property-dds Major
@fluid-experimental/property-inspector-table Major
@fluid-experimental/property-properties Major
@fluid-experimental/property-proxy Major
@fluid-experimental/property-query Major
@fluid-experimental/attributable-map Major
@fluid-experimental/ot Major
@fluid-experimental/sharejs-json1 Major
@fluid-experimental/sequence-deprecated Major
@fluid-experimental/data-objects Major
@fluid-experimental/last-edited Major
@fluid-experimental/ink Major
@fluid-experimental/pact-map Major
@fluid-experimental/attributor Major
@fluid-experimental/data-object-base Major
@fluid-experimental/dds-interceptions Major
@fluid-experimental/oldest-client-observer Major
@fluid-experimental/odsp-end-to-end-tests Major
@fluid-internal/platform-dependent Major
@fluid-internal/client-utils Major
@fluid-internal/local-server-tests Major
@fluid-internal/mocha-test-setup Major
@fluid-internal/test-snapshots Major
@fluid-internal/test-app-insights-logger Major
@fluid-internal/test-driver-definitions Major
@fluid-internal/test-service-load Major
@fluid-internal/replay-tool Major
@fluid-private/test-dds-utils Major
@fluid-private/test-loader-utils Major
@fluid-private/stochastic-test-utils Major
@fluid-private/test-drivers Major
@fluid-private/test-pairwise-generator Major
@fluid-private/test-version-utils Major
@fluid-private/changelog-generator-wrapper Major
@fluid-tools/fetch-tool Major
@fluid-tools/markdown-magic Major
@fluidframework/azure-local-service Major
@fluidframework/azure-service-utils Major
@fluidframework/container-definitions Major
@fluidframework/core-interfaces Major
@fluidframework/core-utils Major
@fluidframework/driver-definitions Major
@fluidframework/cell Major
@fluidframework/counter Major
@fluidframework/map Major
@fluidframework/matrix Major
@fluidframework/merge-tree Major
@fluidframework/ordered-collection Major
@fluidframework/register-collection Major
@fluidframework/sequence Major
@fluidframework/shared-object-base Major
@fluidframework/shared-summary-block Major
@fluidframework/task-manager Major
@fluidframework/debugger Major
@fluidframework/driver-base Major
@fluidframework/driver-web-cache Major
@fluidframework/file-driver Major
@fluidframework/local-driver Major
@fluidframework/odsp-driver-definitions Major
@fluidframework/odsp-driver Major
@fluidframework/odsp-urlresolver Major
@fluidframework/replay-driver Major
@fluidframework/routerlicious-driver Major
@fluidframework/routerlicious-urlresolver Major
@fluidframework/tinylicious-driver Major
@fluidframework/agent-scheduler Major
@fluidframework/aqueduct Major
@fluidframework/app-insights-logger Major
@fluidframework/fluid-static Major
@fluidframework/request-handler Major
@fluidframework/synthesize Major
@fluidframework/undo-redo Major
@fluidframework/container-loader Major
@fluidframework/driver-utils Major
@fluidframework/container-runtime-definitions Major
@fluidframework/container-runtime Major
@fluidframework/datastore-definitions Major
@fluidframework/datastore Major
@fluidframework/id-compressor Major
@fluidframework/runtime-definitions Major
@fluidframework/runtime-utils Major
@fluidframework/test-runtime-utils Major
@fluidframework/odsp-client Major
@fluidframework/tinylicious-client Major
@fluidframework/test-utils Major
@fluidframework/fluid-runner Major
@fluidframework/odsp-doclib-utils Major
@fluidframework/telemetry-utils Major
@fluidframework/tool-utils Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: tree public api change Changes to a public API base: main PRs targeted against main branch labels Jul 26, 2024
Copy link

azure-boards bot commented Jul 26, 2024

✅ Successfully linked to Azure Boards work item(s):

@github-actions github-actions bot added the area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct label Jul 29, 2024
Copy link
Member

@tylerbutler tylerbutler left a comment

Choose a reason for hiding this comment

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

Please add a changeset.

@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Jul 30, 2024

@fluid-example/bundle-size-tests: +1.56 KB
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 461.15 KB 461.19 KB +35 Bytes
azureClient.js 558.32 KB 558.37 KB +49 Bytes
connectionState.js 680 Bytes 680 Bytes No change
containerRuntime.js 261.76 KB 261.78 KB +14 Bytes
fluidFramework.js 409.15 KB 409.83 KB +691 Bytes
loader.js 134.04 KB 134.05 KB +14 Bytes
map.js 42.13 KB 42.14 KB +7 Bytes
matrix.js 146.48 KB 146.48 KB +7 Bytes
odspClient.js 526.46 KB 526.51 KB +49 Bytes
odspDriver.js 97.55 KB 97.57 KB +21 Bytes
odspPrefetchSnapshot.js 42.61 KB 42.62 KB +14 Bytes
sharedString.js 163.21 KB 163.21 KB +7 Bytes
sharedTree.js 399.67 KB 400.34 KB +684 Bytes
Total Size 3.32 MB 3.32 MB +1.56 KB

Baseline commit: 06f2989

Generated by 🚫 dangerJS against 135659d

@alexvy86 alexvy86 requested a review from a team as a code owner July 30, 2024 23:28
@CraigMacomber
Copy link
Contributor

CraigMacomber commented Jul 30, 2024

Do we plan to generalize this to apply to treeChanged in the future? I could see the same functionality being great there as well.

That also makes me thing: I don't think this includes a test where we change a node deeper in the tree (ex: a child) and make sure the parent doesn't get a nodeChanged, of when it does, keys inly deeply edited don't get included in the changed key list (like they would be in treeChanged).

Anyway, the parts I looked at (API, changeset and tests) generally look good to me, though I left some suggestions.

@@ -390,7 +390,9 @@ export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAl

// @public @sealed
export interface TreeChangeEvents {
nodeChanged(): void;
nodeChanged({ changedProperties }: {
changedProperties: ReadonlySet<string>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little concerned about forward compat (for when we finally expose information about what the changes were).
Is there a design for what that will look like?
Are we expecting to just deprecate changedProperties and use another key for the future API? (propertyChanges ?)
Or would we be better off exposing changedProperties: ReadonlyMap<string, unknown> for now, so we can fill in the blanks later?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the fact that changedProperties is inside of a property bag {...} (as opposed to directly being the first parameter to the event) is sufficient for future-proofing and about as good of a guess as we can make. To add more information in the future, we don't need to break the event signature, we just add more properties to the event bag. Maybe there's some overlap with the existing properties and a new property supersedes an old one, but that's fine, the user can just ignore the deprecated one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm cool with that so long as we're going into it with our eyes open.
Feel free to resolve this comment without further changes.

@tylerbutler tylerbutler dismissed their stale review July 31, 2024 19:13

Dismissing since there's a changeset now. Haven't reviewed it yet but don't block on me.

*/
export function getViewForForkedBranch<TSchema extends ImplicitFieldSchema>(
originalView: SchematizingSimpleTreeView<TSchema>,
): { forkView: SchematizingSimpleTreeView<TSchema>; forkCheckout: ITreeCheckoutFork } {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we define a type for this? That would give us a better place to document it properties and such.

nodeChanged(): void;
nodeChanged({
changedProperties,
}: { readonly changedProperties: ReadonlySet<string> }): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we define a type for this?

@CraigMacomber
Copy link
Contributor

I created #22229 which merges main into this and fixed up a few things.

CraigMacomber added a commit that referenced this pull request Aug 16, 2024
…g. (#22222)

## Description

See changeset for details.

This will be used for things like providing object node specific events
with strong typing.

This is aimed to provide the functionality attempted in
alexvy86#7 to better support node
kind specific data in
#22043
CraigMacomber added a commit that referenced this pull request Sep 5, 2024
…ent (#22229)

## Description

Updated version of
#22043 .

See changeset for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds: tree area: dds Issues related to distributed data structures area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch changeset-present public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants