@threadbase-sh/streamer 1.36.3 → 1.36.4

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.cjs CHANGED
@@ -1449,6 +1449,9 @@ var import_fs6 = require("fs");
1449
1449
  var import_path6 = require("path");
1450
1450
 
1451
1451
  // src/services/questions/detectPermissionGate.ts
1452
+ function permissionContentKey(gate) {
1453
+ return `${gate.prompt ?? ""}::${gate.detail ?? ""}::${gate.options.map((o) => `${o.index}.${o.label}`).join(",")}::${gate.cursor ?? ""}`;
1454
+ }
1452
1455
  var OSC_777_PERMISSION_RE = /\x1b\]777;notify;Claude Code;[^\x07\x1b]*needs your permission/;
1453
1456
  var OSC_777_WAITING_RE = /\x1b\]777;notify;Claude Code;[^\x07\x1b]*waiting for your input/;
1454
1457
  function hasPermissionOsc(rawData) {
@@ -6884,6 +6887,11 @@ var StreamerServer = class {
6884
6887
  // to pendingQuestions; mobile answers it by sending the option index via
6885
6888
  // /input { keys }. Cleared when the gate closes.
6886
6889
  pendingPermission = /* @__PURE__ */ new Map();
6890
+ // Content key (prompt + detail + options + cursor) of the permission gate
6891
+ // currently broadcast for a session — mirrors pendingQuestionKey so a PTY
6892
+ // repaint of the same gate doesn't re-broadcast on every tick. Cleared
6893
+ // alongside pendingPermission.
6894
+ pendingPermissionKey = /* @__PURE__ */ new Map();
6887
6895
  scanner = null;
6888
6896
  // Set when better-sqlite3 is unusable (e.g. node ABI mismatch made
6889
6897
  // ConversationCache.open throw), or when config.scannerPersistent is false
@@ -7181,6 +7189,7 @@ var StreamerServer = class {
7181
7189
  this.cancelPendingQuestion(session.id);
7182
7190
  }
7183
7191
  this.pendingPermission.delete(session.id);
7192
+ this.pendingPermissionKey.delete(session.id);
7184
7193
  this.contendedSessions.delete(session.id);
7185
7194
  this.rememberSelfPtyEnded(session.id);
7186
7195
  }
@@ -9217,10 +9226,14 @@ var StreamerServer = class {
9217
9226
  if (gate === null) {
9218
9227
  if (!this.pendingPermission.has(sessionId)) return;
9219
9228
  this.pendingPermission.delete(sessionId);
9229
+ this.pendingPermissionKey.delete(sessionId);
9220
9230
  this.wsHub.broadcast({ type: "permission_cancelled", sessionId });
9221
9231
  return;
9222
9232
  }
9233
+ const key = permissionContentKey(gate);
9234
+ if (this.pendingPermissionKey.get(sessionId) === key) return;
9223
9235
  this.pendingPermission.set(sessionId, gate);
9236
+ this.pendingPermissionKey.set(sessionId, key);
9224
9237
  const subscriberCount = this.sessionSubscribers.get(sessionId)?.size ?? 0;
9225
9238
  this.log.info(
9226
9239
  `[ws.broadcast_permission] ${sessionId.slice(0, 8)} subscribers=${subscriberCount}`,