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

feat(autoedits): make it reactive to config changes #6537

Merged
merged 11 commits into from
Jan 8, 2025

Conversation

hitesh-1997
Copy link
Contributor

@hitesh-1997 hitesh-1997 commented Jan 6, 2025

Context

Currently auto-edits is not reactive to config changes and hence requires vscode reloading. If the user doesn't reload vscode auto-edits suggestion doesn't do away because the auto-edits provider is not disposed on the config change.
This results into:

  1. If the user turns off the suggestion mode: they will keep on seeing the auto-edits suggestions.
  2. If user switches from the auto-edits to autocomplete mode, they will see the suggestion from both autocomplete and auto-edits.
  3. The PR makes auto-edits reactive to the authStatus and config change similar to autocomplete, so that auto-edits is reactive and destroyed/created on the config changes without reloading vscode.
  4. Build on top of: suggestion mode UI #6523

Example image below:
image

Test plan

  1. Add the breakpoints at dispose function and provideInlineCompletion function for autocomplete and auto-edits and make sure they are disposed and created upon config changes without reloading vscode.
  2. CI

@hitesh-1997 hitesh-1997 changed the base branch from main to hitesh/suggetion-mode-option January 6, 2025 12:49
@hitesh-1997 hitesh-1997 force-pushed the hitesh/make-autoedits-reactive branch from 2018bc0 to 0f22a0e Compare January 6, 2025 21:39
@valerybugakov valerybugakov changed the title Hitesh/make autoedits reactive feat(autoedits): make it reactive to config changes Jan 7, 2025
Comment on lines +710 to +716
distinctUntilChanged((a, b) => {
return (
isEqual(a[0].configuration, b[0].configuration) &&
isEqual(a[1], b[1]) &&
isEqual(a[2], b[2])
)
}),
Copy link
Member

Choose a reason for hiding this comment

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

😭

Copy link
Contributor Author

@hitesh-1997 hitesh-1997 Jan 7, 2025

Choose a reason for hiding this comment

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

simply copied from registerAutocomplete anything wrong with this approach 😅

Copy link
Member

Choose a reason for hiding this comment

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

😭😭😭

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think there's a TODO to address it. We should look into it at some point.

Comment on lines 39 to 41
return promiseFactoryToObservable(async () => {
return await getAutoeditsProviderDocumentFilters()
}).pipe(
Copy link
Member

Choose a reason for hiding this comment

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

Since we don't have a setting for languages that autoedits are enabled for, we can use a static list for now without the promiseFactoryToObservable call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

})
}),
catchError(error => {
logError('registerAutoedits', 'Error', error)
Copy link
Member

Choose a reason for hiding this comment

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

Can we use autoeditsOutputChannelLogger here to ensure this message is added to the autotedits output channel in the dev environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Base automatically changed from hitesh/suggetion-mode-option to main January 7, 2025 10:16
@@ -68,7 +74,7 @@ export function getConfiguration(
debugVerbose: config.get<boolean>(CONFIG_KEY.debugVerbose, false),
debugFilter: debugRegex,
telemetryLevel: config.get<'all' | 'off'>(CONFIG_KEY.telemetryLevel, 'all'),
autocomplete: config.get(CONFIG_KEY.autocompleteEnabled, true),
autocomplete: codyAutoSuggestionsMode === CodyAutoSuggestionMode.Autocomplete,
Copy link
Member

Choose a reason for hiding this comment

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

Should we migrate settings from people with the old configuration field in their settings.json? If I have "cody.autocomplete.enabled": false in my settings I expect CONFIG_KEY.suggestionsMode to be false too when I upgrade to the new version. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, sorry I missed this.
Should we add a manual override here ?

Copy link
Member

Choose a reason for hiding this comment

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

Can we programmatically migrate the current setting value to a new field? For example, if autocomplete.enabled is set to false, suggestions.mode should be manually updated to off. Also, let's create an issue to follow up and remove this code later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@valerybugakov valerybugakov left a comment

Choose a reason for hiding this comment

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

Approving to unblock, but let's ensure we address the backward compatibility of the new setting before merging. Or, if I missed anything and it's unnecessary, let me know in the review thread.

@hitesh-1997 hitesh-1997 merged commit dc16680 into main Jan 8, 2025
21 of 22 checks passed
@hitesh-1997 hitesh-1997 deleted the hitesh/make-autoedits-reactive branch January 8, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants