diff --git a/src/shared/native-chat/input/native-chat-paste-bytes.test.ts b/src/shared/native-chat/input/native-chat-paste-bytes.test.ts index bb7c5cad670..37545d986dc 100644 --- a/src/shared/native-chat/input/native-chat-paste-bytes.test.ts +++ b/src/shared/native-chat/input/native-chat-paste-bytes.test.ts @@ -31,13 +31,13 @@ describe('buildNativeChatPasteBytes', () => { expect(buildNativeChatPasteBytes('hi\x1b there')).toBe('hi␛ there') }) - it('frames single-line text over 1 KiB of UTF-8 so agents keep every read (#13332)', () => { - const atBoundary = 'é'.repeat(512) + it('frames single-line text over 512 UTF-8 bytes so agents keep every read (#13332, #32071)', () => { + const atBoundary = 'é'.repeat(256) const overBoundary = `${atBoundary}x` expect(buildNativeChatPasteBytes(atBoundary)).toBe(atBoundary) expect(buildNativeChatPasteBytes(overBoundary)).toBe(`${BEGIN}${overBoundary}${END}`) // Each ESC becomes a 3-byte ␛, so the sent length, not the typed one, decides. - expect(buildNativeChatPasteBytes('\x1b'.repeat(400))).toBe(`${BEGIN}${'␛'.repeat(400)}${END}`) + expect(buildNativeChatPasteBytes('\x1b'.repeat(200))).toBe(`${BEGIN}${'␛'.repeat(200)}${END}`) }) }) diff --git a/src/shared/terminal/input/terminal-bracketed-paste-text.ts b/src/shared/terminal/input/terminal-bracketed-paste-text.ts index 425dcbd8d58..6e75398377e 100644 --- a/src/shared/terminal/input/terminal-bracketed-paste-text.ts +++ b/src/shared/terminal/input/terminal-bracketed-paste-text.ts @@ -3,8 +3,8 @@ const ESCAPE = '\u001b' export const BRACKETED_PASTE_START = `${ESCAPE}[200~` export const BRACKETED_PASTE_END = `${ESCAPE}[201~` -// Agents can keep only the last read of unframed input longer than this (#13332). -export const UNFRAMED_AGENT_INPUT_MAX_BYTES = 1024 +// Agents can split or keep only the last read of unframed input longer than a PTY read (#13332, #32071). +export const UNFRAMED_AGENT_INPUT_MAX_BYTES = 512 // Replace embedded ESC with printable ␛ (U+241B) so pasted framing bytes cannot close the frame and execute its tail. export function sanitizeBracketedPasteText(text: string): string {