Skip to content

Add refactor slash command

Nicolas Dular requested to merge nd/refactor-slash-command into master

What does this MR do and why?

Add refactor slash command

Adds the ability to send selected code and the /refactor slash command as input to directly use the RefactorCode tool.

Issue: #431576 (closed)

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Feature.enable(:slash_commands)
  2. In one browser tab open Duo Chat UI, in second tab open graphql-explorer
  3. Send the following request from graphql explorer and check the result in Duo Chat UI:
mutation {
  aiAction(input: {chat: {content: "/refactor", currentFile: {
    selectedText: "\n@sold_items = %w( onions garlic potatoes ) \ndef print_report\nputs '*** Sales Report for #{Time.new.strftime('%d/%m/%Y')} ***'\n@sold_items.each { |i| puts i }\nputs '*** End of Sales Report ***'\nend",
    fileName: "hello.rb"
  }}}) {
    clientMutationId
    errors
  }
}  

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Nicolas Dular

Merge request reports