fix: address PR review feedback for upstream value composable (#9908)

## Summary
follow up https://github.com/Comfy-Org/ComfyUI_frontend/pull/9851
fix https://github.com/Comfy-Org/ComfyUI_frontend/issues/9877 and
https://github.com/Comfy-Org/ComfyUI_frontend/issues/9878

- Make useUpstreamValue generic to eliminate as Bounds/CurvePoint[]
casts
- Change isBoundsObject to type predicate (value is Bounds)
- Reuse WidgetState from widgetValueStore instead of duplicate interface
- Add length >= 2 guard in isCurvePointArray for empty arrays
- Add disabled guard in effectiveBounds setter
- Add unit tests for singleValueExtractor and boundsExtractor

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-9908-fix-address-PR-review-feedback-for-upstream-value-composable-3236d73d365081f7a01dcb416732544a)
by [Unito](https://www.unito.io)

---------

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Terry Jia
2026-03-13 22:58:30 -04:00
committed by GitHub
parent 4c5a49860c
commit 16f4f3f3ed
5 changed files with 137 additions and 21 deletions

View File

@@ -39,7 +39,7 @@ const upstreamValue = useUpstreamValue(
const effectivePoints = computed(() =>
isDisabled.value && upstreamValue.value
? (upstreamValue.value as CurvePoint[])
? upstreamValue.value
: modelValue.value
)
</script>

View File

@@ -3,6 +3,7 @@ import type { CurvePoint } from './types'
export function isCurvePointArray(value: unknown): value is CurvePoint[] {
return (
Array.isArray(value) &&
value.length >= 2 &&
value.every(
(p) =>
Array.isArray(p) &&

View File

@@ -148,10 +148,10 @@ const upstreamValue = useUpstreamValue(
const effectiveBounds = computed({
get: () =>
isDisabled.value && upstreamValue.value
? (upstreamValue.value as Bounds)
? upstreamValue.value
: modelValue.value,
set: (v) => {
modelValue.value = v
if (!isDisabled.value) modelValue.value = v
}
})