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

Improve behavior of AI Changeset diff editor #14786

Merged

Conversation

tsmaeder
Copy link
Contributor

What it does

Moves the diff to the right side and applies the changes to the underlying file upon "save" in the diff editor. If an editor is open at the time, it will be updated and will retain the same dirty state as before.

partially fixes #14785

How to test

Create an AI change set (for example by invoking @Changeset in the AI chat) and play around with the diff editor, "accept", etc.

Follow-ups

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Contributed on behalf of STMicroelectronics

Review checklist

Reminder for reviewers

partially fixes eclipse-theia#14785

Contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
@tsmaeder tsmaeder requested a review from planger January 28, 2025 17:04
readContents: async () => element.targetState ?? '',
saveContents: async (content: string, options?: ResourceSaveOptions): Promise<void> => {
element.accept();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should still save the content and not just plain accept, because the user may have edited something in the diff editor and then expects that the save stores the file with their edit and not just the original suggestion of the AI agent.
Setting the element to state "accept" is a nice touch though as it is a great reference for the user what they already reviewed and saved.

Copy link
Contributor

@planger planger left a comment

Choose a reason for hiding this comment

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

Excellent work, thank you! Feels pretty good now.
I just found two issues while testing and reviewing the changes:

  • When the user hits save (Ctrl-S) on a new file, Theia asks where to store this file, even though it should actually already be clear where to put this file.
  • When the user modifies the content in the diff editor, the changes are lost. I think this may be easy to fix, if we just store the content -- see inline comment.

WDYT?

Signed-off-by: Thomas Mäder <[email protected]>
@tsmaeder tsmaeder requested a review from planger January 30, 2025 11:06
Copy link
Contributor

@planger planger left a comment

Choose a reason for hiding this comment

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

Thanks for the revision! This is certainly a great improvement to before, so I'm ok with merging it and addressing the remaining issues in follow-ups.

Issues I found:

  • When opening new files (click on the added file item), the label is some random id instead of the file name. Save works fine though.
  • When opening the diff editor on new files and saving, it still asks me where to save the file. I'd have expected that it would just create and save the current content to the defined URI location.

@@ -1,3 +1,2 @@
{
"npm/npmjs/-/unicode-property-aliases-ecmascript/2.1.0": "Manually approved"
Copy link
Contributor

Choose a reason for hiding this comment

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

This change seems unrelated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's not needed anymore

Signed-off-by: Thomas Mäder <[email protected]>
@tsmaeder tsmaeder merged commit 95f4d49 into eclipse-theia:master Jan 30, 2025
11 checks passed
@github-actions github-actions bot added this to the 1.58.0 milestone Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Improve Changeset Diff Editor Experience
2 participants