Skip to content

fix(diagram): keep trivial molecules visible while something is flagged - #170

Merged
adamjohnwright merged 1 commit into
mainfrom
fix/trivial-molecules-stay-visible
Sep 4, 2026
Merged

fix(diagram): keep trivial molecules visible while something is flagged#170
adamjohnwright merged 1 commit into
mainfrom
fix/trivial-molecules-stay-visible

Conversation

@adamjohnwright

Copy link
Copy Markdown
Contributor

Curators, testing on beta: "H2O and H+ disappear with zooming out." And separately #150: a molecule's chemical structure drawn with no molecule underneath it. Those are the same fault seen from two sides — the node was hidden while a different handler carried on drawing its structure.

Why the previous fix did not hold

Flagging pins trivial molecules visible by marking them .always-visible — deliberately a class rather than an inline style, so nothing could lose it.

But the zoom handler writes an inline opacity across every .trivial element, and in cytoscape an inline style beats any stylesheet rule. It painted straight over the class. Detaching it from the zoom event — what the previous attempt did — was not enough, because triggerZoom() calls it directly: on every restyle (a theme change, an analysis loading) and whenever an interactor is opened.

The class is now the authority. The handler leaves anything wearing it alone.

Measured on beta, flag active:

before after
as the diagram loads opacity 0 1
zoomed out 0 1
zoomed in 0 1
after a restyle 0 1

With no flag, molecules still fade out as you zoom away and come back as you zoom in — unchanged.

Why it took two attempts to land

build:libs did not build reactome-cytoscape-style. CI compensated with a step of its own, so a fix to that library passed CI and never reached the dev server, which builds the app without building the library. I spent a while concluding the fix did not work when it had simply never been compiled.

build:libs now covers every workspace library and build depends on it, so any path that produces the app produces what it links against. CI's two special-case steps are gone: it runs the same command a developer runs.

The test

End-to-end rather than a unit test, for two reasons: the library cannot be constructed headlessly (its layers plugin refuses outright), and the bug lives in what a real renderer computes rather than in a pure function.

It reads opacity through the registration cytoscape keeps on its own container, which beats sampling canvas pixels — those cannot tell you which element was faded.

Verified to fail without the fix: both flagging tests go red, the unflagged one stays green.

Fixes #150
Fixes #143

Curators: "H2O and H+ disappear with zooming out." Separately, #150: a
molecule's chemical structure drawn with no molecule underneath it. Same
fault from two sides -- the node was hidden while a different handler
carried on drawing its structure.

Flagging pins trivial molecules visible by marking them `.always-visible`,
a class rather than an inline style precisely so nothing can lose it. But
the zoom handler writes an *inline* opacity across every `.trivial`
element, and in cytoscape an inline style beats any stylesheet rule, so it
painted straight over the class. Detaching it from the zoom event -- what
the previous fix did -- was not enough: `triggerZoom()` calls it directly,
on every restyle and whenever an interactor opens.

The class is now the authority: the handler leaves anything wearing it
alone. Measured on beta, with a flag active, opacity is 1 at every zoom and
across a restyle; with no flag, molecules still fade out and back as
before.

Also, the reason this took two attempts to land: `build:libs` did not build
reactome-cytoscape-style. CI compensated with a step of its own, so a fix
to that library passed CI and never reached the dev server, which builds
the app without building the library. `build:libs` now covers every
workspace library and `build` depends on it, so any path that produces the
app produces what it links against -- and CI's two special-case steps are
gone, because it now runs the same command a developer does.

The regression test is end-to-end rather than a unit test: the library
cannot be constructed headlessly (its layers plugin refuses), and the bug
lives in what a real renderer computes. It reads opacity through the
registration cytoscape keeps on its own container, which beats sampling
canvas pixels -- those cannot say which element was faded. Verified to
fail without the fix: both flagging tests go red, the unflagged one stays
green.

Fixes #150
Fixes #143

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@adamjohnwright
adamjohnwright enabled auto-merge (squash) September 4, 2026 21:46
@adamjohnwright
adamjohnwright merged commit f8ad272 into main Sep 4, 2026
6 checks passed
@adamjohnwright
adamjohnwright deleted the fix/trivial-molecules-stay-visible branch September 4, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chemical structure of trivial molecules appear without their nodes when using flagging Flagging conflict with trivial opacity

1 participant