sourcegraph / cody

AI that knows your entire codebase
https://cody.dev
Apache License 2.0
2.24k stars 213 forks source link

feedback: No longer able to edit the changes in "diff" mode #4671

Open alex-tee opened 1 week ago

alex-tee commented 1 week ago

Version

v1.23.1719313083 (pre-release)

Areas for Improvement

What needs to be improved? Please describe how this affects the user experience and include a screenshot.

After updating my VSCodium extensions, I am no longer able to edit Cody's changes in a new tab in diff mode Now, when i press Alt+K to edit a block of code, when Cody finishes it shows be a diff view but when I go to edit something the diff view goes away and the changes are applied. Now, I don't know what exactly changed because I can't compare what Cody did with what was there before, so it makes it very difficult to correct what Cody did (because it makes mistakes often and needs to be corrected manually).

Describe the solution you'd like to see

Bring back the option to edit changes made by Cody in "diff" mode in another tab.

Describe any alternatives that could be considered

Don't go out of "diff" (currently preview-only) mode when the user attempt to edit some change made by Cody. Make this view editable.

Additional context

No response

umpox commented 6 days ago

Thanks for raising this so quickly @alex-tee!

Don't go out of "diff" (currently preview-only) mode when the user attempt to edit some change made by Cody. Make this view editable.

I think this is likely the best approach going forward. Removing the diff automatically on change is quite jarring, especially when there are deleted lines

Will be improved by: https://github.com/sourcegraph/cody/pull/4684

alex-tee commented 5 days ago

Thanks for the change. I tried it now. It kinda works but it's very buggy if you add a few lines while editing (the bottom of the text blends in with other code that should not be affected), and there is no ability to revert changes per diff-block like before. It feels like loss of functionality. What was wrong with opening a proper diff to edit in a new tab?

alex-tee commented 5 days ago

Another disadvantage of not having the diffs in a separate temporary tab is that I can't even open my file separately to view it normally, while editing the diff. The file in the new tab gets colored too.

umpox commented 4 days ago

@alex-tee Thanks, I understand this a bit more now. I didn't anticipate that the separate diff view would be used to revert part of an edit, but that is totally a valid use case and we should support that.

I think eventually I want to support doing this entirely in-file, i.e. we show a simple "Accept / Discard" CTA above each change, so you can still have partial acceptance without needing to leave your file.

One problem we have is that we require adding empty lines of whitespace in order to show the inline diff. When we open a separate diff view, we need to remove these lines (and anything else from the inline-diff) otherwise we will end up with a duplicate diff. We could remove those lines, but that would pollute the undo/redo stack a lot as we clean up/re-add the diff, and will likely lead to a bunch of issues as we try to keep the inline diff in sync as the file is opened/closed.

I think we can do this:

Looking into this here: https://github.com/sourcegraph/cody/pull/4720

umpox commented 1 day ago

@alex-tee Here's a quick demo of the new experience. Let me know if there's any other use cases you have that you think isn't covered here.

Otherwise I'll let you know when we get this into the next Cody release and close this issue

https://github.com/sourcegraph/cody/assets/9516420/e9d33e8e-ec31-4a59-9bf2-fda72c1411e4

alex-tee commented 1 day ago

@umpox LGTM, thanks for working on this!