Skip to content

fix(apollo-react): compute node height from handle count to stop flicker [MST-11677]#867

Open
KodudulaAshishUiPath wants to merge 2 commits into
mainfrom
fix/MST-11677-basenode-height-flicker
Open

fix(apollo-react): compute node height from handle count to stop flicker [MST-11677]#867
KodudulaAshishUiPath wants to merge 2 commits into
mainfrom
fix/MST-11677-basenode-height-flicker

Conversation

@KodudulaAshishUiPath

@KodudulaAshishUiPath KodudulaAshishUiPath commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the Switch-node height flicker (MST-11677): deleting a case from an unconnected Switch made it oscillate between the 2-handle (96px) and 3-handle (128px) sizes. Root cause was a feedback loop where BaseNode derived its height from the measured height prop and wrote it back via updateNode inside a requestAnimationFrame.

Changes

  • computedHeight is now a pure function of visible handle count + intrinsic footer/default height (getIntrinsicHeight). It never reads the measured height prop, so the value written back can't feed into its own input — the loop is structurally gone.
  • A single, synchronous useEffect writes computedHeight to node.height (no rAF), only when it differs from the explicit getNode(id)?.height, then calls updateNodeInternals. Comparing against the explicit height (not the measured prop) means a lagging ResizeObserver measurement can't retrigger the write. Convergent and idempotent.
  • Keeping node.height authoritative fixes the downstream model: measured height, edge anchoring, fit-view, selection bounds, and handle spacing all agree with the rendered body (fixes handles overflowing on high-fan-out nodes).
  • animatedViewportManager now reads node.measured?.height ?? node.height ?? …, matching the package's dominant convention (previously node.height || 100, which went stale when height wasn't written).
  • Removed the old baseHeightRef/syncedHeightRef bookkeeping and the dead getContainerHeight height param.

Flow

flowchart TD
    A[handleConfigurations / footer] --> B[computedHeight - pure]
    B --> C{getNode.height != computedHeight?}
    C -- yes --> D[updateNode height + updateNodeInternals]
    C -- no --> E[no-op: converged]
    D --> F[node.height authoritative]
    F --> G[measured height / edges / handle spacing agree]
Loading

Testing

  • pnpm lint (Biome) passes
  • pnpm typecheck passes
  • Tests pass — rewritten height suite asserts the write-once/converge behavior, the 128→96 deflation settles with no re-inflation, and no write when already correct (full apollo-react suite green, 1885)
  • pnpm test:visual — runs in CI
  • No as any / type suppressions added

Copilot AI review requested due to automatic review settings June 29, 2026 18:39
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (PT)
apollo-design 🟢 Ready Preview, Logs Jul 10, 2026, 10:29:02 AM
apollo-docs 🟢 Ready Preview, Logs Jul 10, 2026, 10:29:02 AM
apollo-landing 🟢 Ready Preview, Logs Jul 10, 2026, 10:29:02 AM
apollo-vertex 🟢 Ready Preview, Logs Jul 10, 2026, 10:29:02 AM

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Dependency License Review

  • 1948 package(s) scanned
  • ✅ No license issues found
  • ⚠️ 2 package(s) excluded (see details below)
License distribution
License Packages
MIT 1718
ISC 89
Apache-2.0 55
BSD-3-Clause 27
BSD-2-Clause 23
BlueOak-1.0.0 8
MPL-2.0 4
MIT-0 3
CC0-1.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.2.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

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.

Pull request overview

Fixes a React Flow node-height oscillation in apollo-react canvas BaseNode caused by a deferred requestAnimationFrame height sync briefly stamping a “synced” height before the write actually committed, allowing a stale in-flight height to be treated as an external resize.

Changes:

  • Move syncedHeightRef stamping into the rAF callback so it only records heights that were actually committed via updateNode.
  • Tighten comments around syncedHeightRef / baseHeightRef semantics to reflect commit-time stamping and the external-vs-internal height distinction.
  • Add a regression test that keeps rAF deferred and reproduces the stale interleaved render scenario, asserting the node deflates and remains stable.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/apollo-react/src/canvas/components/BaseNode/BaseNode.tsx Stamps syncedHeightRef at rAF commit time (paired with updateNode) to prevent stale in-flight heights from poisoning baseHeightRef.
packages/apollo-react/src/canvas/components/BaseNode/BaseNode.test.tsx Adds a deferred-rAF regression test to reproduce and prevent the 96px ↔ 128px flicker loop.

@github-actions

github-actions Bot commented Jun 29, 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 9.0% 43.82 MB 57.31 MB ±0
@uipath/apollo-react 34.4% 100.0% (10/10) 7.27 MB 27.61 MB −192 B
@uipath/apollo-wind 40.3% 395.0 KB 2.57 MB +15 B
@uipath/ap-chat 85.8% 43.41 MB 55.85 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.

Comment thread packages/apollo-react/src/canvas/components/BaseNode/BaseNode.tsx Outdated
@KodudulaAshishUiPath KodudulaAshishUiPath force-pushed the fix/MST-11677-basenode-height-flicker branch from 04c3ca9 to 7bae0a7 Compare July 1, 2026 13:30
@github-actions github-actions Bot added size:L 100-499 changed lines. and removed size:M 30-99 changed lines. labels Jul 1, 2026
@KodudulaAshishUiPath KodudulaAshishUiPath changed the title fix(apollo-react): stop node height flicker on handle count change [MST-11677] fix(apollo-react): make node height content-driven to stop handle flicker [MST-11677] Jul 1, 2026
Comment thread packages/apollo-react/src/canvas/components/BaseNode/BaseNode.tsx Outdated
Copilot AI review requested due to automatic review settings July 2, 2026 12:23
@KodudulaAshishUiPath KodudulaAshishUiPath force-pushed the fix/MST-11677-basenode-height-flicker branch from 7bae0a7 to ed95b26 Compare July 2, 2026 12:23
@KodudulaAshishUiPath KodudulaAshishUiPath changed the title fix(apollo-react): make node height content-driven to stop handle flicker [MST-11677] fix(apollo-react): compute node height from handle count to stop flicker [MST-11677] Jul 2, 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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread packages/apollo-react/src/canvas/components/BaseNode/BaseNode.tsx
Comment thread packages/apollo-react/src/canvas/components/BaseNode/BaseNode.tsx
@KodudulaAshishUiPath KodudulaAshishUiPath force-pushed the fix/MST-11677-basenode-height-flicker branch from ed95b26 to ad23359 Compare July 3, 2026 07:48
Comment thread packages/apollo-react/src/canvas/components/BaseNode/BaseNode.tsx
Comment thread packages/apollo-react/src/canvas/stores/animatedViewportManager.ts Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 07:00

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 10, 2026 11:17
@KodudulaAshishUiPath KodudulaAshishUiPath force-pushed the fix/MST-11677-basenode-height-flicker branch from 4a3a6a6 to d887e35 Compare July 10, 2026 11:17

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 10, 2026 17:24
@KodudulaAshishUiPath KodudulaAshishUiPath force-pushed the fix/MST-11677-basenode-height-flicker branch from d887e35 to c8a66b4 Compare July 10, 2026 17:24
@KodudulaAshishUiPath KodudulaAshishUiPath enabled auto-merge (rebase) July 10, 2026 17:25

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

// Write computedHeight to node.height and recalculate handle positions. Compare
// against node.height (not the measured `height` prop) so a lagging measurement
// can't retrigger the write.
// biome-ignore lint/correctness/useExhaustiveDependencies: handleConfigurations triggers handle recalculation.
Comment on lines +66 to +70
// Intrinsic height: the fixed footer height when a footer is present, else the default.
const getIntrinsicHeight = (
hasFooter: boolean,
footerVariant: FooterVariant | undefined
): number | 'auto' => {
): number => {
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.

5 participants