Comfy-Org / Comfy-Org/ComfyUI_frontend
refactor: remove internal viewportCache exposure from subgraphNavigationStore and test through public interfaces
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Context
In PR #10247, `viewportCache` was exposed on the public return of `useSubgraphNavigationStore` and marked `@internal` as a pragmatic workaround so unit tests in `src/stores/subgraphNavigationStore.viewport.test.ts` could make direct assertions on the LRU cache (e.g., `viewportCache.set/get/has/delete`).
Exposing the raw LRU gives any consumer full read/write/delete access to internal state, which undermines the store's encapsulation boundary.
## Goal
- Remove `viewportCache` from the store's public return.
- Refactor `src/stores/subgraphNavigationStore.viewport.test.ts` to test viewport behavior exclusively through the public API (`saveViewport`, `restoreViewport`, `saveCurrentViewport`) — e.g., by asserting on observable side-effects such as `canvas.ds.scale`, `canvas.ds.offset`, `canvas.setDirty` calls, and `fitView` spy invocations — rather than inspecting cache internals directly.
## References
- PR: #10247
- Comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10247#discussion_r2998523932
Requested by @DrJKL.
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10627-refactor-remove-internal-viewportCache-exposure-from-subgraphNavigationStore-and-tes-3306d73d365081ff9354e3ebd625cf88) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.