bunnyquery 1.4.4 → 1.4.5

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/engine.mjs CHANGED
@@ -1122,11 +1122,17 @@ var ChatSession = class {
1122
1122
  }
1123
1123
  dispatchAgentRequest(params) {
1124
1124
  var self = this;
1125
+ var dispatchItemId;
1125
1126
  var sendAndPoll = function() {
1126
1127
  return Promise.resolve(
1127
1128
  self._callProviderFor(params.aiPlatform, params.text, params.boundedMessages, params.systemPrompt, params.aiModel, params.userId, params.extractContent)
1128
1129
  ).then(function(initial) {
1129
1130
  if (initial && initial.poll && (initial.status === "pending" || initial.status === "running")) {
1131
+ if (initial.id) {
1132
+ if (dispatchItemId && dispatchItemId !== initial.id) self.historyItemPolls.delete(dispatchItemId);
1133
+ dispatchItemId = initial.id;
1134
+ self.historyItemPolls.set(initial.id, true);
1135
+ }
1130
1136
  return initial.poll({ latency: POLL_INTERVAL });
1131
1137
  }
1132
1138
  return initial;
@@ -1149,6 +1155,7 @@ var ChatSession = class {
1149
1155
  return { content: getErrorMessage(err), isError: true };
1150
1156
  }).then(function(result) {
1151
1157
  delete self.pendingAgentRequests[params.key];
1158
+ if (dispatchItemId) self.historyItemPolls.delete(dispatchItemId);
1152
1159
  var existing = self.aiChatHistoryCache[params.key] || { messages: [], endOfList: false, startKeyHistory: [] };
1153
1160
  var reply = { role: "assistant", content: result.content, isError: result.isError };
1154
1161
  var onThisVisibleChat = self.host.isViewMounted() && self.getHistoryCacheKey() === params.key;
@@ -1232,6 +1239,7 @@ var ChatSession = class {
1232
1239
  self.host.notify();
1233
1240
  }
1234
1241
  if (result && result.poll && (result.status === "pending" || result.status === "running")) {
1242
+ if (serverId) self.historyItemPolls.set(serverId, true);
1235
1243
  return result.poll({ latency: POLL_INTERVAL }).then(function(res) {
1236
1244
  return self.onQueuedSendResponse(capturedComposed, res, capturedPlatform, serverId);
1237
1245
  }).catch(function(err) {
@@ -1371,6 +1379,7 @@ var ChatSession = class {
1371
1379
  else this.state.messages.push(msg);
1372
1380
  }
1373
1381
  onQueuedSendResponse(_composed, response, platform, serverId) {
1382
+ if (serverId) this.historyItemPolls.delete(serverId);
1374
1383
  var targetIdx = this.resolveQueuedUserBubble(serverId);
1375
1384
  if (targetIdx === void 0) {
1376
1385
  this.host.notify();
@@ -1405,6 +1414,7 @@ var ChatSession = class {
1405
1414
  this.host.scrollToBottom(true);
1406
1415
  }
1407
1416
  onQueuedSendError(_composed, err, serverId) {
1417
+ if (serverId) this.historyItemPolls.delete(serverId);
1408
1418
  var isNotExists = err && (err.code === "NOT_EXISTS" || err.body && err.body.code === "NOT_EXISTS");
1409
1419
  if (isNotExists) {
1410
1420
  var userIdx = serverId ? this.state.messages.findIndex(function(m) {