bunnyquery 1.10.8 → 1.10.10

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/bunnyquery.js CHANGED
@@ -6406,9 +6406,39 @@ Index the REMAINING windows - one record per row/item, looking at any page image
6406
6406
  });
6407
6407
  }
6408
6408
  // --- background-task resolution + drain -------------------------------
6409
- handleHistoryItemResolution(itemId, response, platform) {
6409
+ /** Record how long a background indexing pass took, on the bubble that just
6410
+ * settled, so the duration shows immediately instead of waiting for whatever
6411
+ * next refetches history.
6412
+ *
6413
+ * `_tsStart` is otherwise written only by the history mapper, which reads the
6414
+ * row's `executed`; a live settle never sees the row at all (the poll resolves
6415
+ * with the destination's body). This is the same value by the other route.
6416
+ *
6417
+ * `_ts` is stamped too when the branch that built the bubble left it without
6418
+ * one: it is the END of the pass, and the pass ended now. A later history load
6419
+ * replaces both with the server's own numbers.
6420
+ *
6421
+ * Indexing passes only: an ordinary turn has no duration to show, and
6422
+ * `_tsStart`'s presence is what both views read to decide. */
6423
+ _stampPassDuration(itemId, executedAt) {
6424
+ if (!itemId) return;
6425
+ if (!this._indexRefOfItem(itemId)) return;
6426
+ var hasStart = typeof executedAt === "number" && executedAt > 0;
6427
+ for (var i = this.state.messages.length - 1; i >= 0; i--) {
6428
+ var m = this.state.messages[i];
6429
+ if (!m || m.role !== "assistant" || m._serverItemId !== itemId) continue;
6430
+ if (m.isPending) continue;
6431
+ if (typeof m._ts !== "number") m._ts = Date.now();
6432
+ if (hasStart) m._tsStart = executedAt;
6433
+ this.host.notify();
6434
+ this.updateHistoryCache();
6435
+ break;
6436
+ }
6437
+ }
6438
+ handleHistoryItemResolution(itemId, response, platform, executedAt) {
6410
6439
  var indexRef = this._indexRefOfItem(itemId);
6411
6440
  this.applyHistoryItemResolution(itemId, response, platform);
6441
+ this._stampPassDuration(itemId, executedAt);
6412
6442
  this.promoteNextBgQueuedToRunning();
6413
6443
  this.drainBgTaskQueue();
6414
6444
  if (indexRef) this._followWorkerIndexingChain(indexRef.name, indexRef.mime);
@@ -6855,14 +6885,20 @@ Index the REMAINING windows - one record per row/item, looking at any page image
6855
6885
  var capturedId = entry2.id, capturedPlat = plat;
6856
6886
  var capturedEntry = entry2;
6857
6887
  var wasStopped = false;
6858
- var bp = entry2.poll({ latency: POLL_INTERVAL });
6888
+ var executedAt;
6889
+ var bp = entry2.poll({
6890
+ latency: POLL_INTERVAL,
6891
+ onResponse: function(_res, meta) {
6892
+ if (meta && typeof meta.executed === "number" && meta.executed > 0) executedAt = meta.executed;
6893
+ }
6894
+ });
6859
6895
  self._trackPoll(entry2.id, "bg", bp);
6860
6896
  bp.then(function(response) {
6861
6897
  if (isPollStopped(response)) {
6862
6898
  wasStopped = true;
6863
6899
  return;
6864
6900
  }
6865
- self.handleHistoryItemResolution(capturedId, response, capturedPlat);
6901
+ self.handleHistoryItemResolution(capturedId, response, capturedPlat, executedAt);
6866
6902
  self.maybeResumeIndexing(capturedEntry, response, capturedPlat);
6867
6903
  }).catch(function(err) {
6868
6904
  self.historyItemPolls.delete(capturedId);
@@ -7431,9 +7467,14 @@ Index the REMAINING windows - one record per row/item, looking at any page image
7431
7467
  var capturedId = item.id;
7432
7468
  var isBg = !!(item._isBgTask || item._isOnBgQueue);
7433
7469
  var pollOpts = {
7434
- onResponse: function(response) {
7470
+ // `meta.executed` rides on the poll's running ticks, so a pass this
7471
+ // path re-attached to (a reload or a remount while its chain was
7472
+ // still going) shows its duration at settle exactly as one polled
7473
+ // from the drain does. Without it, only passes started in this page
7474
+ // life would be stamped.
7475
+ onResponse: function(response, meta) {
7435
7476
  if (isPollStopped(response)) return;
7436
- self.handleHistoryItemResolution(capturedId, response, platform);
7477
+ self.handleHistoryItemResolution(capturedId, response, platform, meta && meta.executed);
7437
7478
  },
7438
7479
  onError: function(err) {
7439
7480
  self.historyItemPolls.delete(capturedId);
@@ -8278,7 +8319,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
8278
8319
  (function() {
8279
8320
  var MCP_PROD = "https://mcp.broadwayinc.computer";
8280
8321
  var MCP_DEV = "https://mcp-dev.broadwayinc.computer";
8281
- var BQ_VERSION = "1.10.8" ;
8322
+ var BQ_VERSION = "1.10.10" ;
8282
8323
  var ATTACHMENT_URL_EXPIRES_SECONDS = 600;
8283
8324
  var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
8284
8325
  var GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
package/dist/engine.cjs CHANGED
@@ -6550,9 +6550,39 @@ var ChatSession = class {
6550
6550
  });
6551
6551
  }
6552
6552
  // --- background-task resolution + drain -------------------------------
6553
- handleHistoryItemResolution(itemId, response, platform) {
6553
+ /** Record how long a background indexing pass took, on the bubble that just
6554
+ * settled, so the duration shows immediately instead of waiting for whatever
6555
+ * next refetches history.
6556
+ *
6557
+ * `_tsStart` is otherwise written only by the history mapper, which reads the
6558
+ * row's `executed`; a live settle never sees the row at all (the poll resolves
6559
+ * with the destination's body). This is the same value by the other route.
6560
+ *
6561
+ * `_ts` is stamped too when the branch that built the bubble left it without
6562
+ * one: it is the END of the pass, and the pass ended now. A later history load
6563
+ * replaces both with the server's own numbers.
6564
+ *
6565
+ * Indexing passes only: an ordinary turn has no duration to show, and
6566
+ * `_tsStart`'s presence is what both views read to decide. */
6567
+ _stampPassDuration(itemId, executedAt) {
6568
+ if (!itemId) return;
6569
+ if (!this._indexRefOfItem(itemId)) return;
6570
+ var hasStart = typeof executedAt === "number" && executedAt > 0;
6571
+ for (var i = this.state.messages.length - 1; i >= 0; i--) {
6572
+ var m = this.state.messages[i];
6573
+ if (!m || m.role !== "assistant" || m._serverItemId !== itemId) continue;
6574
+ if (m.isPending) continue;
6575
+ if (typeof m._ts !== "number") m._ts = Date.now();
6576
+ if (hasStart) m._tsStart = executedAt;
6577
+ this.host.notify();
6578
+ this.updateHistoryCache();
6579
+ break;
6580
+ }
6581
+ }
6582
+ handleHistoryItemResolution(itemId, response, platform, executedAt) {
6554
6583
  var indexRef = this._indexRefOfItem(itemId);
6555
6584
  this.applyHistoryItemResolution(itemId, response, platform);
6585
+ this._stampPassDuration(itemId, executedAt);
6556
6586
  this.promoteNextBgQueuedToRunning();
6557
6587
  this.drainBgTaskQueue();
6558
6588
  if (indexRef) this._followWorkerIndexingChain(indexRef.name, indexRef.mime);
@@ -6999,14 +7029,20 @@ var ChatSession = class {
6999
7029
  var capturedId = entry2.id, capturedPlat = plat;
7000
7030
  var capturedEntry = entry2;
7001
7031
  var wasStopped = false;
7002
- var bp = entry2.poll({ latency: POLL_INTERVAL });
7032
+ var executedAt;
7033
+ var bp = entry2.poll({
7034
+ latency: POLL_INTERVAL,
7035
+ onResponse: function(_res, meta) {
7036
+ if (meta && typeof meta.executed === "number" && meta.executed > 0) executedAt = meta.executed;
7037
+ }
7038
+ });
7003
7039
  self._trackPoll(entry2.id, "bg", bp);
7004
7040
  bp.then(function(response) {
7005
7041
  if (isPollStopped(response)) {
7006
7042
  wasStopped = true;
7007
7043
  return;
7008
7044
  }
7009
- self.handleHistoryItemResolution(capturedId, response, capturedPlat);
7045
+ self.handleHistoryItemResolution(capturedId, response, capturedPlat, executedAt);
7010
7046
  self.maybeResumeIndexing(capturedEntry, response, capturedPlat);
7011
7047
  }).catch(function(err) {
7012
7048
  self.historyItemPolls.delete(capturedId);
@@ -7575,9 +7611,14 @@ var ChatSession = class {
7575
7611
  var capturedId = item.id;
7576
7612
  var isBg = !!(item._isBgTask || item._isOnBgQueue);
7577
7613
  var pollOpts = {
7578
- onResponse: function(response) {
7614
+ // `meta.executed` rides on the poll's running ticks, so a pass this
7615
+ // path re-attached to (a reload or a remount while its chain was
7616
+ // still going) shows its duration at settle exactly as one polled
7617
+ // from the drain does. Without it, only passes started in this page
7618
+ // life would be stamped.
7619
+ onResponse: function(response, meta) {
7579
7620
  if (isPollStopped(response)) return;
7580
- self.handleHistoryItemResolution(capturedId, response, platform);
7621
+ self.handleHistoryItemResolution(capturedId, response, platform, meta && meta.executed);
7581
7622
  },
7582
7623
  onError: function(err) {
7583
7624
  self.historyItemPolls.delete(capturedId);