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:
+12
-2
@@ -14,6 +14,16 @@ import type { ChatTurn, ThreadMessage } from "./types";
|
||||
|
||||
export const STREAMING_CURSOR = "▍";
|
||||
|
||||
/**
|
||||
* Role markers for the transcript.
|
||||
*
|
||||
* Emoji rather than icon images: Vicinae's markdown renderer is minimal and
|
||||
* there is no reliable way to inline an `icon://` reference into markdown, but
|
||||
* plain text always renders.
|
||||
*/
|
||||
export const USER_MARKER = "👤";
|
||||
export const ASSISTANT_MARKER = "✨";
|
||||
|
||||
/** Prefixes every line so a multi-line message stays one continuous quote block. */
|
||||
export function quote(text: string): string {
|
||||
return text
|
||||
@@ -31,11 +41,11 @@ export function previewText(text: string, max: number): string {
|
||||
|
||||
function renderMessage(message: ThreadMessage): string {
|
||||
if (message.role === "user") {
|
||||
return `**You**\n\n${quote(message.text)}`;
|
||||
return `${USER_MARKER} **You**\n\n${quote(message.text)}`;
|
||||
}
|
||||
|
||||
const body = message.text.trim() || (message.isStreaming ? "_Thinking…_" : "_No response._");
|
||||
const sections = ["**Lam**", "", message.isStreaming ? `${body} ${STREAMING_CURSOR}` : body];
|
||||
const sections = [`${ASSISTANT_MARKER} **Lam**`, "", message.isStreaming ? `${body} ${STREAMING_CURSOR}` : body];
|
||||
|
||||
if (message.error) {
|
||||
sections.push("", `**Error** — ${message.error}`);
|
||||
|
||||
Reference in New Issue
Block a user