Skip to content

Fix EdgeDraw reactivity to Python-side name changes (0.5.24) - #321

Merged
koaning merged 1 commit into
mainfrom
koaning/prepare-bugfix-release
Aug 10, 2026
Merged

Fix EdgeDraw reactivity to Python-side name changes (0.5.24)#321
koaning merged 1 commit into
mainfrom
koaning/prepare-bugfix-release

Conversation

@koaning

@koaning koaning commented Aug 10, 2026

Copy link
Copy Markdown
Owner

What & why

Reported via r/marimo_notebook: adding/removing nodes on an EdgeDraw from Python did nothing. Two causes:

  1. User-side (expected): widget.names.append(...) mutates in place, and traitlets only fires on reassignment — so it never syncs. Documented in the demo.
  2. Real bug (fixed here): even with correct reassignment, the frontend read names only once at init and registered change handlers for links/directed but not names, so Python-side node changes never rendered.

Changes

  • js/edgedraw.js (+ rebuilt wigglystuff/static/edgedraw.js): add a change:names handler that rebuilds nodes (reusing positions for survivors, spawning new ones at center), rebuilds the id maps, clears stale selection, prunes links pointing at removed nodes (and syncs them back to Python), re-binds the .node/.label selections keyed by id, and restarts the force simulation. Promoted the mutated closure bindings from const to let.
  • demos/edgedraw.py: new "Editing nodes from Python" section (text box + Add/Remove buttons using reassignment) with a note on why .append() doesn't work. Bumped the PEP 723 pin to 0.5.24.
  • Release: pyproject.toml / uv.lock0.5.24, CHANGELOG.md entry under ### Fixed.

Verification

  • uv run pytest tests/test_edgedraw.py → 5 passed
  • uv run marimo check demos/edgedraw.py → clean
  • Smoke test: reassigning widget.names add/remove works; links preserved
  • Manual: in the demo, Add node draws a draggable/linkable node; Remove node drops it and its edges

🤖 Generated with Claude Code

EdgeDraw's frontend read `names` only once at init and registered change
handlers for `links`/`directed` but not `names`, so adding or removing nodes
from Python never updated the drawing. Add a `change:names` handler that
rebuilds nodes (reusing positions for survivors), prunes links pointing at
removed nodes (syncing them back), and restarts the force simulation.

Also demos the runtime add/remove-node pattern and bumps the release to 0.5.24.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@koaning
koaning merged commit e9df353 into main Aug 10, 2026
1 check passed
@koaning
koaning deleted the koaning/prepare-bugfix-release branch August 10, 2026 08:39
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.

1 participant