Spaces:
Sleeping
Sleeping
all three status messages ("Thinking...", "Generating...", "Validating...") will appear in the same
Browse files- src/App.js +16 -11
src/App.js
CHANGED
|
@@ -78,6 +78,7 @@ function App() {
|
|
| 78 |
return `sid-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
| 79 |
}, [sessionTrigger]);
|
| 80 |
const [loading, setLoading] = useState(false);
|
|
|
|
| 81 |
const [error, setError] = useState(null);
|
| 82 |
|
| 83 |
// ---------------------------
|
|
@@ -516,7 +517,10 @@ function App() {
|
|
| 516 |
sessionId
|
| 517 |
);
|
| 518 |
|
| 519 |
-
// After streaming completes,
|
|
|
|
|
|
|
|
|
|
| 520 |
try {
|
| 521 |
const debugResult = await sendChat(userMsg.text, strictMode, historyForBackend, token, sessionId);
|
| 522 |
if (debugResult.prolog_query_info) {
|
|
@@ -546,6 +550,7 @@ function App() {
|
|
| 546 |
assistantMsg.text += `\n[Error: ${err.message}]`;
|
| 547 |
setMessages([...newMessages]);
|
| 548 |
} finally {
|
|
|
|
| 549 |
setLoading(false);
|
| 550 |
}
|
| 551 |
}
|
|
@@ -751,7 +756,13 @@ function App() {
|
|
| 751 |
{loading && (() => {
|
| 752 |
const lastMsg = messages[messages.length - 1];
|
| 753 |
const isStillThinking = lastMsg && lastMsg.role === 'assistant' && lastMsg.thinking;
|
| 754 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 755 |
<div style={{
|
| 756 |
display: 'flex',
|
| 757 |
alignItems: 'center',
|
|
@@ -763,9 +774,9 @@ function App() {
|
|
| 763 |
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ animation: "spin 1s linear infinite" }}>
|
| 764 |
<path d="M21 12a9 9 0 1 1-6.219-8.56"/>
|
| 765 |
</svg>
|
| 766 |
-
<span>
|
| 767 |
</div>
|
| 768 |
-
)
|
| 769 |
})()}
|
| 770 |
</form>
|
| 771 |
</main>
|
|
@@ -990,15 +1001,10 @@ function Message({ message }) {
|
|
| 990 |
.replace(/```/g, "")
|
| 991 |
.trim();
|
| 992 |
}, []);
|
| 993 |
-
const isThinking = !isUser && message.thinking && (!message.text || !message.text.trim());
|
| 994 |
-
|
| 995 |
const displayText = React.useMemo(() => {
|
| 996 |
const raw = typeof message.text === "string" ? message.text : "";
|
| 997 |
-
if (isThinking) {
|
| 998 |
-
return "Thinking...";
|
| 999 |
-
}
|
| 1000 |
return raw;
|
| 1001 |
-
}, [message.text
|
| 1002 |
|
| 1003 |
const normalizedText = React.useMemo(
|
| 1004 |
() => normalizeLatex(displayText),
|
|
@@ -1008,7 +1014,6 @@ function Message({ message }) {
|
|
| 1008 |
return (
|
| 1009 |
<div className={`message ${isUser ? "user" : "assistant"}`}>
|
| 1010 |
<div className="bubble">
|
| 1011 |
-
{isThinking && <span className="thinking-spinner"></span>}
|
| 1012 |
<ReactMarkdown
|
| 1013 |
className="markdown-body"
|
| 1014 |
remarkPlugins={[remarkMath, remarkGfm]}
|
|
|
|
| 78 |
return `sid-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
| 79 |
}, [sessionTrigger]);
|
| 80 |
const [loading, setLoading] = useState(false);
|
| 81 |
+
const [isValidating, setIsValidating] = useState(false);
|
| 82 |
const [error, setError] = useState(null);
|
| 83 |
|
| 84 |
// ---------------------------
|
|
|
|
| 517 |
sessionId
|
| 518 |
);
|
| 519 |
|
| 520 |
+
// After streaming completes, switch to validation phase
|
| 521 |
+
setIsValidating(true);
|
| 522 |
+
|
| 523 |
+
// Fetch debug info via non-streaming endpoint
|
| 524 |
try {
|
| 525 |
const debugResult = await sendChat(userMsg.text, strictMode, historyForBackend, token, sessionId);
|
| 526 |
if (debugResult.prolog_query_info) {
|
|
|
|
| 550 |
assistantMsg.text += `\n[Error: ${err.message}]`;
|
| 551 |
setMessages([...newMessages]);
|
| 552 |
} finally {
|
| 553 |
+
setIsValidating(false);
|
| 554 |
setLoading(false);
|
| 555 |
}
|
| 556 |
}
|
|
|
|
| 756 |
{loading && (() => {
|
| 757 |
const lastMsg = messages[messages.length - 1];
|
| 758 |
const isStillThinking = lastMsg && lastMsg.role === 'assistant' && lastMsg.thinking;
|
| 759 |
+
let statusText = 'Generating...';
|
| 760 |
+
if (isStillThinking) {
|
| 761 |
+
statusText = 'Thinking...';
|
| 762 |
+
} else if (isValidating) {
|
| 763 |
+
statusText = 'Validating...';
|
| 764 |
+
}
|
| 765 |
+
return (
|
| 766 |
<div style={{
|
| 767 |
display: 'flex',
|
| 768 |
alignItems: 'center',
|
|
|
|
| 774 |
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ animation: "spin 1s linear infinite" }}>
|
| 775 |
<path d="M21 12a9 9 0 1 1-6.219-8.56"/>
|
| 776 |
</svg>
|
| 777 |
+
<span>{statusText}</span>
|
| 778 |
</div>
|
| 779 |
+
);
|
| 780 |
})()}
|
| 781 |
</form>
|
| 782 |
</main>
|
|
|
|
| 1001 |
.replace(/```/g, "")
|
| 1002 |
.trim();
|
| 1003 |
}, []);
|
|
|
|
|
|
|
| 1004 |
const displayText = React.useMemo(() => {
|
| 1005 |
const raw = typeof message.text === "string" ? message.text : "";
|
|
|
|
|
|
|
|
|
|
| 1006 |
return raw;
|
| 1007 |
+
}, [message.text]);
|
| 1008 |
|
| 1009 |
const normalizedText = React.useMemo(
|
| 1010 |
() => normalizeLatex(displayText),
|
|
|
|
| 1014 |
return (
|
| 1015 |
<div className={`message ${isUser ? "user" : "assistant"}`}>
|
| 1016 |
<div className="bubble">
|
|
|
|
| 1017 |
<ReactMarkdown
|
| 1018 |
className="markdown-body"
|
| 1019 |
remarkPlugins={[remarkMath, remarkGfm]}
|