@adhdev/daemon-standalone 0.9.37 → 0.9.38

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
@@ -41051,17 +41051,24 @@ ${effect.notification.body || ""}`.trim();
41051
41051
  normalizePersistableCliHistoryContent(message.content)
41052
41052
  ].join("|");
41053
41053
  }
41054
+ function hasSamePersistableCliHistoryIdentity(a, b2) {
41055
+ return String(a?.role || "") === String(b2?.role || "") && String(a?.kind || "") === String(b2?.kind || "") && String(a?.senderName || "") === String(b2?.senderName || "") && String(a?.content || "") === String(b2?.content || "");
41056
+ }
41054
41057
  function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages) {
41055
41058
  if (!Array.isArray(currentMessages) || currentMessages.length === 0) return [];
41056
41059
  if (!Array.isArray(previousMessages) || previousMessages.length === 0) return currentMessages;
41057
- const previousSignatures = previousMessages.map(buildPersistableCliHistorySignature);
41058
- const currentSignatures = currentMessages.map(buildPersistableCliHistorySignature);
41060
+ const comparableLength = Math.min(previousMessages.length, currentMessages.length);
41059
41061
  let sharedPrefixLength = 0;
41060
- while (sharedPrefixLength < previousSignatures.length && sharedPrefixLength < currentSignatures.length && previousSignatures[sharedPrefixLength] === currentSignatures[sharedPrefixLength]) {
41062
+ while (sharedPrefixLength < comparableLength && hasSamePersistableCliHistoryIdentity(previousMessages[sharedPrefixLength], currentMessages[sharedPrefixLength])) {
41063
+ sharedPrefixLength += 1;
41064
+ }
41065
+ if (sharedPrefixLength === currentMessages.length) return [];
41066
+ if (sharedPrefixLength === previousMessages.length) return currentMessages.slice(sharedPrefixLength);
41067
+ while (sharedPrefixLength < comparableLength && buildPersistableCliHistorySignature(previousMessages[sharedPrefixLength]) === buildPersistableCliHistorySignature(currentMessages[sharedPrefixLength])) {
41061
41068
  sharedPrefixLength += 1;
41062
41069
  }
41063
- if (sharedPrefixLength === currentSignatures.length) return [];
41064
- if (sharedPrefixLength === previousSignatures.length) return currentMessages.slice(sharedPrefixLength);
41070
+ if (sharedPrefixLength === currentMessages.length) return [];
41071
+ if (sharedPrefixLength === previousMessages.length) return currentMessages.slice(sharedPrefixLength);
41065
41072
  return currentMessages;
41066
41073
  }
41067
41074
  var CachedDatabaseSync = null;
@@ -41307,13 +41314,15 @@ ${effect.notification.body || ""}`.trim();
41307
41314
  }));
41308
41315
  if (!canonicalBackedHistory && !shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
41309
41316
  const incrementalMessages = buildIncrementalHistoryAppendMessages(this.lastPersistedHistoryMessages, normalizedMessagesToSave);
41310
- this.historyWriter.appendNewMessages(
41311
- this.type,
41312
- incrementalMessages,
41313
- parsedStatus?.title || dirName,
41314
- this.instanceId,
41315
- this.providerSessionId
41316
- );
41317
+ if (incrementalMessages.length > 0) {
41318
+ this.historyWriter.appendNewMessages(
41319
+ this.type,
41320
+ incrementalMessages,
41321
+ parsedStatus?.title || dirName,
41322
+ this.instanceId,
41323
+ this.providerSessionId
41324
+ );
41325
+ }
41317
41326
  }
41318
41327
  if (!canonicalBackedHistory) {
41319
41328
  this.lastPersistedHistoryMessages = normalizedMessagesToSave;