microsoft / microsoft/FluidFramework
[code-simplifier] refactor(tree): clarify array-node event delta logic
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.9k
- Forks
- 586
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 146
Description
Overview
This PR makes small readability-focused refactors in the recently-updated array-node change event wiring, without changing runtime behavior.
Files Simplified
packages/dds/tree/src/simple-tree/api/treeNodeApi.ts- Simplifies the shallow-change guard for array-node
nodeChangedto make the early-return condition more direct.
- Simplifies the shallow-change guard for array-node
packages/dds/tree/src/simple-tree/core/unhydratedFlexTree.ts- Extracts the
fieldMarksmap construction into a named local for clarity.
- Extracts the
Why
These areas were recently updated to include delta payloads for array-node events; the refactors make the intent easier to read while preserving the exact semantics (including the marks === undefined fallback behavior).
Changes Based On
- #26927 - array node treeChanged delta payload and unhydrated node fix
Testing
- ✅
corepack pnpm -C packages/dds/tree run build:test:esm - ✅
corepack pnpm -C packages/dds/tree run build:test:cjs - ✅
corepack pnpm -C packages/dds/tree run eslint - ✅
corepack pnpm -C packages/dds/tree run check:biome
Notes
- Full-repo
pnpm run build:fastwas attempted but did not complete reliably in this environment due to unrelated worker/process termination; targeted package checks for@fluidframework/treepassed.
Review Focus
- Confirm behavior is unchanged (only refactors).
- Sanity-check the array-node
nodeChangedearly-return logic readability.
Generated by Code Simplifier · ◷
To install this agentic workflow, run
gh aw add github/gh-aw/.github/workflows/code-simplifier.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4
[!WARNING]
⚠️ Firewall blocked 3 domains
The following domains were blocked by the firewall during workflow execution:
googlechromelabs.github.ioreleaseassets.githubusercontent.comstorage.googleapis.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:network: allowed: - defaults - "googlechromelabs.github.io" - "releaseassets.githubusercontent.com" - "storage.googleapis.com"See Network Configuration for more information.
- expires on Apr 16, 2026, 10:08 AM UTC
[!NOTE]
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branchcode-simplifier/tree-event-refactors-2026-04-15-e1be576c4c61bdd7.
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests.
Show patch preview (50 of 50 lines)
From 4f67235bd1565c21b7c452fc5c2062a14685ff5a Mon Sep 17 00:00:00 2001
From: tylerbutler <tylerbutler@users.noreply.github.com>
Date: Wed, 15 Apr 2026 09:53:30 +0000
Subject: [PATCH] refactor(tree): clarify array-node event delta logic
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
packages/dds/tree/src/simple-tree/api/treeNodeApi.ts | 8 ++++----
.../dds/tree/src/simple-tree/core/unhydratedFlexTree.ts | 3 ++-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/packages/dds/tree/src/simple-tree/api/treeNodeApi.ts b/packages/dds/tree/src/simple-tree/api/treeNodeApi.ts
index c1d40d2..88d2a0e 100644
--- a/packages/dds/tree/src/simple-tree/api/treeNodeApi.ts
+++ b/packages/dds/tree/src/simple-tree/api/treeNodeApi.ts
@@ -284,10 +284,10 @@ export const treeNodeApi: TreeNodeApi = {
// internal passes), we conservatively fire nodeChanged rather than silently
// dropping the event, even though the underlying change may have been
// purely deep. This is a known limitation of the current eventing stack.
- const hasShallowChange =
- marks === undefined ||
- marks.some((m) => m.attach !== undefined || m.detach !== undefined);
- if (!hasShallowChange) {
+ if (
+ marks !== undefined &&
+ !marks.some((m) => m.attach !== undefined || m.detach !== undefined)
+ ) {
return;
}
// `marks` is undefined when the field was modified across multiple batches
diff --git a/packages/dds/tree/src/simple-tree/core/unhydratedFlexTree.ts b/packages/dds/tree/src/simple-tree/core/unhydratedFlexTree.ts
index 9df6bce..39340b4 100644
--- a/packages/dds/tree/src/simple-tree/core/unhydratedFlexTree.ts
+++ b/packages/dds/tree/src/simple-tree/core/unhydratedFlexTree.ts
@@ -289,9 +289,10 @@ export class UnhydratedFlexTreeNode
* When omitted (e.g. for non-sequence fields), `fieldMarks` is empty.
*/
public emitChangedEvent(key: FieldKey, marks?: readonly DeltaMark[]): void
... (truncated)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read packages/dds/tree/src/simple-tree/api/treeNodeApi.ts and packages/dds/tree/src/simple-tree/core/unhydratedFlexTree.ts, focusing on the array-node event wiring and fieldMarks construction. Run the targeted package build, eslint, and Biome checks listed in the issue; done means the refactor preserves the existing marks === undefined behavior and runtime semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- distributed-systems
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 20/100