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/cli/index.js CHANGED
@@ -30208,6 +30208,7 @@ var init_daemon_p2p = __esm({
30208
30208
  commandHandler = null;
30209
30209
  ptyInputHandler = null;
30210
30210
  ptyResizeHandler = null;
30211
+ screenshotStartHandler = null;
30211
30212
  _ssDebugDone = false;
30212
30213
  // PTY scrollback buffer per cliType (send recent output on reconnect)
30213
30214
  ptyScrollback = /* @__PURE__ */ new Map();
@@ -30615,6 +30616,7 @@ ${e?.stack || ""}`);
30615
30616
  peer.screenshotIdeType = parsed.ideType;
30616
30617
  peer.needsFirstFrame = true;
30617
30618
  log(`screenshot_start: peer=${peerId}, ideType=${parsed.ideType}, channelOpen=${!!peer.dataChannel}, state=${peer.state}`);
30619
+ this.screenshotStartHandler?.();
30618
30620
  } else {
30619
30621
  log(`screenshot_start: peer ${peerId} NOT FOUND in peers map!`);
30620
30622
  }
@@ -30766,6 +30768,9 @@ ${e?.stack || ""}`);
30766
30768
  onPtyResize(handler) {
30767
30769
  this.ptyResizeHandler = handler;
30768
30770
  }
30771
+ onScreenshotStart(handler) {
30772
+ this.screenshotStartHandler = handler;
30773
+ }
30769
30774
  // ─── P2P command/input/file handling ────────────────
30770
30775
  async handleP2PCommand(peerId, msg) {
30771
30776
  const { id, commandType, data } = msg;
@@ -31009,6 +31014,14 @@ var init_screenshot_controller = __esm({
31009
31014
  this.timer = null;
31010
31015
  }
31011
31016
  }
31017
+ /** Force immediate tick — called when screenshot_start is received to minimize first-frame latency */
31018
+ triggerImmediate() {
31019
+ if (this.timer) {
31020
+ clearTimeout(this.timer);
31021
+ this.timer = null;
31022
+ }
31023
+ this.timer = setTimeout(() => this.tick(), 50);
31024
+ }
31012
31025
  // ─── Core loop ────────────────────────────────
31013
31026
  async tick() {
31014
31027
  if (!this.deps.isRunning()) return;
@@ -31024,21 +31037,22 @@ var init_screenshot_controller = __esm({
31024
31037
  this.checkBudgetReset();
31025
31038
  if (this.dailyBudgetMs > 0) {
31026
31039
  const now = Date.now();
31027
- if (active && this.lastActiveTimestamp > 0) {
31040
+ if (active && isRelay && this.lastActiveTimestamp > 0) {
31028
31041
  this.dailyUsedMs += now - this.lastActiveTimestamp;
31029
31042
  }
31030
- this.lastActiveTimestamp = active ? now : 0;
31043
+ this.lastActiveTimestamp = active && isRelay ? now : 0;
31031
31044
  if (this.dailyUsedMs >= this.dailyBudgetMs && !this.budgetExhausted) {
31032
31045
  this.budgetExhausted = true;
31033
31046
  const usedMin = Math.round(this.dailyUsedMs / 6e4);
31034
- LOG.info("Screenshot", `Daily budget exhausted: ${usedMin}/${this.dailyBudgetMinutes}min \u2014 pausing until midnight UTC`);
31047
+ LOG.info("Screenshot", `Daily TURN budget exhausted: ${usedMin}/${this.dailyBudgetMinutes}min \u2014 pausing relay until midnight UTC`);
31035
31048
  }
31036
31049
  }
31037
- if (!active || !cdp || this.budgetExhausted) {
31050
+ const budgetBlocked = this.budgetExhausted && isRelay;
31051
+ if (!active || !cdp || budgetBlocked) {
31038
31052
  this.staticFrameCount = 0;
31039
31053
  this.currentInterval = profile.maxInterval;
31040
31054
  if (!active) this.lastActiveTimestamp = 0;
31041
- this.timer = setTimeout(() => this.tick(), this.budgetExhausted ? 3e4 : this.currentInterval);
31055
+ this.timer = setTimeout(() => this.tick(), budgetBlocked ? 3e4 : this.currentInterval);
31042
31056
  return;
31043
31057
  }
31044
31058
  this.debugCount++;
@@ -31174,7 +31188,7 @@ var init_adhdev_daemon = __esm({
31174
31188
  fs11 = __toESM(require("fs"));
31175
31189
  path14 = __toESM(require("path"));
31176
31190
  import_chalk2 = __toESM(require("chalk"));
31177
- pkgVersion = "0.6.22";
31191
+ pkgVersion = "0.6.24";
31178
31192
  if (pkgVersion === "unknown") {
31179
31193
  try {
31180
31194
  const possiblePaths = [
@@ -31363,6 +31377,7 @@ ${err?.stack || ""}`);
31363
31377
  sendScreenshotBuffer: (buf) => this.p2p.sendScreenshotBuffer(buf)
31364
31378
  }, planLimits ?? void 0);
31365
31379
  this.screenshotController.start();
31380
+ this.p2p.onScreenshotStart(() => this.screenshotController?.triggerImmediate());
31366
31381
  } else {
31367
31382
  console.log(import_chalk2.default.gray(" \u26A0 P2P unavailable \u2014 using server relay"));
31368
31383
  }