blob: 21a957a490dc1272c64ca38626d697066e97efd5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/**
* main.js - Application Entry Point
*/
import { ui } from './ui.js';
import { api } from './api.js';
import { terminal } from './components/terminal.js';
import { config } from './components/config.js';
import { results } from './components/results.js';
async function init() {
console.log('Initializing AI Reasoning Framework GUI...');
// Init Core Components
terminal.init();
await config.init();
await results.init();
// Init UI behaviors
ui.initTabs((tabId) => {
// Refresh data when switching to results tabs
if (['csv', 'images', 'judge'].includes(tabId)) {
results.loadAll();
}
});
// Initial Status Check
try {
const status = await api.get('/api/run/status');
ui.updateStatus(status.status, status.start_time);
if (status.status === 'running') {
config.setRunningState(true);
// Re-attach to stream if page reloaded
api.streamLogs(
(log) => terminal.append(log),
() => {
config.setRunningState(false);
ui.updateStatus('complete');
results.loadAll();
}
);
}
} catch (e) {
console.warn('Initial status check failed', e);
}
}
// Start the app
function start() {
init().catch(err => {
console.error("Initialization error:", err);
const logsContainer = document.getElementById('logs-container');
if (logsContainer) {
const errorLine = document.createElement('div');
errorLine.className = 'terminal-line error';
errorLine.textContent = `[GUI STARTUP ERROR] ${err.message}`;
logsContainer.appendChild(errorLine);
}
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', start);
} else {
start();
}
|