diff --git a/extensions/void/src/sidebar/SidebarChat.tsx b/extensions/void/src/sidebar/SidebarChat.tsx index 4b029a66..645afb46 100644 --- a/extensions/void/src/sidebar/SidebarChat.tsx +++ b/extensions/void/src/sidebar/SidebarChat.tsx @@ -23,21 +23,43 @@ ${content} } const userInstructionsStr = (instructions: string, files: File[], selection: CodeSelection | null) => { - return ` -${filesStr(files)} + let str = ''; -${!selection ? '' : ` + if (files.length > 0) { + str += filesStr(files); + } + + if (selection) { + str += ` I am currently selecting this code: -\`\`\`${selection.selectionStr}\`\`\` -`} +\t\`\`\`${selection.selectionStr}\`\`\` +`; + } -Please edit the code following these instructions (or, if appropriate, answer my question instead): -${instructions} - -If you make a change, rewrite the entire file. + if (files.length > 0 && selection) { + str += ` +Please edit the selected code or the entire file following these instructions: +`; + } else if (files.length > 0) { + str += ` +Please edit the file following these instructions: +`; + } else if (selection) { + str += ` +Please edit the selected code following these instructions: +`; + } + + str += ` +\t${instructions} +`; + if (files.length > 0) { + str += ` +\tIf you make a change, rewrite the entire file. `; // TODO don't rewrite the whole file on prompt, instead rewrite it when click Apply -} - + } + return str; +}; const ChatBubble = ({ chatMessage }: { chatMessage: ChatMessage }) => {