Skip to content

CURVE node#12757

Merged
jtydhr88 merged 9 commits intomasterfrom
curve-node
Mar 24, 2026
Merged

CURVE node#12757
jtydhr88 merged 9 commits intomasterfrom
curve-node

Conversation

@jtydhr88
Copy link
Copy Markdown
Contributor

@jtydhr88 jtydhr88 commented Mar 4, 2026

  • Add CurveEditor node as a general-purpose utility for editing curves

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 4, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds curve types and a node. Introduces CurvePoint alias, CurveInput ABC, and MonotoneCubicCurve and LinearCurve implementations (with interp, interp_array, to_lut) in comfy_api/latest/_input/basic_types.py. Re-exports CurveInput, MonotoneCubicCurve, and LinearCurve via comfy_api.latest._input and comfy_api.input. Adds a public CurveEditor node (INPUT_TYPES expects a CURVE with default points and interpolation, RETURN_TYPES ("CURVE",), FUNCTION execute) and registers it in NODE_CLASS_MAPPINGS and NODE_DISPLAY_NAME_MAPPINGS. In comfy_api.latest._io, Curve.Type is removed at runtime and now exists only under TYPE_CHECKING.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.74% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'CURVE node' is vague and generic, using non-descriptive language that doesn't clearly convey what the changeset accomplishes. Consider a more descriptive title like 'Add CurveEditor node for curve editing utilities' to better communicate the primary change.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description directly references the changeset by describing the addition of a CurveEditor node as a general-purpose utility for editing curves.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@comfy_extras/nodes_custom_sampler.py`:
- Around line 1069-1089: In execute (nodes_custom_sampler.execute) clamp the
interpolated y to [0.0,1.0] before converting to a sigma and avoid calling
model_sampling.percent_to_sigma with a 0.0 sentinel: compute percent = 1.0 -
clamp(y,0.0,1.0) and if percent <= 0.0 use model_sampling.sigma_max.item() (or
the equivalent sigma_max from the model) instead of percent_to_sigma(0.0);
otherwise call model_sampling.percent_to_sigma(percent) and append that float to
sigmas, keeping the existing fallback (y * sigma_max) when model_sampling is
None and preserving the final sigmas[-1] = 0.0 behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2f409527-bbae-4232-99ed-5da206a7f411

📥 Commits

Reviewing files that changed from the base of the PR and between eb01173 and 4c11d5f.

📒 Files selected for processing (2)
  • comfy_extras/nodes_custom_sampler.py
  • nodes.py

@jtydhr88
Copy link
Copy Markdown
Contributor Author

jtydhr88 commented Mar 16, 2026

@christian-byrne I merged your changes and follow your pattern to add one more type linear curve
image

FE change is Comfy-Org/ComfyUI_frontend#10118

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@comfy_api/latest/_input/basic_types.py`:
- Around line 226-227: LinearCurve.interp_array currently calls np.interp
directly and raises ValueError for empty control-point lists; update
interp_array to mirror interp()'s behavior by checking if self._xs/self._ys are
empty (e.g., if not self._xs or len(self._xs)==0) and in that case return an
array of zeros shaped like xs_in (use np.zeros_like(xs_in)), otherwise call
np.interp as before; reference: LinearCurve.interp_array, LinearCurve.interp(),
and to_lut().

In `@nodes.py`:
- Around line 2039-2058: The node's execute method assumes curve is a dict with
"points" but INPUT_TYPES advertises a bare point list; update execute to accept
both shapes: if curve is a CurveInput return it, elif isinstance(curve, (list,
tuple)) treat it as the raw point list, else if it's a dict read points =
curve.get("points") and interpolation =
curve.get("interpolation","monotone_cubic"); then build points =
[(float(x),float(y))...] and return LinearCurve(points) or
MonotoneCubicCurve(points) as before (referencing INPUT_TYPES, execute,
CurveInput, LinearCurve, MonotoneCubicCurve).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 87c6f8cb-67ef-4888-b880-9dc0595ec77e

📥 Commits

Reviewing files that changed from the base of the PR and between 62d9a99 and cfaa4c3.

📒 Files selected for processing (4)
  • comfy_api/input/__init__.py
  • comfy_api/latest/_input/__init__.py
  • comfy_api/latest/_input/basic_types.py
  • nodes.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • comfy_api/input/init.py

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@comfy_api/latest/_input/basic_types.py`:
- Around line 172-175: The edge-case branches in Monotone.interp_array (when n
== 0 or n == 1) currently use np.zeros_like(xs_in) and np.full_like(xs_in,
ys[0]), which inherit xs_in's dtype and can truncate floats when xs_in is
integer; change these to explicitly return float arrays (e.g. use
dtype=np.float64) so outputs match LinearCurve.interp_array's behavior; update
the branches referencing xs_in and ys in the Monotone.interp_array method to
construct results with dtype=np.float64.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d9511f24-c1aa-4bea-ad53-bd4cf84925b9

📥 Commits

Reviewing files that changed from the base of the PR and between cfaa4c3 and 525fc73.

📒 Files selected for processing (4)
  • comfy_api/input/__init__.py
  • comfy_api/latest/_input/__init__.py
  • comfy_api/latest/_input/basic_types.py
  • nodes.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • comfy_api/input/init.py

christian-byrne pushed a commit to Comfy-Org/ComfyUI_frontend that referenced this pull request Mar 17, 2026
## Summary

Change the CURVE widget value from CurvePoint[] to CurveData ({ points,
interpolation }) to support multiple interpolation types. Add a Select
dropdown in the widget UI for switching between Smooth (monotone cubic)
and Linear interpolation, with the SVG preview updating accordingly.

- Add CurveData type with CURVE_INTERPOLATIONS const enum
- Add createLinearInterpolator with piecewise linear + binary search
- Add createInterpolator factory dispatching by interpolation type
- Add isCurveData type guard in curveUtils
- Update ICurveWidget value type to CurveData
- Add interpolation prop to CurveEditor and useCurveEditor composable
- Linear mode generates direct M...L... SVG path (no sampling)
- Add i18n entries for interpolation labels
- Add unit tests for createLinearInterpolator

BE change is Comfy-Org/ComfyUI#12757

## Screenshots (if applicable)
<img width="1437" height="670" alt="image"
src="https://github.com/user-attachments/assets/550aedec-e5da-425b-8233-86a4f28067fa"
/>

<img width="1445" height="648" alt="image"
src="https://github.com/user-attachments/assets/0a8dc654-3f92-4ca2-9fa2-c1fef3be6d66"
/>

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10118-feat-add-linear-interpolation-type-to-CURVE-widget-3256d73d36508185a86edf73bb555c51)
by [Unito](https://www.unito.io)
github-actions bot pushed a commit to Comfy-Org/ComfyUI_frontend that referenced this pull request Mar 17, 2026
## Summary

Change the CURVE widget value from CurvePoint[] to CurveData ({ points,
interpolation }) to support multiple interpolation types. Add a Select
dropdown in the widget UI for switching between Smooth (monotone cubic)
and Linear interpolation, with the SVG preview updating accordingly.

- Add CurveData type with CURVE_INTERPOLATIONS const enum
- Add createLinearInterpolator with piecewise linear + binary search
- Add createInterpolator factory dispatching by interpolation type
- Add isCurveData type guard in curveUtils
- Update ICurveWidget value type to CurveData
- Add interpolation prop to CurveEditor and useCurveEditor composable
- Linear mode generates direct M...L... SVG path (no sampling)
- Add i18n entries for interpolation labels
- Add unit tests for createLinearInterpolator

BE change is Comfy-Org/ComfyUI#12757

## Screenshots (if applicable)
<img width="1437" height="670" alt="image"
src="https://github.com/user-attachments/assets/550aedec-e5da-425b-8233-86a4f28067fa"
/>

<img width="1445" height="648" alt="image"
src="https://github.com/user-attachments/assets/0a8dc654-3f92-4ca2-9fa2-c1fef3be6d66"
/>

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10118-feat-add-linear-interpolation-type-to-CURVE-widget-3256d73d36508185a86edf73bb555c51)
by [Unito](https://www.unito.io)
github-actions bot pushed a commit to Comfy-Org/ComfyUI_frontend that referenced this pull request Mar 17, 2026
## Summary

Change the CURVE widget value from CurvePoint[] to CurveData ({ points,
interpolation }) to support multiple interpolation types. Add a Select
dropdown in the widget UI for switching between Smooth (monotone cubic)
and Linear interpolation, with the SVG preview updating accordingly.

- Add CurveData type with CURVE_INTERPOLATIONS const enum
- Add createLinearInterpolator with piecewise linear + binary search
- Add createInterpolator factory dispatching by interpolation type
- Add isCurveData type guard in curveUtils
- Update ICurveWidget value type to CurveData
- Add interpolation prop to CurveEditor and useCurveEditor composable
- Linear mode generates direct M...L... SVG path (no sampling)
- Add i18n entries for interpolation labels
- Add unit tests for createLinearInterpolator

BE change is Comfy-Org/ComfyUI#12757

## Screenshots (if applicable)
<img width="1437" height="670" alt="image"
src="https://github.com/user-attachments/assets/550aedec-e5da-425b-8233-86a4f28067fa"
/>

<img width="1445" height="648" alt="image"
src="https://github.com/user-attachments/assets/0a8dc654-3f92-4ca2-9fa2-c1fef3be6d66"
/>

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10118-feat-add-linear-interpolation-type-to-CURVE-widget-3256d73d36508185a86edf73bb555c51)
by [Unito](https://www.unito.io)
github-actions bot pushed a commit to Comfy-Org/ComfyUI_frontend that referenced this pull request Mar 17, 2026
## Summary

Change the CURVE widget value from CurvePoint[] to CurveData ({ points,
interpolation }) to support multiple interpolation types. Add a Select
dropdown in the widget UI for switching between Smooth (monotone cubic)
and Linear interpolation, with the SVG preview updating accordingly.

- Add CurveData type with CURVE_INTERPOLATIONS const enum
- Add createLinearInterpolator with piecewise linear + binary search
- Add createInterpolator factory dispatching by interpolation type
- Add isCurveData type guard in curveUtils
- Update ICurveWidget value type to CurveData
- Add interpolation prop to CurveEditor and useCurveEditor composable
- Linear mode generates direct M...L... SVG path (no sampling)
- Add i18n entries for interpolation labels
- Add unit tests for createLinearInterpolator

BE change is Comfy-Org/ComfyUI#12757

## Screenshots (if applicable)
<img width="1437" height="670" alt="image"
src="https://github.com/user-attachments/assets/550aedec-e5da-425b-8233-86a4f28067fa"
/>

<img width="1445" height="648" alt="image"
src="https://github.com/user-attachments/assets/0a8dc654-3f92-4ca2-9fa2-c1fef3be6d66"
/>

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10118-feat-add-linear-interpolation-type-to-CURVE-widget-3256d73d36508185a86edf73bb555c51)
by [Unito](https://www.unito.io)
github-actions bot pushed a commit to Comfy-Org/ComfyUI_frontend that referenced this pull request Mar 17, 2026
## Summary

Change the CURVE widget value from CurvePoint[] to CurveData ({ points,
interpolation }) to support multiple interpolation types. Add a Select
dropdown in the widget UI for switching between Smooth (monotone cubic)
and Linear interpolation, with the SVG preview updating accordingly.

- Add CurveData type with CURVE_INTERPOLATIONS const enum
- Add createLinearInterpolator with piecewise linear + binary search
- Add createInterpolator factory dispatching by interpolation type
- Add isCurveData type guard in curveUtils
- Update ICurveWidget value type to CurveData
- Add interpolation prop to CurveEditor and useCurveEditor composable
- Linear mode generates direct M...L... SVG path (no sampling)
- Add i18n entries for interpolation labels
- Add unit tests for createLinearInterpolator

BE change is Comfy-Org/ComfyUI#12757

## Screenshots (if applicable)
<img width="1437" height="670" alt="image"
src="https://github.com/user-attachments/assets/550aedec-e5da-425b-8233-86a4f28067fa"
/>

<img width="1445" height="648" alt="image"
src="https://github.com/user-attachments/assets/0a8dc654-3f92-4ca2-9fa2-c1fef3be6d66"
/>

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10118-feat-add-linear-interpolation-type-to-CURVE-widget-3256d73d36508185a86edf73bb555c51)
by [Unito](https://www.unito.io)
Copy link
Copy Markdown
Member

@Kosinkadink Kosinkadink left a comment

Choose a reason for hiding this comment

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

The curve code is fine in the PR, but this should be restructured to not add code to nodes.py; that file is already cluttered with a bunch of legacy code so it would be best not to add new things into it. The Curve editor node can be added to its own nodes_extras file and be written in V3. Extending the typing of v1 is not really worthwhile.

jtydhr88 and others added 6 commits March 21, 2026 08:35
CurveInput is an abstract base class so future curve representations
(bezier, LUT-based, analytical functions) can be added without breaking
downstream nodes that type-check against CurveInput.

MonotoneCubicCurve is the concrete implementation that:
- Mirrors frontend createMonotoneInterpolator (curveUtils.ts) exactly
- Pre-computes slopes as numpy arrays at construction time
- Provides vectorised interp_array() using numpy for batch evaluation
- interp() for single-value evaluation
- to_lut() for generating lookup tables

CurveEditor node wraps raw widget points in MonotoneCubicCurve.
@jtydhr88
Copy link
Copy Markdown
Contributor Author

jtydhr88 commented Mar 21, 2026

Add Histogram to support in curve editor

  • Add HISTOGRAM comfytype for passing histogram data between nodes
  • CurveEditor accepts optional histogram input and forwards it to frontend via ui output for display behind the curve editor

used in FE change in Comfy-Org/ComfyUI_frontend#10365

image image

but I don't include image to histogram node in this PR, will add in follow up PR

@jtydhr88 jtydhr88 force-pushed the curve-node branch 2 times, most recently from 116b18d to d7a4f7c Compare March 23, 2026 14:59
@jtydhr88 jtydhr88 assigned christian-byrne and unassigned jtydhr88 Mar 23, 2026
@jtydhr88 jtydhr88 merged commit 8e73678 into master Mar 24, 2026
21 checks passed
@jtydhr88 jtydhr88 deleted the curve-node branch March 24, 2026 23:52
christian-byrne pushed a commit to Comfy-Org/ComfyUI_frontend that referenced this pull request Mar 28, 2026
## Summary

Change the CURVE widget value from CurvePoint[] to CurveData ({ points,
interpolation }) to support multiple interpolation types. Add a Select
dropdown in the widget UI for switching between Smooth (monotone cubic)
and Linear interpolation, with the SVG preview updating accordingly.

- Add CurveData type with CURVE_INTERPOLATIONS const enum
- Add createLinearInterpolator with piecewise linear + binary search
- Add createInterpolator factory dispatching by interpolation type
- Add isCurveData type guard in curveUtils
- Update ICurveWidget value type to CurveData
- Add interpolation prop to CurveEditor and useCurveEditor composable
- Linear mode generates direct M...L... SVG path (no sampling)
- Add i18n entries for interpolation labels
- Add unit tests for createLinearInterpolator

BE change is Comfy-Org/ComfyUI#12757

## Screenshots (if applicable)
<img width="1437" height="670" alt="image"
src="https://github.com/user-attachments/assets/550aedec-e5da-425b-8233-86a4f28067fa"
/>

<img width="1445" height="648" alt="image"
src="https://github.com/user-attachments/assets/0a8dc654-3f92-4ca2-9fa2-c1fef3be6d66"
/>

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10118-feat-add-linear-interpolation-type-to-CURVE-widget-3256d73d36508185a86edf73bb555c51)
by [Unito](https://www.unito.io)
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.

5 participants