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

remove fixup command handling from refactor menu #766

Merged
merged 6 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Starting from `0.2.0`, Cody is using `major.EVEN_NUMBER.patch` for release versi
- Cody Commands: Don't require Esc to dismiss Cody menu. [pull/700](https://github.com/sourcegraph/cody/pull/700)
- Updated welcome chat words. [pull/748](https://github.com/sourcegraph/cody/pull/748)
- Autocomplete: Reduce network bandwidth with requests are resolved by previous responses. [pull/762](https://github.com/sourcegraph/cody/pull/762)
- Fixup: Remove `/document` and other command handling from the Refactor Menu. [pull/766](https://github.com/sourcegraph/cody/pull/766)

## [0.6.7]

Expand Down
65 changes: 3 additions & 62 deletions vscode/src/non-stop/FixupTypingUI.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,19 @@
import * as vscode from 'vscode'

import { FixupIntent } from '@sourcegraph/cody-shared/src/chat/recipes/fixup'

import { FixupTask } from './FixupTask'
import { FixupTaskFactory } from './roles'

type FixupCommand = `/${FixupIntent}`
interface FixupQuickPickItem {
description: string
placeholder: string
/**
* Optional value to insert.
* Some commands (like /document) are self explanatory and a user might not want to write anything
**/
value?: string
}

const FixupCommands = new Map<FixupCommand, FixupQuickPickItem>([
[
'/fix',
{
description: 'Fix a problem in the selected code',
placeholder: 'Describe what you want Cody to fix',
value: 'Fix any problems in the selected code',
},
],
[
'/document',
{
description: 'Generate documentation or comments for the selected code',
placeholder: 'Describe what you want Cody to do',
value: 'Generate documentation or comments for the selected code',
},
],
])

const FixupQuickPickItems: vscode.QuickPickItem[] = [...FixupCommands].map(([command, item]) => ({
label: command,
...item,
}))

/**
* The UI for creating non-stop fixup tasks by typing instructions.
*/
export class FixupTypingUI {
constructor(private readonly taskFactory: FixupTaskFactory) {}

private async getInstructionFromQuickPick({
title = 'Cody',
placeholder = "Tell Cody what to do, or type '/' for commands",
title = 'Cody: Refactor Code',
placeholder = 'Enter your refactoring instruction here...',
value = '',
prefix = '',
prefix = '/fix',
} = {}): Promise<string> {
const quickPick = vscode.window.createQuickPick()
quickPick.title = title
Expand All @@ -69,32 +32,10 @@ export class FixupTypingUI {
quickPick.hide()
})

quickPick.onDidChangeValue(value => {
if (value.startsWith('/')) {
quickPick.items = FixupQuickPickItems
} else {
// We show no items by default
quickPick.items = []
}
})

quickPick.show()

return new Promise(resolve =>
quickPick.onDidAccept(() => {
const selectedItem = quickPick.selectedItems[0]?.label
const command = FixupCommands.get(selectedItem as FixupCommand)
if (command) {
return resolve(
this.getInstructionFromQuickPick({
title: `Cody - ${selectedItem}`,
placeholder: command.placeholder,
value: command.value,
prefix: selectedItem,
})
)
}

const instruction = quickPick.value.trim()
if (!instruction) {
// noop
Expand Down
Loading