feat: mark each speaker with a role icon in the transcript (#5)

This commit was merged in pull request #5.
This commit is contained in:
2026-10-03 21:03:26 +00:00
parent 31eb688455
commit d448a4377b
3 changed files with 30 additions and 2 deletions
+14
View File
@@ -1,6 +1,8 @@
import { describe, expect, it } from "vitest";
import {
ASSISTANT_MARKER,
STREAMING_CURSOR,
USER_MARKER,
buildThreadMarkdown,
previewText,
quote,
@@ -44,6 +46,18 @@ describe("buildThreadMarkdown", () => {
expect(markdown).toContain("4");
});
it("marks each speaker with a role icon", () => {
const markdown = buildThreadMarkdown([
message({ role: "user", text: "q" }),
message({ role: "assistant", text: "a" }),
]);
expect(markdown).toContain(USER_MARKER);
expect(markdown).toContain(ASSISTANT_MARKER);
// The user marker must not leak onto the answer or vice versa.
expect(markdown.indexOf(USER_MARKER)).toBeLessThan(markdown.indexOf(ASSISTANT_MARKER));
});
it("keeps the conversation in order", () => {
const markdown = buildThreadMarkdown([
message({ id: "a", role: "user", text: "first" }),