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/cli/index.js CHANGED
@@ -13537,6 +13537,14 @@ var init_provider_cli_adapter = __esm({
13537
13537
  }
13538
13538
  this.resolveStartupState("settled");
13539
13539
  if (this.startupParseGate) return;
13540
+ if (!this.isWaitingForResponse && !this.currentTurnScope && !this.activeModal && !this.parseErrorMessage) {
13541
+ const tail = this.settledBuffer || this.recentOutputBuffer;
13542
+ const modal2 = this.runParseApproval(tail);
13543
+ const lightweightStatus = this.cliScripts?.detectStatus ? this.runDetectStatus(tail) : null;
13544
+ if (!modal2 && lightweightStatus === "idle" && this.currentStatus === "idle") {
13545
+ return;
13546
+ }
13547
+ }
13540
13548
  const session = this.runParseSession();
13541
13549
  if (!session) return;
13542
13550
  const { status, messages, modal, parsedStatus } = session;
@@ -15050,17 +15058,24 @@ function buildPersistableCliHistorySignature(message) {
15050
15058
  normalizePersistableCliHistoryContent(message.content)
15051
15059
  ].join("|");
15052
15060
  }
15061
+ function hasSamePersistableCliHistoryIdentity(a, b) {
15062
+ 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 || "");
15063
+ }
15053
15064
  function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages) {
15054
15065
  if (!Array.isArray(currentMessages) || currentMessages.length === 0) return [];
15055
15066
  if (!Array.isArray(previousMessages) || previousMessages.length === 0) return currentMessages;
15056
- const previousSignatures = previousMessages.map(buildPersistableCliHistorySignature);
15057
- const currentSignatures = currentMessages.map(buildPersistableCliHistorySignature);
15067
+ const comparableLength = Math.min(previousMessages.length, currentMessages.length);
15058
15068
  let sharedPrefixLength = 0;
15059
- while (sharedPrefixLength < previousSignatures.length && sharedPrefixLength < currentSignatures.length && previousSignatures[sharedPrefixLength] === currentSignatures[sharedPrefixLength]) {
15069
+ while (sharedPrefixLength < comparableLength && hasSamePersistableCliHistoryIdentity(previousMessages[sharedPrefixLength], currentMessages[sharedPrefixLength])) {
15070
+ sharedPrefixLength += 1;
15071
+ }
15072
+ if (sharedPrefixLength === currentMessages.length) return [];
15073
+ if (sharedPrefixLength === previousMessages.length) return currentMessages.slice(sharedPrefixLength);
15074
+ while (sharedPrefixLength < comparableLength && buildPersistableCliHistorySignature(previousMessages[sharedPrefixLength]) === buildPersistableCliHistorySignature(currentMessages[sharedPrefixLength])) {
15060
15075
  sharedPrefixLength += 1;
15061
15076
  }
15062
- if (sharedPrefixLength === currentSignatures.length) return [];
15063
- if (sharedPrefixLength === previousSignatures.length) return currentMessages.slice(sharedPrefixLength);
15077
+ if (sharedPrefixLength === currentMessages.length) return [];
15078
+ if (sharedPrefixLength === previousMessages.length) return currentMessages.slice(sharedPrefixLength);
15064
15079
  return currentMessages;
15065
15080
  }
15066
15081
  function getDatabaseSync() {
@@ -15327,13 +15342,15 @@ var init_cli_provider_instance = __esm({
15327
15342
  }));
15328
15343
  if (!canonicalBackedHistory && !shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
15329
15344
  const incrementalMessages = buildIncrementalHistoryAppendMessages(this.lastPersistedHistoryMessages, normalizedMessagesToSave);
15330
- this.historyWriter.appendNewMessages(
15331
- this.type,
15332
- incrementalMessages,
15333
- parsedStatus?.title || dirName,
15334
- this.instanceId,
15335
- this.providerSessionId
15336
- );
15345
+ if (incrementalMessages.length > 0) {
15346
+ this.historyWriter.appendNewMessages(
15347
+ this.type,
15348
+ incrementalMessages,
15349
+ parsedStatus?.title || dirName,
15350
+ this.instanceId,
15351
+ this.providerSessionId
15352
+ );
15353
+ }
15337
15354
  }
15338
15355
  if (!canonicalBackedHistory) {
15339
15356
  this.lastPersistedHistoryMessages = normalizedMessagesToSave;
@@ -15468,8 +15485,8 @@ var init_cli_provider_instance = __esm({
15468
15485
  }
15469
15486
  detectStatusTransition() {
15470
15487
  const now = Date.now();
15471
- const adapterStatus = this.adapter.getStatus();
15472
- const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
15488
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
15489
+ const parsedStatus = null;
15473
15490
  const rawStatus = adapterStatus.status;
15474
15491
  const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
15475
15492
  if (autoApproveActive && !this.autoApproveBusy) {
@@ -15562,7 +15579,7 @@ var init_cli_provider_instance = __esm({
15562
15579
  this.completedDebouncePending = { chatTitle, duration: duration3, timestamp: now };
15563
15580
  this.completedDebounceTimer = setTimeout(() => {
15564
15581
  if (this.completedDebouncePending) {
15565
- const latestStatus = this.adapter.getStatus();
15582
+ const latestStatus = this.adapter.getStatus({ allowParse: false });
15566
15583
  const latestAutoApproveActive = latestStatus.status === "waiting_approval" && this.shouldAutoApprove();
15567
15584
  const latestVisibleStatus = latestAutoApproveActive ? "generating" : latestStatus.status;
15568
15585
  if (latestVisibleStatus !== "idle") {
@@ -88295,7 +88312,7 @@ var init_adhdev_daemon = __esm({
88295
88312
  init_version();
88296
88313
  init_src();
88297
88314
  init_runtime_defaults();
88298
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.37" });
88315
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.39" });
88299
88316
  AdhdevDaemon = class _AdhdevDaemon {
88300
88317
  localHttpServer = null;
88301
88318
  localWss = null;
@@ -88613,12 +88630,24 @@ var init_adhdev_daemon = __esm({
88613
88630
  }
88614
88631
  findProviderStateBySessionId(sessionId) {
88615
88632
  if (!this.components || !sessionId) return null;
88616
- const states = this.components.instanceManager.collectAllStates();
88617
- for (const state of states) {
88618
- if (state.instanceId === sessionId) return state;
88619
- if (state.category === "ide") {
88633
+ const directInstance = this.components.instanceManager.getInstance(sessionId);
88634
+ if (directInstance) {
88635
+ try {
88636
+ return directInstance.getState();
88637
+ } catch (error48) {
88638
+ LOG.warn("P2P", `Failed to collect subscribed session state for ${sessionId}: ${error48?.message || String(error48)}`);
88639
+ return null;
88640
+ }
88641
+ }
88642
+ for (const instance of this.components.instanceManager.getByCategory("ide")) {
88643
+ try {
88644
+ const state = instance.getState();
88645
+ if (state.instanceId === sessionId) return state;
88646
+ if (state.category !== "ide") continue;
88620
88647
  const child = state.extensions.find((entry) => entry.instanceId === sessionId);
88621
88648
  if (child) return child;
88649
+ } catch (error48) {
88650
+ LOG.warn("P2P", `Failed to collect IDE child state for ${sessionId}: ${error48?.message || String(error48)}`);
88622
88651
  }
88623
88652
  }
88624
88653
  return null;