Skip to content

Conversation

@geoffgscott
Copy link
Member

@geoffgscott geoffgscott commented Oct 30, 2025

Problem

When there is very large tags open we have too many DOM elements to handle elegantly.

Solution

Virtualizes operations with a fixed estimated height and a fairly long render window.

Checklist

I've gone through the following:

  • I've added an explanation why this change is needed.
  • I've added a changeset (pnpm changeset).
  • I've added tests for the regression or new feature.
  • I've updated the documentation.

Note

Lazily renders Operation.vue using a new useVirtual hook that shows a placeholder height and mounts content only when in view.

  • API Reference
    • Operation virtualization:
      • features/Operation/Operation.vue: wraps layouts in a container with ref="virtual", applies minHeight from placeholderHeight, and conditionally renders when isVisible using useTemplateRef and useVirtual.
      • Preserves both ClassicLayout and ModernLayout rendering paths behind visibility check.
    • New hook:
      • hooks/use-virtual.ts: adds useVirtual using IntersectionObserver (large rootMargin) to expose isVisible and placeholderHeight for lazy mounting.

Written by Cursor Bugbot for commit 012c286. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2025

⚠️ No Changeset found

Latest commit: 012c286

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Observer Cleanup Issue

The IntersectionObserver created in useVirtual isn't cleaned up when the component unmounts. The current watch only handles changes to the observed element, not component destruction. This leaves active observers holding references to DOM elements and callbacks, which can cause memory leaks.

packages/api-reference/src/hooks/use-virtual.ts#L7-L29

watch(el, () => {
if (el.value) {
observer.value?.disconnect()
observer.value = new IntersectionObserver(
([entry]) => {
if (entry?.isIntersecting) {
isVisible.value = true
nextTick(() => {
placeholderHeight.value = el.value?.offsetHeight || 1000
})
}
},
{
rootMargin: '9000px',
},
)
observer.value.observe(el.value)
} else {
observer.value?.disconnect()
}
})

Fix in Cursor Fix in Web


Bug: Virtual Elements Fail to Unrender

The useVirtual hook's IntersectionObserver sets isVisible to true when an element enters the viewport but lacks logic to set it back to false when the element leaves. This causes elements to remain rendered permanently once visible, defeating the purpose of virtualization and negating its intended performance benefits.

packages/api-reference/src/hooks/use-virtual.ts#L12-L19

observer.value = new IntersectionObserver(
([entry]) => {
if (entry?.isIntersecting) {
isVisible.value = true
nextTick(() => {
placeholderHeight.value = el.value?.offsetHeight || 1000
})
}

Fix in Cursor Fix in Web


@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

Scalar References End to End Test Results

failed  3 failed
passed  61 passed

Details

report  Open report ↗︎
stats  64 tests across 29 suites
duration  17 seconds
commit  012c286

Failed tests

test/snapshots/models.e2e.ts › Scalar Galaxy (Classic Layout)
test/snapshots/operations.e2e.ts › Scalar Galaxy
test/snapshots/operations.e2e.ts › Scalar Galaxy (Classic Layout)

Important

These tests include snapshots that may need to be updated if there are intentional changes to the UI components. To update the snapshots run pnpm test:e2e:update in packages/api-reference and commit the changes.

@github-actions
Copy link
Contributor

Scalar Components Snapshot Test Results

passed  152 passed

Details

report  Open report ↗︎
stats  152 tests across 19 suites
duration  46.3 seconds
commit  012c286

@github-actions
Copy link
Contributor

Scalar CDN Snapshot Diff Results

failed  17 failed
passed  2 passed

Details

report  Open report ↗︎
stats  19 tests across 1 suite
duration  38.5 seconds
commit  012c286
info  These tests are non-blocking and will not prevent merging of your PR.

Failed tests

test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Scalar Galaxy
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Scalar Galaxy Registry
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Scalar Galaxy (Classic Layout)
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Stripe
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Swagger Petstore 2.0
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Swagger Petstore 3.0
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Swagger Petstore 3.1
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Hello World (string)
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Valtown
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Zoom
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Cloudinary
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Tailscale
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Maersk
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Bolt
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - OpenStatus
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Spotify
test/snapshots-cdn/snapshot.e2e.ts › Diff with CDN - Circular

Important

These tests detect visual differences between the current PR and the latest CDN build which means they may be affected by other changes in main that haven't been released yet.

They can help determine if the changes in the PR are causing any unexpected visual regressions but may be less helpful in isolating the exact cause. For more details see the readme.

@geoffgscott geoffgscott marked this pull request as draft October 30, 2025 20:31
@hanspagel hanspagel changed the title feat(api-refernece): Concept for virtualized operations. feat(api-refernece): virtualized operations Oct 31, 2025
@hanspagel hanspagel changed the title feat(api-refernece): virtualized operations feat(api-reference): virtualized operations Oct 31, 2025
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.

2 participants