diff --git a/src/renderer/src/components/native-chat/native-chat-runtime-send.test.ts b/src/renderer/src/components/native-chat/native-chat-runtime-send.test.ts index 5f054b6db65..dc7fa05e830 100644 --- a/src/renderer/src/components/native-chat/native-chat-runtime-send.test.ts +++ b/src/renderer/src/components/native-chat/native-chat-runtime-send.test.ts @@ -369,7 +369,16 @@ describe('sendNativeChatMessageWithImageAttachments', () => { expect(sendRuntimePtyInput).toHaveBeenLastCalledWith(SETTINGS, PTY, NATIVE_CHAT_SUBMIT) }) - it('separates multiple image pastes from each other and from following prompt text', () => { + it('treats whitespace-only prompt input as attachment-only', () => { + sendNativeChatMessageWithImageAttachments(SETTINGS, PTY, ' ', ['/tmp/orca-paste-image.png']) + + expectWriteOrder(sendRuntimePtyInput.mock.calls, [ + NATIVE_CHAT_CLEAR_UNSUBMITTED_INPUT, + '\x1b[200~/tmp/orca-paste-image.png\x1b[201~' + ]) + }) + + it('keeps multiple image frames bare and separates only the final frame from prompt text', () => { sendNativeChatMessageWithImageAttachments(SETTINGS, PTY, 'hello', ['/tmp/a.png', '/tmp/b.png']) expectWriteOrder(sendRuntimePtyInput.mock.calls, [ diff --git a/src/shared/image-paste-following-text.test.ts b/src/shared/image-paste-following-text.test.ts index 068c3876a6b..ef46c4c7a9e 100644 --- a/src/shared/image-paste-following-text.test.ts +++ b/src/shared/image-paste-following-text.test.ts @@ -1,34 +1,31 @@ import { describe, expect, it } from 'vitest' import { IMAGE_PASTE_FOLLOWING_TEXT_SEPARATOR, - joinImagePastesAndPrompt + imagePasteWritesFollowedByText } from './image-paste-following-text' const IMAGE_A = '\x1b[200~/tmp/orca-paste-a.png\x1b[201~' const IMAGE_B = '\x1b[200~/tmp/orca-paste-b.png\x1b[201~' -const PROMPT = - 'add the QR code for wechat group 8 next to group 7. saying if group 7 is full can join group 8' -describe('joinImagePastesAndPrompt', () => { +describe('imagePasteWritesFollowedByText', () => { it('separates an attachment path from following prompt text by a single space', () => { - expect(joinImagePastesAndPrompt([IMAGE_A], PROMPT)).toBe(`${IMAGE_A} ${PROMPT}`) - expect(joinImagePastesAndPrompt([IMAGE_A], PROMPT)).not.toBe(`${IMAGE_A}${PROMPT}`) - expect(joinImagePastesAndPrompt([IMAGE_A], PROMPT)).not.toContain('pngadd') + expect(imagePasteWritesFollowedByText([IMAGE_A], true)).toEqual([`${IMAGE_A} `]) expect(IMAGE_PASTE_FOLLOWING_TEXT_SEPARATOR).toBe(' ') }) it('keeps an attachment-only send as the framed path with no trailing separator', () => { - expect(joinImagePastesAndPrompt([IMAGE_A], '')).toBe(IMAGE_A) + expect(imagePasteWritesFollowedByText([IMAGE_A], false)).toEqual([IMAGE_A]) }) - it('leaves prompt-only text unchanged', () => { - expect(joinImagePastesAndPrompt([], PROMPT)).toBe(PROMPT) + it('returns no writes when there are no image pastes', () => { + expect(imagePasteWritesFollowedByText([], true)).toEqual([]) }) it('keeps back-to-back image frames bare and separates only the final frame from prompt text', () => { - expect(joinImagePastesAndPrompt([IMAGE_A, IMAGE_B], PROMPT)).toBe( - `${IMAGE_A}${IMAGE_B} ${PROMPT}` - ) - expect(joinImagePastesAndPrompt([IMAGE_A, IMAGE_B], '')).toBe(`${IMAGE_A}${IMAGE_B}`) + expect(imagePasteWritesFollowedByText([IMAGE_A, IMAGE_B], true)).toEqual([ + IMAGE_A, + `${IMAGE_B} ` + ]) + expect(imagePasteWritesFollowedByText([IMAGE_A, IMAGE_B], false)).toEqual([IMAGE_A, IMAGE_B]) }) }) diff --git a/src/shared/image-paste-following-text.ts b/src/shared/image-paste-following-text.ts index 22afbd1df76..4efd7363427 100644 --- a/src/shared/image-paste-following-text.ts +++ b/src/shared/image-paste-following-text.ts @@ -23,11 +23,3 @@ export function imagePasteWritesFollowedByText( ) ) } - -/** Exact PTY bytes for image pastes plus optional prompt text. */ -export function joinImagePastesAndPrompt( - framedImagePastes: readonly string[], - prompt: string -): string { - return `${imagePasteWritesFollowedByText(framedImagePastes, prompt.length > 0).join('')}${prompt}` -}