diff --git a/src/shared/native-chat-image-transcript-markers.test.ts b/src/shared/native-chat-image-transcript-markers.test.ts index cd9e7d3b8d6..e08caac8d3c 100644 --- a/src/shared/native-chat-image-transcript-markers.test.ts +++ b/src/shared/native-chat-image-transcript-markers.test.ts @@ -44,8 +44,10 @@ describe('normalizeImageTranscriptMessages', () => { it.each([ ['[Image #1] describe this', 'describe this'], ['[Image #1]\t describe this', 'describe this'], + [' \t[Image #1] describe this', 'describe this'], ['describe this [Image #1]', 'describe this'], ['describe this \t[Image #1]', 'describe this'], + ['describe this [Image #1]\t ', 'describe this'], ['describe [Image #1] this', 'describe this'], ['describe [Image #1]\t this', 'describe \t this'], ['describe[Image #1]\t this', 'describe\t this'], diff --git a/src/shared/native-chat-image-transcript-markers.ts b/src/shared/native-chat-image-transcript-markers.ts index 6523688018b..c9f9d13eb51 100644 --- a/src/shared/native-chat-image-transcript-markers.ts +++ b/src/shared/native-chat-image-transcript-markers.ts @@ -3,8 +3,8 @@ import { isTextBlock, type NativeChatBlock, type NativeChatMessage } from './nat const IMAGE_SOURCE_MARKER = /^\[Image:\s*source:\s*(.+?)\]\s*$/ const IMAGE_PROMPT_MARKER = /\[Image #\d+\]/ const IMAGE_PROMPT_MARKERS = /\[Image #\d+\]/g -const IMAGE_PROMPT_MARKER_AT_START = /^\[Image #\d+\]/ -const IMAGE_PROMPT_MARKER_AT_END = /\[Image #\d+\]$/ +const IMAGE_PROMPT_MARKER_AT_START = /^[^\S\r\n]*\[Image #\d+\]/ +const IMAGE_PROMPT_MARKER_AT_END = /\[Image #\d+\][^\S\r\n]*$/ const HORIZONTAL_WHITESPACE_START = /^[^\S\r\n]+/ const HORIZONTAL_WHITESPACE_END = /[^\S\r\n]+$/