Skip to content

Highlight difference in rewrite steps#445

Open
kwyip wants to merge 5 commits intozxcalc:masterfrom
kwyip:highlight
Open

Highlight difference in rewrite steps#445
kwyip wants to merge 5 commits intozxcalc:masterfrom
kwyip:highlight

Conversation

@kwyip
Copy link

@kwyip kwyip commented Feb 22, 2026

Aim to fix #190

  1. Introduced apply_step_difference_highlighting(current, next_graph) to compute and apply diff_highlight flags on the currently displayed graph.
  2. Vertices: when vdata(..., "diff_highlight") is true, draw thicker yellow outlines (selected and unselected states handled).
  3. Edges: when edata(..., "diff_highlight") is true, draw a yellow overlay stroke.

For example, in fusing two nodes the new node and a neighboring node are highlighted, as in Lia's example.

But...

  • Position-only changes do not highlight.
  • Equivalent geometry with different vertex IDs does not highlight.
zxlive_190.mp4

@lia-approves
Copy link
Collaborator

Hello, thanks for the PR. It has the issue that Boldi described in #435 :

In particular, when two spiders are fused, it is the nodes and the connecting edge that should be highlighted.

Nodes that don't participate in teh rewrite rule should not be highlighted. Let us know if you have any questions.

@RazinShaikh
Copy link
Collaborator

Hi @kwyip thanks for the PR. It looks promising but can you address Lia's comment and also fix the checks that are failing?

@kwyip
Copy link
Author

kwyip commented Feb 26, 2026

Hi @kwyip thanks for the PR. It looks promising but can you address Lia's comment and also fix the checks that are failing?

Sorry for the late reply. I am currently working on this particular PR right now.

@kwyip
Copy link
Author

kwyip commented Feb 26, 2026

Hi @lia-approves @RazinShaikh
I have fixed the highlight inconsistencies for fusing, and some other derivation steps. It could be fine now, and fulfill the requirements of two spiders+edge being highlighted.
I have added tests for many different proof steps, e.g. fusing, removal, ZX type, etc. Please let me know if there are any incorrect highlight items, if you are interested in this pull request.

zxlive_190_2.mp4

@boldar99
Copy link
Collaborator

Hi,
I have tested the new functionality and it is not correct. When I applied colour change, it highlighted something completely unrelated.

@RazinShaikh
Copy link
Collaborator

In addition to that, there should be a toggle in settings to have highlight differences on/off

@kwyip
Copy link
Author

kwyip commented Feb 27, 2026

Hi @boldar99 @RazinShaikh ,
Let me see what's wrong in the color change scenario. It seems that it was working as intended: highlighting the spider whose color was changed.

zxlive_190_3.mov

Let me also add the toggle functionality.

@RazinShaikh
Copy link
Collaborator

Could you try applying many different rewrites (including color change) and see if it always works? I don't remember which sequence of rewrites break this

@boldar99
Copy link
Collaborator

Here is an example. Colour change as well as Strong complementarity are highlighted incorrectly.

Screen.Recording.2026-02-28.at.01.11.09.mov

@boldar99
Copy link
Collaborator

Other example with fusion:

Screen.Recording.2026-02-28.at.01.14.22.mov

@kwyip
Copy link
Author

kwyip commented Mar 1, 2026

In addition to that, there should be a toggle in settings to have highlight differences on/off

Hi @RazinShaikh @boldar99 ,
I have added the toggle button in the preference setting. I have also rewritten the “add identity” rule, where the edge was now being highlighted.

I realized what’s wrong in the video above. Essentially, the highlights for every rule (except remove parallel edges, which I don't know how to apply) are correct if one adds a rewrite step, clicks on the previous rewrite, and then views the highlight. If one does that for every step, all the highlights are correct. However, if one adds rewrite steps all at once without clicking anything on the right-side panel, the highlights for most of the steps fail (by some shifts in highlighed vertices).

After realizing the issue and that most users would do the latter, I have not been able to fix it for now.If you could provide any hints, I would really appreciate it.

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.

Highlight difference in rewrite steps

4 participants