feat: validate graph connections during drag - #75
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I added opt-in browser checks for direction, type, input capacity, duplicates, and cycles, plus Python validators that evaluate candidate handles when a drag starts and show rejection reasons in the canvas. This lets applications prevent invalid interactive connections before creating an edge; Python validators do not restrict programmatic edges, so state-dependent rules still need checking in
edge_added. I added a runnable demo, a how-to guide, and API/Playwright coverage. No new dependencies or migration steps are required.To reproduce, run
PYTHONPATH=src pixi run panel serve examples/connection_validation.py --show, then drag Source.text to Transform.text (allowed), Number.value to Transform.text (type mismatch), and Source.text to Publish.text (Python rejection).Before: invalid drags could create edges and required application-side rollback. After: rejected candidates show their reason during dragging and the browser blocks the drop. The demo above shows both states of the new handle feedback.
Verification:
pixi run compile,PYTHON_GIL=1 PYTHONPATH=src pixi run pytest -q(169 passed, 4 skipped),pixi run -e lint ruff check src/panel_reactflow/base.py tests/test_api.py tests/ui/test_ui.py,pixi run -e docs docs-build, and commit hooks passed. Two focused Playwright tests reported 2 passed, 35 deselected; the process then timed out because Bokeh session-cleanup callbacks continued after pytest reported its result. The full browser suite did not finish here.AI Disclosure
Tool & Model: Kilo Code + openai/gpt-6-sol.
Usage: AI drafted the connection-validation how-to guide, linked it in the docs, reviewed the existing feature changes, ran verification, and prepared this PR.
Checklist