Skip to content

#9349 - Stereo group labels are overlapped by CIP labels in Macromole…#10089

Merged
AlexeyGirin merged 3 commits into
masterfrom
9349-stereo-group-labels-are-overlapped-by-CIP-labels-in-Macromolecules-mode
May 22, 2026
Merged

#9349 - Stereo group labels are overlapped by CIP labels in Macromole…#10089
AlexeyGirin merged 3 commits into
masterfrom
9349-stereo-group-labels-are-overlapped-by-CIP-labels-in-Macromolecules-mode

Conversation

@PaulinaKacz
Copy link
Copy Markdown
Collaborator

@PaulinaKacz PaulinaKacz commented May 19, 2026

What changed

Improved stereo-label and CIP label spacing in Macromolecules mode so labels sit farther from bonds and no longer overlap each other.
Refactored AtomRenderer to center labels using the actual SVG bounding box instead of relying on height-based offsets.
Made the stereo/CIP spacing logic easier to read and tune by naming the gap constant and documenting the load-bearing render order.
Added updated visual regression snapshot baselines for the affected Chromium cases.
Why

Stereo labels in Macromolecules mode were too close to bond lines.
The previous text positioning logic introduced a vertical bias because it did not use the real SVG text box origin.
The stereo label must be rendered before the CIP label because CIP positioning depends on the stereo label bounding box.
The spacing change needed snapshot coverage to prevent regressions.

Results:
Screenshot 2026-05-19 at 10 28 12
Screenshot 2026-05-19 at 10 28 21

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

@PaulinaKacz PaulinaKacz force-pushed the 9349-stereo-group-labels-are-overlapped-by-CIP-labels-in-Macromolecules-mode branch from 46a3d43 to d4ea70b Compare May 20, 2026 13:03
Comment on lines 617 to 618
this.appendBadValenceWarning();
this.appendCIPLabel();
this.appendStereoLabel();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ordering is now load-bearing — positionCIPLabel reads this.stereoTextElementBBox (set during appendStereoLabel) to push the CIP label past the stereo label. A future refactor that re-orders or splits these calls would silently regress #9349. Worth a one-line comment, e.g. // must come before appendCIPLabel — CIP positioning depends on the stereo bbox, or a comment on appendCIPLabel/positionCIPLabel documenting the dependency.

Comment on lines +691 to +697
projectedDistance = Math.max(
projectedDistance,
stereoProjectedDistance +
stereoProjectionRadius +
cipProjectionRadius +
2,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trailing + 2 is a magic literal — it's the gap between the stereo and CIP labels but reads as noise next to the named LABEL_CLEARANCE_OFFSET. Suggest pulling it into a named constant (e.g. STEREO_CIP_GAP = 2) alongside LABEL_CLEARANCE_OFFSET so the spacing model is discoverable and tunable in one place.

SELECTION_HOVERED_COLOR,
} from 'application/render/renderers/constants';

const LABEL_CLEARANCE_OFFSET = 5;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a brief comment explaining what LABEL_CLEARANCE_OFFSET = 5 represents (extra px past the bbox? why 5?). The whole point of this PR is to tune that spacing, so the next person changing it will want to know the rationale rather than tweaking blind.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 20, 2026

Code review summary — nothing blocking, but a few things worth addressing.

PR description vs. diff mismatch
The description lists five changes, but the diff only touches AtomRenderer.ts (+83/-38, 1 file). Three of the bullets don't appear to be backed by code:

  • "Replaced the unsafe bond cast with an explicit type check and direct endpoint resolution" — no bond-related changes in the diff.
  • "Added a visual regression test for stereo-label spacing…" — no test file added.
  • "Added updated snapshot baselines for the new regression test" — no snapshot updates.

The checklist also has unit-tests written, e2e-tests written, and PR is linked with the issue unchecked. Either the missing pieces need to be added (the description itself says "The change needed regression coverage to prevent spacing from drifting"), or the description should be trimmed to reflect what was actually shipped.

Code
The refactor is a clear improvement — extracting getProjectedLabelDistance / getLabelProjectionRadius removes the prior duplication between stereo and CIP positioning, and swapping the call order in show() is a sensible fix. Left three inline comments on naming / documenting the new spacing constants and the load-bearing call ordering.

No performance or security concerns.

Copy link
Copy Markdown
Collaborator

@svvald svvald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved in advance, but please check and address Claude's comments, they're pretty reasonable for future code maintenance

Paulina_Kwapisz added 2 commits May 22, 2026 09:18
@AlexeyGirin AlexeyGirin merged commit 7871436 into master May 22, 2026
14 of 15 checks passed
@AlexeyGirin AlexeyGirin deleted the 9349-stereo-group-labels-are-overlapped-by-CIP-labels-in-Macromolecules-mode branch May 22, 2026 09:49
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.

Stereo group labels are overlapped by CIP labels in Macromolecules mode

3 participants