fix(views): fold copy timestamps into full-body copy (merge #5873)

Reconcile #5873's "timestamps in copied events" (merged to main) with
this branch's full-body copy rewrite: traceEventCopyText now prefixes
each line with the RFC 3339 timestamp when created_at is valid, on top of
the complete (untruncated) body, events separated by a blank line. The
two #5873 copy tests are updated to the full-body format; the orphaned
formatEventForClipboard helper is removed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Naiyuan Qing
2026-07-24 16:04:43 +08:00
parent 145fd3c19a
commit 30a7fcc8ec
2 changed files with 10 additions and 5 deletions

View File

@@ -408,11 +408,13 @@ describe("AgentTranscriptDialog", () => {
fireEvent.click(screen.getByRole("button", { name: "Copy all" }));
// Full body (not the truncated summary) with the RFC 3339 prefix, events
// separated by a blank line.
expect(copyTextMock).toHaveBeenCalledWith(
[
"[2026-06-08T00:00:00.000Z] [Agent] Agent summary",
"[2026-06-08T00:00:00.000Z] [Agent] Agent summary\nAgent hidden detail",
"[2026-06-08T08:00:05.123Z] [Thinking] Thinking summary",
].join("\n"),
].join("\n\n"),
);
});
@@ -434,7 +436,7 @@ describe("AgentTranscriptDialog", () => {
fireEvent.click(screen.getByRole("button", { name: "Copy all" }));
expect(copyTextMock).toHaveBeenCalledWith(
["[Agent] Missing timestamp", "[Error] Invalid timestamp"].join("\n"),
["[Agent] Missing timestamp", "[Error] Invalid timestamp"].join("\n\n"),
);
});
});

View File

@@ -147,7 +147,8 @@ export function traceEventSummary(event: TraceEvent): string {
/**
* Full, untruncated text for "copy all" — the complete body, not the one-line
* summary. Tool calls copy their full input JSON; results and prose copy their
* whole content. Callers apply secret redaction on the result.
* whole content. An RFC 3339 timestamp prefixes the line when the event has a
* valid `created_at` (#5873). Callers apply secret redaction on the result.
*/
export function traceEventCopyText(event: TraceEvent): string {
const label = traceEventLabel(event);
@@ -162,7 +163,9 @@ export function traceEventCopyText(event: TraceEvent): string {
default:
body = event.content ?? "";
}
return body ? `[${label}] ${body}` : `[${label}]`;
const date = event.created_at ? new Date(event.created_at) : null;
const timestamp = date && !Number.isNaN(date.getTime()) ? `[${date.toISOString()}] ` : "";
return body ? `${timestamp}[${label}] ${body}` : `${timestamp}[${label}]`;
}
export function traceEventHasDetail(event: TraceEvent): boolean {