Spaces:
Sleeping
Sleeping
Thinking expander
Browse files- web/src/App.css +66 -0
- web/src/App.tsx +81 -69
web/src/App.css
CHANGED
|
@@ -1135,4 +1135,70 @@ details.tool-section[open] summary::before {
|
|
| 1135 |
|
| 1136 |
.logout-btn:active {
|
| 1137 |
transform: scale(0.98);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1138 |
}
|
|
|
|
| 1135 |
|
| 1136 |
.logout-btn:active {
|
| 1137 |
transform: scale(0.98);
|
| 1138 |
+
}
|
| 1139 |
+
|
| 1140 |
+
/* Thinking Expander Styles */
|
| 1141 |
+
.thinking-expander {
|
| 1142 |
+
margin: 0.75rem 0;
|
| 1143 |
+
background: #211d1a;
|
| 1144 |
+
border: 1px solid #3a342e;
|
| 1145 |
+
border-radius: 8px;
|
| 1146 |
+
overflow: hidden;
|
| 1147 |
+
}
|
| 1148 |
+
|
| 1149 |
+
.thinking-header {
|
| 1150 |
+
cursor: pointer;
|
| 1151 |
+
padding: 0.875rem 1rem;
|
| 1152 |
+
background: #2a2520;
|
| 1153 |
+
display: flex;
|
| 1154 |
+
align-items: center;
|
| 1155 |
+
gap: 0.75rem;
|
| 1156 |
+
transition: background 0.2s ease;
|
| 1157 |
+
list-style: none;
|
| 1158 |
+
user-select: none;
|
| 1159 |
+
}
|
| 1160 |
+
|
| 1161 |
+
.thinking-header:hover {
|
| 1162 |
+
background: #312c27;
|
| 1163 |
+
}
|
| 1164 |
+
|
| 1165 |
+
.thinking-header::-webkit-details-marker {
|
| 1166 |
+
display: none;
|
| 1167 |
+
}
|
| 1168 |
+
|
| 1169 |
+
.thinking-spinner {
|
| 1170 |
+
width: 16px;
|
| 1171 |
+
height: 16px;
|
| 1172 |
+
border: 2px solid #3a342e;
|
| 1173 |
+
border-top-color: #8b7355;
|
| 1174 |
+
border-radius: 50%;
|
| 1175 |
+
animation: spin 1s linear infinite;
|
| 1176 |
+
flex-shrink: 0;
|
| 1177 |
+
}
|
| 1178 |
+
|
| 1179 |
+
@keyframes spin {
|
| 1180 |
+
to {
|
| 1181 |
+
transform: rotate(360deg);
|
| 1182 |
+
}
|
| 1183 |
+
}
|
| 1184 |
+
|
| 1185 |
+
.thinking-label {
|
| 1186 |
+
color: #c9b8a3;
|
| 1187 |
+
font-weight: 600;
|
| 1188 |
+
font-size: 0.95rem;
|
| 1189 |
+
letter-spacing: 0.5px;
|
| 1190 |
+
}
|
| 1191 |
+
|
| 1192 |
+
.thinking-content {
|
| 1193 |
+
padding: 0;
|
| 1194 |
+
}
|
| 1195 |
+
|
| 1196 |
+
.thinking-expander[open] .thinking-spinner {
|
| 1197 |
+
animation: spin 1s linear infinite;
|
| 1198 |
+
}
|
| 1199 |
+
|
| 1200 |
+
/* When thinking is complete (has final content), stop spinner */
|
| 1201 |
+
.thinking-expander:not([open]) .thinking-spinner {
|
| 1202 |
+
border-top-color: #6e5d4d;
|
| 1203 |
+
animation: none;
|
| 1204 |
}
|
web/src/App.tsx
CHANGED
|
@@ -654,77 +654,89 @@ function App() {
|
|
| 654 |
</span>
|
| 655 |
</div>
|
| 656 |
</div>
|
| 657 |
-
|
| 658 |
-
<ReactMarkdown
|
| 659 |
-
remarkPlugins={[remarkMath, remarkGfm]}
|
| 660 |
-
rehypePlugins={[rehypeKatex]}
|
| 661 |
-
components={{
|
| 662 |
-
code({ className, children, ...props }: any) {
|
| 663 |
-
const match = /language-(\w+)/.exec(className || '');
|
| 664 |
-
return match ? (
|
| 665 |
-
<SyntaxHighlighter
|
| 666 |
-
style={terminalTheme as any}
|
| 667 |
-
language={match[1]}
|
| 668 |
-
PreTag="div"
|
| 669 |
-
{...props}
|
| 670 |
-
>
|
| 671 |
-
{String(children).replace(/\n$/, '')}
|
| 672 |
-
</SyntaxHighlighter>
|
| 673 |
-
) : (
|
| 674 |
-
<code className={className} {...props}>
|
| 675 |
-
{children}
|
| 676 |
-
</code>
|
| 677 |
-
);
|
| 678 |
-
},
|
| 679 |
-
}}
|
| 680 |
-
>
|
| 681 |
-
{preprocessMath(message.content)}
|
| 682 |
-
</ReactMarkdown>
|
| 683 |
-
</div>
|
| 684 |
{message.toolCalls && message.toolCalls.length > 0 && (
|
| 685 |
-
<
|
| 686 |
-
|
| 687 |
-
<
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
<span className="
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
<div className="tool-
|
| 721 |
-
<
|
| 722 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
</div>
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
</
|
| 727 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 728 |
</div>
|
| 729 |
)}
|
| 730 |
</div>
|
|
|
|
| 654 |
</span>
|
| 655 |
</div>
|
| 656 |
</div>
|
| 657 |
+
{/* Thinking expander - only show if there are tool calls */}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 658 |
{message.toolCalls && message.toolCalls.length > 0 && (
|
| 659 |
+
<details className="thinking-expander" open={!message.content || message.toolCalls.some(t => t.isGenerating || t.isExecuting)}>
|
| 660 |
+
<summary className="thinking-header">
|
| 661 |
+
<div className="thinking-spinner"></div>
|
| 662 |
+
<span className="thinking-label">Thinking...</span>
|
| 663 |
+
</summary>
|
| 664 |
+
<div className="thinking-content">
|
| 665 |
+
<div className="tool-calls">
|
| 666 |
+
{message.toolCalls.map((tool, idx) => (
|
| 667 |
+
<details key={idx} className="tool-call">
|
| 668 |
+
<summary className="tool-call-header">
|
| 669 |
+
<span className="tool-name">{tool.name}</span>
|
| 670 |
+
{tool.isGenerating && (
|
| 671 |
+
<span className="tool-status generating">
|
| 672 |
+
<span className="dot"></span>
|
| 673 |
+
<span className="dot"></span>
|
| 674 |
+
<span className="dot"></span>
|
| 675 |
+
<span className="status-text">Generating...</span>
|
| 676 |
+
</span>
|
| 677 |
+
)}
|
| 678 |
+
{tool.isExecuting && (
|
| 679 |
+
<span className="tool-status executing">
|
| 680 |
+
<span className="dot"></span>
|
| 681 |
+
<span className="dot"></span>
|
| 682 |
+
<span className="dot"></span>
|
| 683 |
+
<span className="status-text">Executing...</span>
|
| 684 |
+
</span>
|
| 685 |
+
)}
|
| 686 |
+
{tool.output && !tool.isGenerating && !tool.isExecuting && (
|
| 687 |
+
tool.error ? (
|
| 688 |
+
<span className="crossmark">✗</span>
|
| 689 |
+
) : (
|
| 690 |
+
<span className="checkmark">✓</span>
|
| 691 |
+
)
|
| 692 |
+
)}
|
| 693 |
+
</summary>
|
| 694 |
+
<div className="tool-call-content">
|
| 695 |
+
<details className="tool-section">
|
| 696 |
+
<summary className="tool-section-label">Input:</summary>
|
| 697 |
+
<pre className="tool-code tool-input-scroll">{tool.input}</pre>
|
| 698 |
+
</details>
|
| 699 |
+
{tool.output && (
|
| 700 |
+
<div className="tool-section">
|
| 701 |
+
<div className="tool-section-label">Output:</div>
|
| 702 |
+
<pre className="tool-output">{tool.output}</pre>
|
| 703 |
+
</div>
|
| 704 |
+
)}
|
| 705 |
</div>
|
| 706 |
+
</details>
|
| 707 |
+
))}
|
| 708 |
+
</div>
|
| 709 |
+
</div>
|
| 710 |
+
</details>
|
| 711 |
+
)}
|
| 712 |
+
{/* Final response content - shown after thinking */}
|
| 713 |
+
{message.content && (
|
| 714 |
+
<div className="message-content">
|
| 715 |
+
<ReactMarkdown
|
| 716 |
+
remarkPlugins={[remarkMath, remarkGfm]}
|
| 717 |
+
rehypePlugins={[rehypeKatex]}
|
| 718 |
+
components={{
|
| 719 |
+
code({ className, children, ...props }: any) {
|
| 720 |
+
const match = /language-(\w+)/.exec(className || '');
|
| 721 |
+
return match ? (
|
| 722 |
+
<SyntaxHighlighter
|
| 723 |
+
style={terminalTheme as any}
|
| 724 |
+
language={match[1]}
|
| 725 |
+
PreTag="div"
|
| 726 |
+
{...props}
|
| 727 |
+
>
|
| 728 |
+
{String(children).replace(/\n$/, '')}
|
| 729 |
+
</SyntaxHighlighter>
|
| 730 |
+
) : (
|
| 731 |
+
<code className={className} {...props}>
|
| 732 |
+
{children}
|
| 733 |
+
</code>
|
| 734 |
+
);
|
| 735 |
+
},
|
| 736 |
+
}}
|
| 737 |
+
>
|
| 738 |
+
{preprocessMath(message.content)}
|
| 739 |
+
</ReactMarkdown>
|
| 740 |
</div>
|
| 741 |
)}
|
| 742 |
</div>
|