feat: display toggles, smart session resume, fix stale transcript pane (#8)

This commit was merged in pull request #8.
This commit is contained in:
2026-10-03 21:22:04 +00:00
parent ffe2c6b7ed
commit ee96f1ee61
8 changed files with 304 additions and 73 deletions
+16 -5
View File
@@ -28,6 +28,14 @@ export const STREAMING_CURSOR = "▍";
export const USER_LABEL = "You";
export const ASSISTANT_LABEL = "Lam";
/** Which optional sections the transcript includes. Driven by preferences. */
export interface TranscriptOptions {
showToolCalls: boolean;
showReasoning: boolean;
}
const SHOW_EVERYTHING: TranscriptOptions = { showToolCalls: true, showReasoning: true };
/** Prefixes every line so a multi-line message stays one continuous quote block. */
export function quote(text: string): string {
return text
@@ -36,7 +44,7 @@ export function quote(text: string): string {
.join("\n");
}
function renderMessage(message: ThreadMessage): string {
function renderMessage(message: ThreadMessage, options: TranscriptOptions): string {
if (message.role === "user") {
return `**${USER_LABEL}**\n\n${quote(message.text)}`;
}
@@ -51,14 +59,14 @@ function renderMessage(message: ThreadMessage): string {
sections.push("", `**Error** — ${message.error}`);
}
if (message.toolCalls.length > 0) {
if (options.showToolCalls && message.toolCalls.length > 0) {
const lines = message.toolCalls.map(
(call) => `- \`${call.name}\`${call.isError ? " — failed" : ""}`,
);
sections.push("", "**Tools used**", ...lines);
}
if (message.thinking.trim().length > 0) {
if (options.showReasoning && message.thinking.trim().length > 0) {
sections.push("", "_Reasoning_", "", quote(message.thinking.trim()));
}
@@ -79,7 +87,10 @@ function renderMessage(message: ThreadMessage): string {
* separates one exchange from the next rather than dividing every single
* message.
*/
export function buildThreadMarkdown(messages: ThreadMessage[]): string {
export function buildThreadMarkdown(
messages: ThreadMessage[],
options: TranscriptOptions = SHOW_EVERYTHING,
): string {
if (messages.length === 0) return "";
const blocks: string[] = [];
@@ -98,7 +109,7 @@ export function buildThreadMarkdown(messages: ThreadMessage[]): string {
flush();
currentTurn = turnId;
}
buffer.push(renderMessage(message));
buffer.push(renderMessage(message, options));
}
flush();