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

Fix updating task states, preventing state="" replacing existing state #586

Closed
wants to merge 5 commits into from

Conversation

kinow
Copy link
Member

@kinow kinow commented Jan 27, 2021

This is a small change with no associated Issue.

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Appropriate tests are included (unit and/or functional).
  • Appropriate change log entry included.
  • No documentation update required.

@kinow kinow self-assigned this Jan 27, 2021
@kinow kinow added this to the 0.3 milestone Jan 27, 2021
@kinow
Copy link
Member Author

kinow commented Jan 27, 2021

This should be fixed now. The test failures are fixed in #584

@kinow
Copy link
Member Author

kinow commented Jan 27, 2021

@hjoliver we can wait for #584 to be merged before reviewing. Then I'll rebase this one and CI will be OK again.

@hjoliver
Copy link
Member

Just tested, the unknown task status is gone, but now the held indicator doesn't show up.

@kinow
Copy link
Member Author

kinow commented Jan 27, 2021

Just tested, the unknown task status is gone, but now the held indicator doesn't show up.

Hmmm. @hjoliver what happens if you hold a task, and then expand it in the tree?

@hjoliver
Copy link
Member

Then it shows up!

@kinow
Copy link
Member Author

kinow commented Jan 28, 2021

Rebased 🤞

@codecov-io
Copy link

codecov-io commented Jan 28, 2021

Codecov Report

Merging #586 (a1e5b82) into master (a5c7750) will decrease coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #586      +/-   ##
==========================================
- Coverage   81.66%   81.59%   -0.08%     
==========================================
  Files          66       66              
  Lines        1320     1320              
  Branches       81       81              
==========================================
- Hits         1078     1077       -1     
- Misses        223      224       +1     
  Partials       19       19              
Flag Coverage Δ
e2e 48.63% <100.00%> (-0.08%) ⬇️
unittests 79.79% <50.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/components/cylc/tree/TreeItem.vue 96.15% <ø> (ø)
src/components/cylc/tree/index.js 100.00% <ø> (ø)
src/graphql/queries.js 100.00% <ø> (ø)
src/components/cylc/tree/cylc-tree.js 99.31% <100.00%> (-0.69%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5c7750...a1e5b82. Read the comment docs.

@hjoliver
Copy link
Member

From @kinow on Element chat:

looks like it's just a reactivity issue ...

I've done some progress with the Task component not updating. When I update name or status, the new values are immediately rendered (both are string 🤔).

But changing progress (number) or isHeld (Boolean) has no effect until something else changes (like status, expanded in another element, etc) and then the component re-renders

@kinow
Copy link
Member Author

kinow commented Jan 28, 2021

Rebased

@kinow
Copy link
Member Author

kinow commented Jan 28, 2021

@hjoliver I was adding the ID to the element key, so I could more easily manipulate/find it in vue-dev-tools or programmatically while debugging the issue.

But adding :key="node.node.id" appears to have made it work 🕵️ . My guess is that Vue was not able to link the change in state to the component. But having the :key of the component, when the data changed Vue was able to now locate the component and update it. But I would like to keep digging in the reactivity of the CylcTree and components using it a bit longer after this issue.

But if that fixes the issue for now, at least we can fix this issue and open another one for follow-up.

@kinow
Copy link
Member Author

kinow commented Jan 28, 2021

To test, I have Chromium and Firefox open, in two monitors. With queued workflow (how I named the workflow you sent me yesterday @hjoliver). After a hard-refresh with CTRL + F5, things appear to be working OK. Though some indication that the UI is working after/during a mutation is executed would be helpful too.

In Firefox I hold a task, then confirm Chromium and Firefox updated the component. Then do the same with Chromium, confirming in Firefox. Some times I hold a task, some times release. Removing and killing appears to work fine too.

@hjoliver
Copy link
Member

Hmmm, isHeld still isn't reactive for me (updated branch, re-install, re-build, hard refresh). Tried with Firefox and Chrome.

@kinow
Copy link
Member Author

kinow commented Feb 8, 2021

I think I found the issue. Appears to be because isHeld is not defined in the deltas.added, due to stripNull: true (when stripNull: false, isHeld is returned as false for the task proxies).

When that happens, the JS object added to the CylcTree does not have a isHeld attribute, so Vue doesn't create an observer for it. When we receive a delta with the update that contains isHeld: any-value, we merge object, setting isHeld in the object.

But since there's no observer for isHeld, Vue components do not react. I tested changing locally added(stripNull: false) and the component was updated correctly. (@hjoliver I will leave my last commit from some days ago, key-ing the components, as that's actually good; and when vue-dev utils is open, that appears to somehow trigger the component update, probably that's why it was working for me but didn't work for you).

Posted a question to the Element chat room to see if stripNull is working as expected. A possible solution for this is simply use added(stripNull: false), but will wait for the reply there first.

@kinow
Copy link
Member Author

kinow commented Feb 8, 2021

image

@kinow
Copy link
Member Author

kinow commented Feb 8, 2021

@hjoliver whenever you have time, could you please take another look and confirm if that fixes the issue for you? The isHeld should be applied correctly now after you trigger the mutation 🤞 Thanks!

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

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

This seems like a logical change to me though I've encountered the issue it's fixing myself. Hopefully Hillary can confirm it fixes the reported issue.

@kinow kinow mentioned this pull request Feb 16, 2021
12 tasks
@kinow kinow marked this pull request as draft February 17, 2021 20:56
Copy link
Member Author

@kinow kinow left a comment

Choose a reason for hiding this comment

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

I've moved it back to draft as I've incorporated these changes into #530 since the state could be interfering with the outputs being updated correctly.

If that PR is merged, we can probably close this one as superseded. I will take a better look after #530 is merged.

# value for isHeld, and then it is stripped. When stripNull: false is used,
# we will actually get the default value from Protobuf (in the case of
# isHeld, we will get isHeld: false, which is what we want for the UI).
added (stripNull: false) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Marking as draft. @hjoliver the new merge customizer (from Lodash API) used in #530 appears to remove the need for this stripNull. Will test again once we have merged that PR.

})
cylcTree.updateTaskProxy(updateTaskProxy)
expect(cylcTree.root.children[0].children[0].children[0].node.state).to.equal(TaskState.RUNNING.name)
})
Copy link
Member Author

Choose a reason for hiding this comment

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

Added in #530

delete taskProxy.state
const taskProxyNode = createTaskProxyNode(taskProxy)
expect(taskProxyNode.node.state).to.equal('')
})
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed in #530

@kinow
Copy link
Member Author

kinow commented Feb 24, 2021

Confirmed it has been added to #530, with the only difference being that we did not need the stripNull: true in the added delta. @hjoliver I've tested the UI after updating my master branch, everything seems to be working OK.

Calling mutations with the aotf form, then the state is updated correctly in the UI in ~1 second. Without the need of changing the expand/collapse state of the component.

@kinow kinow closed this Feb 24, 2021
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.

None yet

4 participants