Skip to content

Add alpha splice method to TreeArrayNode#26740

Merged
brrichards merged 20 commits intomicrosoft:mainfrom
brrichards:new-array-splice
Mar 24, 2026
Merged

Add alpha splice method to TreeArrayNode#26740
brrichards merged 20 commits intomicrosoft:mainfrom
brrichards:new-array-splice

Conversation

@brrichards
Copy link
Copy Markdown
Contributor

@brrichards brrichards commented Mar 16, 2026

Summary

Adds splice method to a new alpha TreeArrayNode interface, TreeArrayNodeAlpha, that follows Array.prototype.splice semantics. Supports removing and inserting items in a single opertaion, with optional deleteCount and negative start indices. Wraps remove + insert in a transaction for hydrated nodes to enable atomic undo/redo. Users opt into using the new api by doing asAlpha(<TreeArrayNode>) which then allows them to use splice and also still interact with other non-alpha TreeArrayNodes

@brrichards brrichards requested review from a team as code owners March 16, 2026 17:56
Copilot AI review requested due to automatic review settings March 16, 2026 17:56
Comment thread packages/dds/tree/src/simple-tree/node-kinds/array/arrayNode.ts Outdated
Copy link
Copy Markdown
Contributor

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

Adds a new splice API to TreeArrayNode to support combined remove/insert operations with Array.prototype.splice-like behavior, including negative start indices and optional deleteCount, and updates the public API surface accordingly.

Changes:

  • Adds TreeArrayNode.splice to the public interface and implements it in arrayNode.ts (wrapping hydrated edits in a transaction).
  • Adds unit tests covering several splice scenarios.
  • Updates API reports and adds a changeset entry documenting the new API.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/dds/tree/src/test/simple-tree/node-kinds/arrayNode.spec.ts Adds new splice test cases for array nodes
packages/dds/tree/src/simple-tree/node-kinds/array/arrayNode.ts Adds splice to the interface and implements the method
packages/dds/tree/api-report/tree.public.api.md Updates public API report to include splice
packages/dds/tree/api-report/tree.legacy.public.api.md Updates legacy public API report to include splice
packages/dds/tree/api-report/tree.legacy.beta.api.md Updates legacy beta API report to include splice
packages/dds/tree/api-report/tree.beta.api.md Updates beta API report to include splice
packages/dds/tree/api-report/tree.alpha.api.md Updates alpha API report to include splice
.changeset/plain-tires-melt.md Adds a minor changeset describing the new splice method and usage

Comment thread packages/dds/tree/src/simple-tree/node-kinds/array/arrayNode.ts
Comment thread packages/dds/tree/src/test/simple-tree/node-kinds/arrayNode.spec.ts Outdated
Comment thread packages/dds/tree/src/test/simple-tree/node-kinds/arrayNode.spec.ts Outdated
Comment thread .changeset/plain-tires-melt.md Outdated
Comment thread .changeset/plain-tires-melt.md Outdated
Comment thread .changeset/plain-tires-melt.md Outdated
Comment thread .changeset/plain-tires-melt.md Outdated
Comment thread packages/dds/tree/src/simple-tree/node-kinds/array/arrayNode.ts Outdated
Copy link
Copy Markdown
Contributor

@jzaffiro jzaffiro left a comment

Choose a reason for hiding this comment

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

Small nit but approved for docs

Comment thread .changeset/plain-tires-melt.md Outdated
Comment thread .changeset/plain-tires-melt.md
Comment thread .changeset/plain-tires-melt.md Outdated
Comment thread .changeset/plain-tires-melt.md Outdated
Comment thread .changeset/plain-tires-melt.md Outdated
Comment thread packages/dds/tree/src/test/simple-tree/node-kinds/arrayNode.spec.ts
Comment thread packages/dds/tree/src/test/simple-tree/node-kinds/arrayNode.spec.ts Outdated
Comment thread packages/dds/tree/src/test/simple-tree/node-kinds/arrayNode.spec.ts Outdated
Comment thread packages/dds/tree/src/simple-tree/node-kinds/array/arrayNode.ts Outdated
Comment thread packages/dds/tree/src/simple-tree/node-kinds/array/arrayNode.ts Outdated
Comment thread packages/dds/tree/api-report/tree.public.api.md Outdated
Copy link
Copy Markdown
Contributor

@CraigMacomber CraigMacomber left a comment

Choose a reason for hiding this comment

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

Despite having approval from an API Reviewer, this has not been api reviewed (GitHub doesn't let people approve for a subset of their review groups), so I'm going to use my requesting of changes as a placeholder for the need for an API review. If approving for API review, feel free to dismiss this.

@brrichards brrichards requested a review from a team as a code owner March 18, 2026 22:44
@brrichards brrichards changed the title Add splice method to TreeArrayNode Add alpha splice method to TreeArrayNode Mar 19, 2026
Comment thread .changeset/plain-tires-melt.md Outdated
Comment thread .changeset/plain-tires-melt.md Outdated
Copy link
Copy Markdown
Contributor

@noencke noencke left a comment

Choose a reason for hiding this comment

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

Implementation looks good to me

Comment thread packages/dds/tree/src/simple-tree/node-kinds/array/arrayNodeTypes.ts Outdated
true,
options ?? {},
);
) as unknown as ArrayNodeCustomizableSchemaAlpha<
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any way to avoid this cast? My guess is no, but curious what @CraigMacomber thinks

…pes.ts

Co-authored-by: Noah Encke <78610362+noencke@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@Abe27342 Abe27342 left a comment

Choose a reason for hiding this comment

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

Did not review the tree code.

Approving for merge-tree, which doesn't actually have any changes we care about in this PR. Talked with Brennan offline and this is probably just a sticky GH check.

Also approving for API council as the PR contains only alpha API changes. I can see that this is also a sticky check from a previous revision that touched more broadly visible API files.

Comment thread .changeset/plain-tires-melt.md Outdated
Comment thread .changeset/plain-tires-melt.md Outdated
Co-authored-by: jzaffiro <110866475+jzaffiro@users.noreply.github.com>
@brrichards brrichards dismissed CraigMacomber’s stale review March 24, 2026 16:40

Api, tree, and docs approval received after Api moved from public to alpha

@github-actions
Copy link
Copy Markdown
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> fluid-framework-docs-site@0.0.0 ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> fluid-framework-docs-site@0.0.0 serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> fluid-framework-docs-site@0.0.0 check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  272172 links
    1863 destination URLs
    2108 URLs ignored
       0 warnings
       0 errors


@brrichards brrichards merged commit f2b0cf9 into microsoft:main Mar 24, 2026
35 checks passed
agarwal-navin pushed a commit to agarwal-navin/FluidFramework that referenced this pull request Apr 13, 2026
## Summary

Adds `splice` method to a new alpha `TreeArrayNode` interface,
`TreeArrayNodeAlpha`, that follows `Array.prototype.splice` semantics.
Supports removing and inserting items in a single opertaion, with
optional `deleteCount` and negative `start` indices. Wraps remove +
insert in a transaction for hydrated nodes to enable atomic undo/redo.
Users opt into using the new api by doing `asAlpha(<TreeArrayNode>)`
which then allows them to use splice and also still interact with other
non-alpha `TreeArrayNodes`

---------

Co-authored-by: Noah Encke <78610362+noencke@users.noreply.github.com>
Co-authored-by: jzaffiro <110866475+jzaffiro@users.noreply.github.com>
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.

6 participants