Skip to content

Fix blank Mulliken 3D viewer (geometry persistence + lazy render) - #103

Merged
jonathanschultzNU merged 1 commit into
mainfrom
cursor/mulliken-viewer-fix-c6d9
Aug 30, 2026
Merged

Fix blank Mulliken 3D viewer (geometry persistence + lazy render)#103
jonathanschultzNU merged 1 commit into
mainfrom
cursor/mulliken-viewer-fix-c6d9

Conversation

@jonathanschultzNU

Copy link
Copy Markdown
Collaborator

Summary

Fixes the blank molecule viewer in the Mulliken Populations accordion while keeping the charge table and bar chart working.

Root cause: the dedicated Mulliken viewer needs a full Molecule (coordinates), but history replay often had Mulliken charges in result.json without any reachable geometry. Rendering also happened while the accordion content was still hidden, which Voilà can skip for <script> execution.

Changes

  • Geometry persistencesave_result(..., molecule=calc_mol) writes a top-level geometry field to result.json; mol_from_result_dir() and build_history_context() load it for history replay.
  • Robust geometry resolution_mulliken_molecule() falls back through ctx.molecule, mol_from_result_dir(), _analysis_displayed_molecule, and _molecule.
  • Lazy render — populate caches _mulliken_pending_molecule; the authoritative draw happens in _on_mulliken_accordion_show when the panel is visible.
  • Unavailable message — when coordinates cannot be resolved, the viewer slot shows an inline explanation instead of a blank area.
  • Theme/backend refresh_rerender_3d_views() now refreshes the Mulliken viewer alongside the other Analysis 3D viewers.
  • Tests — regression coverage for lazy render, result.json geometry replay, unavailable message, and theme rerender.

Test plan

  • pytest tests/test_mulliken_panel.py tests/test_results_storage.py tests/test_populations_overlay.py
  • pytest tests/test_sp_analysis_history.py tests/test_theme_contrast.py
  • Manual: run Single Point, open Mulliken accordion — 3D viewer shows with charge colours
  • Manual: load History result — viewer renders without requiring Calculate-tab molecule
  • Manual: toggle Light/Dark theme — Mulliken viewer background updates
Open in Web Open in Cursor 

The Mulliken Populations panel now resolves geometry from result.json,
history context, and disk sidecars; defers py3Dmol rendering until the
accordion is visible; shows an inline message when coordinates are missing;
and refreshes on theme/backend re-render like other Analysis viewers.

Co-authored-by: Jonathan Schultz <jonathanschultzNU@users.noreply.github.com>
@jonathanschultzNU
jonathanschultzNU marked this pull request as ready for review August 30, 2026 16:19
@jonathanschultzNU
jonathanschultzNU merged commit 06a1357 into main Aug 30, 2026
5 checks passed
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.

2 participants