Duo Chat slash commands whitespace on auto-complete, no trailing clear on submit, Duo thinks it is a question
Checklist
-
I'm using the latest version of the extension (see the latest version in the right column of this page) - Extension version: v4.7.0
-
I'm using the latest VS Code version (find the latest version here) - VS Code version: 1.87.0, macOS
-
I'm using a supported version of GitLab (see README for the supported version) - GitLab version: "happens on
gitlab.com"
- GitLab version: "happens on
Summary
Duo Chat Slash commands automatically add a whitespace on auto-completion.
This is helpful for commands that allow refining the prompt, for example /explain, /refactor, /tests but causes irritations with the Chat prompt because Chat thinks this is a question, and not a slash command action.
Steps to reproduce
- Open Duo Chat in VS Code
- Ask a question to fill the history
- Type
/and selectclean - Use
enterto confirm the selection - Press
enteragain to submit the chat prompt.
What is the current bug behavior?
The prompt sends /clean and not /clean and does not remove the trailing whitespace. This makes Duo Chat think that this is a question, and it responds with saying that it cannot help.
As a user, I expect it to interpret and execution on slash commands accordingly. First-time experience: Not good UX. Suggest fixing this for GA.
What is the expected correct behavior?
Strip the trailing whitespace at the end automatically on prompt submission, and ensure Chat prompt interprets this string as command action, and not a question.
The GitLab UI Chat prompt does not provide auto-complete yet and does not show this behavior with the additional whitespace.
Relevant logs and/or screenshots
gitlab_duo_chat_vs_code_trailing_whitespace_bug.mp4
Possible fixes
On prompt submission, trim all trailing white spaces (beginning, end) to ensure the prompt can be actioned in the AI framework. Suggest fixing this problem on the client side, which controls the user prompt. If the problem continues in other IDEs, find a way to sanitize the prompts in the AI framework / API gateway.
Suggestion: The regex that decides if a prompt is a Slash command is here. It currently just looks at whether the question begins with a /. We then parse the command here and use that string to see if it matches one of the slash commands defined in a def self.slash_commands method.
When we pull the command from the user input in ee/lib/gitlab/llm/chain/slash_command.rb, we should strip whitespace
/cc @tlinz @katiemacoy