adhdev 0.6.22 → 0.6.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -29768,6 +29768,7 @@ var init_daemon_p2p = __esm({
29768
29768
  commandHandler = null;
29769
29769
  ptyInputHandler = null;
29770
29770
  ptyResizeHandler = null;
29771
+ screenshotStartHandler = null;
29771
29772
  _ssDebugDone = false;
29772
29773
  // PTY scrollback buffer per cliType (send recent output on reconnect)
29773
29774
  ptyScrollback = /* @__PURE__ */ new Map();
@@ -30175,6 +30176,7 @@ ${e?.stack || ""}`);
30175
30176
  peer.screenshotIdeType = parsed.ideType;
30176
30177
  peer.needsFirstFrame = true;
30177
30178
  log(`screenshot_start: peer=${peerId}, ideType=${parsed.ideType}, channelOpen=${!!peer.dataChannel}, state=${peer.state}`);
30179
+ this.screenshotStartHandler?.();
30178
30180
  } else {
30179
30181
  log(`screenshot_start: peer ${peerId} NOT FOUND in peers map!`);
30180
30182
  }
@@ -30326,6 +30328,9 @@ ${e?.stack || ""}`);
30326
30328
  onPtyResize(handler) {
30327
30329
  this.ptyResizeHandler = handler;
30328
30330
  }
30331
+ onScreenshotStart(handler) {
30332
+ this.screenshotStartHandler = handler;
30333
+ }
30329
30334
  // ─── P2P command/input/file handling ────────────────
30330
30335
  async handleP2PCommand(peerId, msg) {
30331
30336
  const { id, commandType, data } = msg;
@@ -30569,6 +30574,14 @@ var init_screenshot_controller = __esm({
30569
30574
  this.timer = null;
30570
30575
  }
30571
30576
  }
30577
+ /** Force immediate tick — called when screenshot_start is received to minimize first-frame latency */
30578
+ triggerImmediate() {
30579
+ if (this.timer) {
30580
+ clearTimeout(this.timer);
30581
+ this.timer = null;
30582
+ }
30583
+ this.timer = setTimeout(() => this.tick(), 50);
30584
+ }
30572
30585
  // ─── Core loop ────────────────────────────────
30573
30586
  async tick() {
30574
30587
  if (!this.deps.isRunning()) return;
@@ -30584,21 +30597,22 @@ var init_screenshot_controller = __esm({
30584
30597
  this.checkBudgetReset();
30585
30598
  if (this.dailyBudgetMs > 0) {
30586
30599
  const now = Date.now();
30587
- if (active && this.lastActiveTimestamp > 0) {
30600
+ if (active && isRelay && this.lastActiveTimestamp > 0) {
30588
30601
  this.dailyUsedMs += now - this.lastActiveTimestamp;
30589
30602
  }
30590
- this.lastActiveTimestamp = active ? now : 0;
30603
+ this.lastActiveTimestamp = active && isRelay ? now : 0;
30591
30604
  if (this.dailyUsedMs >= this.dailyBudgetMs && !this.budgetExhausted) {
30592
30605
  this.budgetExhausted = true;
30593
30606
  const usedMin = Math.round(this.dailyUsedMs / 6e4);
30594
- LOG.info("Screenshot", `Daily budget exhausted: ${usedMin}/${this.dailyBudgetMinutes}min \u2014 pausing until midnight UTC`);
30607
+ LOG.info("Screenshot", `Daily TURN budget exhausted: ${usedMin}/${this.dailyBudgetMinutes}min \u2014 pausing relay until midnight UTC`);
30595
30608
  }
30596
30609
  }
30597
- if (!active || !cdp || this.budgetExhausted) {
30610
+ const budgetBlocked = this.budgetExhausted && isRelay;
30611
+ if (!active || !cdp || budgetBlocked) {
30598
30612
  this.staticFrameCount = 0;
30599
30613
  this.currentInterval = profile.maxInterval;
30600
30614
  if (!active) this.lastActiveTimestamp = 0;
30601
- this.timer = setTimeout(() => this.tick(), this.budgetExhausted ? 3e4 : this.currentInterval);
30615
+ this.timer = setTimeout(() => this.tick(), budgetBlocked ? 3e4 : this.currentInterval);
30602
30616
  return;
30603
30617
  }
30604
30618
  this.debugCount++;
@@ -30734,7 +30748,7 @@ var init_adhdev_daemon = __esm({
30734
30748
  fs11 = __toESM(require("fs"));
30735
30749
  path14 = __toESM(require("path"));
30736
30750
  import_chalk2 = __toESM(require("chalk"));
30737
- pkgVersion = "0.6.22";
30751
+ pkgVersion = "0.6.24";
30738
30752
  if (pkgVersion === "unknown") {
30739
30753
  try {
30740
30754
  const possiblePaths = [
@@ -30923,6 +30937,7 @@ ${err?.stack || ""}`);
30923
30937
  sendScreenshotBuffer: (buf) => this.p2p.sendScreenshotBuffer(buf)
30924
30938
  }, planLimits ?? void 0);
30925
30939
  this.screenshotController.start();
30940
+ this.p2p.onScreenshotStart(() => this.screenshotController?.triggerImmediate());
30926
30941
  } else {
30927
30942
  console.log(import_chalk2.default.gray(" \u26A0 P2P unavailable \u2014 using server relay"));
30928
30943
  }