adhdev 0.8.63 → 0.8.65

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
@@ -974,6 +974,51 @@ var init_host_memory = __esm({
974
974
  }
975
975
  });
976
976
 
977
+ // ../../oss/packages/daemon-core/src/status/chat-tail-hot-sessions.ts
978
+ function parseMessageTimestamp(value) {
979
+ if (typeof value === "number" && Number.isFinite(value)) return value;
980
+ if (typeof value === "string") {
981
+ const parsed = Date.parse(value);
982
+ if (Number.isFinite(parsed)) return parsed;
983
+ }
984
+ return 0;
985
+ }
986
+ function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessionIds, options = {}) {
987
+ const now = options.now ?? Date.now();
988
+ const recentMessageGraceMs = Math.max(
989
+ 0,
990
+ Number.isFinite(options.recentMessageGraceMs) ? Number(options.recentMessageGraceMs) : DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS
991
+ );
992
+ const activeStatuses = options.activeStatuses ?? DEFAULT_ACTIVE_CHAT_POLL_STATUSES;
993
+ const active = /* @__PURE__ */ new Set();
994
+ for (const session of sessions) {
995
+ const sessionId = typeof session?.id === "string" ? session.id : "";
996
+ if (!sessionId) continue;
997
+ const status = String(session?.status || "").toLowerCase();
998
+ const lastMessageAt = parseMessageTimestamp(session?.lastMessageAt);
999
+ const recentlyUpdated = lastMessageAt > 0 && now - lastMessageAt <= recentMessageGraceMs;
1000
+ if (activeStatuses.has(status) || recentlyUpdated) {
1001
+ active.add(sessionId);
1002
+ }
1003
+ }
1004
+ const finalizing = new Set(
1005
+ Array.from(previousHotSessionIds).filter((sessionId) => !active.has(sessionId))
1006
+ );
1007
+ return { active, finalizing };
1008
+ }
1009
+ var DEFAULT_ACTIVE_CHAT_POLL_STATUSES, DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS;
1010
+ var init_chat_tail_hot_sessions = __esm({
1011
+ "../../oss/packages/daemon-core/src/status/chat-tail-hot-sessions.ts"() {
1012
+ "use strict";
1013
+ DEFAULT_ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
1014
+ "generating",
1015
+ "waiting_approval",
1016
+ "starting"
1017
+ ]);
1018
+ DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS = 8e3;
1019
+ }
1020
+ });
1021
+
977
1022
  // ../../oss/packages/daemon-core/src/logging/logger.ts
978
1023
  function setLogLevel(level) {
979
1024
  currentLevel = level;
@@ -2839,19 +2884,75 @@ var init_status_monitor = __esm({
2839
2884
  });
2840
2885
 
2841
2886
  // ../../oss/packages/daemon-core/src/providers/chat-message-normalization.ts
2887
+ function canonicalizeKindHint(value) {
2888
+ return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
2889
+ }
2890
+ function resolveBuiltinOrAliasKind(kind) {
2891
+ if (typeof kind !== "string") return null;
2892
+ const normalizedKind = canonicalizeKindHint(kind);
2893
+ if (!normalizedKind) return null;
2894
+ if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
2895
+ return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
2896
+ }
2897
+ function inferHintKind(value) {
2898
+ const direct = resolveBuiltinOrAliasKind(value);
2899
+ if (direct) return direct;
2900
+ if (typeof value !== "string") return null;
2901
+ const normalized = canonicalizeKindHint(value);
2902
+ if (!normalized) return null;
2903
+ if (/thought|thinking|reasoning/.test(normalized)) return "thought";
2904
+ if (/tool/.test(normalized)) return "tool";
2905
+ if (/terminal|command|shell|console/.test(normalized)) return "terminal";
2906
+ return null;
2907
+ }
2908
+ function inferKindFromToolCalls(message) {
2909
+ const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
2910
+ if (toolCalls.length === 0) return null;
2911
+ if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
2912
+ if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
2913
+ if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
2914
+ return "terminal";
2915
+ }
2916
+ return "tool";
2917
+ }
2918
+ function inferMissingChatMessageKind(message) {
2919
+ const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
2920
+ if (role === "system") return "system";
2921
+ const meta3 = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
2922
+ const hintCandidates = [
2923
+ message?._sub,
2924
+ message?._type,
2925
+ meta3?.label,
2926
+ typeof message?.senderName === "string" ? message.senderName : void 0
2927
+ ];
2928
+ for (const candidate of hintCandidates) {
2929
+ const inferred = inferHintKind(candidate);
2930
+ if (inferred) return inferred;
2931
+ }
2932
+ const inferredFromToolCalls = inferKindFromToolCalls(message);
2933
+ if (inferredFromToolCalls) return inferredFromToolCalls;
2934
+ return null;
2935
+ }
2842
2936
  function isBuiltinChatMessageKind(kind) {
2843
- return typeof kind === "string" && KNOWN_CHAT_MESSAGE_KINDS.has(kind.trim().toLowerCase());
2937
+ return resolveBuiltinOrAliasKind(kind) !== null;
2844
2938
  }
2845
2939
  function normalizeChatMessageKind(kind, role) {
2846
- const normalizedKind = typeof kind === "string" ? kind.trim().toLowerCase() : "";
2847
- if (normalizedKind && KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
2940
+ const resolvedKind = resolveBuiltinOrAliasKind(kind);
2941
+ if (resolvedKind) return resolvedKind;
2848
2942
  const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
2849
2943
  return normalizedRole === "system" ? "system" : "standard";
2850
2944
  }
2945
+ function resolveChatMessageKind(message) {
2946
+ const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
2947
+ if (explicitKind) return explicitKind;
2948
+ const inferredKind = inferMissingChatMessageKind(message);
2949
+ if (inferredKind) return inferredKind;
2950
+ return normalizeChatMessageKind(message?.kind, message?.role);
2951
+ }
2851
2952
  function buildChatMessage(message) {
2852
2953
  return {
2853
2954
  ...message,
2854
- kind: normalizeChatMessageKind(message?.kind, message?.role)
2955
+ kind: resolveChatMessageKind(message)
2855
2956
  };
2856
2957
  }
2857
2958
  function buildSystemChatMessage(message) {
@@ -2874,6 +2975,24 @@ function buildAssistantChatMessage(message) {
2874
2975
  kind: message?.kind || "standard"
2875
2976
  });
2876
2977
  }
2978
+ function buildThoughtChatMessage(message) {
2979
+ return buildAssistantChatMessage({
2980
+ ...message,
2981
+ kind: message?.kind || "thought"
2982
+ });
2983
+ }
2984
+ function buildToolChatMessage(message) {
2985
+ return buildAssistantChatMessage({
2986
+ ...message,
2987
+ kind: message?.kind || "tool"
2988
+ });
2989
+ }
2990
+ function buildTerminalChatMessage(message) {
2991
+ return buildAssistantChatMessage({
2992
+ ...message,
2993
+ kind: message?.kind || "terminal"
2994
+ });
2995
+ }
2877
2996
  function buildUserChatMessage(message) {
2878
2997
  return buildChatMessage({
2879
2998
  ...message,
@@ -2887,12 +3006,30 @@ function normalizeChatMessage(message) {
2887
3006
  function normalizeChatMessages(messages) {
2888
3007
  return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
2889
3008
  }
2890
- var BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS;
3009
+ var BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES;
2891
3010
  var init_chat_message_normalization = __esm({
2892
3011
  "../../oss/packages/daemon-core/src/providers/chat-message-normalization.ts"() {
2893
3012
  "use strict";
2894
3013
  BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
2895
3014
  KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
3015
+ CHAT_MESSAGE_KIND_ALIASES = {
3016
+ text: "standard",
3017
+ message: "standard",
3018
+ assistant: "standard",
3019
+ thinking: "thought",
3020
+ think: "thought",
3021
+ reasoning: "thought",
3022
+ reason: "thought",
3023
+ toolcall: "tool",
3024
+ tool_call: "tool",
3025
+ tooluse: "tool",
3026
+ tool_use: "tool",
3027
+ action: "tool",
3028
+ command: "terminal",
3029
+ cmd: "terminal",
3030
+ shell: "terminal",
3031
+ console: "terminal"
3032
+ };
2896
3033
  }
2897
3034
  });
2898
3035
 
@@ -4377,11 +4514,13 @@ var init_ide_provider_instance = __esm({
4377
4514
  if (pm.receivedAt) prevByHash.set(h, pm.receivedAt);
4378
4515
  }
4379
4516
  const now = Date.now();
4380
- const messages = chat.messages || [];
4381
- for (const msg of messages) {
4517
+ const rawMessages = chat.messages || [];
4518
+ for (const msg of rawMessages) {
4382
4519
  const h = `${msg.role}:${(msg.content || "").slice(0, 100)}`;
4383
4520
  msg.receivedAt = prevByHash.get(h) || now;
4384
4521
  }
4522
+ chat.messages = normalizeChatMessages(rawMessages);
4523
+ const messages = chat.messages || [];
4385
4524
  if (messages.length > 0) {
4386
4525
  const hiddenKinds = /* @__PURE__ */ new Set();
4387
4526
  if (this.settings.showThinking === false) hiddenKinds.add("thought");
@@ -28692,6 +28831,7 @@ var init_acp_provider_instance = __esm({
28692
28831
  activeToolCalls = [];
28693
28832
  stopReason = null;
28694
28833
  partialContent = "";
28834
+ partialThoughtContent = "";
28695
28835
  /** Rich content blocks accumulated during streaming */
28696
28836
  partialBlocks = [];
28697
28837
  /** Tool calls collected during current turn */
@@ -28737,6 +28877,10 @@ var init_acp_provider_instance = __esm({
28737
28877
  content
28738
28878
  });
28739
28879
  }));
28880
+ if (this.currentStatus === "generating") {
28881
+ const partialThoughtMessage = this.buildPartialThoughtMessage(Date.now());
28882
+ if (partialThoughtMessage) recentMessages.push(partialThoughtMessage);
28883
+ }
28740
28884
  if (this.currentStatus === "generating" && (this.partialContent || this.partialBlocks.length > 0)) {
28741
28885
  const blocks = this.buildPartialBlocks();
28742
28886
  if (blocks.length > 0) {
@@ -29295,6 +29439,7 @@ var init_acp_provider_instance = __esm({
29295
29439
  }));
29296
29440
  this.currentStatus = "generating";
29297
29441
  this.partialContent = "";
29442
+ this.partialThoughtContent = "";
29298
29443
  this.partialBlocks = [];
29299
29444
  this.turnToolCalls = [];
29300
29445
  this.detectStatusTransition();
@@ -29377,7 +29522,14 @@ var init_acp_provider_instance = __esm({
29377
29522
  this.currentStatus = "generating";
29378
29523
  break;
29379
29524
  }
29380
- case "agent_thought_chunk":
29525
+ case "agent_thought_chunk": {
29526
+ const content = update.content;
29527
+ if (content?.type === "text" && typeof content.text === "string") {
29528
+ this.partialThoughtContent += content.text;
29529
+ }
29530
+ this.currentStatus = "generating";
29531
+ break;
29532
+ }
29381
29533
  case "user_message_chunk": {
29382
29534
  break;
29383
29535
  }
@@ -29532,8 +29684,82 @@ var init_acp_provider_instance = __esm({
29532
29684
  blocks.push(...this.partialBlocks);
29533
29685
  return blocks;
29534
29686
  }
29687
+ buildPartialThoughtMessage(timestamp = Date.now()) {
29688
+ const content = this.partialThoughtContent.trim();
29689
+ if (!content) return null;
29690
+ return buildThoughtChatMessage({
29691
+ content,
29692
+ timestamp,
29693
+ meta: {
29694
+ label: "Thought",
29695
+ isRunning: this.currentStatus === "generating"
29696
+ }
29697
+ });
29698
+ }
29699
+ buildToolCallBubbleKind(toolCall) {
29700
+ if (toolCall.kind === "think") return "thought";
29701
+ if (toolCall.kind === "execute") return "terminal";
29702
+ if (Array.isArray(toolCall.content) && toolCall.content.some((entry) => entry?.type === "terminal")) return "terminal";
29703
+ return "tool";
29704
+ }
29705
+ summarizeToolCallBubbleContent(toolCall) {
29706
+ const rawOutput = typeof toolCall.rawOutput === "string" ? toolCall.rawOutput.trim() : toolCall.rawOutput != null ? JSON.stringify(toolCall.rawOutput) : "";
29707
+ if (rawOutput) return rawOutput;
29708
+ const contentText = Array.isArray(toolCall.content) ? toolCall.content.map((entry) => {
29709
+ if (!entry || typeof entry !== "object") return "";
29710
+ if (entry.type === "content") return flattenContent([entry.content]).trim();
29711
+ if (entry.type === "diff") return `${entry.path}
29712
+ ${entry.newText || ""}`.trim();
29713
+ if (entry.type === "terminal") return `Terminal: ${entry.terminalId || ""}`.trim();
29714
+ return "";
29715
+ }).filter(Boolean).join("\n\n").trim() : "";
29716
+ if (contentText) return contentText;
29717
+ const rawInput = typeof toolCall.rawInput === "string" ? toolCall.rawInput.trim() : toolCall.rawInput != null ? JSON.stringify(toolCall.rawInput) : "";
29718
+ if (rawInput) {
29719
+ return toolCall.title ? `${toolCall.title}
29720
+ ${rawInput}` : rawInput;
29721
+ }
29722
+ return toolCall.title || "";
29723
+ }
29724
+ buildTurnToolCallMessages(timestamp = Date.now()) {
29725
+ return this.turnToolCalls.map((toolCall) => {
29726
+ const content = this.summarizeToolCallBubbleContent(toolCall);
29727
+ if (!content) return null;
29728
+ const isRunning = toolCall.status === "pending" || toolCall.status === "in_progress";
29729
+ const label = toolCall.title || void 0;
29730
+ const kind = this.buildToolCallBubbleKind(toolCall);
29731
+ if (kind === "thought") {
29732
+ return buildThoughtChatMessage({
29733
+ content,
29734
+ timestamp,
29735
+ meta: { label: label || "Thought", isRunning }
29736
+ });
29737
+ }
29738
+ if (kind === "terminal") {
29739
+ return buildTerminalChatMessage({
29740
+ content,
29741
+ timestamp,
29742
+ meta: { label: label || "Ran command", isRunning }
29743
+ });
29744
+ }
29745
+ return buildToolChatMessage({
29746
+ content,
29747
+ timestamp,
29748
+ meta: { label: label || "Tool call", isRunning }
29749
+ });
29750
+ }).filter(Boolean);
29751
+ }
29535
29752
  /** Finalize streaming content into an assistant message */
29536
29753
  finalizeAssistantMessage() {
29754
+ const timestamp = Date.now();
29755
+ const thoughtMessage = this.buildPartialThoughtMessage(timestamp);
29756
+ if (thoughtMessage) {
29757
+ this.messages.push(thoughtMessage);
29758
+ }
29759
+ const toolCallMessages = this.buildTurnToolCallMessages(timestamp);
29760
+ if (toolCallMessages.length > 0) {
29761
+ this.messages.push(...toolCallMessages);
29762
+ }
29537
29763
  const blocks = this.buildPartialBlocks();
29538
29764
  const finalBlocks = blocks.map((b) => {
29539
29765
  if (b.type === "text" && b.text.endsWith("...")) {
@@ -29549,6 +29775,7 @@ var init_acp_provider_instance = __esm({
29549
29775
  }));
29550
29776
  }
29551
29777
  this.partialContent = "";
29778
+ this.partialThoughtContent = "";
29552
29779
  this.partialBlocks = [];
29553
29780
  this.turnToolCalls = [];
29554
29781
  }
@@ -34187,6 +34414,9 @@ function parseMessageTime(value) {
34187
34414
  }
34188
34415
  return 0;
34189
34416
  }
34417
+ function getMessageEventTime(message) {
34418
+ return parseMessageTime(message?.receivedAt) || parseMessageTime(message?.timestamp) || 0;
34419
+ }
34190
34420
  function stringifyPreviewContent(content) {
34191
34421
  if (typeof content === "string") return content;
34192
34422
  if (Array.isArray(content)) {
@@ -34231,7 +34461,7 @@ function getLastDisplayMessage(session) {
34231
34461
  return {
34232
34462
  role,
34233
34463
  preview,
34234
- receivedAt: parseMessageTime(candidate?.receivedAt),
34464
+ receivedAt: getMessageEventTime(candidate),
34235
34465
  hash: simplePreviewHash(`${role}:${preview}`)
34236
34466
  };
34237
34467
  }
@@ -34240,7 +34470,7 @@ function getLastDisplayMessage(session) {
34240
34470
  function getSessionMessageUpdatedAt(session) {
34241
34471
  const lastMessage = session.activeChat?.messages?.at?.(-1);
34242
34472
  if (!lastMessage) return 0;
34243
- return parseMessageTime(lastMessage.receivedAt) || 0;
34473
+ return getMessageEventTime(lastMessage);
34244
34474
  }
34245
34475
  function getSessionCompletionMarker(session) {
34246
34476
  const lastMessage = session.activeChat?.messages?.at?.(-1);
@@ -34250,7 +34480,7 @@ function getSessionCompletionMarker(session) {
34250
34480
  if (typeof lastMessage._turnKey === "string" && lastMessage._turnKey) return `turn:${lastMessage._turnKey}`;
34251
34481
  if (typeof lastMessage.id === "string" && lastMessage.id) return `id:${lastMessage.id}`;
34252
34482
  if (typeof lastMessage.index === "number" && Number.isFinite(lastMessage.index)) return `idx:${lastMessage.index}`;
34253
- const timestamp = parseMessageTime(lastMessage.receivedAt);
34483
+ const timestamp = getMessageEventTime(lastMessage);
34254
34484
  return timestamp > 0 ? `ts:${timestamp}` : "";
34255
34485
  }
34256
34486
  function getSessionLastUsedAt(session) {
@@ -35583,6 +35813,7 @@ var init_provider_adapter = __esm({
35583
35813
  "use strict";
35584
35814
  init_control_effects();
35585
35815
  init_provider_patch_state();
35816
+ init_chat_message_normalization();
35586
35817
  ProviderStreamAdapter = class {
35587
35818
  agentType;
35588
35819
  agentName;
@@ -35692,7 +35923,7 @@ var init_provider_adapter = __esm({
35692
35923
  agentName: this.agentName,
35693
35924
  extensionId: this.extensionId,
35694
35925
  status: data.status || "idle",
35695
- messages: data.messages || [],
35926
+ messages: normalizeChatMessages(Array.isArray(data.messages) ? data.messages : []),
35696
35927
  inputContent: data.inputContent || "",
35697
35928
  activeModal: data.activeModal
35698
35929
  };
@@ -42963,6 +43194,8 @@ __export(src_exports, {
42963
43194
  CdpDomHandlers: () => CdpDomHandlers,
42964
43195
  CliProviderInstance: () => CliProviderInstance,
42965
43196
  DAEMON_WS_PATH: () => DAEMON_WS_PATH,
43197
+ DEFAULT_ACTIVE_CHAT_POLL_STATUSES: () => DEFAULT_ACTIVE_CHAT_POLL_STATUSES,
43198
+ DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS: () => DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS,
42966
43199
  DEFAULT_DAEMON_PORT: () => DEFAULT_DAEMON_PORT,
42967
43200
  DEFAULT_SESSION_HOST_APP_NAME: () => DEFAULT_SESSION_HOST_APP_NAME,
42968
43201
  DEFAULT_STANDALONE_SESSION_HOST_APP_NAME: () => DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
@@ -42991,7 +43224,11 @@ __export(src_exports, {
42991
43224
  buildSessionEntries: () => buildSessionEntries,
42992
43225
  buildStatusSnapshot: () => buildStatusSnapshot,
42993
43226
  buildSystemChatMessage: () => buildSystemChatMessage,
43227
+ buildTerminalChatMessage: () => buildTerminalChatMessage,
43228
+ buildThoughtChatMessage: () => buildThoughtChatMessage,
43229
+ buildToolChatMessage: () => buildToolChatMessage,
42994
43230
  buildUserChatMessage: () => buildUserChatMessage,
43231
+ classifyHotChatSessionsForSubscriptionFlush: () => classifyHotChatSessionsForSubscriptionFlush,
42995
43232
  clearDebugTrace: () => clearDebugTrace,
42996
43233
  configureDebugTraceStore: () => configureDebugTraceStore,
42997
43234
  connectCdpManager: () => connectCdpManager,
@@ -43058,6 +43295,7 @@ __export(src_exports, {
43058
43295
  resetConfig: () => resetConfig,
43059
43296
  resetDebugRuntimeConfig: () => resetDebugRuntimeConfig,
43060
43297
  resetState: () => resetState,
43298
+ resolveChatMessageKind: () => resolveChatMessageKind,
43061
43299
  resolveDebugRuntimeConfig: () => resolveDebugRuntimeConfig,
43062
43300
  resolveSessionHostAppName: () => resolveSessionHostAppName,
43063
43301
  saveConfig: () => saveConfig,
@@ -43084,6 +43322,7 @@ var init_src = __esm({
43084
43322
  init_ide_detector();
43085
43323
  init_cli_detector();
43086
43324
  init_host_memory();
43325
+ init_chat_tail_hot_sessions();
43087
43326
  init_manager();
43088
43327
  init_devtools();
43089
43328
  init_setup();
@@ -52403,7 +52642,7 @@ function stopDaemon(ref = {}) {
52403
52642
  return false;
52404
52643
  }
52405
52644
  }
52406
- var os26, fs18, path27, import_http, import_ws3, pkgVersion, ACTIVE_CHAT_POLL_STATUSES, AdhdevDaemon;
52645
+ var os26, fs18, path27, import_http, import_ws3, pkgVersion, AdhdevDaemon;
52407
52646
  var init_adhdev_daemon = __esm({
52408
52647
  "src/adhdev-daemon.ts"() {
52409
52648
  "use strict";
@@ -52422,12 +52661,8 @@ var init_adhdev_daemon = __esm({
52422
52661
  import_ws3 = require("ws");
52423
52662
  init_source2();
52424
52663
  init_version();
52425
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.63" });
52426
- ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
52427
- "generating",
52428
- "waiting_approval",
52429
- "starting"
52430
- ]);
52664
+ init_src();
52665
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.65" });
52431
52666
  AdhdevDaemon = class _AdhdevDaemon {
52432
52667
  localHttpServer = null;
52433
52668
  localWss = null;
@@ -52654,14 +52889,12 @@ var init_adhdev_daemon = __esm({
52654
52889
  }
52655
52890
  getHotChatSessionIdsForP2PFlush() {
52656
52891
  const snapshot = this.buildLiveStatusSnapshot();
52657
- const active = new Set(
52658
- snapshot.sessions.filter((session) => ACTIVE_CHAT_POLL_STATUSES.has(String(session.status || "").toLowerCase())).map((session) => session.id)
52659
- );
52660
- const finalizing = new Set(
52661
- Array.from(this.hotP2PChatSessionIds).filter((sessionId) => !active.has(sessionId))
52892
+ const hotSessions = classifyHotChatSessionsForSubscriptionFlush(
52893
+ snapshot.sessions,
52894
+ this.hotP2PChatSessionIds
52662
52895
  );
52663
- this.hotP2PChatSessionIds = active;
52664
- return { active, finalizing };
52896
+ this.hotP2PChatSessionIds = hotSessions.active;
52897
+ return hotSessions;
52665
52898
  }
52666
52899
  async flushP2PChatSubscriptions(options = {}) {
52667
52900
  if (!this.p2p?.isConnected || !this.p2p.hasChatSubscriptions()) return;