Skip to content

fix(client): hide hydrogens via [!H] selection, not residue-level hideCid - #41

Merged
martinemnoble1 merged 1 commit into
mainfrom
fix/hydrogen-hiding-residue-bug
Jun 10, 2026
Merged

fix(client): hide hydrogens via [!H] selection, not residue-level hideCid#41
martinemnoble1 merged 1 commit into
mainfrom
fix/hydrogen-hiding-residue-bug

Conversation

@martinemnoble1

Copy link
Copy Markdown
Owner

Fixes two compounding bugs in the hide-hydrogens toggle (#39).

Bug 1 — ligand vanished

H were hidden with mol.hideCidadd_to_non_drawn_bonds, which resolves selections at residue level. A hydrogen CID therefore matched the ligand's whole residue and hid it entirely (ligand drew, then disappeared).

Bug 2 — toggle looked inverted, waters ballooned

After switching to the correct atom-level mechanism (exclude H from the bond selection with [!H], as Moorhen's own "Hide Hydrogens" does), the dict re-perceive step (fetchIfDirtyAndDraw) hardcodes cid="/*/*/*/*" — so against our [!H] rep it added a duplicate full-atom rep that re-drew every hydrogen. That made the toggle look backwards and turned each water (now O–H–H) into a fat ball-and-stick blob instead of a lone-O dot. (The "ligands" style itself excludes waters — it wasn't scooping them up.)

Fix

  • Draw bonds reps with the H-aware cid ([!H] when hiding, /*/* when showing); ribbons (CRs, no atoms) keep the plain selection.
  • Re-perceive the dict via updateAtoms() + redrawing the existing rep, not fetchIfDirtyAndDraw (which spawns the duplicate). Applied at model load, focal pose, pinned pose, and the merge flow (same trap).
  • Toggle re-skins each atom rep's cid + redraw().

Non-destructive throughout — coordinates untouched, Save keeps the H.

Verification

Verified in-app: ligand stays drawn; default-on hides H (waters = small dots); toggling off shows H (waters show their H); merge with toggle on leaves no H/water balloon. ("That is the badger.")

🤖 Generated with Claude Code

…eCid

The hide-hydrogens toggle (#39) had two compounding bugs:

1) It hid H with mol.hideCid (add_to_non_drawn_bonds), which resolves
   selections at RESIDUE level — so a hydrogen CID matched whole residues
   and hid the entire ligand (ligand drew, then vanished).

2) After switching to the correct atom-level mechanism (exclude H from the
   bond selection with [!H], as Moorhen's own 'Hide Hydrogens' does), the
   dict re-perceive step (fetchIfDirtyAndDraw) hardcodes cid '/*/*/*/*', so
   against our [!H] rep it ADDED a duplicate full-atom rep that re-showed
   every hydrogen — making the toggle look inverted and ballooning waters
   (a water became O-H-H instead of a lone-O dot).

Fix: draw bonds reps with the H-aware [!H]/'/*/*' cid; re-perceive the dict
via updateAtoms() + redrawing the EXISTING rep (not fetchIfDirtyAndDraw);
toggle by swapping rep.cid + redraw. Applied at model load, focal pose,
pinned pose, and the merge flow. Non-destructive throughout (coords
untouched; Save keeps the H). Ribbons (CRs, no atoms) unaffected; the
'ligands' style already excludes waters.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@martinemnoble1
martinemnoble1 merged commit d6a8129 into main Jun 10, 2026
4 checks passed
@martinemnoble1
martinemnoble1 deleted the fix/hydrogen-hiding-residue-bug branch June 10, 2026 21:04
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