Skip to content

Commit 6c55764

Browse files
committed
test(gateway): cover UTF-16 tail cap through merge path
1 parent e60d356 commit 6c55764

3 files changed

Lines changed: 12 additions & 30 deletions

File tree

src/gateway/live-chat-projector.test.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/gateway/live-chat-projector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function resolveAssistantLiveChatInput(
3333
};
3434
}
3535

36-
export function capLiveAssistantBuffer(text: string): string {
36+
function capLiveAssistantBuffer(text: string): string {
3737
if (text.length <= MAX_LIVE_CHAT_BUFFER_CHARS) {
3838
return text;
3939
}

src/gateway/server-chat.stream-text-merge.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,15 @@ describe("server chat stream text merge", () => {
9393
expect(result).toHaveLength(MAX_LIVE_CHAT_BUFFER_CHARS);
9494
expect(result.endsWith("bbbb")).toBe(true);
9595
});
96+
97+
it("does not start the capped tail with the low half of a surrogate pair", () => {
98+
const safeTail = "y".repeat(MAX_LIVE_CHAT_BUFFER_CHARS - 1);
99+
const result = resolveMergedAssistantText({
100+
previousText: "",
101+
nextText: `x🚀${safeTail}`,
102+
nextDelta: "",
103+
});
104+
105+
expect(result).toBe(safeTail);
106+
});
96107
});

0 commit comments

Comments
 (0)