jlewi / foyle

Foyle is a copilot to help developers deploy and operate their applications.
https://foyle.io
Apache License 2.0
110 stars 9 forks source link

UI: Cell focus changed when removing ghost cells #316

Open jlewi opened 4 weeks ago

jlewi commented 4 weeks ago

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 commented 4 weeks ago

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 https://github.com/stateful/vscode-runme/pull/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 commented 2 weeks ago

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

jlewi commented 4 days ago

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.