Replay your coding agent sessions as a map and a timeline
Python agent-observabilityai-agentsclaudeclaude-codecodexcoding-agentscursordeveloper-toolsdevtoolsgithub-copilotkirollmobservabilityopencodeprivacypythonsession-replaytypescriptvisualization
feat(viewer): add copy link button to explorer toolbar
OMEE-Y3f26ed9e50a0
diff --git a/viewer/src/explorer/ExplorerToolbar.test.tsx b/viewer/src/explorer/ExplorerToolbar.test.tsxindex 2b7e31e..f3eefd3 100644--- a/viewer/src/explorer/ExplorerToolbar.test.tsx+++ b/viewer/src/explorer/ExplorerToolbar.test.tsx@@ -1,6 +1,6 @@import { act } from 'react';import { createRoot, type Root } from 'react-dom/client';-import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest';+import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';import type { ModelUsage } from '@/core/sessionScope';import { ExplorerToolbar } from './ExplorerToolbar';@@ -34,8 +34,8 @@ afterEach(() => {});function renderToolbar(- model: string | null,- onModel: (model: string | null) => void+ model: string | null = null,+ onModel: (model: string | null) => void = () => {}) {const host = document.body.appendChild(document.createElement('div'));root = createRoot(host);@@ -92,3 +92,44 @@ describe('ModelPicker', () => {expect(onModel).toHaveBeenCalledExactlyOnceWith('claude-sonnet-4-5');});});++describe('CopyLinkButton', () => {+ beforeEach(() => {+ vi.useFakeTimers();+ });++ afterEach(() => {+ vi.useRealTimers();+ });++ it('copies window.location.href to clipboard and shows brief Copied confirmation', async () => {+ const writeText = vi.fn().mockResolvedValue(undefined);+ Object.assign(navigator, {+ clipboard: { writeText },+ });++ renderToolbar();++ const copyBtn = document.querySelector<HTMLButtonElement>(+ 'button[aria-label="Copy link to current view"]'+ )!;+ expect(copyBtn).toBeTruthy();+ expect(copyBtn.textContent).toContain('Copy link');++ await act(async () => {+ copyBtn.click();+ });++ expect(writeText).toHaveBeenCalledExactlyOnceWith(window.location.href);+ expect(copyBtn.textContent).toContain('Copied');+ expect(copyBtn.getAttribute('aria-label')).toBe('Link copied');++ // Advance 2s timer to ensure it resets back to "Copy link"+ act(() => {+ vi.advanceTimersByTime(2000);+ });++ expect(copyBtn.textContent).toContain('Copy link');+ expect(copyBtn.getAttribute('aria-label')).toBe('Copy link to current view');+ });+});\ No newline at end of filediff --git a/viewer/src/explorer/ExplorerToolbar.tsx b/viewer/src/explorer/ExplorerToolbar.tsxindex 433f5ea..c9ef8ba 100644--- a/viewer/src/explorer/ExplorerToolbar.tsx+++ b/viewer/src/explorer/ExplorerToolbar.tsx@@ -1,5 +1,5 @@-import { useRef, useState, type ReactNode, type RefObject } from 'react';-import { CaretDown, Check } from '@phosphor-icons/react';+import { useEffect, useRef, useState, type ReactNode, type RefObject } from 'react';+import { CaretDown, Check, Link } from '@phosphor-icons/react';import { Button } from '@/components/ui/button';import {Command,@@ -67,10 +67,62 @@ export function ExplorerToolbar(props: Props) {Clear filters</Button>) : null}+ <CopyLinkButton /></div>);}+/** A local button that copies the current viewer URL to clipboard. */+function CopyLinkButton() {+ const [copied, setCopied] = useState(false);+ const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);++ useEffect(() => {+ return () => {+ if (timerRef.current) clearTimeout(timerRef.current);+ };+ }, []);++ const handleCopy = async () => {+ try {+ await navigator.clipboard.writeText(window.location.href);+ setCopied(true);+ if (timerRef.current) clearTimeout(timerRef.current);+ timerRef.current = setTimeout(() => {+ setCopied(false);+ }, 2000);+ } catch {+ // Fallback or ignore clipboard errors quietly in non-secure contexts+ }+ };++ return (+ <Button+ variant="outline"+ size="sm"+ onClick={handleCopy}+ aria-label={copied ? 'Link copied' : 'Copy link to current view'}+ aria-live="polite"+ className={cn(+ 'h-7 gap-1.5 px-2.5 font-normal text-ds-text-darker transition-colors',+ copied && 'border-ds-brand-subtler bg-ds-brand-lightest text-ds-brand-default'+ )}+ >+ {copied ? (+ <>+ <Check size={12} aria-hidden className="shrink-0" />+ <span>Copied</span>+ </>+ ) : (+ <>+ <Link size={12} aria-hidden className="shrink-0 text-ds-text-subtle" />+ <span>Copy link</span>+ </>+ )}+ </Button>+ );+}+/** The trigger's "Label: value ▾" contents. */function TriggerLabel({label,@@ -294,4 +346,4 @@ function ModelPicker({ models, model, onModel }: Props) {)}</Picker>);-}+}\ No newline at end of file