Skip to content

Commit 89f3e24

Browse files
authored
1 parent 5328852 commit 89f3e24

File tree

6 files changed

+44
-44
lines changed

6 files changed

+44
-44
lines changed

education-ai-suite/smart-classroom/ui/package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

education-ai-suite/smart-classroom/ui/src/App.tsx

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,20 @@ const App: React.FC = () => {
1515
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
1616

1717
const [backendStatus, setBackendStatus] = useState<'checking' | 'available' | 'unavailable'>('checking');
18-
const wasInitiallyUnavailableRef = useRef(false);
19-
const reloadTriggeredRef = useRef(false);
2018

2119
const checkBackendHealth = async () => {
2220
try {
2321
const isHealthy = await pingBackend();
22+
2423
if (isHealthy) {
2524
setBackendStatus('available');
26-
// reload only if backend was initially unavailable
27-
if (wasInitiallyUnavailableRef.current && !reloadTriggeredRef.current) {
28-
reloadTriggeredRef.current = true;
29-
window.location.reload();
30-
return;
31-
}
3225
loadSettings();
33-
} else {
34-
setBackendStatus('unavailable');
35-
if (!wasInitiallyUnavailableRef.current) {
36-
wasInitiallyUnavailableRef.current = true;
37-
}
26+
return;
3827
}
28+
29+
setBackendStatus('unavailable');
3930
} catch {
4031
setBackendStatus('unavailable');
41-
if (!wasInitiallyUnavailableRef.current) {
42-
wasInitiallyUnavailableRef.current = true;
43-
}
4432
}
4533
};
4634

@@ -54,18 +42,43 @@ const App: React.FC = () => {
5442
};
5543

5644
useEffect(() => {
57-
checkBackendHealth(); // initial check
45+
checkBackendHealth();
5846
}, []);
5947

6048
useEffect(() => {
61-
if ((backendStatus === 'unavailable' || backendStatus === 'checking') && wasInitiallyUnavailableRef.current && !reloadTriggeredRef.current) {
62-
const interval = setInterval(() => {
63-
checkBackendHealth();
64-
}, 5000);
65-
return () => clearInterval(interval);
66-
}
49+
if (backendStatus === 'available') return;
50+
51+
const interval = setInterval(checkBackendHealth, 5000);
52+
return () => clearInterval(interval);
6753
}, [backendStatus]);
6854

55+
56+
if (backendStatus === 'checking') {
57+
return (
58+
<div className="app-loading">
59+
<div className="loading-content">
60+
<div className="spinner" />
61+
<h2>Checking backend status</h2>
62+
<p>Please wait while we connect to the backend…</p>
63+
</div>
64+
</div>
65+
);
66+
}
67+
68+
if (backendStatus === 'unavailable') {
69+
return (
70+
<div className="app-error">
71+
<div className="error-content">
72+
<h1>Backend Not Available</h1>
73+
<p>
74+
The backend server is currently unreachable.
75+
Please ensure it is running.
76+
</p>
77+
</div>
78+
</div>
79+
);
80+
}
81+
6982
return (
7083
<div className="app">
7184
<MetricsPoller />

education-ai-suite/smart-classroom/ui/src/components/Tabs/MindMapTab.tsx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { useEffect, useRef } from "react";
22
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
33
import "../../assets/css/MindMap.css";
4+
import jsMind from "jsmind";
5+
import "jsmind/style/jsmind.css";
46
import {
57
clearMindmapStartRequest,
68
mindmapStart as uiMindmapStart,
@@ -19,7 +21,6 @@ import {
1921
} from "../../redux/slices/mindmapSlice";
2022

2123
import { fetchMindmap } from "../../services/api";
22-
import "../../assets/css/MindMap.css";
2324
import { useTranslation } from "react-i18next";
2425

2526
declare global {
@@ -125,24 +126,9 @@ const MindMapTab: React.FC = () => {
125126
}, [sessionId]);
126127

127128
useEffect(() => {
128-
const loadJsMind = async () => {
129-
if (window.jsMind) return;
130-
const cssLink = document.createElement('link');
131-
cssLink.rel = 'stylesheet';
132-
cssLink.href = '//cdn.jsdelivr.net/npm/jsmind@0.8.5/style/jsmind.css';
133-
document.head.appendChild(cssLink);
134-
const script = document.createElement('script');
135-
script.src = '//cdn.jsdelivr.net/npm/jsmind@0.8.5/es6/jsmind.js';
136-
script.onload = () => {
137-
console.log('jsMind loaded successfully');
138-
};
139-
script.onerror = () => {
140-
console.error('Failed to load jsMind');
141-
};
142-
document.head.appendChild(script);
143-
};
144-
145-
loadJsMind();
129+
if (!window.jsMind) {
130+
window.jsMind = jsMind;
131+
}
146132
}, []);
147133

148134
useEffect(() => {

education-ai-suite/smart-classroom/ui/src/components/common/Button.tsx

Whitespace-only changes.

education-ai-suite/smart-classroom/ui/src/components/common/Modal.tsx

Whitespace-only changes.

education-ai-suite/smart-classroom/ui/src/services/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export type StartSessionResponse = { sessionId: string };
2525

2626
const env = (import.meta as any).env ?? {};
2727
const BASE_URL: string = env.VITE_API_BASE_URL || 'http://127.0.0.1:8000';
28-
const HEALTH_TIMEOUT_MS = 10000;
28+
const HEALTH_TIMEOUT_MS = 5000;
2929

3030
async function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {
3131
return Promise.race([

0 commit comments

Comments
 (0)