Skip to content

Fix unhydrated node parent tracking #24708

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

Merged
merged 5 commits into from
May 27, 2025

Conversation

CraigMacomber
Copy link
Contributor

Description

Fix unhydrated node parent tracking by centralizing the logic to update parents, and applying it consistently after every edit.

This does make small edits in large sequences do O(N) parent updates, but they were already O(N) from modifying the large array, and need to do O(N) parent updates in the insertion is near the front anyway.

Reviewer Guidance

The review process is outlined on this wiki page.

@Copilot Copilot AI review requested due to automatic review settings May 23, 2025 21:55
@CraigMacomber CraigMacomber requested review from a team as code owners May 23, 2025 21:55
@github-actions github-actions bot added base: main PRs targeted against main branch area: dds Issues related to distributed data structures area: dds: tree changeset-present labels May 23, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes unhydrated node parent tracking by centralizing the logic for updating parent pointers after every edit.

  • Centralizes parent updates in the edit() method of UnhydratedFlexTreeField
  • Updates tests to validate correct key and parent tracking for both insertions and removals

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/dds/tree/src/test/simple-tree/api/treeNodeApi.spec.ts Updates tests with new hydration descriptions and behaviors for key and parent tracking
packages/dds/tree/src/simple-tree/core/unhydratedFlexTree.ts Refactors parent updates by clearing and resetting adoptBy in the edit() method, and removes redundant adoptBy calls in removal blocks
.changeset/eight-ears-feel.md Documents the fix for Tree.key and Tree.parent for unhydrated nodes
Comments suppressed due to low confidence (1)

packages/dds/tree/src/simple-tree/core/unhydratedFlexTree.ts:503

  • Since the explicit adoptBy(undefined) call for removed nodes was removed in favor of centralized reset logic in the edit() method, please add a comment clarifying this change to improve maintainability.
const c = this.mapTrees[i];

CraigMacomber and others added 2 commits May 23, 2025 16:06
Co-authored-by: Joshua Smithrud <54606601+Josmithr@users.noreply.github.com>
Copy link
Contributor

@Josmithr Josmithr left a comment

Choose a reason for hiding this comment

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

Approving for docs. The code changes seem reasonable to me, but I'm missing some context. Would probably be good to get a review from @noencke or someone too.

@CraigMacomber CraigMacomber merged commit 8aa5c23 into microsoft:main May 27, 2025
34 checks passed
@CraigMacomber CraigMacomber deleted the UnhydratedParent branch May 27, 2025 22:17
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 base: main PRs targeted against main branch changeset-present
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants