@adhdev/daemon-core 0.9.82-rc.77 → 0.9.82-rc.79

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.
@@ -43,6 +43,11 @@ type CompletedDebouncePending = {
43
43
  loggedBlockReason?: string;
44
44
  };
45
45
 
46
+ type CompletedFinalizationBlock = {
47
+ reason: string;
48
+ terminal?: boolean;
49
+ };
50
+
46
51
  const COMPLETED_FINALIZATION_RETRY_MS = 1000;
47
52
  const COMPLETED_FINALIZATION_MAX_WAIT_MS = 30_000;
48
53
 
@@ -817,29 +822,34 @@ export class CliProviderInstance implements ProviderInstance {
817
822
  return !this.hasAdapterPendingResponse();
818
823
  }
819
824
 
820
- private getCompletedFinalizationBlockReason(latestVisibleStatus: string): string | null {
821
- if (latestVisibleStatus !== 'idle') return `status:${latestVisibleStatus}`;
825
+ private getCompletedFinalizationBlock(latestVisibleStatus: string): CompletedFinalizationBlock | null {
826
+ if (latestVisibleStatus !== 'idle') return { reason: `status:${latestVisibleStatus}`, terminal: true };
822
827
 
823
828
  const adapterAny = this.adapter as any;
824
- if (adapterAny?.isWaitingForResponse === true) return 'adapter_waiting_for_response';
825
- if (adapterAny?.currentTurnScope) return 'adapter_turn_scope_active';
829
+ if (adapterAny?.isWaitingForResponse === true) return { reason: 'adapter_waiting_for_response', terminal: true };
830
+ if (adapterAny?.currentTurnScope) return { reason: 'adapter_turn_scope_active', terminal: true };
831
+ if (this.hasAdapterPendingResponse()) return { reason: 'adapter_pending_response', terminal: true };
826
832
 
827
833
  const partial = typeof this.adapter.getPartialResponse === 'function'
828
834
  ? this.adapter.getPartialResponse()
829
835
  : '';
830
- if (typeof partial === 'string' && partial.trim()) return 'partial_response_pending';
836
+ if (typeof partial === 'string' && partial.trim()) return { reason: 'partial_response_pending', terminal: true };
831
837
 
832
838
  let parsed: any;
833
839
  try {
834
840
  parsed = this.adapter.getScriptParsedStatus();
835
841
  } catch (error: any) {
836
- return `parse_error:${error?.message || String(error)}`;
842
+ return { reason: `parse_error:${error?.message || String(error)}` };
837
843
  }
838
844
 
839
845
  const parsedStatus = typeof parsed?.status === 'string' ? parsed.status : 'unknown';
840
- if (parsedStatus !== 'idle') return `parsed_status:${parsedStatus}`;
841
- if (parsed?.activeModal || parsed?.modal) return 'parsed_modal_active';
842
- if (!this.completionHasFinalAssistantMessage(parsed?.messages)) return 'missing_final_assistant';
846
+ if (parsedStatus !== 'idle') {
847
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
848
+ if (this.shouldSuppressStaleParsedBusyStatus(parsed, adapterStatus)) return null;
849
+ return { reason: `parsed_status:${parsedStatus}`, terminal: isCliGeneratingLikeStatus(parsedStatus) };
850
+ }
851
+ if (parsed?.activeModal || parsed?.modal) return { reason: 'parsed_modal_active', terminal: true };
852
+ if (!this.completionHasFinalAssistantMessage(parsed?.messages)) return { reason: 'missing_final_assistant' };
843
853
 
844
854
  return null;
845
855
  }
@@ -866,10 +876,11 @@ export class CliProviderInstance implements ProviderInstance {
866
876
  return;
867
877
  }
868
878
 
869
- const blockReason = this.getCompletedFinalizationBlockReason(latestVisibleStatus);
870
- if (blockReason) {
879
+ const block = this.getCompletedFinalizationBlock(latestVisibleStatus);
880
+ if (block) {
881
+ const blockReason = block.reason;
871
882
  const waitedMs = Date.now() - pending.firstObservedAt;
872
- if (waitedMs < COMPLETED_FINALIZATION_MAX_WAIT_MS) {
883
+ if (block.terminal || waitedMs < COMPLETED_FINALIZATION_MAX_WAIT_MS) {
873
884
  if (pending.loggedBlockReason !== blockReason) {
874
885
  LOG.info('CLI', `[${this.type}] waiting to emit completed until transcript finalizes (${blockReason})`);
875
886
  pending.loggedBlockReason = blockReason;