Skip to content

Molkit 0.5.1

Released April 10, 2026

New Features

  • Canvas 2D overlay system for transient UI feedback (selection rect, alignment guides, snap dots, bond preview)
  • Canvas overlay bypasses SVG rendering pipeline entirely for drag overlays, using immediate-mode Canvas 2D drawing
  • Feature flag (`USE_CANVAS_OVERLAY`) allows instant revert to legacy SVG/DOM rendering

Improvements

  • Dev animation flags now persist in .mkit files (saved on export, restored on load)
  • Dev animation flags persist across auto-save, tab switch, and OPFS recovery
  • Selection rect drag no longer triggers full Renderer.render() when nothing is selected (skips unnecessary dispatch)
  • State strip click uses lightweight CSS class toggle instead of full DOM rebuild with timeline recomputation
  • States panel active-state switch uses fast highlight path instead of full list rebuild
  • buildPreviewTimeline result cached in StateStrip (only recomputed on structural animation changes)
  • BCR (getBoundingClientRect) cached for the duration of each drag operation (eliminates per-pointermove layout queries)
  • Auto-scroll detection skipped during selection rect drag (eliminates forced layout thrashing from read-after-write BCR pattern)
  • Alignment guides, snap dots, and snap labels render via Canvas 2D (eliminates dozens of SVG createElement/setAttribute/appendChild calls per frame during atom and annotation drag)
  • Bond preview renders via Canvas 2D overlay during bond tool drag
  • What's New dialog loads instantly (was waiting for a failed network fetch before falling back to embedded data)
  • What's New dialog now shows full changelog content for all versions (was showing truncated entries for older versions)
  • Changelog data imported directly via Vite JSON import (always in sync with markdown files)
  • Status messages during PDF rasterization and clipboard copy use the notification system instead of the never-implemented StatusBar object
  • Store.notify() is now resilient to subscriber errors (individual try/catch per subscriber prevents cascade failures)
  • ESLint with no-undef rule added to project (npm run lint)
  • verify-all.js script runs all 6 verification checks in sequence (ESLint, audit-references, check-layers, build, tests, smoke)
  • Vite dev server pinned to port 4200 with strictPort (localStorage/API keys persist across restarts)
  • Suppressed Vite dynamic import warnings for CodeMirror CDN imports

Bug Fixes

  • Fixed 103 bare cross-module references caught by ESLint no-undef (crashes on specific code paths)
  • Fixed window.Molkit bridge missing StateStrip and schedulePresAutosave (animation state strip UI updates and presentation autosave were silently disabled)
  • Fixed circular import: image-utils.js imported renderer.js statically, causing init-order dependency (now uses late-bound _deps.Renderer)
  • Fixed font-size-picker blur handler calling 5 methods on Renderer that belong to EventHandlers (text editor auto-close on focus loss was completely dead)
  • Fixed Renderer.setTool() call in template browser (setTool is an EventHandlers method, tool switch after template insert was dead)
  • Fixed CanvasInteraction bare reference in formatting toolbar (pre-existing monolith bug, was always undefined, arrow text zone saves were dead)
  • Fixed Handlers bare reference in renderer-utils.js (pre-existing monolith bug, atom label hiding during inline edit was dead)
  • Fixed UPDATE_SETTINGS dispatch type with no reducer handler (orbital visibility toggle from status bar was a silent no-op)
  • Fixed getElementById targeting a CSS class instead of an ID in ai-progress.js (progress overlay container lookup always returned null)
  • Fixed 4 instances of wrong UI state key names: selectedBondIds/selectedAtomIds instead of selectedBonds/selectedAtoms (selection after validation click, LaTeX insert, SMILES import, and text creation silently failed)
  • Fixed selectedOrbitals missing from tab snapshot round-trip (orbital selection leaked between tabs and was lost on switch)
  • Fixed animations array missing from blank canvas state (new tabs had inconsistent state shape)
  • Fixed DevMenu flags dropped during tab snapshot (snapshotActiveTab captured toolState but not devFlags)
  • Fixed DevMenu flags not restored from auto-save on page reload (DevMenu created after recovery, flags now deferred)
  • Fixed selection rectangle persisting after drag (RDKitModule bare reference threw in Store subscriber, killing the notification chain before preview cleanup)
  • Fixed bond/guide preview ghost persisting after undo (canvas overlay now cleared by Renderer.clearPreview)
  • Fixed 46 double-undo-push bugs across 8 files (explicit pushUndo followed by non-skipUndo dispatch caused two undo entries per action, making Ctrl+Z appear to do nothing on first press)

Performance

  • Removed force-repaint hack that toggled will-change on every pan/zoom frame (CSS `will-change: contents` was never implemented by any browser, the toggle was always a no-op that added overhead)
  • Crossing-bond recomputation (O(bonds^2)) now skipped during continuous drag, recomputed once on drop
  • 20 Store subscribers skip during continuous drag (panels, validation, IUPAC, ChemCalc, alignment toolbar, auto-save, etc.), only Renderer and text editor viewport sync continue
  • Fast-path SVG patching during atom drag: atoms, bonds, annotations, vertex fills, and aromatic circles updated in place instead of full DOM rebuild (5-10x faster drag frames on 300+ atom molecules)
  • Bond groups use translate transform during drag (handles all bond types uniformly: single, double, triple, wedge, dash)
  • Annotation groups patched with cumulative delta from cached original positions and transforms
  • Selection rect auto-scroll re-enabled with cached BCR (canvas-space anchor prevents drift during viewport pan)
  • Structural sharing in BATCH_UPDATE_ATOMS reducer: only changed atoms get new objects, unchanged atoms/bonds share references (25x allocation reduction during drag on 500-atom molecules)
  • Eliminated getComputedStyle DOM thrash in foreignObject atom label rendering (replaced with cached getElementColor lookup)
  • Two-phase zoom: instant CSS transform on every zoom tick, full SVG rebuild deferred to 120ms after zoom settles (molecular content has zero zoom-dependent properties, so CSS scale is visually perfect during zoom)
  • 14 Store subscribers skip during continuous zoom (same pattern as drag guards)
  • Spatial hash grid for hit-testing: 40px cell-based spatial partitioning replaces linear scans in findAtomAt, findBondAt, findAnnotationAt, findChargeAt, findLonePairAt, findRadicalAt (500-atom hover: 25x faster, 2000-atom hover: 90x faster)
  • Undo diffs for MOVE_ATOMS: drag-end pushes lightweight position diff instead of full deepClone of canvas state (eliminates 1-5ms clone on every drag commit, diff is ~50 bytes per entity vs ~50-100KB for full snapshot)
  • Hybrid undo stack supports mixed full-snapshot and diff entries with correct undo/redo for both