Files
breakpilot-compliance/admin-compliance/components/sdk/advisor/useClipboard.ts
T
Benjamin Admin e8ea179228 feat(advisor): topic threads, per-question delete/copy, fullscreen
Adds case management to the Compliance Advisor widget.

- topic threads: cases group into threads; the left menu shows each
  thread's first question as the Thema with expandable follow-ups.
  Send = follow-up to the active thread (carries the thread's prior Q&A
  as history for contextual answers); "+" starts a new topic.
- delete: a trash action per question (menu + stacked view).
- copy: single Q&A (question + answer + evidence + footnotes) or a whole
  thread, as Markdown to the clipboard (pure formatters in copy.ts).
- fullscreen: compact -> panel -> fullscreen view.
- route.ts consumes an optional bounded `history` so follow-ups are
  contextual for both the widget and the workspace consumer.

Tests: copy formatter unit tests + Playwright specs (threads/new-topic,
delete, fullscreen, copy affordance). No deploy.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-01 18:51:17 +02:00

20 lines
554 B
TypeScript

'use client'
import { useCallback, useState } from 'react'
/** Writes text to the clipboard and flags the copied key briefly (for a check-mark affordance). */
export function useClipboard(resetMs = 1500) {
const [copiedKey, setCopiedKey] = useState<string | null>(null)
const copy = useCallback(
(key: string, text: string) => {
void navigator.clipboard?.writeText(text)
setCopiedKey(key)
window.setTimeout(() => setCopiedKey((k) => (k === key ? null : k)), resetMs)
},
[resetMs],
)
return { copiedKey, copy }
}