hermiod

Experimenting with different UX for showing llm-suggested edits in neovim

I've been working on a kind of cursor.sh for neovim called carrier.nvim (don't use yet, it's a WIP).

I've been trying to think through what the user experience should be to display the diffs in LLM-suggested edits the user asks for.

The flow is like this:

  1. The user visually selects some code block they want to edit
  2. They are prompted for an edit instruction
  3. ??? We show the edited code as it's streamed in from the model somehow
  4. The user chooses to accept, reject, or re-prompt for another edit.

I've considered a couple options.

First, we could just not have an explicit accept or reject step. We'd just delete the old code to edit and stream in the new code.

I've found that it's really important to be able to see explicitly what changed between the old and the new. If you're squinting or guessing, you're probably going to miss something key.

Second, I tried using extmarks to display a diff using virtual text. This had several problems, but the most important one is that your cursor doesn't interact with the virtual text. For large blocks of code you wouldn't be able to fit all the virtual text inside your window.

What I have settled on for now is opening a buffer from the bottom that shows the diff as it's streamed in. This is similar to what happens if you use fugitive's :Git diff. Then, when you accept or reject a suggestion it automatically deletes that buffer.

Some other things to consider in the future:

  1. A way richer virtual text diff that inline marks up your code with the edits (whether that block of code will be deleted or added, etc.)
  2. Something like fugitive's :Git blame where you have a side by side buffer including the additions.