Skip to content

Commit

Permalink
adding autoedits onboarding setup for dotcom users
Browse files Browse the repository at this point in the history
  • Loading branch information
hitesh-1997 committed Dec 27, 2024
1 parent 91ac295 commit ab9ec69
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
6 changes: 6 additions & 0 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,12 @@
"markdownDescription": "Enable hints for Cody commands such as \"Opt+K to Edit\" or \"Opt+D to Document\"",
"default": true
},
"cody.experimental.autoedits.enabled": {
"order": 99,
"type": "boolean",
"markdownDescription": "Enable Autoedit, an experimental feature that automatically applies suggested edits.",
"default": false
},
"cody.experimental.tracing": {
"order": 99,
"type": "boolean",
Expand Down
26 changes: 26 additions & 0 deletions vscode/src/autoedits/autoedit-onboarding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

import * as vscode from 'vscode'

export async function showAutoeditOnboarding(): Promise<void> {
const selection = await vscode.window.showInformationMessage(
'✨ Try Cody Autoedits - An alternative to autocomplete that helps you edit code more efficiently',
'Enable Autoedits'
)

if (selection === 'Enable Autoedits') {
// Enable the setting programmatically
await vscode.workspace.getConfiguration().update(
'cody.experimental.autoedits.enabled',
true,
vscode.ConfigurationTarget.Global
)

// Open VS Code settings UI and focus on the Cody Autoedits setting
await vscode.commands.executeCommand(
'workbench.action.openSettings',
'cody.experimental.autoedits'
)
}
}


5 changes: 5 additions & 0 deletions vscode/src/completions/inline-completion-item-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
} from './suggested-autocomplete-items-cache'
import { indentation } from './text-processing'
import type { ProvideInlineCompletionItemsTracer, ProvideInlineCompletionsItemTraceData } from './tracer'
import { showAutoeditOnboarding } from '../autoedits/autoedit-onboarding'

interface AutocompleteResult extends vscode.InlineCompletionList {
logId: CompletionLogID
Expand Down Expand Up @@ -138,6 +139,10 @@ export class InlineCompletionItemProvider
tracer = null,
...config
}: CodyCompletionItemProviderConfig) {

// Show the onboarding if the user has not enabled autoedits and want to use that instead of autocomplete
showAutoeditOnboarding()

// This is a static field to allow for easy access in the static `configuration` getter.
// There must only be one instance of this class at a time.
InlineCompletionItemProviderConfigSingleton.set({
Expand Down
3 changes: 2 additions & 1 deletion vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ function shouldEnableExperimentalAutoedits(
if (config.configuration.experimentalAutoeditsEnabled !== undefined) {
return config.configuration.experimentalAutoeditsEnabled
}
// If the feature flag is enabled, use the flag instead of the config.
return autoeditExperimentFlag && isS2(authStatus) && isRunningInsideAgent() === false
}

Expand Down Expand Up @@ -824,7 +825,7 @@ function registerAutocomplete(
})
)
.subscribe({})
)
),
)
}

Expand Down
4 changes: 4 additions & 0 deletions vscode/src/wink-nlp-utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ declare module 'wink-nlp-utils' {
}
}


export default winkUtils
}



0 comments on commit ab9ec69

Please sign in to comment.