Comfy-Org / Comfy-Org/ComfyUI_frontend

refactor: abstract node-visibility AABB check into a standalone utility

Open
#10,937 1 comment 0 reactions 1 assignee Claimed by @DrJKL View on GitHub
developer experience
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

The inline AABB (axis-aligned bounding box) visibility check added in #10810 (`src/stores/subgraphNavigationStore.ts`) is duplicated in at least one other location (`src/scripts/app.ts` lines 1272–1281). It should be extracted into a reusable, well-named standalone utility function.

## Context

- PR: #10810 (comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10810#discussion_r3046136063)
- Requested by: @DrJKL

## Proposed utility signature (standalone function, not a method on LGraphCanvas)

Per the project ADR (ADR 0008), new behavior must **not** be added as methods to `LGraphNode`, `LGraphCanvas`, `LGraph`, or `Subgraph`. The utility should live in an appropriate location such as `src/utils/graphTraversalUtil.ts` or a new `src/utils/viewportUtil.ts`.

```ts
/**
* Returns true if at least one node's bounding box intersects the canvas
* visible area (i.e. some content is currently on screen).
*/
function hasVisibleNodes(canvas: LGraphCanvas): boolean
```

The implementation would encapsulate:
1. `canvas.ds.computeVisibleArea(canvas.viewport)`
2. Reading `canvas.visible_area`
3. The AABB intersection check over `canvas.graph.nodes`

## Acceptance criteria

- [ ] Extract the logic into a standalone exported utility (not a class method on any LiteGraph entity).
- [ ] Replace the inline check in `subgraphNavigationStore.ts` with the utility call.
- [ ] Replace or consolidate the equivalent check in `app.ts` (lines ~1272–1281) if applicable.
- [ ] Add unit tests for the utility.

/cc @artokun

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10937-refactor-abstract-node-visibility-AABB-check-into-a-standalone-utility-33b6d73d36508121ad19ea159ea259f7) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.