Skip to content

Commit ef6c1c6

Browse files
mrabbaniclaude
andauthored
feat: add copy button to Event Log for full untruncated entries (#68)
Save event values are truncated to 120 chars in the display. The copy button copies all entries with full JSON values to the clipboard. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3233426 commit ef6c1c6

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

src/components/settings/Settings.stories.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import type { Meta, StoryObj } from '@storybook/react';
3-
import React, { useRef, useState } from 'react';
4-
import { Save } from 'lucide-react';
3+
import React, { useRef, useState, useCallback } from 'react';
4+
import { Save, Copy, Check } from 'lucide-react';
55
import { Button } from '../ui/button';
66
import { Settings } from './index';
77
import type { SettingsElement, SettingsProps } from './settings-types';
@@ -23,12 +23,39 @@ type LogEntry = {
2323
};
2424

2525
function EventLog({ entries }: { entries: LogEntry[] }) {
26+
const [copied, setCopied] = useState(false);
27+
28+
const handleCopy = useCallback(() => {
29+
const text = entries
30+
.map((e) => {
31+
const base = `${e.time} ${e.type === 'save' ? 'onSave' : 'onChange'} pageId="${e.pageId}"`;
32+
if (e.type === 'change') return `${base} key="${e.key}" value=${JSON.stringify(e.value)}`;
33+
if (e.type === 'save') return `${base} values=${JSON.stringify(e.values, null, 2)}`;
34+
return base;
35+
})
36+
.join('\n');
37+
navigator.clipboard.writeText(text).then(() => {
38+
setCopied(true);
39+
setTimeout(() => setCopied(false), 2000);
40+
});
41+
}, [entries]);
42+
2643
if (entries.length === 0) return null;
2744
return (
2845
<div className="mt-4 rounded-lg border border-border bg-muted/40 max-h-64 overflow-y-auto">
2946
<div className="px-3 py-2 border-b border-border bg-muted/60 flex justify-between items-center">
3047
<span className="text-xs font-semibold text-foreground">Event Log</span>
31-
<span className="text-xs text-muted-foreground">{entries.length} events</span>
48+
<div className="flex items-center gap-2">
49+
<span className="text-xs text-muted-foreground">{entries.length} events</span>
50+
<button
51+
onClick={handleCopy}
52+
className="inline-flex items-center gap-1 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-foreground rounded transition-colors"
53+
title="Copy full log to clipboard"
54+
>
55+
{copied ? <Check className="w-3 h-3 text-green-600" /> : <Copy className="w-3 h-3" />}
56+
{copied ? 'Copied' : 'Copy'}
57+
</button>
58+
</div>
3259
</div>
3360
{entries.length > 0 ? (
3461
<div className="divide-y divide-border">

0 commit comments

Comments
 (0)