Skip to content

Commit b9e92b9

Browse files
committed
test(gateway): cover chat display UTF-16 boundary
1 parent aaa9858 commit b9e92b9

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

src/gateway/server-methods/server-methods.test.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ describe("waitForAgentJob", () => {
660660
expect(agentJobTesting.getAgentRunCacheSize()).toBe(max);
661661
agentJobTesting.resetAgentRunCache();
662662
});
663-
664663
});
665664

666665
describe("augmentChatHistoryWithCanvasBlocks", () => {
@@ -824,6 +823,28 @@ describe("injectTimestamp", () => {
824823
});
825824

826825
describe("sanitizeChatHistoryMessages", () => {
826+
it("truncates display text without splitting surrogate pairs", () => {
827+
const prefix = "a".repeat(7);
828+
const result = sanitizeChatHistoryMessages(
829+
[
830+
{
831+
role: "assistant",
832+
content: [{ type: "text", text: `${prefix}😀tail` }],
833+
timestamp: 1,
834+
},
835+
],
836+
8,
837+
);
838+
839+
expect(result).toEqual([
840+
{
841+
role: "assistant",
842+
content: [{ type: "text", text: `${prefix}\n...(truncated)...` }],
843+
timestamp: 1,
844+
},
845+
]);
846+
});
847+
827848
it("redacts base64 audio content blocks from chat history", () => {
828849
const data = Buffer.from("voice-bytes").toString("base64");
829850
const result = sanitizeChatHistoryMessages([

0 commit comments

Comments
 (0)