enso-org / enso

Hybrid visual and textual functional programming.
https://enso.org
Apache License 2.0
7.34k stars 321 forks source link

CB modifies code (looking at the visualization) but the change is not reflected in node/code editor #5334

Closed wdanilo closed 1 year ago

wdanilo commented 1 year ago

This task is automatically imported from the old Task Issue Board and it was originally created by Radosław Waśko. Original issue is here.


This may be a few issues intertwined, let me describe it:

The repro that works for me is to create a node with the following content (full screenshot below): Table.new [["X", [1, 0.0, Nothing, Number.nan]]], then open the code editor, Ctrl+LMB on the node to edit it (editing must be done with code editor open, otherwise the bug may not show in full) and move the with arrow keys and then click escape seeing that weird stuff happens.

What I'd expect to happen - I can move the cursor with arrow keys to edit part of the node - for example to change the 0.0 to 1.0.

What happens - arrow keys trigger events in the component browser, selecting some components. The visualization attached to node starts showing weird errors, as if the Vector that I'm editing has been replaced with some random method invocation. However after I click Escape to exit, I still see the unmodified code - both on the node and in the editor (in the code editor I saw some code changes while CB was open, but once it was submitted, it is reverted to old code but visualization still shows the error). But it seems that the code was somehow changed, because the visualization is still showing the error related to some selected CB entry.

After the file is saved, the original code is preserved and so after restarting the GUI the error no longer displays.

I imagine the error being kept displayed may be because the actual new visualization fails to parse: ERROR app/gui/src/presenter/graph/visualization.rs:110 Failed to deserialize visualization update: expected value at line 1 column 43 and so the old one from the time CB preview was open is preserved.

So I see more or less 3 intertwined issues:

Comments:

Screenshots (Radosław Waśko - Oct 25, 2022)


farmaazon commented 1 year ago

I cannot move around node editor using arrow keys because the CB keeps focus and keeps changing the value in preview (although it seems that after Ctrl+Enter the code I actually entered is kept, so I am able to edit stuff, it is just super confusing).

Should be covered by #4966

farmaazon commented 1 year ago

@radeusgd I cannot reproduce this issue (except point one, but see the comment above). Could you check if it's still reproducible on your part?

radeusgd commented 1 year ago

Nope, the main points seem to be gone. I was able to successfully move around text inside of the node and edit the contents, even with the code editor open. After Ctrl+Enter the new contents got correctly re-evaluated and visualized.

Seems that most of this ticket is resolved.

There is only one part:

The visualization attached to node starts showing weird errors, as if the Vector that I'm editing has been replaced with some random method invocation.

image

For some reason, when I enter edit mode (Ctrl+Click), the node stops visualizing correcrtly and displays this error as above. Once I confirm (or abandon with Escape key) the edit, it goes back to the correct visualization.

It was technically reported as part of this issue so not sure if it's worth creating a new ticket for it? I know technically the visualization should show a live preview of the currently edited node. I don't know why this visualization shows an error when the node contents did not yet change at all (or changed in a correct way since after confirming the edit it visualizes correctly again).

radeusgd commented 1 year ago

cc: @farmaazon

farmaazon commented 1 year ago

It was technically reported as part of this issue so not sure if it's worth creating a new ticket for it? I know technically the visualization should show a live preview of the currently edited node. I don't know why this visualization shows an error when the node contents did not yet change at all (or changed in a correct way since after confirming the edit it visualizes correctly again).

Technically, we do not visualize the current node input, only the currently selected CB entry. In other words, we visualize what would happen after pressing enter and thus inserting the currently selected suggestion into the input.

Perhaps that's bad design, but I would rather start discussion about it.

wdanilo commented 1 year ago

I believe the design is correct. There is though another question here - when should we stop selecting the "Best match" and just think that what user has written is what he means. Probably if the match has a very low score we could do it.

farmaazon commented 1 year ago

Started discussion here: https://github.com/enso-org/enso/discussions/5856

GitHub
How to improve Visualization Previews · enso-org/enso · Discussion #5856
So, the Component Browser's Visualization Preview was implemented some time ago, and roughly works as described in the design. But once the CB was used by various people, a few UX issues emerge...
farmaazon commented 1 year ago

Closing it right now. If we decide to improve visualizations, we create a new task from the discussion above.