MCPcopy Index your code
hub / github.com/handsontable/handsontable / Thread

Function Thread

docs/src/components/DocsAssistant/Thread.tsx:20–161  ·  view source on GitHub ↗
({
  messages,
  streaming,
  error,
  composerRef,
  pendingDraft,
  onPendingDraftConsumed,
  onSend,
  onStop,
  onRetry,
  onFeedback,
}: Props)

Source from the content-addressed store, hash-verified

18}
19
20export function Thread({
21 messages,
22 streaming,
23 error,
24 composerRef,
25 pendingDraft,
26 onPendingDraftConsumed,
27 onSend,
28 onStop,
29 onRetry,
30 onFeedback,
31}: Props) {
32 const [draft, setDraft] = useState('');
33
34 useEffect(() => {
35 if (pendingDraft) {
36 setDraft(pendingDraft);
37 onPendingDraftConsumed?.();
38 setTimeout(() => composerRef.current?.focus(), 100);
39 }
40 }, [pendingDraft]);
41 const scrollRef = useRef<HTMLDivElement>(null);
42
43 useEffect(() => {
44 const el = scrollRef.current;
45 if (!el) return;
46 el.scrollTop = el.scrollHeight;
47 }, [messages, streaming]);
48
49 const submit = () => {
50 const text = draft.trim();
51 if (!text || streaming) return;
52 onSend(text);
53 setDraft('');
54 };
55
56 const onKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
57 if (e.key === 'Enter' && !e.shiftKey) {
58 e.preventDefault();
59 submit();
60 }
61 };
62
63 const lastAssistantId = [...messages].reverse().find((m) => m.role === 'assistant')?.id;
64 const empty = messages.length === 0;
65
66 return (
67 <div className="da-thread">
68 <div className="da-scroll" ref={scrollRef}>
69 {empty ? (
70 <div className="da-welcome">
71 <div className="da-welcome-hero">
72 <div className="da-welcome-text">
73 <h3>{WELCOME.headline}</h3>
74 <p>{WELCOME.sub}</p>
75 </div>
76 <IllustrationWelcome className="da-welcome-illustration" />
77 </div>

Callers

nothing calls this directly

Calls 5

submitFunction · 0.85
reverseMethod · 0.80
preventDefaultMethod · 0.80
focusMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…