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

UI: Cell focus changed when removing ghost cells #316

Open
jlewi opened this issue Oct 21, 2024 · 4 comments · Fixed by stateful/vscode-runme#1827
Open

UI: Cell focus changed when removing ghost cells #316

jlewi opened this issue Oct 21, 2024 · 4 comments · Fixed by stateful/vscode-runme#1827
Labels
bug Something isn't working vscode

Comments

@jlewi
Copy link
Owner

jlewi commented Oct 21, 2024

I think when ghost cells are deleted it can affect the rendered view.

Here's what I think I'm observing.

Suppose you were editing cell K where K < N and N is the number of cells in the document.
So we generate ghost cells at position K+1 , K+2, ...
(I was testing with #285) which was generating multiple ghost cells.

I then started editing cell N+1.
I think what happens is that when we start editing cell N+1 we delete the current ghost cells (K+1, K+2, ...). This causes the cells to shift up to fill in the gaps. I think this causes problems. I think I observed the cell I was editing disappearing.
Even more confusing, since we are generating new ghost cells, N+2, N+3,... those ghost cells now appear. So to the user it looks like the cell they were editing was deleted and replaced with some ghost cells.

We should try to reproduce this in a more controlled way so we can reproduce it and test fixes.

Could we create a function to insert ghost cells at a particular location?

@jlewi jlewi added the ui label Oct 21, 2024
@jlewi
Copy link
Owner Author

jlewi commented Oct 22, 2024

I think another case where this happening is if you have an earlier cell running a long running commands (e.g. watching the logs). Everytime the cell output changes that will trigger ghost cell generation (at least it will with stateful/vscode-runme#1744). So if cell K is long running and you are working on cell N, then each time cell K's output changes we will create ghost cells K+1,...,K+j this could cause the cells to change which I think can move cell N up or down which I think could cause problems.

@jlewi jlewi added vscode and removed ui labels Oct 22, 2024
@jlewi jlewi added the bug Something isn't working label Nov 4, 2024
@jlewi
Copy link
Owner Author

jlewi commented Nov 4, 2024

Does this mean we end up logging a suggestion acceptance event when we delete cells?

@jlewi
Copy link
Owner Author

jlewi commented Nov 15, 2024

I think this is most pronounced when removing ghost cells that are above the newly focused cell as the deletion will shift the current cells up.

So I think a quick hack be to remove ghost cells as soon as the focus changes to a new cell.

@jlewi
Copy link
Owner Author

jlewi commented Nov 27, 2024

There's a couple ways we could potentially fix this

  1. We could try resetting the focus after doing the deletion
  2. We could try doing the deletion as soon as the cell focus changes

We might need to set the focus even if we do the delete immediately upon focus change. I rarely accept suggestions if I don't accept them immediately. So that probably makes sense to do.

jlewi added a commit to stateful/vscode-runme that referenced this issue Nov 28, 2024
* The bug is described in jlewi/foyle#316
* The problem was we weren't deleting the previous ghost cells until we were ready to
  insert the new ghost cells. When we deleted the ghost cells this could shift
  the current cells up. This could lead to the active cell shifting up and losing
  focus. This was very confusing. It felt like the ground was changing underneath you.

* This PR fixes that by deleting the ghost cells from the current compeltion
  as soon as you change the cell focus to a new cell. Therefore by the time
  you start typing the previous ghost cells have already been removed.

* I think this is a much better experience.

* I think the original UX was motivated in part to give you time to look
  at the previous ghost cells while you are still typing. I also
  think it might have partially been for demo purposes to give you some
  ghost cells to continue to look at.

* In practice, I find that if I don't select a ghost cell immediately after
  switching cell focus I never bother to look at it. So persisting the ghost
  cells after switching focus wasn't adding any value.

* On the other hand, the cell losing focus was super frustrating.

* Fix jlewi/foyle#316
sourishkrout pushed a commit to stateful/vscode-runme that referenced this issue Dec 2, 2024
* The bug is described in jlewi/foyle#316
* The problem was we weren't deleting the previous ghost cells until we were ready to
  insert the new ghost cells. When we deleted the ghost cells this could shift
  the current cells up. This could lead to the active cell shifting up and losing
  focus. This was very confusing. It felt like the ground was changing underneath you.

* This PR fixes that by deleting the ghost cells from the current compeltion
  as soon as you change the cell focus to a new cell. Therefore by the time
  you start typing the previous ghost cells have already been removed.

* I think this is a much better experience.

* I think the original UX was motivated in part to give you time to look
  at the previous ghost cells while you are still typing. I also
  think it might have partially been for demo purposes to give you some
  ghost cells to continue to look at.

* In practice, I find that if I don't select a ghost cell immediately after
  switching cell focus I never bother to look at it. So persisting the ghost
  cells after switching focus wasn't adding any value.

* On the other hand, the cell losing focus was super frustrating.

* Fix jlewi/foyle#316
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vscode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant