adhdev 0.9.37 → 0.9.39

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
@@ -12581,6 +12581,14 @@ var init_provider_cli_adapter = __esm({
12581
12581
  }
12582
12582
  this.resolveStartupState("settled");
12583
12583
  if (this.startupParseGate) return;
12584
+ if (!this.isWaitingForResponse && !this.currentTurnScope && !this.activeModal && !this.parseErrorMessage) {
12585
+ const tail = this.settledBuffer || this.recentOutputBuffer;
12586
+ const modal2 = this.runParseApproval(tail);
12587
+ const lightweightStatus = this.cliScripts?.detectStatus ? this.runDetectStatus(tail) : null;
12588
+ if (!modal2 && lightweightStatus === "idle" && this.currentStatus === "idle") {
12589
+ return;
12590
+ }
12591
+ }
12584
12592
  const session = this.runParseSession();
12585
12593
  if (!session) return;
12586
12594
  const { status, messages, modal, parsedStatus } = session;
@@ -14094,17 +14102,24 @@ function buildPersistableCliHistorySignature(message) {
14094
14102
  normalizePersistableCliHistoryContent(message.content)
14095
14103
  ].join("|");
14096
14104
  }
14105
+ function hasSamePersistableCliHistoryIdentity(a, b) {
14106
+ return String(a?.role || "") === String(b?.role || "") && String(a?.kind || "") === String(b?.kind || "") && String(a?.senderName || "") === String(b?.senderName || "") && String(a?.content || "") === String(b?.content || "");
14107
+ }
14097
14108
  function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages) {
14098
14109
  if (!Array.isArray(currentMessages) || currentMessages.length === 0) return [];
14099
14110
  if (!Array.isArray(previousMessages) || previousMessages.length === 0) return currentMessages;
14100
- const previousSignatures = previousMessages.map(buildPersistableCliHistorySignature);
14101
- const currentSignatures = currentMessages.map(buildPersistableCliHistorySignature);
14111
+ const comparableLength = Math.min(previousMessages.length, currentMessages.length);
14102
14112
  let sharedPrefixLength = 0;
14103
- while (sharedPrefixLength < previousSignatures.length && sharedPrefixLength < currentSignatures.length && previousSignatures[sharedPrefixLength] === currentSignatures[sharedPrefixLength]) {
14113
+ while (sharedPrefixLength < comparableLength && hasSamePersistableCliHistoryIdentity(previousMessages[sharedPrefixLength], currentMessages[sharedPrefixLength])) {
14114
+ sharedPrefixLength += 1;
14115
+ }
14116
+ if (sharedPrefixLength === currentMessages.length) return [];
14117
+ if (sharedPrefixLength === previousMessages.length) return currentMessages.slice(sharedPrefixLength);
14118
+ while (sharedPrefixLength < comparableLength && buildPersistableCliHistorySignature(previousMessages[sharedPrefixLength]) === buildPersistableCliHistorySignature(currentMessages[sharedPrefixLength])) {
14104
14119
  sharedPrefixLength += 1;
14105
14120
  }
14106
- if (sharedPrefixLength === currentSignatures.length) return [];
14107
- if (sharedPrefixLength === previousSignatures.length) return currentMessages.slice(sharedPrefixLength);
14121
+ if (sharedPrefixLength === currentMessages.length) return [];
14122
+ if (sharedPrefixLength === previousMessages.length) return currentMessages.slice(sharedPrefixLength);
14108
14123
  return currentMessages;
14109
14124
  }
14110
14125
  function getDatabaseSync() {
@@ -14371,13 +14386,15 @@ var init_cli_provider_instance = __esm({
14371
14386
  }));
14372
14387
  if (!canonicalBackedHistory && !shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
14373
14388
  const incrementalMessages = buildIncrementalHistoryAppendMessages(this.lastPersistedHistoryMessages, normalizedMessagesToSave);
14374
- this.historyWriter.appendNewMessages(
14375
- this.type,
14376
- incrementalMessages,
14377
- parsedStatus?.title || dirName,
14378
- this.instanceId,
14379
- this.providerSessionId
14380
- );
14389
+ if (incrementalMessages.length > 0) {
14390
+ this.historyWriter.appendNewMessages(
14391
+ this.type,
14392
+ incrementalMessages,
14393
+ parsedStatus?.title || dirName,
14394
+ this.instanceId,
14395
+ this.providerSessionId
14396
+ );
14397
+ }
14381
14398
  }
14382
14399
  if (!canonicalBackedHistory) {
14383
14400
  this.lastPersistedHistoryMessages = normalizedMessagesToSave;
@@ -14512,8 +14529,8 @@ var init_cli_provider_instance = __esm({
14512
14529
  }
14513
14530
  detectStatusTransition() {
14514
14531
  const now = Date.now();
14515
- const adapterStatus = this.adapter.getStatus();
14516
- const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
14532
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
14533
+ const parsedStatus = null;
14517
14534
  const rawStatus = adapterStatus.status;
14518
14535
  const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
14519
14536
  if (autoApproveActive && !this.autoApproveBusy) {
@@ -14606,7 +14623,7 @@ var init_cli_provider_instance = __esm({
14606
14623
  this.completedDebouncePending = { chatTitle, duration: duration3, timestamp: now };
14607
14624
  this.completedDebounceTimer = setTimeout(() => {
14608
14625
  if (this.completedDebouncePending) {
14609
- const latestStatus = this.adapter.getStatus();
14626
+ const latestStatus = this.adapter.getStatus({ allowParse: false });
14610
14627
  const latestAutoApproveActive = latestStatus.status === "waiting_approval" && this.shouldAutoApprove();
14611
14628
  const latestVisibleStatus = latestAutoApproveActive ? "generating" : latestStatus.status;
14612
14629
  if (latestVisibleStatus !== "idle") {
@@ -56575,7 +56592,7 @@ var init_adhdev_daemon = __esm({
56575
56592
  init_version();
56576
56593
  init_src();
56577
56594
  init_runtime_defaults();
56578
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.37" });
56595
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.39" });
56579
56596
  AdhdevDaemon = class _AdhdevDaemon {
56580
56597
  localHttpServer = null;
56581
56598
  localWss = null;
@@ -56893,12 +56910,24 @@ var init_adhdev_daemon = __esm({
56893
56910
  }
56894
56911
  findProviderStateBySessionId(sessionId) {
56895
56912
  if (!this.components || !sessionId) return null;
56896
- const states = this.components.instanceManager.collectAllStates();
56897
- for (const state of states) {
56898
- if (state.instanceId === sessionId) return state;
56899
- if (state.category === "ide") {
56913
+ const directInstance = this.components.instanceManager.getInstance(sessionId);
56914
+ if (directInstance) {
56915
+ try {
56916
+ return directInstance.getState();
56917
+ } catch (error48) {
56918
+ LOG.warn("P2P", `Failed to collect subscribed session state for ${sessionId}: ${error48?.message || String(error48)}`);
56919
+ return null;
56920
+ }
56921
+ }
56922
+ for (const instance of this.components.instanceManager.getByCategory("ide")) {
56923
+ try {
56924
+ const state = instance.getState();
56925
+ if (state.instanceId === sessionId) return state;
56926
+ if (state.category !== "ide") continue;
56900
56927
  const child = state.extensions.find((entry) => entry.instanceId === sessionId);
56901
56928
  if (child) return child;
56929
+ } catch (error48) {
56930
+ LOG.warn("P2P", `Failed to collect IDE child state for ${sessionId}: ${error48?.message || String(error48)}`);
56902
56931
  }
56903
56932
  }
56904
56933
  return null;