Skip to content

#3922 - Macro: After undoing and redoing all steps, Undo and Redo buttons do not turn gray, as they do in Micro mode. - #11903

Open
mariam-khutuashvili wants to merge 6 commits into
masterfrom
3922-macro-after-undoing-and-redoing-all-steps-undo-and-redo-buttons-do-not-turn-gray-as-they-do-in-micro-mode
Open

mariam-khutuashvili wants to merge 6 commits into
masterfrom
3922-macro-after-undoing-and-redoing-all-steps-undo-and-redo-buttons-do-not-turn-gray-as-they-do-in-micro-mode

Conversation

@mariam-khutuashvili

@mariam-khutuashvili mariam-khutuashvili commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator
cc.mp4

In Macro mode the Undo and Redo buttons rendered as enabled whenever the editor was usable, regardless of whether there was anything to undo or redo. Micro mode greys them out at either end of the history; Macro mode never did.

TopMenuComponent now reads the history through useSyncExternalStore: it subscribes to the editor's modelChange event and derives canUndo/canRedo from EditorHistory's pointer and stack. The read is synchronous during render, so the buttons are correct from the first paint, and the component only re-renders when one of the two booleans actually changes.

Two autotests only passed because the buttons were wrongly enabled — they clicked Undo/Redo past the ends of the history, which now times out on a disabled button. undo-redo.spec.ts asserts Redo is disabled while nothing has been undone and undoes while the button is enabled rather than a fixed count; sequence-mode-copy-paste.spec.ts drops two pointless undo steps after a copy. The stale note on the "buttons turn gray" test saying it could not work until #3922 was fixed is removed.

Screenshot baselines (69 files) were taken from this branch's own CI runs — first-attempt actuals, mapped through the sha1 of each expected copy, and each audited to confirm the change is confined to a 14–47 × 5–6 px box at the Undo/Redo position of the toolbar. Tests that take several screenshots stop at the first mismatch, so the set was completed over three CI rounds.

Deliberately not rebaselined, since they are unrelated to this change:

  • macro-micro-switcher.spec.ts "Mol-/Ket-structure opened in Macro mode is visible in Micro mode" — a micro-canvas offset that is byte-identical with and without this fix (verified locally) and passes or fails from run to run.
  • snake-bond-tool.spec.ts and custom-templates.spec.ts — known-unstable rendering tests that fail and pass on retry.

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

…tons do not turn gray, as they do in Micro mode

The macromolecules top menu rendered Undo and Redo as enabled whenever the
editor was usable, regardless of whether there was anything to undo or redo.
Micro mode greys them out at either end of the history; macro mode never did.

Read the history through useSyncExternalStore: subscribe to the editor's
`modelChange` event and derive `canUndo`/`canRedo` from `EditorHistory`'s
pointer and stack. The read is synchronous during render, so the buttons are
right from the first paint - an effect would leave both briefly disabled on
a canvas that does have a history - and the component only re-renders when
one of the two booleans actually changes.
…of the history

Two tests only passed because the buttons were wrongly enabled. With the
buttons now disabled at either end of the history, a click there times out.

`undo-redo.spec.ts` "Undo redo for monomers and bonds addition" clicked Redo
twice up front and Undo five times later on to "stop on the first operation".
Assert that Redo is disabled while nothing has been undone, and undo while the
button is enabled instead of guessing a count. Also drop the note on "Check
that after undoing and redoing all steps ..." saying the test could not work
until #3922 was fixed - that is this change.

`sequence-mode-copy-paste.spec.ts` "Select letters with Shift & ArrowLeft then
paste ket from clipboard and undo" undid twice after a copy for no reason;
remove those steps and the screenshot that depended on them.
…edo buttons

Undo and Redo now render greyed out at either end of the history, so every
page screenshot of the macromolecules editor taken with nothing to undo or
redo changes by those two icons.

Baselines are the first-attempt actuals of the CI run on 184890a (runs
34836062970 and 34836065787), taken from the blob reports and mapped to their
files through the sha1 of each expected copy. Every file was audited before
being written: the change is confined to a 14-47 px wide, 5-6 px tall box at
the Undo/Redo position of the toolbar, and nothing else moved.

Not included, on purpose:
- macro-micro-switcher "Mol-/Ket-structure opened in Macro mode is visible in
  Micro mode": a micro-canvas offset that is byte-identical with and without
  this fix, so it is not caused by it.
- snake-bond-tool "Check snake mode arrange for peptides chain": a canvas diff
  from a spec known to be unstable.
- Tests that passed on retry.

Tests that take several screenshots stop at the first mismatch, so their
later screenshots are refreshed in the next CI round.
…led Undo/Redo buttons

Second round of the same harvest, from the CI run on d9d5551 (runs
35061170508 and 35061172909). A test stops at its first screenshot mismatch,
so the tests that take several screenshots only exposed their next one once
the first had been refreshed. Same mapping through the sha1 of the expected
copy, same audit: each change is a 14-47 px wide, 5-6 px tall box at the
Undo/Redo position of the toolbar.
…led Undo/Redo buttons

Third screenshot of "Case 8: clicking the icon when the window is opened, or the X, closes that window", exposed only once its first two had been refreshed. Same source (CI run 35063589284 on 8939af0), same sha1 mapping, same audit: a 14 px wide, 5 px tall box at the Undo position of the toolbar.
…age screenshots that depend on the leftover history
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.

Macro: After undoing and redoing all steps, Undo and Redo buttons do not turn gray, as they do in Micro mode.

1 participant