Render transcript markdown and fold command stdout
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
60
ui/src/components/transcript/RunTranscriptView.test.tsx
Normal file
60
ui/src/components/transcript/RunTranscriptView.test.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
// @vitest-environment node
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import type { TranscriptEntry } from "../../adapters";
|
||||
import { ThemeProvider } from "../../context/ThemeContext";
|
||||
import { RunTranscriptView, normalizeTranscript } from "./RunTranscriptView";
|
||||
|
||||
describe("RunTranscriptView", () => {
|
||||
it("keeps running command stdout inside the command fold instead of a standalone stdout block", () => {
|
||||
const entries: TranscriptEntry[] = [
|
||||
{
|
||||
kind: "tool_call",
|
||||
ts: "2026-03-12T00:00:00.000Z",
|
||||
name: "command_execution",
|
||||
toolUseId: "cmd_1",
|
||||
input: { command: "ls -la" },
|
||||
},
|
||||
{
|
||||
kind: "stdout",
|
||||
ts: "2026-03-12T00:00:01.000Z",
|
||||
text: "file-a\nfile-b",
|
||||
},
|
||||
];
|
||||
|
||||
const blocks = normalizeTranscript(entries, false);
|
||||
|
||||
expect(blocks).toHaveLength(1);
|
||||
expect(blocks[0]).toMatchObject({
|
||||
type: "command_group",
|
||||
items: [{ result: "file-a\nfile-b", status: "running" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("renders assistant and thinking content as markdown in compact mode", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<ThemeProvider>
|
||||
<RunTranscriptView
|
||||
density="compact"
|
||||
entries={[
|
||||
{
|
||||
kind: "assistant",
|
||||
ts: "2026-03-12T00:00:00.000Z",
|
||||
text: "Hello **world**",
|
||||
},
|
||||
{
|
||||
kind: "thinking",
|
||||
ts: "2026-03-12T00:00:01.000Z",
|
||||
text: "- first\n- second",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
expect(html).toContain("<strong>world</strong>");
|
||||
expect(html).toContain("<li>first</li>");
|
||||
expect(html).toContain("<li>second</li>");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user