Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node button to enable/disable output context #6205

Merged
merged 14 commits into from
Apr 11, 2023

Conversation

Procrat
Copy link
Contributor

@Procrat Procrat commented Apr 5, 2023

Pull Request Description

Closes #5929: Adding a node button to enable and disable the output context for that particular node.

I also added a temporary shortcut (cmd-shift-c) to switch the execution environment so we can properly test it.

2023-04-05.11-02-59.online-video-cutter.com.mp4

Important Notes

While we're waiting to integrate it with the language server, the execution environment is temporarily stored in the presenter. (Otherwise we'd have to define it in multiple places and the behaviour would look rather weird.)

I also fixed a bug where the view didn't get any updates when the context switch expression changed. I'll make a comment on the relevant part. I think the SKIP and FREEZE macros might have the same issue.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the Scala, Java, and Rust style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@Procrat Procrat added the CI: No changelog needed Do not require a changelog entry for this PR. label Apr 5, 2023
} else {
None
};
self.log_action(
|| {
let ast_id =
self.state.update_from_view().set_node_context_switch(id, expr.clone())?;
let ast_id = self.state.ast_node_id_of_view(id)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part that I changed to get the expression updates to reach the view. Based on my understanding, what used to happen is this:

  1. In this function (which triggers when the button is clicked), both the presenter state and the controller get updated.
  2. When we get an update back from the controller, we trigger this FRP link: expression_update <= update_data.map(|update| update.set_node_expressions());.
  3. In set_node_expressions, the nodes are checked for a mismatch between the controller update and the presenter state. However, since the state was already updated, no mismatch was found and therefore no update is triggered.

By removing the explicit view update here, we create that mismatch and the update fires correctly. I'm not sure if this was the correct approach. In any case, I think the skip and freeze changes have the same problem. Should I do the same thing there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. How to reproduce this issue in a previous version of the code? I don't understand why we need to update the view if it was already updated.

app/gui/view/graph-editor/src/lib.rs Outdated Show resolved Hide resolved
app/gui/view/graph-editor/src/lib.rs Outdated Show resolved Hide resolved
app/gui/view/graph-editor/src/lib.rs Show resolved Hide resolved
app/gui/view/graph-editor/src/component/node/action_bar.rs Outdated Show resolved Hide resolved
app/gui/view/graph-editor/src/component/node/action_bar.rs Outdated Show resolved Hide resolved
app/gui/view/graph-editor/src/component/node/action_bar.rs Outdated Show resolved Hide resolved
app/gui/view/graph-editor/src/component/node.rs Outdated Show resolved Hide resolved
app/gui/src/presenter/graph.rs Outdated Show resolved Hide resolved
} else {
None
};
self.log_action(
|| {
let ast_id =
self.state.update_from_view().set_node_context_switch(id, expr.clone())?;
let ast_id = self.state.ast_node_id_of_view(id)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. How to reproduce this issue in a previous version of the code? I don't understand why we need to update the view if it was already updated.

app/gui/src/presenter/graph.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@vitvakatu vitvakatu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary after internal call:
After reviewing the code, I found an issue with its functionality. When I tested the feature by opening a new project, clicking the button, and switching the global environment with a shortcut, I observed that the added expression disappeared from the node. This behavior is incorrect and needs to be addressed.

Based on my analysis, I hypothesize that the highlight may be coupled to the state of the ToggleButton, causing an additional "click" event that removes the expression. I suggest that we decouple the highlight from the state of the ToggleButton or find an alternative solution.

Regarding the updates, I believe that node_action_context_switch is correct and does not require any changes. However, I suggest modifying the FRP logic. Currently, output_context_updated only stores the state of the last updated node, resulting in only a single node being updated when the global context changes. To address this issue, I suggest we loop over every node, similar to set_node_expressions.

@Procrat Procrat requested a review from vitvakatu April 6, 2023 14:40
@Procrat
Copy link
Contributor Author

Procrat commented Apr 6, 2023

@vitvakatu If you're having another look, it might be worth going through commit by commit to understand which parts belong together and why that change was made.

@Procrat Procrat force-pushed the wip/procrat/toggle-reevaluation-button-5929 branch from 92e0c57 to 449dcb9 Compare April 11, 2023 12:33
@Procrat
Copy link
Contributor Author

Procrat commented Apr 11, 2023

I think I addressed everything except the tooltip tabel question. I also found another edge case that should be solved now.

My apologies if the force push is inconvenient. I had to roll back the merge with the latest version of develop because of the devtools issue.

Copy link
Contributor

@vitvakatu vitvakatu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA: passed.

@@ -31,9 +33,11 @@ const BUTTON_OFFSET: f32 = 0.5;
/// Grow the hover area in x direction by this amount. Used to close the gap between action
/// icons and node.
const HOVER_EXTENSION_X: f32 = 15.0;
const VISIBILITY_TOOLTIP_LABEL: &str = "Show preview";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the old labels were not sentences. But if these are, should they be followed by a period?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't think single-sentence UI components generally use periods?

@Procrat Procrat added the CI: Ready to merge This PR is eligible for automatic merge label Apr 11, 2023
@mergify mergify bot merged commit 810127b into develop Apr 11, 2023
@mergify mergify bot deleted the wip/procrat/toggle-reevaluation-button-5929 branch April 11, 2023 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding output context switch icon for the nodes.
4 participants