mahammadaftab commited on
Commit
18438c3
·
1 Parent(s): 6298125

Final updated

Browse files
Files changed (1) hide show
  1. dashboard/app.js +7 -4
dashboard/app.js CHANGED
@@ -38,13 +38,13 @@ document.addEventListener('DOMContentLoaded', async () => {
38
  }
39
  });
40
  // Auto-initialize on page load so Step/Auto work immediately
41
- await resetEnv();
42
  });
43
 
44
  // ============================================================
45
  // API Calls
46
  // ============================================================
47
- async function resetEnv() {
48
  const taskId = document.getElementById('task-select').value;
49
  const turnsInput = document.getElementById('turns-input');
50
  let maxSteps = parseInt(turnsInput.value) || 50;
@@ -68,12 +68,15 @@ async function resetEnv() {
68
  body: JSON.stringify({ task_id: taskId, max_steps: maxSteps }),
69
  });
70
  const data = await res.json();
71
- updateDashboard(data.observation, null, null);
 
 
 
72
 
73
  // Fetch full state to get emergent metrics immediately
74
  const stateRes = await fetch(`${API}/state`);
75
  const state = await stateRes.json();
76
- if (state && state.emergent) {
77
  const em = state.emergent;
78
  document.getElementById('em-gini').textContent = em.wealth_inequality.toFixed(2);
79
  document.getElementById('em-unrest').textContent = em.social_unrest.toFixed(2);
 
38
  }
39
  });
40
  // Auto-initialize on page load so Step/Auto work immediately
41
+ await resetEnv(true);
42
  });
43
 
44
  // ============================================================
45
  // API Calls
46
  // ============================================================
47
+ async function resetEnv(silent = false) {
48
  const taskId = document.getElementById('task-select').value;
49
  const turnsInput = document.getElementById('turns-input');
50
  let maxSteps = parseInt(turnsInput.value) || 50;
 
68
  body: JSON.stringify({ task_id: taskId, max_steps: maxSteps }),
69
  });
70
  const data = await res.json();
71
+
72
+ if (!silent) {
73
+ updateDashboard(data.observation, null, null);
74
+ }
75
 
76
  // Fetch full state to get emergent metrics immediately
77
  const stateRes = await fetch(`${API}/state`);
78
  const state = await stateRes.json();
79
+ if (state && state.emergent && !silent) {
80
  const em = state.emergent;
81
  document.getElementById('em-gini').textContent = em.wealth_inequality.toFixed(2);
82
  document.getElementById('em-unrest').textContent = em.social_unrest.toFixed(2);