iitian commited on
Commit
c725cbc
·
1 Parent(s): 1c620a3

fix: restored action wrapping in UI payload

Browse files
Files changed (1) hide show
  1. server/static/app.js +11 -1
server/static/app.js CHANGED
@@ -46,8 +46,17 @@ document.addEventListener('DOMContentLoaded', () => {
46
  const response = await fetch('/step', {
47
  method: 'POST',
48
  headers: { 'Content-Type': 'application/json' },
49
- body: JSON.stringify(actionObj)
50
  });
 
 
 
 
 
 
 
 
 
51
  const data = await response.json();
52
  const obs = data.observation || data;
53
  const reward = data.reward !== undefined ? data.reward : (obs.reward || 0);
@@ -70,6 +79,7 @@ document.addEventListener('DOMContentLoaded', () => {
70
  } catch (err) {
71
  log(`❌ Execution failed: ${err.message}`, 'error');
72
  envStatus.textContent = 'Error';
 
73
  }
74
  }
75
 
 
46
  const response = await fetch('/step', {
47
  method: 'POST',
48
  headers: { 'Content-Type': 'application/json' },
49
+ body: JSON.stringify({ action: actionObj })
50
  });
51
+
52
+ if (!response.ok) {
53
+ const errorData = await response.json().catch(() => ({}));
54
+ const msg = errorData.detail
55
+ ? (typeof errorData.detail === 'string' ? errorData.detail : JSON.stringify(errorData.detail))
56
+ : response.statusText;
57
+ throw new Error(`Server ${response.status}: ${msg}`);
58
+ }
59
+
60
  const data = await response.json();
61
  const obs = data.observation || data;
62
  const reward = data.reward !== undefined ? data.reward : (obs.reward || 0);
 
79
  } catch (err) {
80
  log(`❌ Execution failed: ${err.message}`, 'error');
81
  envStatus.textContent = 'Error';
82
+ showToast(`Error: ${err.message}`);
83
  }
84
  }
85