mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-28 20:21:50 +01:00
Add raw transcript timestamp tooltips
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
89b94da25b
commit
d72b693fd6
2 files changed
+39
-3
No files matched your search
@@ -1,6 +1,6 @@
|
||||
// @vitest-environment node
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import type { TranscriptEntry } from "../../adapters";
|
||||
import { ThemeProvider } from "../../context/ThemeContext";
|
||||
@@ -110,4 +110,31 @@ describe("RunTranscriptView", () => {
|
||||
expect(html).toMatch(/<li[^>]*>posted issue update<\/li>/);
|
||||
expect(html).not.toContain("result");
|
||||
});
|
||||
|
||||
it("adds timestamp and age tooltip to raw mode labels", () => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-03-12T00:03:00.000Z"));
|
||||
try {
|
||||
const html = renderToStaticMarkup(
|
||||
<ThemeProvider>
|
||||
<RunTranscriptView
|
||||
mode="raw"
|
||||
entries={[
|
||||
{
|
||||
kind: "stdout",
|
||||
ts: "2026-03-12T00:00:00.000Z",
|
||||
text: "hello",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
expect(html).toContain("Timestamp:");
|
||||
expect(html).toContain("Ago: 3m ago");
|
||||
expect(html).toContain(">stdout</span>");
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import type { TranscriptEntry } from "../../adapters";
|
||||
import { MarkdownBody } from "../MarkdownBody";
|
||||
import { cn, formatTokens } from "../../lib/utils";
|
||||
import { timeAgo } from "../../lib/timeAgo";
|
||||
import { cn, formatDateTime, formatTokens } from "../../lib/utils";
|
||||
import {
|
||||
Check,
|
||||
ChevronDown,
|
||||
@@ -136,6 +137,11 @@ function truncate(value: string, max: number): string {
|
||||
return value.length > max ? `${value.slice(0, Math.max(0, max - 1))}…` : value;
|
||||
}
|
||||
|
||||
function formatRawEntryTimestampTooltip(ts: string): string {
|
||||
if (Number.isNaN(new Date(ts).getTime())) return ts;
|
||||
return `Timestamp: ${formatDateTime(ts)}; Ago: ${timeAgo(ts)}`;
|
||||
}
|
||||
|
||||
function humanizeLabel(value: string): string {
|
||||
return value
|
||||
.replace(/[_-]+/g, " ")
|
||||
@@ -1365,7 +1371,10 @@ function RawTranscriptView({
|
||||
"grid-cols-[auto_1fr]",
|
||||
)}
|
||||
>
|
||||
<span className="text-[10px] uppercase tracking-[0.18em] text-muted-foreground">
|
||||
<span
|
||||
className="text-[10px] uppercase tracking-[0.18em] text-muted-foreground"
|
||||
title={formatRawEntryTimestampTooltip(entry.ts)}
|
||||
>
|
||||
{entry.kind}
|
||||
</span>
|
||||
<pre className="min-w-0 whitespace-pre-wrap break-words text-foreground/80">
|
||||
|
||||
Reference in new issue
Block a user