Skip to content

MAT-91342: wrap nucleic acid sequence rows in a snake pattern - #169

Open
spot-uncountable wants to merge 5 commits into
masterfrom
spot/mat-91342-snake-sequence-rows
Open

spot-uncountable wants to merge 5 commits into
masterfrom
spot/mat-91342-snake-sequence-rows

Conversation

@spot-uncountable

@spot-uncountable spot-uncountable commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

In sequence mode, every second row of an RNA or DNA chain now runs right to left, so the sequence continues from the end of the row above. The direction belongs to the row, so the caret slot and every item type in the row move with the bases, and caret navigation follows the drawn columns.

Decisions for the reviewer to confirm:

  • ArrowLeft, ArrowRight, Home, and End keep sequence order. On a reversed row, ArrowRight moves the caret to the next base, which is to the left.
  • ArrowUp and ArrowDown move the caret to the item in the same drawn column.
  • The snake applies to a chain that has a nucleotide or a nucleoside (RNA or DNA). A chain with only peptides stays left to right.
  • A short reversed row starts at the right edge, under the end of the row above. In a narrow drawer, the start of that row can be outside the visible area until the user scrolls.
  • The change applies to every customer that has the macromolecule editor turned on.

This replaces #168. That PR reversed only the nucleotide renderers, so the caret slot at the chain end and the other item types stayed in the left-to-right columns.

Context: Evan Hammerstein asked for wrapped RNA rows to follow a snake pattern. Slack thread
Ticket: MAT-91342

What did I (author) test?

Testing recommendations and risks (for reviewers)

Reproduce the issue (on the base branch):

  1. Set Chem Search Settings > Macromolecule Editor to Show.
  2. Open Chemical Search, open the drawer, and switch the mode to Macromolecules.
  3. In sequence mode with RNA selected, type 41 A bases.
  4. Row 2 starts again at the left edge.

With this change, row 2 starts under base 30 and runs right to left.

Checked live in the platform Chemical Search drawer, with the ketcher-core build of this branch in the served vendor bundle:

case result
RNA, 41 bases row 2 starts under base 30 and runs right to left
type G at the end G is added to the left of base 41
ArrowUp from the end of row 2, then ArrowDown the caret goes to the item in the same column of row 1, then back
click the right half, then the left half, of a base in row 2 the caret goes to the clicked side of the base
Backspace, then undo the base before the caret goes away, then comes back
64 bases row 3 runs left to right from under base 60; End on row 2 puts the caret at its left end
peptide chain, 35 symbols row 2 starts at the left edge, as before

The new __tests__/unc-regression/sequence-snake-rows.test.ts passes, and so do the existing __tests__/application/render/renderers/sequence and __tests__/unc-regression jest suites. A CI run of the sequence-mode, ruler, antisense, and sequence copy-paste Playwright specs passed with updated snapshots. This PR updates the 22 snapshots that changed because nucleic acid rows now alternate direction. The run also changed 5 sequence-edit snapshots because an earlier peptide test in the same worker left the editor in peptide mode. Those 5 snapshots stay unchanged.

E2E gate declaration:

  • option: 1
  • ticket case (option 1): a wrapped RNA row continues from the opposite side (claims 1 and 2), and editing still works (claim 2 and the table above).
  • claims (option 1):
    • claim 1: on the base branch, row 2 of a 41-base RNA sequence starts at the left edge.
      • evidence: before: row 2 starts at the left edge
      • proves it: bases 31 to 41 sit at the left, under bases 1 to 11.
    • claim 2: with this change, row 2 starts under base 30 and runs right to left, and the caret stays after base 41.
      • evidence: after: row 2 runs right to left
      • proves it: base 31 sits under base 30, label 40 is left of label 30, and the caret is to the left of base 41.
    • claim 3: rows keep alternating, and row 3 runs left to right again.
      • evidence: after: three rows of 64 bases
      • proves it: row 2 holds bases 31 to 60 from right to left, and row 3 starts at the left edge under base 60.
    • claim 4: a peptide chain keeps every row left to right.
      • evidence: after: peptide row 2 starts at the left edge
      • proves it: symbols 31 to 35 sit at the left, under symbols 1 to 5.
  • coverage (option 1):
    • happy path: claim 2
    • negative/error path: none: the change moves items and the caret, and it has no error branch a user can reach
    • edge/boundary case: claims 3, 4
    • full changed surface: claims 2, 3, 4 together with the editing cases in the table above

Main gets this change with the next Ketcher version bump after a fork release.

Spot Dot (Claude Opus 5.5)

🤖 Generated with Claude Code

In sequence mode, every second row of a nucleic acid chain now runs right
to left, so the sequence continues from the end of the row above. The row
direction applies to every item in the row, including the caret slot, and
caret navigation follows the drawn columns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
spot-uncountable and others added 3 commits October 9, 2026 19:19
Regenerate the 22 Playwright snapshots whose nucleic acid rows now wrap in a
snake pattern: the ruler, sequence-mode, antisense, and sequence copy-paste
cases. The images come from the CI Playwright container.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The full Playwright run on c0b890c failed three screenshot checks that
show the reversed second row: Ketcher 3.1.0 bugs Case 14, Ketcher 3.5.0
bugs Case 19, and Ruler Case 16 screenshot 1. The new images come from
that run. Ruler Case 16 screenshot 1 keeps the 527 px canvas height of
the full run, because the Calculate Properties window is still opening
when the test takes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@spot-uncountable

Copy link
Copy Markdown
Collaborator Author

FullScale result for cf5a037 (run 38019637503), compared to fork master run 37065340895 and other recent runs:

Failures from the snake-row change (fixed in 602fa85)

  • ketcher-3.1.0-bugs Case 14, ketcher-3.5.0-bugs Case 19, and Ruler Case 16 now pass screenshot 1. Each test then failed at screenshot 2, which shows the reversed second row.
  • 602fa85 updates screenshot 2 of the three tests and screenshot 3 of Case 19.
  • The images come from CI. The actual image was identical on all 3 retries. An isolated refresh run gave byte-identical images for Case 14 and Case 19 screenshot 2, and gave Case 19 screenshot 3.
  • Ruler Case 16 screenshot 2 uses the full-run image. In full runs the content is 5 px lower than in an isolated run, which matches the master snapshot.
  • Behavior to check in review: in Case 14, Shift+Down from row 1 moves to the visual position below, so the selection starts at position 51 on the reversed row 2. In Case 19 screenshot 3, the caret on the empty fourth row starts at the right edge because even rows run right to left.

Failures not from this change

  • Shard 2: identical to master.
  • Shard 6: 4 simple-objects-draw-line tests are not in master run 37065340895, but they fail on master runs 36612174673 and 37065007320.
  • Shard 1: 60 micro-editor tests (MOL and RXN save, CIP, Layout, Clean, explicit hydrogens, auto-mapping) and ketcher-3.4.0-bugs Case 23 fail. The same 61 tests fail on run 37339206179 of gordon/mat-90499-narrow-macro-mode-switch.
  • Shard 5 hit the 120-minute job limit. The sequence-mode-replacement.spec.ts beforeEach timed out at Library.ts:196 (monomer card not visible) and every retry repeated the timeout. Master runs 36624521512 and 36483283135 show the same beforeEach timeout on the same tests (Case 4-5-4, Case 14-1-3, Case 8-9-13). The previous run on this branch (c0b890c) passed shard 5 with the same code.

Next: the FullScale run on 602fa85.

calculateProperties waits only 1 second for the result. For the 1001-nucleotide
structure the properties window can finish after the first screenshot, so the
canvas height changes between the first ruler drag and its scroll. Wait for the
gross formula, then refresh screenshots 1 and 2 for the settled canvas height.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@spot-uncountable

Copy link
Copy Markdown
Collaborator Author

FullScale result for 602fa85 (run 38037050894), compared to fork master runs:

Ruler Case 16 (the one failure from the snake-row change), fixed in 04cb3a6. The first ruler drag scrolls with the canvas height at that moment. calculateProperties waits only 1 second for the result. For 1001-dna-monomers.ket, the properties window can finish after screenshot 1, so the canvas height changes before or after that scroll. A probe run (38045190841) recorded the drag translate at y=11.2 on master (stale 527 px height) and y=5.9 on the branch (474 px). Master CI landed on the stale side in 5 of 5 runs, and the branch landed on each side once. The fix waits for the gross formula before screenshot 1, and refreshes screenshots 1 and 2 for the settled height. Screenshots 3 to 6 do not change. A verification run (38046130758) passed Case 16 4 of 4 times in one worker, and in a full ruler.spec.ts run (only Ruler Case 4 failed, which is flaky on master).

Other failures match the master baseline:

  • Shard 1: the same micro-editor failures as master (147 here). One auto-mapping test that is new against the previous branch run also fails on master run 37065007320.
  • Shard 2: identical to master.
  • Shard 6: micro-editor shape and toolbar timeouts (draw-rectangle, left toolbar shapes, hotkeys ESC, reaction mapping icons), the same family as the master draw-line and draw-rectangle failures.
  • Shards 5 and 6: the sequence-mode-replacement.spec.ts beforeEach timeout at Library.ts:196 (shard 5 cancelled at the job limit), the same as master runs 36624521512 and 36483283135.
  • new-sequence-representation2 Case 44 and sequence-mode-edit "add new nucleotides in the middle" pass on retry 1, the same as 3 master runs.

@spot-uncountable

Copy link
Copy Markdown
Collaborator Author

Correction to the comment above: the shard 1 auto-mapping test (reaction-am-tool-veryfing-button.spec.ts:54) fails on master run 36612174673, not on run 37065007320.

@spot-uncountable

Copy link
Copy Markdown
Collaborator Author

FullScale result for 04cb3a6 (run 38047025758), compared to the earlier runs of this PR and to fork master runs:

  • Ruler Case 16 passes. The fix in 04cb3a6 waits for the Calculate Properties panel before screenshot 1.
  • Shards 3 and 5 pass. Shard 2 has the same 27 failures as the earlier PR run. Each shard 1 failure also fails on fork master. For example, the SVG test image-files.spec.ts:1916 fails on master runs 37065340895, 36612174673, and 37065007320. Shard 6 fails only Molecules-mode tests. The only shard 6 failures that are new since the earlier PR run are 2 tests in simple-objects-draw-line.spec.ts, which are in the known flaky simple-objects family.
  • Shard 4 has one failure: hydrogen-bonds-for-monomers.spec.ts:468 "4. Connect with hydrogen bond nucleotide(5hMedC) and peptide(A) already connected with single bond". The spec sets retries: 0. The test hit its 25 s timeout in flex mode after the hydrogen bond drag. This PR changes only the sequence-mode renderer. A separate run (38058523875) ran the full spec 3 times on this head and 3 times on fork master e84f04a. Each side passed 1128 tests and failed 0. I read the shard 4 failure as a flaky timeout.

The PR has no failure that its change causes, and it is ready for review.

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

Labels

ai-workflow-1 PR created by an AI workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant