Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions apps/server/src/textGeneration/ThreadTitleLinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,23 @@ it.effect(
? Effect.sync(() => {
expect(cwd).toBe("/tmp/project");
calls.push(url.href);
return { title: "t".repeat(400), body: "b".repeat(2_000) };
// Change 1 puts an emoji across each limit; change 2 ends one inside it.
const pad = url.pathname.endsWith("/1") ? 0 : 1;
return {
title: `${"t".repeat(299 - pad)}πŸš€${"t".repeat(100)}`,
body: `${"b".repeat(1_199 - pad)}πŸš€${"b".repeat(800)}`,
};
})
: undefined,
}),
),
);
expect(calls).toEqual(["https://forge.test/change/1", "https://forge.test/change/2"]);
expect(result).toBe(
calls
.map(
(url) =>
`${url}\n${encodeSubject({ title: "t".repeat(300), body: "b".repeat(1_200) })}`,
)
.join("\n\n"),
[
`${calls[0]}\n${encodeSubject({ title: "t".repeat(299), body: "b".repeat(1_199) })}`,
`${calls[1]}\n${encodeSubject({ title: `${"t".repeat(298)}πŸš€`, body: `${"b".repeat(1_198)}πŸš€` })}`,
].join("\n\n"),
);
}),
);
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/textGeneration/ThreadTitleLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const resolveThreadTitleLinks = Effect.fn("resolveThreadTitleLinks")(func
lookup.pipe(
Effect.flatMap((subject) =>
encodeSubject({
title: subject.title.slice(0, 300),
body: subject.body?.slice(0, 1_200) ?? "",
title: subject.title.slice(0, 300).replace(/\p{Surrogate}$/u, ""),
body: subject.body?.slice(0, 1_200).replace(/\p{Surrogate}$/u, "") ?? "",
}),
),
Effect.map((summary) => `${url}\n${summary}`),
Expand Down
Loading