fix(client): hide hydrogens via [!H] selection, not residue-level hideCid - #41
Merged
Merged
Conversation
…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>
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.
Fixes two compounding bugs in the hide-hydrogens toggle (#39).
Bug 1 — ligand vanished
H were hidden with
mol.hideCid→add_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) hardcodescid="/*/*/*/*"— 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
[!H]when hiding,/*/*when showing); ribbons (CRs, no atoms) keep the plain selection.updateAtoms()+ redrawing the existing rep, notfetchIfDirtyAndDraw(which spawns the duplicate). Applied at model load, focal pose, pinned pose, and the merge flow (same trap).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