TypeScript · 863 bytes Raw Blame History
1 import { useState } from "react";
2 import { TextBlock } from "./TextBlock";
3
4 export function ThinkingBlock({ text }: { text: string }) {
5 const [expanded, setExpanded] = useState(false);
6 if (!text.trim()) return null;
7 return (
8 <div className="my-2 overflow-hidden rounded border border-border/60 bg-bg-1/60">
9 <button
10 type="button"
11 onClick={() => setExpanded((x) => !x)}
12 className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-fg-3 transition hover:bg-bg-2"
13 >
14 <span>💭</span>
15 <span>thinking</span>
16 <span className="ml-auto text-[10px]">
17 {expanded ? "hide" : "show"}
18 </span>
19 </button>
20 {expanded && (
21 <div className="border-t border-border/60 px-3 py-2">
22 <TextBlock text={text} />
23 </div>
24 )}
25 </div>
26 );
27 }