diff --git a/src/components/chat-item/chat-prompt-input.ts b/src/components/chat-item/chat-prompt-input.ts index 72ad838d..4a0d95e6 100644 --- a/src/components/chat-item/chat-prompt-input.ts +++ b/src/components/chat-item/chat-prompt-input.ts @@ -355,11 +355,21 @@ export class ChatPromptInput { }); codeAttachment = this.userPromptHistory[this.userPromptHistoryIndex].codeAttachment ?? ''; } - if (codeAttachment.trim().length > 0) { - codeAttachment = codeAttachment - .replace(/~~~~~~~~~~/, '') - .replace(/~~~~~~~~~~$/, '') - .trim(); + codeAttachment = codeAttachment.trim(); + if (codeAttachment.length > 0) { + // the way we mark code in our example mynah client + if (codeAttachment.startsWith('~~~~~~~~~~') && codeAttachment.endsWith('~~~~~~~~~~')) { + codeAttachment = codeAttachment + .replace(/^~~~~~~~~~~/, '') + .replace(/~~~~~~~~~~$/, '') + .trim(); + } else if (codeAttachment.startsWith('```') && codeAttachment.endsWith('```')) { + // the way code is marked in VScode and JetBrains extensions + codeAttachment = codeAttachment + .replace(/^```/, '') + .replace(/```$/, '') + .trim(); + } this.addAttachment(codeAttachment, 'code'); } } diff --git a/ui-tests/__test__/main.spec.ts b/ui-tests/__test__/main.spec.ts index 0f1f9c0a..d57688eb 100644 --- a/ui-tests/__test__/main.spec.ts +++ b/ui-tests/__test__/main.spec.ts @@ -216,7 +216,7 @@ describe('Open MynahUI', () => { it('should navigate down to next prompt', async () => { await navigatePromptsDown(page); }, - 20000); + 25000); it('should navigate down to current empty prompt', async () => { await navigatePromptsToEmpty(page); });