Spaces:
Sleeping

fraudTech commited on
Commit
0e433bf
·
1 Parent(s): 2975422

add spinner while debug is generating

Browse files
Files changed (1) hide show
  1. src/App.js +26 -1
src/App.js CHANGED
@@ -673,7 +673,7 @@ function App() {
673
 
674
  // Create empty assistant bubble for streaming.
675
  // We render a "Thinking..." placeholder while text is still empty.
676
- const assistantMsg = { role: "assistant", text: "", debug: null, thinking: true, statusText: "" };
677
  newMessages.push(assistantMsg);
678
 
679
  setMessages(newMessages);
@@ -721,6 +721,7 @@ function App() {
721
  // Finalize the streaming response
722
  assistantMsg.thinking = false;
723
  assistantMsg.statusText = "";
 
724
  setMessages([...newMessages]);
725
 
726
  // Fetch debug info in background without blocking or replacing text
@@ -733,6 +734,7 @@ function App() {
733
  const lastMsg = updated[updated.length - 1];
734
  if (lastMsg && lastMsg.role === 'assistant') {
735
  lastMsg.debug = debugResult.prolog_query_info;
 
736
  }
737
  return updated;
738
  });
@@ -740,6 +742,14 @@ function App() {
740
  } catch (debugErr) {
741
  // Silently fail - debug info is optional
742
  console.warn("Failed to fetch debug info:", debugErr);
 
 
 
 
 
 
 
 
743
  }
744
 
745
  } catch (err) {
@@ -1277,6 +1287,21 @@ function Message({ message }) {
1277
  </ReactMarkdown>
1278
  )}
1279
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1280
  {!isUser && message.debug && (
1281
  <>
1282
  <button
 
673
 
674
  // Create empty assistant bubble for streaming.
675
  // We render a "Thinking..." placeholder while text is still empty.
676
+ const assistantMsg = { role: "assistant", text: "", debug: null, thinking: true, statusText: "", loadingDebug: false };
677
  newMessages.push(assistantMsg);
678
 
679
  setMessages(newMessages);
 
721
  // Finalize the streaming response
722
  assistantMsg.thinking = false;
723
  assistantMsg.statusText = "";
724
+ assistantMsg.loadingDebug = true;
725
  setMessages([...newMessages]);
726
 
727
  // Fetch debug info in background without blocking or replacing text
 
734
  const lastMsg = updated[updated.length - 1];
735
  if (lastMsg && lastMsg.role === 'assistant') {
736
  lastMsg.debug = debugResult.prolog_query_info;
737
+ lastMsg.loadingDebug = false;
738
  }
739
  return updated;
740
  });
 
742
  } catch (debugErr) {
743
  // Silently fail - debug info is optional
744
  console.warn("Failed to fetch debug info:", debugErr);
745
+ setMessages(prevMessages => {
746
+ const updated = [...prevMessages];
747
+ const lastMsg = updated[updated.length - 1];
748
+ if (lastMsg && lastMsg.role === 'assistant') {
749
+ lastMsg.loadingDebug = false;
750
+ }
751
+ return updated;
752
+ });
753
  }
754
 
755
  } catch (err) {
 
1287
  </ReactMarkdown>
1288
  )}
1289
  </div>
1290
+ {!isUser && message.loadingDebug && (
1291
+ <div style={{
1292
+ display: 'flex',
1293
+ alignItems: 'center',
1294
+ gap: '8px',
1295
+ marginTop: '8px',
1296
+ color: '#888',
1297
+ fontSize: '0.9em'
1298
+ }}>
1299
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ animation: "spin 1s linear infinite" }}>
1300
+ <path d="M21 12a9 9 0 1 1-6.219-8.56"/>
1301
+ </svg>
1302
+ <span>Loading debug info...</span>
1303
+ </div>
1304
+ )}
1305
  {!isUser && message.debug && (
1306
  <>
1307
  <button