Skip to content

perf(apollo-react): batch BaseNode's updateNodeInternals calls per React Flow store [ECS-2160] - #1572

Merged
pateljay43 merged 4 commits into
mainfrom
jay/apollo-basenode-batch-internals
Nov 13, 2026
Merged

pateljay43 merged 4 commits into
mainfrom
jay/apollo-basenode-batch-internals

Conversation

@pateljay43

Copy link
Copy Markdown
Contributor

Each BaseNode called updateNodeInternals on mount and React Flow turned every call into its own full-store update, so a 585-node DMN diagram paid 585 store updates on open.
BaseNode now queues its id and sends one update per React Flow store per task, which cut the longest open task from 6.3 s to 1.25 s at 4x CPU with an identical end screenshot.
ECS-2160

Copilot AI balanced review requested due to automatic review settings November 12, 2026 20:01
@github-actions
github-actions Bot temporarily deployed to preview/apollo-landing November 12, 2026 20:01 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-vertex November 12, 2026 20:01 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-docs November 12, 2026 20:02 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-design November 12, 2026 20:02 Destroyed
@github-actions github-actions Bot added the size:L 100-499 changed lines. label Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the change that batches node-internals updates per React Flow store.

No open issues 🎉

What changed in this PR

Reduces repeated React Flow store updates when mounting large diagrams by batching BaseNode internals updates per store.

Changes:

  • Adds a microtask-based hook that collects and deduplicates node IDs separately for each store.
  • Switches BaseNode to the batched hook and adds tests for batching, store isolation, StrictMode, and subsequent updates.
  • Updates AgentCanvas test mocks to provide the store API required by the hook.
File Description
packages/​apollo-react/​src/​canvas/​components/​BaseNode/​useBatchedUpdateNodeInternals.ts Adds per-store batching and ID deduplication.
packages/​apollo-react/​src/​canvas/​components/​BaseNode/​useBatchedUpdateNodeInternals.test.tsx Tests batching, store isolation, and repeat updates.
packages/​apollo-react/​src/​canvas/​components/​BaseNode/​BaseNode.tsx Uses the batched internals-update hook.
packages/​apollo-react/​src/​canvas/​components/​BaseNode/​BaseNode.test.tsx Tests batched mounting and handle-change updates.
packages/​apollo-react/​src/​canvas/​components/​AgentCanvas/​nodes/​ResourceNode.test.tsx Adds the required store API mock.
packages/​apollo-react/​src/​canvas/​components/​AgentCanvas/​nodes/​AgentNode.test.tsx Adds the required store API mock.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Dependency License Review

  • ✅ 1958 package(s) scanned
  • ✅ No license issues found
  • ⚠️ 2 package(s) excluded (see details below)
License distribution
License Packages
MIT 1722
ISC 91
Apache-2.0 57
BSD-3-Clause 28
BSD-2-Clause 23
BlueOak-1.0.0 8
MPL-2.0 4
CC0-1.0 4
MIT-0 3
MIT OR Apache-2.0 2
(MIT OR Apache-2.0) 2
Unlicense 2
LGPL-3.0-or-later 1
Python-2.0 1
CC-BY-4.0 1
(MPL-2.0 OR Apache-2.0) 1
Unknown 1
Artistic-2.0 1
(WTFPL OR MIT) 1
(BSD-2-Clause OR MIT OR Apache-2.0) 1
CC-BY-3.0 1
0BSD 1
(MIT OR CC0-1.0) 1
MIT AND ISC 1
Excluded packages
Package Version License Reason
@img/sharp-libvips-linux-x64 1.3.4 LGPL-3.0-or-later LGPL pre-built binary, not linked
khroma 2.1.0 Unknown MIT per GitHub repo, missing license field in package.json

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

📊 Coverage + size by package

Per-package coverage and bundle size on this PR. New-line coverage = of the source lines this PR adds or changes, the % hit by tests.

Package Coverage New-line coverage Packed (gzip) Unpacked vs main
@uipath/apollo-core — — 42.02 MB 50.17 MB ±0
@uipath/apollo-react 59.7% 97.2% (35/36) 2.49 MB 14.02 MB +609 B
@uipath/apollo-ui-icons — — 2.86 MB 6.97 MB ±0
@uipath/apollo-vertex 92.6% — 350.1 KB 1.98 MB ±0
@uipath/apollo-wind 82.4% 96.9% (253/261) 909.2 KB 5.12 MB +27 B
@uipath/ap-chat 85.8% — 40.48 MB 46.10 MB ±0

"Coverage" is each package's own coverage.include scope (e.g. apollo-core instruments only scripts/). "Packed"/"Unpacked" come from npm pack --dry-run and only cover built packages — "—" means not measured this run (package not affected / not built). "vs main" is the packed (gzipped) delta against the last successful main build (the package-sizes artifact from the Release workflow); "—" there means no main baseline was available this run. The baseline is main's latest build, not this PR's exact merge-base, so it includes any drift since the branch diverged. Packages with no vitest config are omitted.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Storybook visual diff

⚠️ Visual changes detected: 14 changed, 3 errored (of 406 compared, 389 unchanged). View report

Baseline is the deployed main Storybook, so changes merged to main after this branch was last updated can also appear here. Logs

Updated (PT): Nov 13, 2026, 08:24:07 AM

…act Flow store [ECS-2160]

Each BaseNode called updateNodeInternals on mount and React Flow turned every
call into its own full-store update, so mounting N nodes cost N updates.
BaseNode now queues its id and sends one update per store per task.
@pateljay43
pateljay43 force-pushed the jay/apollo-basenode-batch-internals branch from b4b1517 to e09629e Compare November 12, 2026 20:58
Copilot AI balanced review requested due to automatic review settings November 12, 2026 20:58
@github-actions
github-actions Bot temporarily deployed to preview/apollo-docs November 12, 2026 20:58 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-design November 12, 2026 20:58 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-vertex November 12, 2026 20:58 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-landing November 12, 2026 20:58 Destroyed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The review identifies no active issues in the per-store node-internals batching change.

No open issues 🎉

Review effort: Balanced

@pateljay43
pateljay43 marked this pull request as ready for review November 12, 2026 21:53
@pateljay43
pateljay43 requested a review from ayushya November 12, 2026 21:54

@ayushya ayushya left a comment

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.

LGTM. Follow-up: SmartHandle still calls updateNodeInternals per handle on mount (prevPositionRef starts null), so useSmartHandles nodes keep the fan-out. Could reuse this hook there.

…ernals calls [ECS-2160]

Both called updateNodeInternals per node from their own rAF, and microtasks run
between rAF callbacks, so mounting N nodes still cost N store updates. They now
call useBatchedUpdateNodeInternals from the effect; xyflow still measures in its rAF.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 13:34
@github-actions
github-actions Bot temporarily deployed to preview/apollo-landing November 13, 2026 13:35 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-docs November 13, 2026 13:35 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-design November 13, 2026 13:35 Destroyed
@pateljay43

Copy link
Copy Markdown
Contributor Author

@ayushya the SmartHandle follow-up is in 3f1858c: SmartHandle and ContainerNode now call the batched hook from the effect instead of their own rAF (xyflow already measures inside its own rAF), so N nodes mounting together is one update per store.

@github-actions
github-actions Bot temporarily deployed to preview/apollo-vertex November 13, 2026 13:35 Destroyed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the React Flow node-update batching change.

No open issues 🎉

Review effort: Balanced

@pateljay43
pateljay43 requested a review from ayushya November 13, 2026 15:08
…hooks [ECS-2160]

BaseNode renders SmartHandle, so SmartHandle importing from BaseNode/ was an upward edge.
The hook now sits with the other shared canvas hooks; the public barrel is unchanged.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 15:35
@github-actions
github-actions Bot temporarily deployed to preview/apollo-landing November 13, 2026 15:35 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-docs November 13, 2026 15:35 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-vertex November 13, 2026 15:35 Destroyed
@github-actions
github-actions Bot temporarily deployed to preview/apollo-design November 13, 2026 15:35 Destroyed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the per-store node-internals batching change.

No open issues 🎉

Review effort: Balanced

@pateljay43
pateljay43 merged commit d1e5013 into main Nov 13, 2026
43 checks passed
@pateljay43
pateljay43 deleted the jay/apollo-basenode-batch-internals branch November 13, 2026 16:24

This branch was successfully deployed

No deployments
preview/apollo-design — 5106e30a Deployed Nov 13, 2026 by github-actions[bot]
preview/apollo-docs — 5106e30a Deployed Nov 13, 2026 by github-actions[bot]
preview/apollo-vertex — 5106e30a Deployed Nov 13, 2026 by github-actions[bot]
preview/apollo-landing — 5106e30a Deployed Nov 13, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:apollo-react size:L 100-499 changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants