Jarvis2345 commited on
Commit
67bea17
·
verified ·
1 Parent(s): f6d5e74

deploy(S4): Blender headless pipeline + WebAR client + backend fixes

Browse files
Files changed (2) hide show
  1. backend/ws/agent_ws.py +28 -2
  2. dist/app-release.apk +1 -1
backend/ws/agent_ws.py CHANGED
@@ -274,8 +274,17 @@ class ConnectionManager:
274
  "payload": {"ok": True,
275
  "queued": len(self.pending_commands)},
276
  })
277
- # The PC is back: run whatever was sent while it was away.
278
- replayed = await self.flush_pending_commands(websocket)
 
 
 
 
 
 
 
 
 
279
  except Exception as exc:
280
  logging.warning("PC registration follow-up failed: %s", exc)
281
  if replayed:
@@ -296,8 +305,25 @@ class ConnectionManager:
296
  if data.get("event") == "relay:status":
297
  payload = data.get("payload")
298
  if isinstance(payload, dict):
 
299
  self.last_pc_status = payload
300
  self.last_pc_status_at = time.time()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  return
302
 
303
  if data.get("event") == "relay:result":
 
274
  "payload": {"ok": True,
275
  "queued": len(self.pending_commands)},
276
  })
277
+ # Release the queue ONLY if this desktop is already known to
278
+ # be unlocked. A PC that reconnects locked (the normal state
279
+ # after a reboot) would refuse every replayed command and
280
+ # destroy the backlog, so those are held until it reports
281
+ # unlocked — see the relay:status branch.
282
+ if self.last_pc_status.get("unlocked"):
283
+ replayed = await self.flush_pending_commands(websocket)
284
+ elif self.pending_commands:
285
+ logging.info(
286
+ "PC online but not known-unlocked; holding %d command(s)",
287
+ len(self.pending_commands))
288
  except Exception as exc:
289
  logging.warning("PC registration follow-up failed: %s", exc)
290
  if replayed:
 
305
  if data.get("event") == "relay:status":
306
  payload = data.get("payload")
307
  if isinstance(payload, dict):
308
+ was_unlocked = bool(self.last_pc_status.get("unlocked"))
309
  self.last_pc_status = payload
310
  self.last_pc_status_at = time.time()
311
+ # FLUSH ON UNLOCK, not merely on connect.
312
+ #
313
+ # The queue used to drain the instant a PC registered — which is
314
+ # BEFORE anyone knows whether that PC will accept commands. After
315
+ # a reboot the desktop reconnects locked, so every queued command
316
+ # was replayed into a locked session, refused, and lost. The user
317
+ # had been promised those would run when the PC came back, and
318
+ # instead a restart silently destroyed them.
319
+ #
320
+ # Waiting for the desktop's own "unlocked" report means the queue
321
+ # survives the reboot and runs the moment the session is opened.
322
+ if payload.get("unlocked") and not was_unlocked and self.pending_commands:
323
+ if websocket is not None:
324
+ logging.info("PC reported unlocked — releasing %d held command(s)",
325
+ len(self.pending_commands))
326
+ await self.flush_pending_commands(websocket)
327
  return
328
 
329
  if data.get("event") == "relay:result":
dist/app-release.apk CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5706a878f23fa24ffa79b70dd7700521315c9bba6ba784df823fbed781579d07
3
  size 116554783
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4901f695b82214a34b316e1c13503a39c50af8b798d4060306757995f3c29f89
3
  size 116554783