da03 commited on
Commit
2e9eadb
·
1 Parent(s): e600968
Files changed (1) hide show
  1. static/index.html +14 -4
static/index.html CHANGED
@@ -130,8 +130,7 @@
130
  <h5 class="card-title">Instructions:</h5>
131
  <ul class="mb-0">
132
  <li>Move your mouse inside the blue box to interact with NeuralOS</li>
133
- <li>Click to perform left-click actions</li>
134
- <li>Right-click to perform context menu actions</li>
135
  <li>Use your keyboard to type within the simulated environment</li>
136
  <li>Adjust sampling steps to control quality/speed tradeoff</li>
137
  <li>Toggle "Use RNN" to switch between RNN and diffusion mode</li>
@@ -151,6 +150,7 @@
151
  let isConnected = false;
152
  let reconnectAttempts = 0;
153
  const MAX_RECONNECT_DELAY = 30000; // Maximum delay between reconnection attempts (30 seconds)
 
154
 
155
  let isProcessing = false;
156
 
@@ -175,6 +175,7 @@
175
  socket.onopen = function(event) {
176
  console.log("WebSocket connection established");
177
  isConnected = true;
 
178
  //reconnectAttempts = 0;
179
 
180
  // Start auto-input mechanism
@@ -204,6 +205,7 @@
204
  }
205
 
206
  isConnected = false;
 
207
  stopAutoInput(); // Stop auto-input when connection is lost
208
  stopTimeoutCountdown(); // Stop timeout countdown when connection is lost
209
  //clearInterval(heartbeatInterval);
@@ -275,8 +277,8 @@
275
  }, 1000); // Send heartbeat every 15 seconds
276
  }
277
 
278
- // Initial connection
279
- connect();
280
 
281
  // Draw initial state on the canvas
282
  drawInitialCanvas();
@@ -492,6 +494,14 @@
492
 
493
  // Capture mouse movements and clicks
494
  canvas.addEventListener("mousemove", function (event) {
 
 
 
 
 
 
 
 
495
  if (!isConnected || isProcessing) return;
496
  let rect = canvas.getBoundingClientRect();
497
  let x = event.clientX - rect.left;
 
130
  <h5 class="card-title">Instructions:</h5>
131
  <ul class="mb-0">
132
  <li>Move your mouse inside the blue box to interact with NeuralOS</li>
133
+ <li>Click (left-click or right-click) to perform click actions</li>
 
134
  <li>Use your keyboard to type within the simulated environment</li>
135
  <li>Adjust sampling steps to control quality/speed tradeoff</li>
136
  <li>Toggle "Use RNN" to switch between RNN and diffusion mode</li>
 
150
  let isConnected = false;
151
  let reconnectAttempts = 0;
152
  const MAX_RECONNECT_DELAY = 30000; // Maximum delay between reconnection attempts (30 seconds)
153
+ let connectionAttempted = false; // Flag to prevent multiple connection attempts
154
 
155
  let isProcessing = false;
156
 
 
175
  socket.onopen = function(event) {
176
  console.log("WebSocket connection established");
177
  isConnected = true;
178
+ //connectionAttempted = false; // Reset flag for potential reconnections
179
  //reconnectAttempts = 0;
180
 
181
  // Start auto-input mechanism
 
205
  }
206
 
207
  isConnected = false;
208
+ //connectionAttempted = false; // Reset flag to allow reconnection attempts
209
  stopAutoInput(); // Stop auto-input when connection is lost
210
  stopTimeoutCountdown(); // Stop timeout countdown when connection is lost
211
  //clearInterval(heartbeatInterval);
 
277
  }, 1000); // Send heartbeat every 15 seconds
278
  }
279
 
280
+ // Don't connect immediately - wait for user interaction
281
+ // connect();
282
 
283
  // Draw initial state on the canvas
284
  drawInitialCanvas();
 
494
 
495
  // Capture mouse movements and clicks
496
  canvas.addEventListener("mousemove", function (event) {
497
+ // Establish connection on first mouse movement if not already connected
498
+ if (!isConnected && !connectionAttempted) {
499
+ console.log("First mouse movement detected - establishing WebSocket connection");
500
+ connectionAttempted = true;
501
+ connect();
502
+ return; // Skip this event, let the next one be processed
503
+ }
504
+
505
  if (!isConnected || isProcessing) return;
506
  let rect = canvas.getBoundingClientRect();
507
  let x = event.clientX - rect.left;