2026-02-18 15:29:29 -06:00
|
|
|
import { useCallback, useRef, useState } from "react";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
|
|
|
|
|
interface CopyTextProps {
|
|
|
|
|
text: string;
|
|
|
|
|
/** What to display. Defaults to `text`. */
|
|
|
|
|
children?: React.ReactNode;
|
|
|
|
|
className?: string;
|
|
|
|
|
/** Tooltip message shown after copying. Default: "Copied!" */
|
|
|
|
|
copiedLabel?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function CopyText({ text, children, className, copiedLabel = "Copied!" }: CopyTextProps) {
|
|
|
|
|
const [visible, setVisible] = useState(false);
|
2026-03-02 16:44:03 -06:00
|
|
|
const [label, setLabel] = useState(copiedLabel);
|
UI: Identity component, LiveRunWidget, issue identifiers, and UX improvements
Add Identity component (avatar + name) used across agent/issue displays. Add
LiveRunWidget for real-time streaming of active heartbeat runs on issue detail
pages via WebSocket. Display issue identifiers (PAP-42) instead of UUID
fragments throughout Issues, Inbox, CommandPalette, and detail pages.
Enhance CommentThread with re-open checkbox, Cmd+Enter submit, sorted display,
and run linking. Improve Activity page with richer formatting and filtering.
Update Dashboard with live metrics. Add reports-to agent link in AgentProperties.
Various small fixes: StatusIcon centering, CopyText ref init, agent detail
run-issue cross-links.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 09:10:07 -06:00
|
|
|
const timerRef = useRef<ReturnType<typeof setTimeout>>(undefined);
|
2026-02-18 15:29:29 -06:00
|
|
|
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
|
|
|
|
2026-03-02 16:44:03 -06:00
|
|
|
const handleClick = useCallback(async () => {
|
|
|
|
|
try {
|
|
|
|
|
await navigator.clipboard.writeText(text);
|
|
|
|
|
setLabel(copiedLabel);
|
|
|
|
|
} catch {
|
|
|
|
|
setLabel("Copy failed");
|
|
|
|
|
}
|
2026-02-18 15:29:29 -06:00
|
|
|
clearTimeout(timerRef.current);
|
|
|
|
|
setVisible(true);
|
|
|
|
|
timerRef.current = setTimeout(() => setVisible(false), 1500);
|
2026-03-02 16:44:03 -06:00
|
|
|
}, [copiedLabel, text]);
|
2026-02-18 15:29:29 -06:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<span className="relative inline-flex">
|
|
|
|
|
<button
|
|
|
|
|
ref={triggerRef}
|
|
|
|
|
type="button"
|
|
|
|
|
className={cn(
|
|
|
|
|
"cursor-copy hover:text-foreground transition-colors",
|
|
|
|
|
className,
|
|
|
|
|
)}
|
|
|
|
|
onClick={handleClick}
|
|
|
|
|
>
|
|
|
|
|
{children ?? text}
|
|
|
|
|
</button>
|
|
|
|
|
<span
|
2026-03-02 16:44:03 -06:00
|
|
|
role="status"
|
|
|
|
|
aria-live="polite"
|
2026-02-18 15:29:29 -06:00
|
|
|
className={cn(
|
|
|
|
|
"pointer-events-none absolute left-1/2 -translate-x-1/2 bottom-full mb-1.5 rounded-md bg-foreground text-background px-2 py-1 text-xs whitespace-nowrap transition-opacity duration-300",
|
|
|
|
|
visible ? "opacity-100" : "opacity-0",
|
|
|
|
|
)}
|
|
|
|
|
>
|
2026-03-02 16:44:03 -06:00
|
|
|
{label}
|
2026-02-18 15:29:29 -06:00
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|