feat(code-actions): add "Fix Code in Current Task" action

Adds ability to fix code within the context of an active task instead of starting a new one. This allows for more efficient workflow when already working with Roo.

Add new FIX_IN_CURRENT_TASK code action and command
Enhance ClineProvider to support context-aware code fixing
Update tests to verify new action functionality
This commit is contained in:
sam hoang
2025-01-27 14:24:26 +07:00
parent 3deeb0c28b
commit 85c49d8eff
4 changed files with 57 additions and 6 deletions

View File

@@ -188,10 +188,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
return findLast(Array.from(this.activeInstances), (instance) => instance.view?.visible === true)
}
public static async handleCodeAction(
promptType: keyof typeof ACTION_NAMES,
params: Record<string, string | any[]>,
): Promise<void> {
public static async getInstance(): Promise<ClineProvider | undefined> {
let visibleProvider = ClineProvider.getVisibleInstance()
// If no visible provider, try to show the sidebar view
@@ -207,10 +204,46 @@ export class ClineProvider implements vscode.WebviewViewProvider {
return
}
return visibleProvider
}
public static async isActiveTask(): Promise<boolean> {
const visibleProvider = await ClineProvider.getInstance()
if (!visibleProvider) {
return false
}
if (visibleProvider.cline) {
return true
}
return false
}
public static async handleCodeAction(
command: string,
promptType: keyof typeof ACTION_NAMES,
params: Record<string, string | any[]>,
): Promise<void> {
const visibleProvider = await ClineProvider.getInstance()
if (!visibleProvider) {
return
}
const { customSupportPrompts } = await visibleProvider.getState()
const prompt = supportPrompt.create(promptType, params, customSupportPrompts)
if (visibleProvider.cline && ["roo-cline.fixCodeInCurrentTask"].indexOf(command) !== -1) {
await visibleProvider.postMessageToWebview({
type: "invoke",
invoke: "sendMessage",
text: prompt,
})
return
}
await visibleProvider.initClineWithTask(prompt)
}