Skip to content

#8249: prevent hanging hydrogen bond when typing after antisense ove…#10143

Open
guranda2626 wants to merge 3 commits into
masterfrom
8249-create-indestructible-hydrogen-bond-on-Sequence-mode
Open

#8249: prevent hanging hydrogen bond when typing after antisense ove…#10143
guranda2626 wants to merge 3 commits into
masterfrom
8249-create-indestructible-hydrogen-bond-on-Sequence-mode

Conversation

@guranda2626
Copy link
Copy Markdown
Collaborator

@guranda2626 guranda2626 commented Jun 1, 2026

Summary

Fixes a bug where an indestructible hanging hydrogen bond appears on the canvas after pressing Enter at the end of an antisense sequence and typing a nucleotide in Sequence mode.

Steps to reproduce:

  1. Open Macromolecules canvas → Sequence mode (clear canvas)
  2. Load from HELM via clipboard:
    RNA1{r(A)p.r(A)p.r(A)p.r(A)}|RNA2{r(U)p.r(U)p.r(U)p.r(U)}$RNA1,RNA2,11:pair-11:pair$$$V2.0
  3. Switch to edit mode at the end of the antisense sequence
  4. Press Enter, then press A

Before: A hanging dashed bond appears — disconnected from any antisense nucleotide, impossible to select or delete.

After: The new A nucleotide is added as a standalone sense node with no bond.


Root cause

When a HELM structure has a partially-paired antisense chain, the SequenceViewModel places unmatched antisense nucleotides into overflow positionsTwoStrandedChainItem nodes where senseNode is EmptySequenceNode and antisenseNode is a real unmatched nucleotide.

Pressing Enter at such a position calls splitCurrentChain(), which detaches the last unmatched antisense nucleotide from the backbone. After re-render, the caret lands at the chain's end node, whose previousNodeInSameChain is {EmptySeq, U2}.

When the user then presses A in sync edit mode, the antisense-creation condition:

// before fix
previousTwoStrandedNodeInSameChain?.antisenseNode ??
currentTwoStrandedNode?.antisenseNode

evaluated U2 as truthy and fired, inserting a new antisense U into U2's existing chain and creating a hydrogen bond between a new sense A (isolated chain) and that antisense U — a bond crossing incompatible chains, making it unremovable.


Fix

The sync-mode branch of the antisense condition in add-sequence-item (SequenceMode.ts) now also requires that the triggering node's senseNode is present and not an EmptySequenceNode:

// after fix
(previousTwoStrandedNodeInSameChain?.senseNode &&
  !(previousTwoStrandedNodeInSameChain.senseNode instanceof EmptySequenceNode) &&
  previousTwoStrandedNodeInSameChain.antisenseNode) ||
(currentTwoStrandedNode?.senseNode &&
  !(currentTwoStrandedNode.senseNode instanceof EmptySequenceNode) &&
  currentTwoStrandedNode.antisenseNode)

Issue link

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

It is possible to create indestructible hydrogen bond on Sequence mode

1 participant