fraudTech commited on
Commit
c952627
ยท
1 Parent(s): 3b27c5f
Files changed (2) hide show
  1. src/App.css +5 -4
  2. src/App.js +396 -75
src/App.css CHANGED
@@ -181,6 +181,9 @@ body, html, #root {
181
  max-width: 75%;
182
  line-height: 1.6; /* improved readability */
183
  word-wrap: break-word; /* prevent overflow */
 
 
 
184
  }
185
 
186
  .message.user .bubble {
@@ -438,10 +441,8 @@ body, html, #root {
438
  border-radius: 50%;
439
  border-top-color: #fff;
440
  animation: spin 1s ease-in-out infinite;
441
- margin-right: 8px;
442
- vertical-align: middle;
443
- position: relative;
444
- top: -1px;
445
  }
446
 
447
  @keyframes spin {
 
181
  max-width: 75%;
182
  line-height: 1.6; /* improved readability */
183
  word-wrap: break-word; /* prevent overflow */
184
+ display: flex;
185
+ align-items: flex-start;
186
+ gap: 8px;
187
  }
188
 
189
  .message.user .bubble {
 
441
  border-radius: 50%;
442
  border-top-color: #fff;
443
  animation: spin 1s ease-in-out infinite;
444
+ flex-shrink: 0;
445
+ margin-top: 4px;
 
 
446
  }
447
 
448
  @keyframes spin {
src/App.js CHANGED
@@ -1,6 +1,7 @@
1
  // src/App.js
2
 
3
- import React, { useState, useEffect, useMemo } from "react";
 
4
  import {
5
  sendChat,
6
  login,
@@ -125,16 +126,6 @@ function App() {
125
  }
126
  }, [messages]);
127
 
128
- // โญ CLEAR CONVERSATION HISTORY WHEN SWITCHING MODES โญ
129
- React.useEffect(() => {
130
- setMessages([
131
- { role: "assistant", text: strictMode
132
- ? "๐Ÿ”’ Strict KB Mode enabled. I will only answer using verified facts from the knowledge base."
133
- : "๐Ÿ”“ Flexible Mode enabled. I can use general knowledge along with the knowledge base."
134
- },
135
- ]);
136
- }, [strictMode]);
137
-
138
 
139
  // ============================================================
140
  // LOAD CURRENT USER INFO (after login / token change)
@@ -552,11 +543,9 @@ function App() {
552
  <header className="header">
553
  <h1 className="header-title">Prolog AI</h1>
554
  </header>
555
-
556
  <main className="main login">
557
  <form className="login-form" onSubmit={handleLogin}>
558
  <h2>Sign In</h2>
559
-
560
  <input
561
  type="text"
562
  placeholder="Username"
@@ -565,7 +554,6 @@ function App() {
565
  setLoginForm({ ...loginForm, username: e.target.value })
566
  }
567
  />
568
-
569
  <input
570
  type="password"
571
  placeholder="Password"
@@ -574,9 +562,7 @@ function App() {
574
  setLoginForm({ ...loginForm, password: e.target.value })
575
  }
576
  />
577
-
578
  <button type="submit">Log In</button>
579
-
580
  {authError && <div className="error">{authError}</div>}
581
  </form>
582
  </main>
@@ -591,7 +577,6 @@ function App() {
591
  <div className="app-root">
592
  <header className="header">
593
  <h1 className="header-title">Prolog AI</h1>
594
-
595
  <div className="header-actions">
596
  <label className="strict-toggle" style={{
597
  padding: "0.5rem 1rem",
@@ -607,21 +592,18 @@ function App() {
607
  />{" "}
608
  {strictMode ? "๐Ÿ”’ Strict KB Mode" : "๐Ÿ”“ Flexible Mode"}
609
  </label>
610
-
611
  <button
612
  className="btn-secondary"
613
  onClick={() => setShowUpload(!showUpload)}
614
  >
615
  ๐Ÿ“ค Upload KB
616
  </button>
617
-
618
  <button
619
  className="btn-secondary"
620
  onClick={() => setShowQueryPanel(!showQueryPanel)}
621
  >
622
  ๐Ÿ” Query KB
623
  </button>
624
-
625
  <button
626
  className="btn-secondary"
627
  onClick={() => {
@@ -632,7 +614,6 @@ function App() {
632
  >
633
  ๐Ÿง  Session Memory
634
  </button>
635
-
636
  {me && me.is_admin && (
637
  <button
638
  className="btn-secondary"
@@ -644,7 +625,6 @@ function App() {
644
  ๐Ÿ‘ค Register User
645
  </button>
646
  )}
647
-
648
  <button
649
  className="logout-btn"
650
  onClick={() => {
@@ -661,7 +641,6 @@ function App() {
661
  </button>
662
  </div>
663
  </header>
664
-
665
  <div className="app-container">
666
  {/* Left Sidebar - Upload Panel */}
667
  {showUpload && (
@@ -679,14 +658,12 @@ function App() {
679
  {uploadStatus && (
680
  <div className="status-message">{uploadStatus}</div>
681
  )}
682
-
683
  <button
684
  onClick={handleLoadMetadata}
685
  style={{ marginTop: "10px", width: "100%" }}
686
  >
687
  ๐Ÿ”„ Refresh Metadata
688
  </button>
689
-
690
  {kbMetadata && (
691
  <div className="metadata-panel" style={{ marginTop: "15px" }}>
692
  <h4>๐Ÿ“‹ KB Metadata</h4>
@@ -697,7 +674,6 @@ function App() {
697
  )}
698
  </aside>
699
  )}
700
-
701
  {/* Main Chat Area */}
702
  <main className="main">
703
  <div className="messages">
@@ -705,9 +681,7 @@ function App() {
705
  <Message key={idx} message={msg} />
706
  ))}
707
  </div>
708
-
709
  {error && <div className="error">{error}</div>}
710
-
711
  <form className="input-row" onSubmit={handleSend}>
712
  <textarea
713
  placeholder="Ask a question about your knowledge base..."
@@ -727,7 +701,6 @@ function App() {
727
  </button>
728
  </form>
729
  </main>
730
-
731
  {/* Right Sidebar - Direct Query Panel */}
732
  {showQueryPanel && (
733
  <aside className="sidebar right-sidebar">
@@ -746,7 +719,6 @@ function App() {
746
  <button type="submit" style={{ marginTop: "10px", width: "100%" }}>
747
  Execute Query
748
  </button>
749
-
750
  <button
751
  type="button"
752
  onClick={handleProveGoal}
@@ -756,7 +728,6 @@ function App() {
756
  {proofLoading ? "โณ Proving..." : "๐Ÿงพ Prove Goal (Trace)"}
757
  </button>
758
  </form>
759
-
760
  {queryResults && (
761
  <div className="query-results" style={{ marginTop: "15px" }}>
762
  <h4>Results</h4>
@@ -765,13 +736,11 @@ function App() {
765
  </pre>
766
  </div>
767
  )}
768
-
769
  {proofStatus && (
770
  <div className="status-message" style={{ marginTop: "10px" }}>
771
  {proofStatus}
772
  </div>
773
  )}
774
-
775
  {proofResult && (
776
  <div className="query-results" style={{ marginTop: "15px" }}>
777
  <h4>Proof Trace</h4>
@@ -782,7 +751,6 @@ function App() {
782
  )}
783
  </aside>
784
  )}
785
-
786
  {/* Right Sidebar - Admin Register Panel */}
787
  {showRegisterPanel && me && me.is_admin && (
788
  <aside className="sidebar right-sidebar">
@@ -790,7 +758,6 @@ function App() {
790
  <p style={{ fontSize: "0.9em", color: "#666" }}>
791
  Create a new user account (admin only)
792
  </p>
793
-
794
  <form onSubmit={handleRegisterUser}>
795
  <input
796
  type="text"
@@ -806,7 +773,6 @@ function App() {
806
  onChange={(e) => setRegisterForm({ ...registerForm, password: e.target.value })}
807
  style={{ width: "100%", marginTop: "10px" }}
808
  />
809
-
810
  <label style={{ display: "flex", alignItems: "center", gap: "8px", marginTop: "10px" }}>
811
  <input
812
  type="checkbox"
@@ -815,12 +781,10 @@ function App() {
815
  />
816
  Overwrite if user exists
817
  </label>
818
-
819
  <button type="submit" style={{ marginTop: "10px", width: "100%" }}>
820
  Create User
821
  </button>
822
  </form>
823
-
824
  {registerStatus && (
825
  <div className="status-message" style={{ marginTop: "10px" }}>
826
  {registerStatus}
@@ -828,7 +792,6 @@ function App() {
828
  )}
829
  </aside>
830
  )}
831
-
832
  {/* Right Sidebar - Session Memory Panel */}
833
  {showSessionPanel && (
834
  <aside className="sidebar right-sidebar">
@@ -836,11 +799,9 @@ function App() {
836
  <p style={{ fontSize: "0.9em", color: "#666" }}>
837
  Staged validated lemmas for this chat session.
838
  </p>
839
-
840
  <div style={{ fontSize: "0.85em", color: "#666", wordBreak: "break-all" }}>
841
  Session ID: {sessionId}
842
  </div>
843
-
844
  <button
845
  className="btn-secondary"
846
  onClick={refreshSessionMemory}
@@ -849,7 +810,6 @@ function App() {
849
  >
850
  ๐Ÿ”„ Refresh
851
  </button>
852
-
853
  <button
854
  className="btn-secondary"
855
  onClick={handleDiscoverAndStage}
@@ -858,7 +818,6 @@ function App() {
858
  >
859
  ๐Ÿงช Discover (Math) & Stage
860
  </button>
861
-
862
  <button
863
  className="btn-secondary"
864
  onClick={handleClearSessionMemory}
@@ -867,7 +826,6 @@ function App() {
867
  >
868
  ๐Ÿงน Clear Session
869
  </button>
870
-
871
  <button
872
  className="btn-secondary"
873
  onClick={handleExportSessionMemory}
@@ -876,7 +834,6 @@ function App() {
876
  >
877
  ๐Ÿ’พ Export Learned Lemmas
878
  </button>
879
-
880
  <button
881
  className="btn-secondary"
882
  onClick={handlePromoteSessionMemory}
@@ -885,7 +842,6 @@ function App() {
885
  >
886
  โœ… Promote (Bench-Gated)
887
  </button>
888
-
889
  <button
890
  className="btn-secondary"
891
  onClick={handleRollbackPromotion}
@@ -894,7 +850,6 @@ function App() {
894
  >
895
  โ†ฉ Rollback Last Promotion
896
  </button>
897
-
898
  <div style={{ marginTop: "15px" }}>
899
  <h4>๐Ÿ“„ Ingest (Stage into session)</h4>
900
  <input
@@ -912,7 +867,6 @@ function App() {
912
  >
913
  ๐Ÿ“„ Ingest arXiv โ†’ Stage
914
  </button>
915
-
916
  <input
917
  type="text"
918
  placeholder="Story URL (e.g., Project Gutenberg .txt)"
@@ -929,20 +883,17 @@ function App() {
929
  ๐Ÿ“š Ingest Story โ†’ Stage
930
  </button>
931
  </div>
932
-
933
  {sessionPanelStatus && (
934
  <div className="status-message" style={{ marginTop: "10px" }}>
935
  {sessionPanelStatus}
936
  </div>
937
  )}
938
-
939
  <div className="query-results" style={{ marginTop: "15px" }}>
940
  <h4>Staged lemmas ({(sessionLemmas || []).length})</h4>
941
  <pre style={{ fontSize: "0.85em", overflowX: "auto" }}>
942
  {JSON.stringify(sessionLemmas || [], null, 2)}
943
  </pre>
944
  </div>
945
-
946
  <div className="query-results" style={{ marginTop: "15px" }}>
947
  <h4>Staged docs</h4>
948
  <pre style={{ fontSize: "0.85em", overflowX: "auto" }}>
@@ -989,25 +940,17 @@ function Message({ message }) {
989
  return (
990
  <div className={`message ${isUser ? "user" : "assistant"}`}>
991
  <div className="bubble">
 
992
  <ReactMarkdown
993
  className="markdown-body"
994
  remarkPlugins={[remarkMath, remarkGfm]}
995
  rehypePlugins={[[rehypeKatex, { strict: "ignore", throwOnError: false, trust: true }]]}
996
  skipHtml={false}
997
  breaks={true}
998
- components={{
999
- p: ({node, ...props}) => {
1000
- if (isThinking) {
1001
- return <p {...props}><span className="thinking-spinner"></span>{props.children}</p>;
1002
- }
1003
- return <p {...props} />;
1004
- }
1005
- }}
1006
  >
1007
  {normalizedText}
1008
  </ReactMarkdown>
1009
  </div>
1010
-
1011
  {!isUser && message.debug && (
1012
  <>
1013
  <button
@@ -1025,7 +968,6 @@ function Message({ message }) {
1025
  >
1026
  {showDebug ? "๐Ÿ”ฝ Hide Prolog Queries" : "๐Ÿ”ผ Show Prolog Queries"}
1027
  </button>
1028
-
1029
  {showDebug && (
1030
  <div className="debug-panel" style={{
1031
  marginTop: "10px",
@@ -1037,7 +979,6 @@ function Message({ message }) {
1037
  color: "#1a1a1a"
1038
  }}>
1039
  <h4 style={{ marginTop: 0, marginBottom: "10px", color: "#1a1a1a" }}>๐Ÿ” Prolog Query Analysis</h4>
1040
-
1041
  {message.debug.llm_analysis && (
1042
  <div style={{ marginBottom: "15px" }}>
1043
  <strong style={{ color: "#1a1a1a" }}>Generated Queries:</strong>
@@ -1053,7 +994,6 @@ function Message({ message }) {
1053
  </pre>
1054
  </div>
1055
  )}
1056
-
1057
  {message.debug.predicates_queried && message.debug.predicates_queried.length > 0 && (
1058
  <div style={{ marginBottom: "15px" }}>
1059
  <strong style={{ color: "#1a1a1a" }}>Predicates Queried:</strong>{" "}
@@ -1062,7 +1002,6 @@ function Message({ message }) {
1062
  </span>
1063
  </div>
1064
  )}
1065
-
1066
  {Array.isArray(message.debug.dropped_calls) && message.debug.dropped_calls.length > 0 && (
1067
  <div style={{ marginBottom: "15px" }}>
1068
  <strong style={{ color: "#1a1a1a" }}>Dropped Tool Calls:</strong>
@@ -1079,7 +1018,6 @@ function Message({ message }) {
1079
  </pre>
1080
  </div>
1081
  )}
1082
-
1083
  {Array.isArray(message.debug.tool_calls_proof_retry) && message.debug.tool_calls_proof_retry.length > 0 && (
1084
  <div style={{ marginBottom: "15px" }}>
1085
  <strong style={{ color: "#1a1a1a" }}>Proof Retry Tool Calls:</strong>
@@ -1096,7 +1034,6 @@ function Message({ message }) {
1096
  </pre>
1097
  </div>
1098
  )}
1099
-
1100
  {message.debug.predicate_docs && message.debug.predicate_docs.length > 0 && (
1101
  <div style={{ marginBottom: "15px" }}>
1102
  <strong style={{ color: "#1a1a1a" }}>Predicate Descriptions:</strong>
@@ -1106,7 +1043,6 @@ function Message({ message }) {
1106
  const doc = p && p.doc ? String(p.doc) : "";
1107
  const usage = p && p.usage ? String(p.usage) : "";
1108
  const latex = p && p.latex ? String(p.latex) : "";
1109
-
1110
  const md = [
1111
  sig ? `**${sig}**` : "**(unknown)**",
1112
  doc ? doc : "",
@@ -1115,7 +1051,6 @@ function Message({ message }) {
1115
  ]
1116
  .filter(Boolean)
1117
  .join("\n\n");
1118
-
1119
  return (
1120
  <li key={idx} style={{ marginBottom: "10px" }}>
1121
  <div style={{ background: "#fff", border: "1px solid #e2e2e2", borderRadius: "4px", padding: "8px" }}>
@@ -1132,7 +1067,6 @@ function Message({ message }) {
1132
  </ul>
1133
  </div>
1134
  )}
1135
-
1136
  {message.debug.queries_executed && message.debug.queries_executed.length > 0 && (
1137
  <div style={{ marginBottom: "15px" }}>
1138
  <strong style={{ color: "#1a1a1a" }}>Executed Queries ({message.debug.queries_executed.length}):</strong>
@@ -1156,7 +1090,6 @@ function Message({ message }) {
1156
  </ul>
1157
  </div>
1158
  )}
1159
-
1160
  {message.debug.evidence && (
1161
  <div style={{ marginBottom: "15px" }}>
1162
  <strong style={{ color: "#1a1a1a" }}>Evidence:</strong>
@@ -1164,7 +1097,6 @@ function Message({ message }) {
1164
  <div>
1165
  Facts: <span style={{ fontWeight: "bold" }}>{(message.debug.evidence.facts || []).length}</span>
1166
  </div>
1167
-
1168
  {message.debug.evidence.fact_bindings && (
1169
  <div style={{ marginTop: "6px" }}>
1170
  Structured bindings:{" "}
@@ -1186,7 +1118,6 @@ function Message({ message }) {
1186
  ) : null}
1187
  </div>
1188
  )}
1189
-
1190
  {message.debug.evidence.citations && message.debug.evidence.citations.length > 0 && (
1191
  <div style={{ marginTop: "8px" }}>
1192
  <div style={{ fontWeight: "600" }}>Citations:</div>
@@ -1198,7 +1129,6 @@ function Message({ message }) {
1198
  const facts = message.debug.evidence.facts || [];
1199
  const i = typeof c.fact_index === "number" ? c.fact_index : Number(c.fact_index);
1200
  const factText = Number.isFinite(i) && i >= 0 && i < facts.length ? facts[i] : null;
1201
-
1202
  return (
1203
  <>
1204
  {factText ? (
@@ -1215,7 +1145,6 @@ function Message({ message }) {
1215
  </ul>
1216
  </div>
1217
  )}
1218
-
1219
  {message.debug.evidence.obligations && (
1220
  <div style={{ marginTop: "8px" }}>
1221
  <div style={{ fontWeight: "600" }}>Proof obligations:</div>
@@ -1232,6 +1161,398 @@ function Message({ message }) {
1232
  </div>
1233
  </div>
1234
  )}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1235
  </div>
1236
  )}
1237
  </>
@@ -1241,4 +1562,4 @@ function Message({ message }) {
1241
  }
1242
 
1243
 
1244
- export default App;
 
1
  // src/App.js
2
 
3
+ import React, { useState } from "react";
4
+ import { useMemo } from "react";
5
  import {
6
  sendChat,
7
  login,
 
126
  }
127
  }, [messages]);
128
 
 
 
 
 
 
 
 
 
 
 
129
 
130
  // ============================================================
131
  // LOAD CURRENT USER INFO (after login / token change)
 
543
  <header className="header">
544
  <h1 className="header-title">Prolog AI</h1>
545
  </header>
 
546
  <main className="main login">
547
  <form className="login-form" onSubmit={handleLogin}>
548
  <h2>Sign In</h2>
 
549
  <input
550
  type="text"
551
  placeholder="Username"
 
554
  setLoginForm({ ...loginForm, username: e.target.value })
555
  }
556
  />
 
557
  <input
558
  type="password"
559
  placeholder="Password"
 
562
  setLoginForm({ ...loginForm, password: e.target.value })
563
  }
564
  />
 
565
  <button type="submit">Log In</button>
 
566
  {authError && <div className="error">{authError}</div>}
567
  </form>
568
  </main>
 
577
  <div className="app-root">
578
  <header className="header">
579
  <h1 className="header-title">Prolog AI</h1>
 
580
  <div className="header-actions">
581
  <label className="strict-toggle" style={{
582
  padding: "0.5rem 1rem",
 
592
  />{" "}
593
  {strictMode ? "๐Ÿ”’ Strict KB Mode" : "๐Ÿ”“ Flexible Mode"}
594
  </label>
 
595
  <button
596
  className="btn-secondary"
597
  onClick={() => setShowUpload(!showUpload)}
598
  >
599
  ๐Ÿ“ค Upload KB
600
  </button>
 
601
  <button
602
  className="btn-secondary"
603
  onClick={() => setShowQueryPanel(!showQueryPanel)}
604
  >
605
  ๐Ÿ” Query KB
606
  </button>
 
607
  <button
608
  className="btn-secondary"
609
  onClick={() => {
 
614
  >
615
  ๐Ÿง  Session Memory
616
  </button>
 
617
  {me && me.is_admin && (
618
  <button
619
  className="btn-secondary"
 
625
  ๐Ÿ‘ค Register User
626
  </button>
627
  )}
 
628
  <button
629
  className="logout-btn"
630
  onClick={() => {
 
641
  </button>
642
  </div>
643
  </header>
 
644
  <div className="app-container">
645
  {/* Left Sidebar - Upload Panel */}
646
  {showUpload && (
 
658
  {uploadStatus && (
659
  <div className="status-message">{uploadStatus}</div>
660
  )}
 
661
  <button
662
  onClick={handleLoadMetadata}
663
  style={{ marginTop: "10px", width: "100%" }}
664
  >
665
  ๐Ÿ”„ Refresh Metadata
666
  </button>
 
667
  {kbMetadata && (
668
  <div className="metadata-panel" style={{ marginTop: "15px" }}>
669
  <h4>๐Ÿ“‹ KB Metadata</h4>
 
674
  )}
675
  </aside>
676
  )}
 
677
  {/* Main Chat Area */}
678
  <main className="main">
679
  <div className="messages">
 
681
  <Message key={idx} message={msg} />
682
  ))}
683
  </div>
 
684
  {error && <div className="error">{error}</div>}
 
685
  <form className="input-row" onSubmit={handleSend}>
686
  <textarea
687
  placeholder="Ask a question about your knowledge base..."
 
701
  </button>
702
  </form>
703
  </main>
 
704
  {/* Right Sidebar - Direct Query Panel */}
705
  {showQueryPanel && (
706
  <aside className="sidebar right-sidebar">
 
719
  <button type="submit" style={{ marginTop: "10px", width: "100%" }}>
720
  Execute Query
721
  </button>
 
722
  <button
723
  type="button"
724
  onClick={handleProveGoal}
 
728
  {proofLoading ? "โณ Proving..." : "๐Ÿงพ Prove Goal (Trace)"}
729
  </button>
730
  </form>
 
731
  {queryResults && (
732
  <div className="query-results" style={{ marginTop: "15px" }}>
733
  <h4>Results</h4>
 
736
  </pre>
737
  </div>
738
  )}
 
739
  {proofStatus && (
740
  <div className="status-message" style={{ marginTop: "10px" }}>
741
  {proofStatus}
742
  </div>
743
  )}
 
744
  {proofResult && (
745
  <div className="query-results" style={{ marginTop: "15px" }}>
746
  <h4>Proof Trace</h4>
 
751
  )}
752
  </aside>
753
  )}
 
754
  {/* Right Sidebar - Admin Register Panel */}
755
  {showRegisterPanel && me && me.is_admin && (
756
  <aside className="sidebar right-sidebar">
 
758
  <p style={{ fontSize: "0.9em", color: "#666" }}>
759
  Create a new user account (admin only)
760
  </p>
 
761
  <form onSubmit={handleRegisterUser}>
762
  <input
763
  type="text"
 
773
  onChange={(e) => setRegisterForm({ ...registerForm, password: e.target.value })}
774
  style={{ width: "100%", marginTop: "10px" }}
775
  />
 
776
  <label style={{ display: "flex", alignItems: "center", gap: "8px", marginTop: "10px" }}>
777
  <input
778
  type="checkbox"
 
781
  />
782
  Overwrite if user exists
783
  </label>
 
784
  <button type="submit" style={{ marginTop: "10px", width: "100%" }}>
785
  Create User
786
  </button>
787
  </form>
 
788
  {registerStatus && (
789
  <div className="status-message" style={{ marginTop: "10px" }}>
790
  {registerStatus}
 
792
  )}
793
  </aside>
794
  )}
 
795
  {/* Right Sidebar - Session Memory Panel */}
796
  {showSessionPanel && (
797
  <aside className="sidebar right-sidebar">
 
799
  <p style={{ fontSize: "0.9em", color: "#666" }}>
800
  Staged validated lemmas for this chat session.
801
  </p>
 
802
  <div style={{ fontSize: "0.85em", color: "#666", wordBreak: "break-all" }}>
803
  Session ID: {sessionId}
804
  </div>
 
805
  <button
806
  className="btn-secondary"
807
  onClick={refreshSessionMemory}
 
810
  >
811
  ๐Ÿ”„ Refresh
812
  </button>
 
813
  <button
814
  className="btn-secondary"
815
  onClick={handleDiscoverAndStage}
 
818
  >
819
  ๐Ÿงช Discover (Math) & Stage
820
  </button>
 
821
  <button
822
  className="btn-secondary"
823
  onClick={handleClearSessionMemory}
 
826
  >
827
  ๐Ÿงน Clear Session
828
  </button>
 
829
  <button
830
  className="btn-secondary"
831
  onClick={handleExportSessionMemory}
 
834
  >
835
  ๐Ÿ’พ Export Learned Lemmas
836
  </button>
 
837
  <button
838
  className="btn-secondary"
839
  onClick={handlePromoteSessionMemory}
 
842
  >
843
  โœ… Promote (Bench-Gated)
844
  </button>
 
845
  <button
846
  className="btn-secondary"
847
  onClick={handleRollbackPromotion}
 
850
  >
851
  โ†ฉ Rollback Last Promotion
852
  </button>
 
853
  <div style={{ marginTop: "15px" }}>
854
  <h4>๐Ÿ“„ Ingest (Stage into session)</h4>
855
  <input
 
867
  >
868
  ๐Ÿ“„ Ingest arXiv โ†’ Stage
869
  </button>
 
870
  <input
871
  type="text"
872
  placeholder="Story URL (e.g., Project Gutenberg .txt)"
 
883
  ๐Ÿ“š Ingest Story โ†’ Stage
884
  </button>
885
  </div>
 
886
  {sessionPanelStatus && (
887
  <div className="status-message" style={{ marginTop: "10px" }}>
888
  {sessionPanelStatus}
889
  </div>
890
  )}
 
891
  <div className="query-results" style={{ marginTop: "15px" }}>
892
  <h4>Staged lemmas ({(sessionLemmas || []).length})</h4>
893
  <pre style={{ fontSize: "0.85em", overflowX: "auto" }}>
894
  {JSON.stringify(sessionLemmas || [], null, 2)}
895
  </pre>
896
  </div>
 
897
  <div className="query-results" style={{ marginTop: "15px" }}>
898
  <h4>Staged docs</h4>
899
  <pre style={{ fontSize: "0.85em", overflowX: "auto" }}>
 
940
  return (
941
  <div className={`message ${isUser ? "user" : "assistant"}`}>
942
  <div className="bubble">
943
+ {isThinking && <span className="thinking-spinner"></span>}
944
  <ReactMarkdown
945
  className="markdown-body"
946
  remarkPlugins={[remarkMath, remarkGfm]}
947
  rehypePlugins={[[rehypeKatex, { strict: "ignore", throwOnError: false, trust: true }]]}
948
  skipHtml={false}
949
  breaks={true}
 
 
 
 
 
 
 
 
950
  >
951
  {normalizedText}
952
  </ReactMarkdown>
953
  </div>
 
954
  {!isUser && message.debug && (
955
  <>
956
  <button
 
968
  >
969
  {showDebug ? "๐Ÿ”ฝ Hide Prolog Queries" : "๐Ÿ”ผ Show Prolog Queries"}
970
  </button>
 
971
  {showDebug && (
972
  <div className="debug-panel" style={{
973
  marginTop: "10px",
 
979
  color: "#1a1a1a"
980
  }}>
981
  <h4 style={{ marginTop: 0, marginBottom: "10px", color: "#1a1a1a" }}>๐Ÿ” Prolog Query Analysis</h4>
 
982
  {message.debug.llm_analysis && (
983
  <div style={{ marginBottom: "15px" }}>
984
  <strong style={{ color: "#1a1a1a" }}>Generated Queries:</strong>
 
994
  </pre>
995
  </div>
996
  )}
 
997
  {message.debug.predicates_queried && message.debug.predicates_queried.length > 0 && (
998
  <div style={{ marginBottom: "15px" }}>
999
  <strong style={{ color: "#1a1a1a" }}>Predicates Queried:</strong>{" "}
 
1002
  </span>
1003
  </div>
1004
  )}
 
1005
  {Array.isArray(message.debug.dropped_calls) && message.debug.dropped_calls.length > 0 && (
1006
  <div style={{ marginBottom: "15px" }}>
1007
  <strong style={{ color: "#1a1a1a" }}>Dropped Tool Calls:</strong>
 
1018
  </pre>
1019
  </div>
1020
  )}
 
1021
  {Array.isArray(message.debug.tool_calls_proof_retry) && message.debug.tool_calls_proof_retry.length > 0 && (
1022
  <div style={{ marginBottom: "15px" }}>
1023
  <strong style={{ color: "#1a1a1a" }}>Proof Retry Tool Calls:</strong>
 
1034
  </pre>
1035
  </div>
1036
  )}
 
1037
  {message.debug.predicate_docs && message.debug.predicate_docs.length > 0 && (
1038
  <div style={{ marginBottom: "15px" }}>
1039
  <strong style={{ color: "#1a1a1a" }}>Predicate Descriptions:</strong>
 
1043
  const doc = p && p.doc ? String(p.doc) : "";
1044
  const usage = p && p.usage ? String(p.usage) : "";
1045
  const latex = p && p.latex ? String(p.latex) : "";
 
1046
  const md = [
1047
  sig ? `**${sig}**` : "**(unknown)**",
1048
  doc ? doc : "",
 
1051
  ]
1052
  .filter(Boolean)
1053
  .join("\n\n");
 
1054
  return (
1055
  <li key={idx} style={{ marginBottom: "10px" }}>
1056
  <div style={{ background: "#fff", border: "1px solid #e2e2e2", borderRadius: "4px", padding: "8px" }}>
 
1067
  </ul>
1068
  </div>
1069
  )}
 
1070
  {message.debug.queries_executed && message.debug.queries_executed.length > 0 && (
1071
  <div style={{ marginBottom: "15px" }}>
1072
  <strong style={{ color: "#1a1a1a" }}>Executed Queries ({message.debug.queries_executed.length}):</strong>
 
1090
  </ul>
1091
  </div>
1092
  )}
 
1093
  {message.debug.evidence && (
1094
  <div style={{ marginBottom: "15px" }}>
1095
  <strong style={{ color: "#1a1a1a" }}>Evidence:</strong>
 
1097
  <div>
1098
  Facts: <span style={{ fontWeight: "bold" }}>{(message.debug.evidence.facts || []).length}</span>
1099
  </div>
 
1100
  {message.debug.evidence.fact_bindings && (
1101
  <div style={{ marginTop: "6px" }}>
1102
  Structured bindings:{" "}
 
1118
  ) : null}
1119
  </div>
1120
  )}
 
1121
  {message.debug.evidence.citations && message.debug.evidence.citations.length > 0 && (
1122
  <div style={{ marginTop: "8px" }}>
1123
  <div style={{ fontWeight: "600" }}>Citations:</div>
 
1129
  const facts = message.debug.evidence.facts || [];
1130
  const i = typeof c.fact_index === "number" ? c.fact_index : Number(c.fact_index);
1131
  const factText = Number.isFinite(i) && i >= 0 && i < facts.length ? facts[i] : null;
 
1132
  return (
1133
  <>
1134
  {factText ? (
 
1145
  </ul>
1146
  </div>
1147
  )}
 
1148
  {message.debug.evidence.obligations && (
1149
  <div style={{ marginTop: "8px" }}>
1150
  <div style={{ fontWeight: "600" }}>Proof obligations:</div>
 
1161
  </div>
1162
  </div>
1163
  )}
1164
+ {message.debug.query_analysis && message.debug.query_analysis.summary_text && (
1165
+ <div style={{
1166
+ marginBottom: "15px",
1167
+ padding: "14px",
1168
+ background: "linear-gradient(135deg, #f3e5f5 0%, #e1f5fe 100%)",
1169
+ border: "2px solid #7b1fa2",
1170
+ borderRadius: "8px",
1171
+ boxShadow: "0 2px 8px rgba(0,0,0,0.1)"
1172
+ }}>
1173
+ <h4 style={{
1174
+ marginTop: 0,
1175
+ marginBottom: "12px",
1176
+ color: "#4a148c",
1177
+ fontSize: "1.15em",
1178
+ borderBottom: "2px solid #7b1fa2",
1179
+ paddingBottom: "6px",
1180
+ fontWeight: "700"
1181
+ }}>
1182
+ ๐Ÿ“Š Query Results by Category
1183
+ </h4>
1184
+ <div style={{
1185
+ background: "#fff",
1186
+ padding: "12px",
1187
+ borderRadius: "6px",
1188
+ fontSize: "0.95em",
1189
+ lineHeight: "1.6",
1190
+ whiteSpace: "pre-wrap",
1191
+ color: "#1a1a1a"
1192
+ }}>
1193
+ <ReactMarkdown
1194
+ remarkPlugins={[remarkMath, remarkGfm]}
1195
+ rehypePlugins={[[rehypeKatex, { strict: "ignore", throwOnError: false, trust: true }]]}
1196
+ >
1197
+ {message.debug.query_analysis.summary_text}
1198
+ </ReactMarkdown>
1199
+ </div>
1200
+ </div>
1201
+ )}
1202
+ {message.debug.lean_mathlib_analysis && message.debug.lean_mathlib_analysis.has_lean_queries && (
1203
+ <div style={{
1204
+ marginBottom: "15px",
1205
+ padding: "12px",
1206
+ background: "linear-gradient(135deg, #e0f7fa 0%, #e1bee7 100%)",
1207
+ border: "2px solid #00897b",
1208
+ borderRadius: "8px"
1209
+ }}>
1210
+ <h4 style={{
1211
+ marginTop: 0,
1212
+ marginBottom: "12px",
1213
+ color: "#00695c",
1214
+ fontSize: "1.1em",
1215
+ borderBottom: "2px solid #00897b",
1216
+ paddingBottom: "6px"
1217
+ }}>
1218
+ ๐ŸŽ“ Lean/Mathlib Verification Details
1219
+ </h4>
1220
+ {message.debug.lean_mathlib_analysis.theorems_verified &&
1221
+ message.debug.lean_mathlib_analysis.theorems_verified.length > 0 && (
1222
+ <div style={{ marginBottom: "12px" }}>
1223
+ <strong style={{ color: "#00695c", fontSize: "1.05em" }}>
1224
+ โœ… Successfully Verified Theorems:
1225
+ </strong>
1226
+ <ul style={{ marginTop: "6px", paddingLeft: "20px", color: "#1a1a1a" }}>
1227
+ {message.debug.lean_mathlib_analysis.theorems_verified.map((vt, idx) => (
1228
+ <li key={idx} style={{ marginBottom: "8px" }}>
1229
+ <code style={{
1230
+ background: "#fff",
1231
+ padding: "3px 8px",
1232
+ borderRadius: "4px",
1233
+ fontSize: "0.95em",
1234
+ color: "#d84315",
1235
+ fontWeight: "600"
1236
+ }}>
1237
+ {vt.theorem}
1238
+ </code>
1239
+ <div style={{
1240
+ marginLeft: "20px",
1241
+ marginTop: "4px",
1242
+ color: "#2e7d32",
1243
+ fontWeight: "500"
1244
+ }}>
1245
+ {vt.status}
1246
+ </div>
1247
+ </li>
1248
+ ))}
1249
+ </ul>
1250
+ </div>
1251
+ )}
1252
+ {message.debug.lean_mathlib_analysis.theorems_searched &&
1253
+ message.debug.lean_mathlib_analysis.theorems_searched.length > 0 && (
1254
+ <div style={{ marginBottom: "12px" }}>
1255
+ <strong style={{ color: "#00695c", fontSize: "1.05em" }}>
1256
+ ๐Ÿ” Mathlib Search Results:
1257
+ </strong>
1258
+ <ul style={{ marginTop: "6px", paddingLeft: "20px", color: "#1a1a1a" }}>
1259
+ {message.debug.lean_mathlib_analysis.theorems_searched.map((sr, idx) => (
1260
+ <li key={idx} style={{ marginBottom: "6px" }}>
1261
+ <span style={{ fontStyle: "italic", color: "#6a1b9a" }}>
1262
+ "{sr.search_term}"
1263
+ </span>
1264
+ {" โ†’ "}
1265
+ <span style={{ color: "#2e7d32", fontWeight: "500" }}>
1266
+ {sr.status}
1267
+ </span>
1268
+ <span style={{ marginLeft: "6px", color: "#555" }}>
1269
+ ({sr.results_count} result{sr.results_count !== 1 ? 's' : ''})
1270
+ </span>
1271
+ </li>
1272
+ ))}
1273
+ </ul>
1274
+ </div>
1275
+ )}
1276
+ {message.debug.lean_mathlib_analysis.proofs_attempted &&
1277
+ message.debug.lean_mathlib_analysis.proofs_attempted.length > 0 && (
1278
+ <div style={{ marginBottom: "12px" }}>
1279
+ <strong style={{ color: "#00695c", fontSize: "1.05em" }}>
1280
+ ๐Ÿ“‹ Proof Verification:
1281
+ </strong>
1282
+ <ul style={{ marginTop: "6px", paddingLeft: "20px", color: "#1a1a1a" }}>
1283
+ {message.debug.lean_mathlib_analysis.proofs_attempted.map((pa, idx) => (
1284
+ <li key={idx} style={{ marginBottom: "10px" }}>
1285
+ <div style={{
1286
+ background: "#fff",
1287
+ border: "1px solid #9c27b0",
1288
+ borderRadius: "4px",
1289
+ padding: "8px"
1290
+ }}>
1291
+ <div style={{ marginBottom: "4px" }}>
1292
+ <strong>Statement:</strong>{" "}
1293
+ <code style={{
1294
+ background: "#f3e5f5",
1295
+ padding: "2px 6px",
1296
+ borderRadius: "3px",
1297
+ color: "#4a148c",
1298
+ fontSize: "0.9em"
1299
+ }}>
1300
+ {pa.statement}
1301
+ </code>
1302
+ </div>
1303
+ <div style={{ marginBottom: "4px" }}>
1304
+ <strong>Using:</strong>{" "}
1305
+ <code style={{
1306
+ background: "#fff3e0",
1307
+ padding: "2px 6px",
1308
+ borderRadius: "3px",
1309
+ color: "#e65100",
1310
+ fontSize: "0.9em"
1311
+ }}>
1312
+ {pa.using_lemma}
1313
+ </code>
1314
+ </div>
1315
+ <div style={{ color: "#2e7d32", fontWeight: "600" }}>
1316
+ {pa.status}
1317
+ </div>
1318
+ </div>
1319
+ </li>
1320
+ ))}
1321
+ </ul>
1322
+ </div>
1323
+ )}
1324
+ {message.debug.lean_mathlib_analysis.mathematical_facts &&
1325
+ message.debug.lean_mathlib_analysis.mathematical_facts.length > 0 && (
1326
+ <div style={{
1327
+ marginTop: "12px",
1328
+ padding: "10px",
1329
+ background: "#fff",
1330
+ border: "2px solid #7b1fa2",
1331
+ borderRadius: "6px"
1332
+ }}>
1333
+ <strong style={{ color: "#6a1b9a", fontSize: "1.05em" }}>
1334
+ ๐ŸŽฏ Mathematical Facts Proven:
1335
+ </strong>
1336
+ <ul style={{ marginTop: "6px", paddingLeft: "20px", color: "#1a1a1a" }}>
1337
+ {message.debug.lean_mathlib_analysis.mathematical_facts.map((fact, idx) => (
1338
+ <li key={idx} style={{ marginBottom: "6px", fontWeight: "500" }}>
1339
+ {fact}
1340
+ </li>
1341
+ ))}
1342
+ </ul>
1343
+ <div style={{
1344
+ marginTop: "10px",
1345
+ fontStyle: "italic",
1346
+ color: "#555",
1347
+ fontSize: "0.95em",
1348
+ borderTop: "1px solid #e1bee7",
1349
+ paddingTop: "8px"
1350
+ }}>
1351
+ These are classical results in number theory, related to Dirichlet's theorem on primes in arithmetic progressions.
1352
+ </div>
1353
+ </div>
1354
+ )}
1355
+ </div>
1356
+ )}
1357
+ {message.debug.query_analysis && message.debug.query_analysis.symbolic_computation &&
1358
+ message.debug.query_analysis.symbolic_computation.has_queries && (
1359
+ <div style={{
1360
+ marginBottom: "15px",
1361
+ padding: "12px",
1362
+ background: "linear-gradient(135deg, #fff3e0 0%, #f1f8e9 100%)",
1363
+ border: "2px solid #ef6c00",
1364
+ borderRadius: "8px"
1365
+ }}>
1366
+ <h4 style={{
1367
+ marginTop: 0,
1368
+ marginBottom: "12px",
1369
+ color: "#e65100",
1370
+ fontSize: "1.1em",
1371
+ borderBottom: "2px solid #ef6c00",
1372
+ paddingBottom: "6px"
1373
+ }}>
1374
+ ๐Ÿงฎ Symbolic Computation Results
1375
+ </h4>
1376
+ {message.debug.query_analysis.symbolic_computation.computations &&
1377
+ message.debug.query_analysis.symbolic_computation.computations.length > 0 && (
1378
+ <div style={{ marginBottom: "10px" }}>
1379
+ <strong style={{ color: "#e65100" }}>Computations Performed:</strong>
1380
+ <ul style={{ marginTop: "6px", paddingLeft: "20px", color: "#1a1a1a" }}>
1381
+ {message.debug.query_analysis.symbolic_computation.computations.map((comp, idx) => (
1382
+ <li key={idx} style={{ marginBottom: "4px" }}>
1383
+ {comp.type && <span style={{ fontWeight: "600", color: "#bf360c" }}>{comp.type}: </span>}
1384
+ <code style={{ background: "#fff", padding: "2px 6px", borderRadius: "3px", fontSize: "0.9em" }}>
1385
+ {comp.expr || comp.query}
1386
+ </code>
1387
+ <span style={{ marginLeft: "8px", color: "#555" }}>({comp.count} result{comp.count !== 1 ? 's' : ''})</span>
1388
+ </li>
1389
+ ))}
1390
+ </ul>
1391
+ </div>
1392
+ )}
1393
+ {message.debug.query_analysis.symbolic_computation.simplifications &&
1394
+ message.debug.query_analysis.symbolic_computation.simplifications.length > 0 && (
1395
+ <div>
1396
+ <strong style={{ color: "#e65100" }}>Simplifications:</strong>
1397
+ <ul style={{ marginTop: "6px", paddingLeft: "20px", color: "#1a1a1a" }}>
1398
+ {message.debug.query_analysis.symbolic_computation.simplifications.map((simp, idx) => (
1399
+ <li key={idx} style={{ marginBottom: "4px" }}>
1400
+ <code style={{ background: "#fff", padding: "2px 6px", borderRadius: "3px", fontSize: "0.9em" }}>
1401
+ {simp.expr}
1402
+ </code>
1403
+ </li>
1404
+ ))}
1405
+ </ul>
1406
+ </div>
1407
+ )}
1408
+ </div>
1409
+ )}
1410
+ {message.debug.query_analysis && message.debug.query_analysis.session_data &&
1411
+ message.debug.query_analysis.session_data.has_queries && (
1412
+ <div style={{
1413
+ marginBottom: "15px",
1414
+ padding: "12px",
1415
+ background: "linear-gradient(135deg, #e8f5e9 0%, #e0f2f1 100%)",
1416
+ border: "2px solid #388e3c",
1417
+ borderRadius: "8px"
1418
+ }}>
1419
+ <h4 style={{
1420
+ marginTop: 0,
1421
+ marginBottom: "12px",
1422
+ color: "#2e7d32",
1423
+ fontSize: "1.1em",
1424
+ borderBottom: "2px solid #388e3c",
1425
+ paddingBottom: "6px"
1426
+ }}>
1427
+ ๐Ÿ’พ Session Data Queries
1428
+ </h4>
1429
+ {message.debug.query_analysis.session_data.lemmas &&
1430
+ message.debug.query_analysis.session_data.lemmas.length > 0 && (
1431
+ <div style={{ marginBottom: "8px" }}>
1432
+ <strong style={{ color: "#2e7d32" }}>๐Ÿ“ Session Lemmas:</strong>
1433
+ <span style={{ marginLeft: "8px", color: "#1a1a1a" }}>
1434
+ Retrieved {message.debug.query_analysis.session_data.lemmas.reduce((sum, l) => sum + l.count, 0)} lemma(s)
1435
+ </span>
1436
+ </div>
1437
+ )}
1438
+ {message.debug.query_analysis.session_data.papers &&
1439
+ message.debug.query_analysis.session_data.papers.length > 0 && (
1440
+ <div style={{ marginBottom: "8px" }}>
1441
+ <strong style={{ color: "#2e7d32" }}>๐Ÿ“„ Papers:</strong>
1442
+ <span style={{ marginLeft: "8px", color: "#1a1a1a" }}>
1443
+ Queried {message.debug.query_analysis.session_data.papers.reduce((sum, p) => sum + p.count, 0)} paper fact(s)
1444
+ </span>
1445
+ </div>
1446
+ )}
1447
+ {message.debug.query_analysis.session_data.stories &&
1448
+ message.debug.query_analysis.session_data.stories.length > 0 && (
1449
+ <div>
1450
+ <strong style={{ color: "#2e7d32" }}>๐Ÿ“– Stories:</strong>
1451
+ <span style={{ marginLeft: "8px", color: "#1a1a1a" }}>
1452
+ Queried {message.debug.query_analysis.session_data.stories.reduce((sum, s) => sum + s.count, 0)} story fact(s)
1453
+ </span>
1454
+ </div>
1455
+ )}
1456
+ </div>
1457
+ )}
1458
+ {message.debug.query_analysis && message.debug.query_analysis.proof_synthesis &&
1459
+ message.debug.query_analysis.proof_synthesis.has_queries && (
1460
+ <div style={{
1461
+ marginBottom: "15px",
1462
+ padding: "12px",
1463
+ background: "linear-gradient(135deg, #fce4ec 0%, #f3e5f5 100%)",
1464
+ border: "2px solid #c2185b",
1465
+ borderRadius: "8px"
1466
+ }}>
1467
+ <h4 style={{
1468
+ marginTop: 0,
1469
+ marginBottom: "12px",
1470
+ color: "#ad1457",
1471
+ fontSize: "1.1em",
1472
+ borderBottom: "2px solid #c2185b",
1473
+ paddingBottom: "6px"
1474
+ }}>
1475
+ ๐Ÿ”ฌ Automated Proof Synthesis
1476
+ </h4>
1477
+ {message.debug.query_analysis.proof_synthesis.synthesized &&
1478
+ message.debug.query_analysis.proof_synthesis.synthesized.length > 0 && (
1479
+ <div>
1480
+ <strong style={{ color: "#ad1457" }}>Proofs Generated:</strong>
1481
+ <ul style={{ marginTop: "6px", paddingLeft: "20px", color: "#1a1a1a" }}>
1482
+ {message.debug.query_analysis.proof_synthesis.synthesized.map((proof, idx) => (
1483
+ <li key={idx} style={{ marginBottom: "6px" }}>
1484
+ <code style={{
1485
+ background: "#fff",
1486
+ padding: "2px 6px",
1487
+ borderRadius: "3px",
1488
+ fontSize: "0.9em",
1489
+ color: "#880e4f"
1490
+ }}>
1491
+ {proof.goal}
1492
+ </code>
1493
+ <span style={{ marginLeft: "8px", color: "#2e7d32", fontWeight: "600" }}>
1494
+ โœ“ {proof.count} solution{proof.count !== 1 ? 's' : ''}
1495
+ </span>
1496
+ </li>
1497
+ ))}
1498
+ </ul>
1499
+ </div>
1500
+ )}
1501
+ </div>
1502
+ )}
1503
+ {message.debug.query_analysis && message.debug.query_analysis.general_kb &&
1504
+ message.debug.query_analysis.general_kb.has_queries &&
1505
+ Object.keys(message.debug.query_analysis.general_kb.facts_by_domain).length > 0 && (
1506
+ <div style={{
1507
+ marginBottom: "15px",
1508
+ padding: "12px",
1509
+ background: "linear-gradient(135deg, #e3f2fd 0%, #f1f8e9 100%)",
1510
+ border: "2px solid #1976d2",
1511
+ borderRadius: "8px"
1512
+ }}>
1513
+ <h4 style={{
1514
+ marginTop: 0,
1515
+ marginBottom: "12px",
1516
+ color: "#0d47a1",
1517
+ fontSize: "1.1em",
1518
+ borderBottom: "2px solid #1976d2",
1519
+ paddingBottom: "6px"
1520
+ }}>
1521
+ ๐Ÿ“š Knowledge Base Facts Retrieved
1522
+ </h4>
1523
+ {Object.entries(message.debug.query_analysis.general_kb.facts_by_domain).map(([domain, facts]) => (
1524
+ <div key={domain} style={{ marginBottom: "10px" }}>
1525
+ <strong style={{ color: "#0d47a1", textTransform: "capitalize" }}>
1526
+ {domain.replace(/_/g, ' ')}:
1527
+ </strong>
1528
+ <div style={{ marginLeft: "16px", marginTop: "4px" }}>
1529
+ {facts.map((fact, idx) => (
1530
+ <div key={idx} style={{ marginBottom: "3px", color: "#1a1a1a" }}>
1531
+ <code style={{
1532
+ background: "#fff",
1533
+ padding: "2px 6px",
1534
+ borderRadius: "3px",
1535
+ fontSize: "0.85em",
1536
+ color: "#1565c0"
1537
+ }}>
1538
+ {fact.predicate}
1539
+ </code>
1540
+ <span style={{ marginLeft: "6px", color: "#555", fontSize: "0.9em" }}>
1541
+ ({fact.count} fact{fact.count !== 1 ? 's' : ''})
1542
+ </span>
1543
+ </div>
1544
+ ))}
1545
+ </div>
1546
+ </div>
1547
+ ))}
1548
+ </div>
1549
+ )}
1550
+ <div>
1551
+ <strong style={{ color: "#1a1a1a" }}>Total Results:</strong>{" "}
1552
+ <span style={{ color: "#00aa00", fontWeight: "bold" }}>
1553
+ {message.debug.total_results || 0}
1554
+ </span>
1555
+ </div>
1556
  </div>
1557
  )}
1558
  </>
 
1562
  }
1563
 
1564
 
1565
+ export default App;