@ai-matrx/chat 0.6.6 → 0.7.1

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.
Files changed (249) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +1 -1
  3. package/dist/agents/components/agent-widgets/AgentChatHistorySidebar.js +16 -55
  4. package/dist/agents/components/chat/chat-door.d.ts +67 -0
  5. package/dist/agents/components/chat/chat-door.js +100 -0
  6. package/dist/agents/components/conversation-history/AgentConversationList.d.ts +83 -0
  7. package/dist/agents/components/conversation-history/AgentConversationList.js +252 -0
  8. package/dist/agents/components/conversation-history/ConversationArchiveSection.d.ts +5 -1
  9. package/dist/agents/components/conversation-history/ConversationArchiveSection.js +22 -4
  10. package/dist/agents/components/conversation-history/ConversationHistorySidebar.js +20 -65
  11. package/dist/agents/components/inputs/input-components/TextareaInput.js +2 -0
  12. package/dist/agents/components/inputs/input-components/VariableInputComponent.js +7 -6
  13. package/dist/agents/components/inputs/smart-input/ConversationCompanionPills.d.ts +3 -0
  14. package/dist/agents/components/inputs/smart-input/ConversationCompanionPills.js +40 -0
  15. package/dist/agents/components/inputs/smart-input/ConversationContextRail.js +6 -29
  16. package/dist/agents/components/inputs/smart-input/DeviceToolsModeRow.d.ts +3 -0
  17. package/dist/agents/components/inputs/smart-input/DeviceToolsModeRow.js +35 -0
  18. package/dist/agents/components/inputs/smart-input/InboxQueueStrip.js +0 -8
  19. package/dist/agents/components/inputs/smart-input/RunToolPicker.js +15 -11
  20. package/dist/agents/components/inputs/smart-input/composer/ComposerPlusMenu.js +22 -0
  21. package/dist/agents/components/inputs/smart-input/rail-pill.d.ts +35 -0
  22. package/dist/agents/components/inputs/smart-input/rail-pill.js +30 -0
  23. package/dist/agents/components/inputs/variable-input-variations/AgentVariableForm.js +52 -48
  24. package/dist/agents/components/run-controls/panels/shared.d.ts +1 -1
  25. package/dist/agents/components/shared/AgentModeController.js +3 -2
  26. package/dist/agents/components/shell/AgentRunSidebarMenu.js +15 -54
  27. package/dist/agents/components/working-document/documents-workspace/DocumentsListRail.js +1 -2
  28. package/dist/agents/engine.d.ts +15 -0
  29. package/dist/agents/engine.js +17 -0
  30. package/dist/agents/hooks/useModelControls.js +3 -175
  31. package/dist/agents/redux/agent-definition/selectors.d.ts +237 -237
  32. package/dist/agents/redux/agent-shortcut-categories/selectors.d.ts +50 -50
  33. package/dist/agents/redux/agent-shortcuts/selectors.d.ts +147 -147
  34. package/dist/agents/redux/conversation-history/thunks.js +6 -18
  35. package/dist/agents/redux/conversation-list/conversation-list.selectors.d.ts +1 -73
  36. package/dist/agents/redux/conversation-list/conversation-list.selectors.js +2 -36
  37. package/dist/agents/redux/conversation-list/conversation-list.slice.d.ts +7 -22
  38. package/dist/agents/redux/conversation-list/conversation-list.slice.js +7 -62
  39. package/dist/agents/redux/conversation-list/conversation-list.thunks.d.ts +0 -25
  40. package/dist/agents/redux/conversation-list/conversation-list.thunks.js +2 -58
  41. package/dist/agents/redux/conversation-list/conversation-list.types.d.ts +0 -5
  42. package/dist/agents/redux/conversation-list/conversation-rows.d.ts +16 -0
  43. package/dist/agents/redux/conversation-list/conversation-rows.js +24 -0
  44. package/dist/agents/redux/conversation-list/conversation-trash.thunks.d.ts +1 -0
  45. package/dist/agents/redux/conversation-list/conversation-trash.thunks.js +13 -18
  46. package/dist/agents/redux/execution-system/active-requests/active-requests.selectors.d.ts +54 -54
  47. package/dist/agents/redux/execution-system/context-state/context-state.selectors.d.ts +14 -14
  48. package/dist/agents/redux/execution-system/conversations/conversations.selectors.d.ts +5 -5
  49. package/dist/agents/redux/execution-system/instance-context/instance-context.selectors.d.ts +3 -3
  50. package/dist/agents/redux/execution-system/instance-resources/instance-resources.selectors.d.ts +8 -8
  51. package/dist/agents/redux/execution-system/instance-ui-state/instance-ui-state.selectors.d.ts +5 -5
  52. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.selectors.d.ts +7 -7
  53. package/dist/agents/redux/execution-system/messages/messages.selectors.d.ts +1 -1
  54. package/dist/agents/redux/execution-system/observability/observability.selectors.d.ts +7 -7
  55. package/dist/agents/redux/execution-system/observational-memory/observational-memory.selectors.d.ts +1 -1
  56. package/dist/agents/redux/execution-system/selectors/aggregate.selectors.d.ts +14 -14
  57. package/dist/agents/redux/execution-system/thunks/create-instance.thunk.d.ts +10 -1
  58. package/dist/agents/redux/execution-system/thunks/create-instance.thunk.js +114 -265
  59. package/dist/agents/redux/execution-system/thunks/dispatch-matrx-extend-tool.thunk.js +18 -2
  60. package/dist/agents/redux/execution-system/thunks/dispatch-surface-client-tool.thunk.js +10 -28
  61. package/dist/agents/redux/execution-system/thunks/dispatch-surface-write.thunk.js +10 -25
  62. package/dist/agents/redux/execution-system/thunks/execute-instance.thunk.js +20 -0
  63. package/dist/agents/redux/execution-system/thunks/execute-manual-instance.thunk.js +6 -1
  64. package/dist/agents/redux/execution-system/thunks/notify-and-play-dispatcher.d.ts +58 -0
  65. package/dist/agents/redux/execution-system/thunks/notify-and-play-dispatcher.js +62 -0
  66. package/dist/agents/redux/execution-system/thunks/post-delegated-tool-outcome.d.ts +23 -0
  67. package/dist/agents/redux/execution-system/thunks/post-delegated-tool-outcome.js +37 -0
  68. package/dist/agents/redux/execution-system/thunks/resume-instance.thunk.js +10 -2
  69. package/dist/agents/redux/execution-system/utils/build-tool-injection.d.ts +7 -0
  70. package/dist/agents/redux/execution-system/utils/build-tool-injection.js +18 -6
  71. package/dist/agents/redux/execution-system/utils/host-turn.d.ts +45 -0
  72. package/dist/agents/redux/execution-system/utils/host-turn.js +119 -0
  73. package/dist/agents/redux/proposed-directives/proposedDirectivesSlice.d.ts +1 -1
  74. package/dist/agents/scribe-tools/dispatcher/dispatch-scribe-tool.thunk.d.ts +50 -20
  75. package/dist/agents/scribe-tools/dispatcher/dispatch-scribe-tool.thunk.js +9 -101
  76. package/dist/agents/types/tool-injection.types.d.ts +18 -2
  77. package/dist/agents/ui-first-tools/redux/agent-lists.selectors.d.ts +2 -2
  78. package/dist/agents/ui-first-tools/redux/pending-asks.slice.d.ts +2 -1
  79. package/dist/agents/ui-first-tools/redux/resolve-asks-with-input.thunk.js +1 -1
  80. package/dist/agents/ui-first-tools/tools/ask-response.d.ts +29 -0
  81. package/dist/agents/ui-first-tools/tools/ask-response.js +15 -0
  82. package/dist/agents/ui-first-tools/tools/schemas.d.ts +3 -25
  83. package/dist/agents/ui-first-tools/tools/schemas.js +1 -12
  84. package/dist/agents/ui-first-tools/ui/ApprovalCard.js +1 -1
  85. package/dist/agents/ui-first-tools/ui/AskWizard.d.ts +1 -1
  86. package/dist/agents/ui-first-tools/ui/AskWizard.js +1 -1
  87. package/dist/cx-chat/_legacy-stubs.d.ts +5 -5
  88. package/dist/cx-chat/components/SsrSidebarChats.js +13 -15
  89. package/dist/cx-chat/components/messages/UserMessage.d.ts +2 -2
  90. package/dist/cx-chat/types/conversation.d.ts +6 -6
  91. package/dist/cx-chat/utils/buildContentBlocksForSave.d.ts +1 -1
  92. package/dist/cx-chat/utils/cx-content-converter.d.ts +1 -1
  93. package/dist/host/bare-host-chrome.js +9 -3
  94. package/dist/host/composer-extensions.d.ts +75 -0
  95. package/dist/host/composer-extensions.js +92 -0
  96. package/dist/host/configure.js +1 -0
  97. package/dist/host/contract.d.ts +105 -13
  98. package/dist/host/defaults/confirm.d.ts +15 -0
  99. package/dist/host/defaults/confirm.js +25 -0
  100. package/dist/host/defaults/files-ui.d.ts +85 -0
  101. package/dist/host/defaults/files-ui.js +158 -0
  102. package/dist/host/defaults/gates.d.ts +27 -0
  103. package/dist/host/defaults/gates.js +72 -0
  104. package/dist/host/defaults/media-client.d.ts +15 -0
  105. package/dist/host/defaults/media-client.js +40 -0
  106. package/dist/host/defaults/voice.d.ts +81 -0
  107. package/dist/host/defaults/voice.js +239 -0
  108. package/dist/host/device-tool-handoff.d.ts +26 -0
  109. package/dist/host/device-tool-handoff.js +45 -0
  110. package/dist/host/index.d.ts +1 -0
  111. package/dist/host/index.js +4 -1
  112. package/dist/host/microphone.d.ts +11 -0
  113. package/dist/host/microphone.js +17 -0
  114. package/dist/host/ui-slots.d.ts +29 -74
  115. package/dist/host/ui-slots.js +40 -42
  116. package/dist/store/create-chat-store.d.ts +2 -2
  117. package/dist/store/middlewares.d.ts +5 -5
  118. package/dist/store/slices.d.ts +1 -1
  119. package/dist/surfaces/redux/selectors.d.ts +2 -2
  120. package/dist/tool-call-visualization/components/ToolCallVisualization.js +3 -2
  121. package/dist/tool-call-visualization/configured-rows/ConfiguredRowRenderer.d.ts +15 -0
  122. package/dist/tool-call-visualization/configured-rows/ConfiguredRowRenderer.js +36 -0
  123. package/dist/tool-call-visualization/configured-rows/ConfiguredToolRow.d.ts +40 -0
  124. package/dist/tool-call-visualization/configured-rows/ConfiguredToolRow.js +296 -0
  125. package/dist/tool-call-visualization/configured-rows/CopyToolButton.d.ts +23 -0
  126. package/dist/tool-call-visualization/configured-rows/CopyToolButton.js +62 -0
  127. package/dist/tool-call-visualization/configured-rows/ToolProgressView.d.ts +23 -0
  128. package/dist/tool-call-visualization/configured-rows/ToolProgressView.js +147 -0
  129. package/dist/tool-call-visualization/configured-rows/field-components.d.ts +15 -0
  130. package/dist/tool-call-visualization/configured-rows/field-components.js +244 -0
  131. package/dist/tool-call-visualization/configured-rows/helpers.d.ts +39 -0
  132. package/dist/tool-call-visualization/configured-rows/helpers.js +110 -0
  133. package/dist/tool-call-visualization/configured-rows/register.d.ts +25 -0
  134. package/dist/tool-call-visualization/configured-rows/register.js +51 -0
  135. package/dist/tool-call-visualization/configured-rows/registries.d.ts +27 -0
  136. package/dist/tool-call-visualization/configured-rows/registries.js +14 -0
  137. package/dist/tool-call-visualization/configured-rows/to-row-entry.d.ts +8 -0
  138. package/dist/tool-call-visualization/configured-rows/to-row-entry.js +38 -0
  139. package/dist/tool-call-visualization/configured-rows/transforms.d.ts +14 -0
  140. package/dist/tool-call-visualization/configured-rows/transforms.js +30 -0
  141. package/dist/tool-call-visualization/configured-rows/types.d.ts +140 -0
  142. package/dist/tool-call-visualization/redux/selectors.d.ts +1 -1
  143. package/dist/tool-call-visualization/registry/registry.d.ts +1 -1
  144. package/dist/tool-call-visualization/registry/registry.js +8 -1
  145. package/dist/tool-call-visualization/types.d.ts +1 -1
  146. package/dist/ui/chat-protocol-types.d.ts +0 -1
  147. package/dist/ui/ownership.d.ts +25 -0
  148. package/dist/ui/ownership.js +18 -0
  149. package/dist/voice-agent/audio/audioCapture.js +11 -6
  150. package/dist/window-panels/windows/agents/AgentRunHistoryWindow.d.ts +1 -2
  151. package/dist/window-panels/windows/agents/AgentRunHistoryWindow.js +21 -181
  152. package/dist/window-panels/windows/agents/AgentRunWindow.js +26 -13
  153. package/package.json +4627 -125
  154. package/dist/agents/components/agent-widgets/chat-assistant/AssistantMessageCard.d.ts +0 -7
  155. package/dist/agents/components/agent-widgets/chat-assistant/AssistantMessageCard.js +0 -33
  156. package/dist/agents/components/agent-widgets/chat-assistant/StatusCard.d.ts +0 -6
  157. package/dist/agents/components/agent-widgets/chat-assistant/StatusCard.js +0 -21
  158. package/dist/agents/components/agent-widgets/chat-assistant/UserMessageCard.d.ts +0 -6
  159. package/dist/agents/components/agent-widgets/chat-assistant/UserMessageCard.js +0 -11
  160. package/dist/agents/components/agent-widgets/chat-assistant/VariableInputCard.d.ts +0 -12
  161. package/dist/agents/components/agent-widgets/chat-assistant/VariableInputCard.js +0 -7
  162. package/dist/agents/components/agent-widgets/execution-gates/PreExecutionCard.d.ts +0 -4
  163. package/dist/agents/components/agent-widgets/execution-gates/PreExecutionCard.js +0 -81
  164. package/dist/agents/components/run/run-sidebar/SidebarHeader.d.ts +0 -21
  165. package/dist/agents/components/run/run-sidebar/SidebarHeader.js +0 -50
  166. package/dist/agents/components/run-controls/AdvancedRunSettings/index.d.ts +0 -6
  167. package/dist/agents/components/run-controls/AdvancedRunSettings/index.js +0 -32
  168. package/dist/agents/components/run-controls/RunSettingsModal.d.ts +0 -5
  169. package/dist/agents/components/run-controls/RunSettingsModal.js +0 -22
  170. package/dist/agents/components/shell/AgentBuildSidebarExtras.d.ts +0 -6
  171. package/dist/agents/components/shell/AgentBuildSidebarExtras.js +0 -30
  172. package/dist/agents/constants/agent-system-competitors.d.ts +0 -9
  173. package/dist/agents/constants/agent-system-competitors.js +0 -125
  174. package/dist/agents/hooks/message-crud/useMessageActions.d.ts +0 -29
  175. package/dist/agents/hooks/message-crud/useMessageActions.js +0 -119
  176. package/dist/agents/hooks/useConversationPendingCalls.d.ts +0 -30
  177. package/dist/agents/hooks/useConversationPendingCalls.js +0 -42
  178. package/dist/agents/model-registry/model-classes.d.ts +0 -1
  179. package/dist/agents/model-registry/model-classes.js +0 -1
  180. package/dist/agents/redux/conversation-history/index.d.ts +0 -18
  181. package/dist/agents/redux/conversation-history/index.js +0 -4
  182. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.thunks.d.ts +0 -38
  183. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.thunks.js +0 -42
  184. package/dist/agents/redux/execution-system/message-crud/server/compact-turns.thunk.d.ts +0 -58
  185. package/dist/agents/redux/execution-system/message-crud/server/compact-turns.thunk.js +0 -50
  186. package/dist/agents/redux/execution-system/message-crud/server/fork-and-run-server.thunk.d.ts +0 -76
  187. package/dist/agents/redux/execution-system/message-crud/server/fork-and-run-server.thunk.js +0 -101
  188. package/dist/agents/redux/execution-system/thunks/attach-workflow-run.d.ts +0 -38
  189. package/dist/agents/redux/execution-system/thunks/attach-workflow-run.js +0 -25
  190. package/dist/agents/redux/execution-system/utils/source-slice-helpers.d.ts +0 -45
  191. package/dist/agents/redux/execution-system/utils/source-slice-helpers.js +0 -50
  192. package/dist/agents/runtime/realtime/launchRealtimeSession.thunk.d.ts +0 -25
  193. package/dist/agents/runtime/realtime/launchRealtimeSession.thunk.js +0 -15
  194. package/dist/agents/services/agentService.d.ts +0 -12
  195. package/dist/agents/services/agentService.js +0 -92
  196. package/dist/agents/utils/escape-code-fences.d.ts +0 -15
  197. package/dist/agents/utils/escape-code-fences.js +0 -9
  198. package/dist/agents/utils/normalize-managed-options.d.ts +0 -30
  199. package/dist/agents/utils/normalize-managed-options.js +0 -29
  200. package/dist/agents/utils/processedDocumentContext.d.ts +0 -51
  201. package/dist/agents/utils/processedDocumentContext.js +0 -51
  202. package/dist/agents/utils/variable-validation.d.ts +0 -28
  203. package/dist/agents/utils/variable-validation.js +0 -54
  204. package/dist/cx-chat/components/ChatConversationSkeleton.d.ts +0 -9
  205. package/dist/cx-chat/components/ChatConversationSkeleton.js +0 -45
  206. package/dist/cx-chat/components/ChatPanelBackButton.d.ts +0 -1
  207. package/dist/cx-chat/components/ChatPanelBackButton.js +0 -26
  208. package/dist/cx-chat/components/messages/MessageErrorBoundary.d.ts +0 -20
  209. package/dist/cx-chat/components/messages/MessageErrorBoundary.js +0 -40
  210. package/dist/cx-chat/components/variable-inputs/CheckboxGroupInput.d.ts +0 -14
  211. package/dist/cx-chat/components/variable-inputs/CheckboxGroupInput.js +0 -160
  212. package/dist/cx-chat/components/variable-inputs/NumberInput.d.ts +0 -15
  213. package/dist/cx-chat/components/variable-inputs/NumberInput.js +0 -79
  214. package/dist/cx-chat/components/variable-inputs/RadioGroupInput.d.ts +0 -14
  215. package/dist/cx-chat/components/variable-inputs/RadioGroupInput.js +0 -125
  216. package/dist/cx-chat/components/variable-inputs/SelectInput.d.ts +0 -14
  217. package/dist/cx-chat/components/variable-inputs/SelectInput.js +0 -92
  218. package/dist/cx-chat/components/variable-inputs/TextareaInput.d.ts +0 -14
  219. package/dist/cx-chat/components/variable-inputs/TextareaInput.js +0 -46
  220. package/dist/cx-chat/components/variable-inputs/ToggleInput.d.ts +0 -14
  221. package/dist/cx-chat/components/variable-inputs/ToggleInput.js +0 -46
  222. package/dist/cx-chat/hooks/useChatPersistence.d.ts +0 -28
  223. package/dist/cx-chat/hooks/useChatPersistence.js +0 -180
  224. package/dist/cx-chat/hooks/useInstanceBootstrap.d.ts +0 -1
  225. package/dist/cx-chat/hooks/useInstanceBootstrap.js +0 -115
  226. package/dist/cx-chat/types/content.d.ts +0 -184
  227. package/dist/cx-chat/types/content.js +0 -91
  228. package/dist/cx-chat/types/cx-tables.d.ts +0 -176
  229. package/dist/cx-chat/utils/settings-diff.d.ts +0 -13
  230. package/dist/cx-chat/utils/settings-diff.js +0 -25
  231. package/dist/public-chat/components/AgentSelector.d.ts +0 -22
  232. package/dist/public-chat/components/AgentSelector.js +0 -80
  233. package/dist/public-chat/components/GuidedVariableInputs.d.ts +0 -25
  234. package/dist/public-chat/components/GuidedVariableInputs.js +0 -623
  235. package/dist/public-chat/components/PublicVariableInputs.d.ts +0 -29
  236. package/dist/public-chat/components/PublicVariableInputs.js +0 -172
  237. package/dist/public-chat/types/content.d.ts +0 -184
  238. package/dist/public-chat/types/content.js +0 -91
  239. package/dist/tool-call-visualization/renderers/_shared-entity/EntityOpenActions.d.ts +0 -15
  240. package/dist/tool-call-visualization/renderers/_shared-entity/EntityOpenActions.js +0 -31
  241. package/dist/tool-call-visualization/utils/toolCallBlockToLifecycleEntry.d.ts +0 -24
  242. package/dist/tool-call-visualization/utils/toolCallBlockToLifecycleEntry.js +0 -26
  243. package/dist/ui/AudioOutputBlockSkeleton.d.ts +0 -17
  244. package/dist/ui/AudioOutputBlockSkeleton.js +0 -78
  245. package/dist/ui/lazy/PublicChatVariableInputs.d.ts +0 -2
  246. package/dist/ui/lazy/PublicChatVariableInputs.js +0 -16
  247. package/dist/utils/xml/readXmlTag.d.ts +0 -12
  248. package/dist/utils/xml/readXmlTag.js +0 -66
  249. /package/dist/{cx-chat/types/cx-tables.js → tool-call-visualization/configured-rows/types.js} +0 -0
@@ -1,6 +1,10 @@
1
1
  import { createAsyncThunk } from "@reduxjs/toolkit";
2
2
  import { supabase } from "../../../host/db.js";
3
3
  import { applyFavoritesFromUes } from "../conversation-list/conversation-list.thunks.js";
4
+ import {
5
+ CONVERSATION_ROW_COLUMNS,
6
+ mapConversationDbRow
7
+ } from "../conversation-list/conversation-rows.js";
4
8
  import {
5
9
  setScopePageSuccess,
6
10
  setScopeStatus,
@@ -20,7 +24,6 @@ import {
20
24
  } from "./types.js";
21
25
  import { readListRpc } from "../../../host/ui-slots.js";
22
26
  import { getUserId, hasBrowserSession } from "../../../host/identity.js";
23
- const HISTORY_COLUMNS = "id, title, description, status, message_count, initial_agent_id, last_model_id, source_app, source_feature, origin_class, created_at, updated_at, exclude_from_kg";
24
27
  const fetchConversationHistory = createAsyncThunk(
25
28
  "conversationHistory/fetchPage",
26
29
  async (args, { dispatch, getState, rejectWithValue }) => {
@@ -62,7 +65,7 @@ const fetchConversationHistory = createAsyncThunk(
62
65
  );
63
66
  return { scopeId: args.scopeId, items: [], hasMore: false, nextOffset: 0, replace };
64
67
  }
65
- let query = supabase.schema("chat").from("conversation").select(HISTORY_COLUMNS).is("deleted_at", null).eq("is_ephemeral", false).order("updated_at", { ascending: false }).range(offset, offset + pageSize - 1);
68
+ let query = supabase.schema("chat").from("conversation").select(CONVERSATION_ROW_COLUMNS).is("deleted_at", null).eq("is_ephemeral", false).order("updated_at", { ascending: false }).range(offset, offset + pageSize - 1);
66
69
  if (viewerId) {
67
70
  query = query.eq("created_by", viewerId);
68
71
  }
@@ -107,22 +110,7 @@ const fetchConversationHistory = createAsyncThunk(
107
110
  return rejectWithValue(error.message);
108
111
  }
109
112
  const rows = data ?? [];
110
- const mapped = rows.map((row) => ({
111
- conversationId: row.id,
112
- title: row.title ?? null,
113
- description: row.description ?? null,
114
- updatedAt: row.updated_at,
115
- createdAt: row.created_at,
116
- status: row.status,
117
- messageCount: row.message_count ?? 0,
118
- isFavorite: false,
119
- excludeFromKg: row.exclude_from_kg ?? false,
120
- agentId: row.initial_agent_id ?? null,
121
- lastModelId: row.last_model_id ?? null,
122
- sourceApp: row.source_app ?? void 0,
123
- sourceFeature: row.source_feature ?? void 0,
124
- originClass: row.origin_class ?? void 0
125
- }));
113
+ const mapped = rows.map(mapConversationDbRow);
126
114
  const items = await applyFavoritesFromUes(mapped);
127
115
  const hasMore = items.length === pageSize;
128
116
  const nextOffset = offset + items.length;
@@ -1,76 +1,5 @@
1
1
  import type { ChatRootState } from "../../../store/root-state.js";
2
2
  import type { ConversationListItem, ConversationListAgentCacheEntry, ConversationListLoadStatus } from "./conversation-list.types.js";
3
- declare const selectSlice: (state: ChatRootState) => import("./conversation-list.types.js").ConversationListState;
4
- export declare const selectGlobalConversationList: ((state: {
5
- voiceAgent: import("../../../voice-agent/types.js").VoiceAgentState;
6
- agentDefinition: import("../../types/agent-definition.types.js").AgentDefinitionSliceState;
7
- conversationList: import("./conversation-list.types.js").ConversationListState;
8
- conversationHistory: import("../conversation-history/index.js").ConversationHistoryState;
9
- agentShortcut: import("../agent-shortcuts/types.js").AgentShortcutSliceState;
10
- agentShortcutCategory: import("../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
11
- surfaceUserState: import("../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
12
- conversations: import("../execution-system/conversations/conversations.slice.js").ConversationsState;
13
- chatIncognito: import("../chat/chat-incognito.slice.js").ChatIncognitoState;
14
- chatRoute: import("../chat/chat-route.slice.js").ChatRouteState;
15
- instanceModelOverrides: import("../execution-system/instance-model-overrides/instance-model-overrides.slice.js").InstanceModelOverridesState;
16
- instanceInputCapabilities: import("../execution-system/instance-input-capabilities/instance-input-capabilities.slice.js").InstanceInputCapabilitiesState;
17
- instanceVariableValues: import("../execution-system/instance-variable-values/instance-variable-values.slice.js").InstanceVariableValuesState;
18
- instanceResources: import("../execution-system/instance-resources/instance-resources.slice.js").InstanceResourcesState;
19
- instanceContext: import("../execution-system/instance-context/instance-context.slice.js").InstanceContextState;
20
- instanceWorkingDocument: import("../execution-system/instance-working-document/instance-working-document.slice.js").InstanceWorkingDocumentSliceState;
21
- instanceUserInput: import("../execution-system/instance-user-input/instance-user-input.slice.js").InstanceUserInputSliceState;
22
- instanceClientTools: import("../execution-system/instance-client-tools/instance-client-tools.slice.js").InstanceClientToolsState;
23
- pendingAsks: import("../../ui-first-tools/redux/pending-asks.slice.js").PendingAsksState;
24
- conversationInbox: import("../execution-system/inbox/inbox.slice.js").ConversationInboxState;
25
- agentLists: import("../../ui-first-tools/redux/agent-lists.slice.js").AgentListsState;
26
- instanceUIState: import("../execution-system/instance-ui-state/instance-ui-state.slice.js").InstanceUIStateSlice;
27
- activeTools: import("../execution-system/active-tools/active-tools.slice.js").ActiveToolsState;
28
- activeRequests: import("../execution-system/active-requests/active-requests.slice.js").ActiveRequestsState;
29
- runSets: import("../execution-system/run-sets/run-sets.slice.js").RunSetsState;
30
- messages: import("../execution-system/messages/messages.slice.js").MessagesState;
31
- observability: import("../execution-system/observability/observability.slice.js").ObservabilityState;
32
- contextState: import("../execution-system/context-state/context-state.slice.js").ContextStateSliceState;
33
- observationalMemory: import("../execution-system/observational-memory/observational-memory.slice.js").ObservationalMemoryState;
34
- cacheBypass: import("../execution-system/message-crud/cache-bypass.slice.js").CacheBypassState;
35
- conversationFocus: import("../execution-system/conversation-focus/conversation-focus.slice.js").ConversationFocusState;
36
- surfaces: import("../surfaces/surfaces.slice.js").SurfacesState;
37
- surfacesCatalog: import("../../../surfaces/redux/surfacesCatalogSlice.js").SurfacesCatalogSliceState;
38
- agentSurfaceBindings: import("../../../surfaces/redux/agentSurfaceBindingsSlice.js").AgentSurfaceBindingsSliceState;
39
- surfaceConfig: import("../../../surfaces/redux/surfaceConfigSlice.js").SurfaceConfigSliceState;
40
- agentAssistantMarkdownDraft: import("../agent-assistant-markdown-draft.slice.js").AgentAssistantMarkdownDraftState;
41
- mcp: import("../mcp/mcp.slice.js").McpSliceState;
42
- proposedDirectives: import("../proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
43
- conversationAttachments: import("../../connectors/attachments.slice.js").AttachmentsSliceState;
44
- chatHost: import("../../../store/chat-host.slice.js").ChatHostState;
45
- hostConversations: import("../execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
46
- } & import("../../../store/root-state.js").ChatHostReadSlices) => ConversationListItem[]) & {
47
- clearCache: () => void;
48
- resultsCount: () => number;
49
- resetResultsCount: () => void;
50
- } & {
51
- resultFunc: (resultFuncArgs_0: import("./conversation-list.types.js").ConversationListState) => ConversationListItem[];
52
- memoizedResultFunc: ((resultFuncArgs_0: import("./conversation-list.types.js").ConversationListState) => ConversationListItem[]) & {
53
- clearCache: () => void;
54
- resultsCount: () => number;
55
- resetResultsCount: () => void;
56
- };
57
- lastResult: () => ConversationListItem[];
58
- dependencies: [typeof selectSlice];
59
- recomputations: () => number;
60
- resetRecomputations: () => void;
61
- dependencyRecomputations: () => number;
62
- resetDependencyRecomputations: () => void;
63
- } & {
64
- memoize: typeof import("reselect").weakMapMemoize;
65
- argsMemoize: typeof import("reselect").weakMapMemoize;
66
- };
67
- export declare const selectGlobalConversationIds: (state: ChatRootState) => string[];
68
- export declare const selectGlobalListStatus: (state: ChatRootState) => ConversationListLoadStatus;
69
- export declare const selectGlobalListError: (state: ChatRootState) => string | null;
70
- export declare const selectGlobalListHasMore: (state: ChatRootState) => boolean;
71
- export declare const selectGlobalListLastFetchedAt: (state: ChatRootState) => number | null;
72
- /** True when the global list is fresh (no refetch needed). */
73
- export declare const selectGlobalListIsFresh: (ttlMs?: number) => (state: ChatRootState) => boolean;
74
3
  export declare const selectConversationListItemById: (conversationId: string) => (state: ChatRootState) => ConversationListItem | null;
75
4
  export declare const selectConversationIsPending: (conversationId: string) => (state: ChatRootState) => boolean;
76
5
  export declare const selectAgentConversationsCache: (agentId: string, versionFilter: number | null) => (state: ChatRootState) => ConversationListAgentCacheEntry | undefined;
@@ -82,7 +11,7 @@ export declare function makeSelectAgentConversationList(agentId: string, version
82
11
  voiceAgent: import("../../../voice-agent/types.js").VoiceAgentState;
83
12
  agentDefinition: import("../../types/agent-definition.types.js").AgentDefinitionSliceState;
84
13
  conversationList: import("./conversation-list.types.js").ConversationListState;
85
- conversationHistory: import("../conversation-history/index.js").ConversationHistoryState;
14
+ conversationHistory: import("../conversation-history/types.js").ConversationHistoryState;
86
15
  agentShortcut: import("../agent-shortcuts/types.js").AgentShortcutSliceState;
87
16
  agentShortcutCategory: import("../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
88
17
  surfaceUserState: import("../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -196,4 +125,3 @@ export declare function selectAgentConversationsEntryForInstance(state: ChatRoot
196
125
  * that was archived or deleted from a list only one of them had loaded.
197
126
  */
198
127
  export declare function findConversationRow(state: ChatRootState, conversationId: string): ConversationListItem | null;
199
- export {};
@@ -1,37 +1,10 @@
1
1
  "use client";
2
2
  import { selectAgentById } from "../agent-definition/selectors.js";
3
3
  import { createSelector } from "@reduxjs/toolkit";
4
- import {
5
- CONVERSATION_LIST_TTL_MS,
6
- conversationListCacheKey
7
- } from "./conversation-list.types.js";
4
+ import { conversationListCacheKey } from "./conversation-list.types.js";
8
5
  import { selectAgentIdFromInstance } from "../execution-system/conversations/conversations.selectors.js";
9
6
  const EMPTY_ITEMS = [];
10
7
  const EMPTY_IDS = [];
11
- const selectSlice = (state) => state.conversationList;
12
- const selectGlobalConversationList = createSelector(
13
- [selectSlice],
14
- (slice) => {
15
- if (slice.allConversationIds.length === 0) return EMPTY_ITEMS;
16
- const out = [];
17
- for (const id of slice.allConversationIds) {
18
- const item = slice.byConversationId[id];
19
- if (item) out.push(item);
20
- }
21
- return out.length === 0 ? EMPTY_ITEMS : out;
22
- }
23
- );
24
- const selectGlobalConversationIds = (state) => state.conversationList.allConversationIds;
25
- const selectGlobalListStatus = (state) => state.conversationList.globalStatus;
26
- const selectGlobalListError = (state) => state.conversationList.globalError;
27
- const selectGlobalListHasMore = (state) => state.conversationList.globalHasMore;
28
- const selectGlobalListLastFetchedAt = (state) => state.conversationList.globalLastFetchedAt;
29
- const selectGlobalListIsFresh = (ttlMs = CONVERSATION_LIST_TTL_MS) => (state) => {
30
- const { globalLastFetchedAt, globalStatus } = state.conversationList;
31
- if (globalStatus === "loading") return true;
32
- if (!globalLastFetchedAt) return false;
33
- return Date.now() - globalLastFetchedAt < ttlMs;
34
- };
35
8
  const selectConversationListItemById = (conversationId) => (state) => state.conversationList.byConversationId[conversationId] ?? null;
36
9
  const selectConversationIsPending = (conversationId) => (state) => state.conversationList.pendingOperations.includes(conversationId);
37
10
  const selectAgentConversationsCache = (agentId, versionFilter) => (state) => state.conversationList.agentCaches[conversationListCacheKey(agentId, versionFilter)];
@@ -98,12 +71,5 @@ export {
98
71
  selectAgentConversationsEntry,
99
72
  selectAgentConversationsEntryForInstance,
100
73
  selectConversationIsPending,
101
- selectConversationListItemById,
102
- selectGlobalConversationIds,
103
- selectGlobalConversationList,
104
- selectGlobalListError,
105
- selectGlobalListHasMore,
106
- selectGlobalListIsFresh,
107
- selectGlobalListLastFetchedAt,
108
- selectGlobalListStatus
74
+ selectConversationListItemById
109
75
  };
@@ -14,13 +14,6 @@ import { type PayloadAction } from "@reduxjs/toolkit";
14
14
  import type { ConversationListItem, ConversationListState, ConversationListLoadStatus } from "./conversation-list.types.js";
15
15
  export { CONVERSATION_LIST_TTL_MS, CONVERSATION_LIST_PAGE_SIZE, } from "./conversation-list.types.js";
16
16
  export declare const conversationListActions: import("@reduxjs/toolkit").CaseReducerActions<{
17
- setGlobalListLoading(state: ConversationListState): void;
18
- setGlobalListSuccess(state: ConversationListState, action: PayloadAction<{
19
- items: ConversationListItem[];
20
- hasMore: boolean;
21
- replace?: boolean;
22
- }>): void;
23
- setGlobalListError(state: ConversationListState, action: PayloadAction<string>): void;
24
17
  setTrashLoading(state: ConversationListState): void;
25
18
  setTrashSuccess(state: ConversationListState, action: PayloadAction<{
26
19
  items: ConversationListItem[];
@@ -35,7 +28,11 @@ export declare const conversationListActions: import("@reduxjs/toolkit").CaseRed
35
28
  conversationId: string;
36
29
  patch: Partial<ConversationListItem>;
37
30
  }>): void;
38
- /** Prepend a newly-created conversation to the global list. */
31
+ /**
32
+ * Put a (restored / newly created) row into the entity store. Which LIST it
33
+ * appears in is the conversation-history scopes' business
34
+ * (`upsertConversationIntoScopes`), not this slice's.
35
+ */
39
36
  prependConversation(state: ConversationListState, action: PayloadAction<ConversationListItem>): void;
40
37
  /** Optimistic rename — pair with `revertRename` on failure. */
41
38
  renameConversation(state: ConversationListState, action: PayloadAction<{
@@ -48,11 +45,6 @@ export declare const conversationListActions: import("@reduxjs/toolkit").CaseRed
48
45
  }>): void;
49
46
  /** Optimistic remove — no matching revert yet (caller re-fetches on error). */
50
47
  removeConversation(state: ConversationListState, action: PayloadAction<string>): void;
51
- /** Bump to top by updatedAt (global list only — agent caches are order-preserving). */
52
- touchConversation(state: ConversationListState, action: PayloadAction<{
53
- conversationId: string;
54
- updatedAt?: string;
55
- }>): void;
56
48
  markPending(state: ConversationListState, action: PayloadAction<string>): void;
57
49
  clearPending(state: ConversationListState, action: PayloadAction<string>): void;
58
50
  setAgentCacheLoading(state: ConversationListState, action: PayloadAction<{
@@ -107,11 +99,7 @@ export declare const conversationListActions: import("@reduxjs/toolkit").CaseRed
107
99
  clearAllAgentCaches(state: ConversationListState): void;
108
100
  resetConversationList(): ConversationListState;
109
101
  }, "conversationList">;
110
- export declare const setGlobalListLoading: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"conversationList/setGlobalListLoading">, setGlobalListSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
111
- items: ConversationListItem[];
112
- hasMore: boolean;
113
- replace?: boolean;
114
- }, "conversationList/setGlobalListSuccess">, setGlobalListError: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "conversationList/setGlobalListError">, setTrashLoading: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"conversationList/setTrashLoading">, setTrashSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
102
+ export declare const setTrashLoading: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"conversationList/setTrashLoading">, setTrashSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
115
103
  items: ConversationListItem[];
116
104
  }, "conversationList/setTrashSuccess">, setTrashError: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "conversationList/setTrashError">, removeFromTrash: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "conversationList/removeFromTrash">, addToTrash: import("@reduxjs/toolkit").ActionCreatorWithPayload<ConversationListItem, "conversationList/addToTrash">, upsertConversation: import("@reduxjs/toolkit").ActionCreatorWithPayload<ConversationListItem, "conversationList/upsertConversation">, patchConversation: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
117
105
  conversationId: string;
@@ -122,10 +110,7 @@ export declare const setGlobalListLoading: import("@reduxjs/toolkit").ActionCrea
122
110
  }, "conversationList/renameConversation">, revertRename: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
123
111
  conversationId: string;
124
112
  previousTitle: string | null;
125
- }, "conversationList/revertRename">, removeConversation: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "conversationList/removeConversation">, touchConversation: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
126
- conversationId: string;
127
- updatedAt?: string;
128
- }, "conversationList/touchConversation">, markPending: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "conversationList/markPending">, clearPending: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "conversationList/clearPending">, setAgentCacheLoading: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
113
+ }, "conversationList/revertRename">, removeConversation: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "conversationList/removeConversation">, markPending: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "conversationList/markPending">, clearPending: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "conversationList/clearPending">, setAgentCacheLoading: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
129
114
  cacheKey: string;
130
115
  agentId: string;
131
116
  versionFilter: number | null;
@@ -6,11 +6,6 @@ import {
6
6
  } from "./conversation-list.types.js";
7
7
  const initialState = {
8
8
  byConversationId: {},
9
- allConversationIds: [],
10
- globalStatus: "idle",
11
- globalError: null,
12
- globalLastFetchedAt: null,
13
- globalHasMore: false,
14
9
  agentCaches: {},
15
10
  trashConversationIds: [],
16
11
  trashByConversationId: {},
@@ -30,34 +25,6 @@ const conversationListSlice = createSlice({
30
25
  name: "conversationList",
31
26
  initialState,
32
27
  reducers: {
33
- // ── Global sidebar list ──────────────────────────────────────────────────
34
- setGlobalListLoading(state) {
35
- state.globalStatus = "loading";
36
- state.globalError = null;
37
- },
38
- setGlobalListSuccess(state, action) {
39
- const { items, hasMore, replace = true } = action.payload;
40
- for (const item of items) mergeItem(state, item);
41
- if (replace) {
42
- state.allConversationIds = items.map((i) => i.conversationId);
43
- } else {
44
- const existing = new Set(state.allConversationIds);
45
- for (const item of items) {
46
- if (!existing.has(item.conversationId)) {
47
- state.allConversationIds.push(item.conversationId);
48
- existing.add(item.conversationId);
49
- }
50
- }
51
- }
52
- state.globalHasMore = hasMore;
53
- state.globalStatus = "succeeded";
54
- state.globalLastFetchedAt = Date.now();
55
- state.globalError = null;
56
- },
57
- setGlobalListError(state, action) {
58
- state.globalStatus = "failed";
59
- state.globalError = action.payload;
60
- },
61
28
  // ── The trash (soft-deleted rows) ────────────────────────────────────────
62
29
  setTrashLoading(state) {
63
30
  state.trashStatus = "loading";
@@ -65,10 +32,10 @@ const conversationListSlice = createSlice({
65
32
  },
66
33
  setTrashSuccess(state, action) {
67
34
  const { items } = action.payload;
68
- state.trashConversationIds = items.map((i) => i.conversationId);
69
35
  for (const item of items) {
70
36
  state.trashByConversationId[item.conversationId] = item;
71
37
  }
38
+ state.trashConversationIds = Object.values(state.trashByConversationId).sort((a, b) => (b.updatedAt ?? "").localeCompare(a.updatedAt ?? "")).map((i) => i.conversationId);
72
39
  state.trashStatus = "succeeded";
73
40
  state.trashError = null;
74
41
  },
@@ -101,13 +68,13 @@ const conversationListSlice = createSlice({
101
68
  if (!existing) return;
102
69
  state.byConversationId[conversationId] = { ...existing, ...patch };
103
70
  },
104
- /** Prepend a newly-created conversation to the global list. */
71
+ /**
72
+ * Put a (restored / newly created) row into the entity store. Which LIST it
73
+ * appears in is the conversation-history scopes' business
74
+ * (`upsertConversationIntoScopes`), not this slice's.
75
+ */
105
76
  prependConversation(state, action) {
106
- const item = action.payload;
107
- mergeItem(state, item);
108
- const idx = state.allConversationIds.indexOf(item.conversationId);
109
- if (idx >= 0) state.allConversationIds.splice(idx, 1);
110
- state.allConversationIds.unshift(item.conversationId);
77
+ mergeItem(state, action.payload);
111
78
  },
112
79
  /** Optimistic rename — pair with `revertRename` on failure. */
113
80
  renameConversation(state, action) {
@@ -125,26 +92,12 @@ const conversationListSlice = createSlice({
125
92
  removeConversation(state, action) {
126
93
  const conversationId = action.payload;
127
94
  delete state.byConversationId[conversationId];
128
- const idx = state.allConversationIds.indexOf(conversationId);
129
- if (idx >= 0) state.allConversationIds.splice(idx, 1);
130
95
  for (const entry of Object.values(state.agentCaches)) {
131
96
  const i = entry.conversationIds.indexOf(conversationId);
132
97
  if (i >= 0) entry.conversationIds.splice(i, 1);
133
98
  }
134
99
  removePending(state, conversationId);
135
100
  },
136
- /** Bump to top by updatedAt (global list only — agent caches are order-preserving). */
137
- touchConversation(state, action) {
138
- const { conversationId, updatedAt } = action.payload;
139
- const item = state.byConversationId[conversationId];
140
- if (!item) return;
141
- item.updatedAt = updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
142
- const idx = state.allConversationIds.indexOf(conversationId);
143
- if (idx > 0) {
144
- state.allConversationIds.splice(idx, 1);
145
- state.allConversationIds.unshift(conversationId);
146
- }
147
- },
148
101
  // ── Pending operations ───────────────────────────────────────────────────
149
102
  markPending(state, action) {
150
103
  if (!state.pendingOperations.includes(action.payload)) {
@@ -251,9 +204,6 @@ const conversationListSlice = createSlice({
251
204
  });
252
205
  const conversationListActions = conversationListSlice.actions;
253
206
  const {
254
- setGlobalListLoading,
255
- setGlobalListSuccess,
256
- setGlobalListError,
257
207
  setTrashLoading,
258
208
  setTrashSuccess,
259
209
  setTrashError,
@@ -265,7 +215,6 @@ const {
265
215
  renameConversation,
266
216
  revertRename,
267
217
  removeConversation,
268
- touchConversation,
269
218
  markPending,
270
219
  clearPending,
271
220
  setAgentCacheLoading,
@@ -304,13 +253,9 @@ export {
304
253
  setAgentCacheError,
305
254
  setAgentCacheLoading,
306
255
  setAgentCacheSuccess,
307
- setGlobalListError,
308
- setGlobalListLoading,
309
- setGlobalListSuccess,
310
256
  setTrashError,
311
257
  setTrashLoading,
312
258
  setTrashSuccess,
313
- touchConversation,
314
259
  upsertAgentConversationInCaches,
315
260
  upsertConversation,
316
261
  upsertConversationInCaches
@@ -68,29 +68,4 @@ export declare const fetchAgentConversationsNormalized: import("@reduxjs/toolkit
68
68
  * agx_agent.id before dispatching the RPC-backed normalized thunk.
69
69
  */
70
70
  export declare function fetchAgentConversations(input: FetchAgentConversationsArgInput): ChatThunk<Promise<FetchAgentConversationsResult>>;
71
- export interface FetchGlobalConversationsArgs {
72
- limit?: number;
73
- offset?: number;
74
- replace?: boolean;
75
- }
76
- export interface FetchGlobalConversationsResult {
77
- items: ConversationListItem[];
78
- hasMore: boolean;
79
- }
80
- /**
81
- * Fetches the signed-in user's most recent conversations across all agents.
82
- * Reads directly from `cx_conversation` — the table is RLS-filtered to the
83
- * requesting user, so no agent scoping is required. Used by the `(a)/chat`
84
- * global history sidebar.
85
- */
86
- export declare const fetchGlobalConversations: import("@reduxjs/toolkit").AsyncThunk<FetchGlobalConversationsResult, void | FetchGlobalConversationsArgs, {
87
- state?: unknown;
88
- dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("redux").UnknownAction>;
89
- extra?: unknown;
90
- serializedErrorType?: unknown;
91
- pendingMeta?: unknown;
92
- fulfilledMeta?: unknown;
93
- rejectedMeta?: unknown;
94
- rejectValue: string;
95
- }>;
96
71
  export {};
@@ -1,6 +1,7 @@
1
1
  import { selectAgentById } from "../agent-definition/selectors.js";
2
2
  import { createAsyncThunk } from "@reduxjs/toolkit";
3
3
  import { supabase } from "../../../host/db.js";
4
+ import { conversationTitleText } from "@ai-matrx/content-ir/surfaces";
4
5
  import { favoritesService } from "../../../context/sources/scopes.js";
5
6
  import { isScopesRpcErr } from "../../../context/sources/scopes.js";
6
7
  import { conversationListCacheKey } from "./conversation-list.types.js";
@@ -8,15 +9,8 @@ import { selectAgentIdFromInstance } from "../execution-system/conversations/con
8
9
  import {
9
10
  setAgentCacheLoading,
10
11
  setAgentCacheSuccess,
11
- setAgentCacheError,
12
- setGlobalListLoading,
13
- setGlobalListSuccess,
14
- setGlobalListError
12
+ setAgentCacheError
15
13
  } from "./conversation-list.slice.js";
16
- import { CONVERSATION_LIST_PAGE_SIZE } from "./conversation-list.types.js";
17
- import { excludeHiddenLane } from "../conversation-history/history-filters.js";
18
- import { getUserId, hasBrowserSession } from "../../../host/identity.js";
19
- import { conversationTitleText } from "@ai-matrx/content-ir/surfaces";
20
14
  function resolveCanonicalAgentIdForConversationsFetch(input, state) {
21
15
  const versionFilter = input.versionFilter === void 0 ? null : input.versionFilter;
22
16
  let mapKey;
@@ -130,60 +124,10 @@ function fetchAgentConversations(input) {
130
124
  ).unwrap();
131
125
  };
132
126
  }
133
- const fetchGlobalConversations = createAsyncThunk(
134
- "conversationList/fetchGlobalConversations",
135
- async (rawArgs, { dispatch, rejectWithValue }) => {
136
- const args = rawArgs;
137
- const limit = args?.limit ?? CONVERSATION_LIST_PAGE_SIZE;
138
- const offset = args?.offset ?? 0;
139
- const replace = args?.replace ?? true;
140
- dispatch(setGlobalListLoading());
141
- const viewerId = getUserId();
142
- if (!viewerId && !await hasBrowserSession()) {
143
- dispatch(setGlobalListSuccess({ items: [], hasMore: false, replace }));
144
- return { items: [], hasMore: false };
145
- }
146
- let listQuery = excludeHiddenLane(
147
- // a mandate candidate's shadow leg is never listed (lanes.ts)
148
- supabase.schema("chat").from("conversation").select(
149
- "id, title, description, status, message_count, initial_agent_id, last_model_id, source_app, source_feature, created_at, updated_at, exclude_from_kg"
150
- ).is("deleted_at", null).eq("is_ephemeral", false)
151
- ).order("updated_at", { ascending: false }).range(offset, offset + limit - 1);
152
- if (viewerId) {
153
- listQuery = listQuery.eq("created_by", viewerId);
154
- }
155
- const { data, error } = await listQuery;
156
- if (error) {
157
- dispatch(setGlobalListError(error.message));
158
- return rejectWithValue(error.message);
159
- }
160
- const rows = data ?? [];
161
- const mapped = rows.map((row) => ({
162
- conversationId: row.id,
163
- title: conversationTitleText(row.title ?? null),
164
- description: row.description ?? null,
165
- updatedAt: row.updated_at,
166
- createdAt: row.created_at,
167
- status: row.status,
168
- messageCount: row.message_count ?? 0,
169
- isFavorite: false,
170
- excludeFromKg: row.exclude_from_kg ?? false,
171
- agentId: row.initial_agent_id ?? null,
172
- lastModelId: row.last_model_id ?? null,
173
- sourceApp: row.source_app ?? void 0,
174
- sourceFeature: row.source_feature ?? void 0
175
- }));
176
- const items = await applyFavoritesFromUes(mapped);
177
- const hasMore = items.length === limit;
178
- dispatch(setGlobalListSuccess({ items, hasMore, replace }));
179
- return { items, hasMore };
180
- }
181
- );
182
127
  export {
183
128
  applyFavoritesFromUes,
184
129
  fetchAgentConversations,
185
130
  fetchAgentConversationsNormalized,
186
- fetchGlobalConversations,
187
131
  mapRpcRowToAgentConversationListItem,
188
132
  mapRpcRowToConversationListItem,
189
133
  resolveCanonicalAgentIdForConversationsFetch
@@ -66,11 +66,6 @@ export interface ConversationListAgentCacheEntry {
66
66
  }
67
67
  export interface ConversationListState {
68
68
  byConversationId: Record<string, ConversationListItem>;
69
- allConversationIds: string[];
70
- globalStatus: ConversationListLoadStatus;
71
- globalError: string | null;
72
- globalLastFetchedAt: number | null;
73
- globalHasMore: boolean;
74
69
  agentCaches: Record<string, ConversationListAgentCacheEntry>;
75
70
  /**
76
71
  * THE TRASH — soft-deleted conversations (`deleted_at IS NOT NULL`), read on
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The ONE place a `chat.conversation` row becomes a `ConversationListItem`,
3
+ * and the one column list every "my conversations" read projects.
4
+ *
5
+ * The global sidebar thunk and the scoped conversation-history thunk each
6
+ * carried their own copy of this projection (same columns, same field-by-field
7
+ * mapper); they differed only by `origin_class` and the title transform.
8
+ * Favorite state is NOT here: it is canonical in `platform.user_entity_state`
9
+ * and overlaid by `applyFavoritesFromUes` after the rows load.
10
+ */
11
+ import type { ConversationListItem } from "./conversation-list.types.js";
12
+ /** Columns projected from `chat.conversation` — enough for any list row. */
13
+ export declare const CONVERSATION_ROW_COLUMNS = "id, title, description, status, message_count, initial_agent_id, last_model_id, source_app, source_feature, origin_class, created_at, updated_at, exclude_from_kg";
14
+ /** Structural row type — the columns above, loosely typed like the query result. */
15
+ export type ConversationDbRow = Record<string, unknown>;
16
+ export declare function mapConversationDbRow(row: ConversationDbRow): ConversationListItem;
@@ -0,0 +1,24 @@
1
+ import { conversationTitleText } from "@ai-matrx/content-ir/surfaces";
2
+ const CONVERSATION_ROW_COLUMNS = "id, title, description, status, message_count, initial_agent_id, last_model_id, source_app, source_feature, origin_class, created_at, updated_at, exclude_from_kg";
3
+ function mapConversationDbRow(row) {
4
+ return {
5
+ conversationId: row.id,
6
+ title: conversationTitleText(row.title ?? null),
7
+ description: row.description ?? null,
8
+ updatedAt: row.updated_at,
9
+ createdAt: row.created_at,
10
+ status: row.status,
11
+ messageCount: row.message_count ?? 0,
12
+ isFavorite: false,
13
+ excludeFromKg: row.exclude_from_kg ?? false,
14
+ agentId: row.initial_agent_id ?? null,
15
+ lastModelId: row.last_model_id ?? null,
16
+ sourceApp: row.source_app ?? void 0,
17
+ sourceFeature: row.source_feature ?? void 0,
18
+ originClass: row.origin_class ?? void 0
19
+ };
20
+ }
21
+ export {
22
+ CONVERSATION_ROW_COLUMNS,
23
+ mapConversationDbRow
24
+ };
@@ -26,6 +26,7 @@ export declare const fetchArchivedConversations: import("@reduxjs/toolkit").Asyn
26
26
  items: ConversationListItem[];
27
27
  }, void | {
28
28
  limit?: number;
29
+ agentIds?: string[];
29
30
  }, {
30
31
  extra?: unknown;
31
32
  serializedErrorType?: unknown;
@@ -3,11 +3,16 @@ import { supabase } from "../../../host/db.js";
3
3
  import { operationFailed } from "@ai-matrx/kit/errors";
4
4
  import { ensureEffectiveKnob } from "../../../host/prefs.js";
5
5
  import { selectActiveOrganizationId } from "../../../context/sources/scopes.js";
6
+ import {
7
+ CONVERSATION_ROW_COLUMNS,
8
+ mapConversationDbRow
9
+ } from "./conversation-rows.js";
6
10
  import {
7
11
  setTrashLoading,
8
12
  setTrashSuccess,
9
13
  setTrashError,
10
14
  removeFromTrash,
15
+ addToTrash,
11
16
  prependConversation
12
17
  } from "./conversation-list.slice.js";
13
18
  import { upsertConversationIntoScopes } from "../conversation-history/slice.js";
@@ -22,7 +27,8 @@ const fetchArchivedConversations = createAsyncThunk(
22
27
  async (rawArgs, { dispatch, getState, rejectWithValue }) => {
23
28
  dispatch(setTrashLoading());
24
29
  const viewerId = getUserId();
25
- let limit = rawArgs?.limit;
30
+ const args = rawArgs;
31
+ let limit = args?.limit;
26
32
  if (limit === void 0) {
27
33
  const organizationId = selectActiveOrganizationId(getState());
28
34
  try {
@@ -49,10 +55,11 @@ const fetchArchivedConversations = createAsyncThunk(
49
55
  return rejectWithValue({ message });
50
56
  }
51
57
  }
52
- let query = supabase.schema("chat").from("conversation").select(
53
- "id, title, description, status, message_count, initial_agent_id, last_model_id, source_app, source_feature, created_at, updated_at, deleted_at, exclude_from_kg"
54
- ).or("deleted_at.not.is.null,status.eq.archived").eq("is_ephemeral", false).order("updated_at", { ascending: false }).limit(limit);
58
+ let query = supabase.schema("chat").from("conversation").select(`${CONVERSATION_ROW_COLUMNS}, deleted_at`).or("deleted_at.not.is.null,status.eq.archived").eq("is_ephemeral", false).order("updated_at", { ascending: false }).limit(limit);
55
59
  if (viewerId) query = query.eq("created_by", viewerId);
60
+ if (args?.agentIds && args.agentIds.length > 0) {
61
+ query = query.in("initial_agent_id", args.agentIds);
62
+ }
56
63
  const { data, error } = await query;
57
64
  if (error) {
58
65
  const message = operationFailed("open the archive", error).message;
@@ -60,21 +67,8 @@ const fetchArchivedConversations = createAsyncThunk(
60
67
  return rejectWithValue({ message });
61
68
  }
62
69
  const items = (data ?? []).map((row) => ({
63
- conversationId: row.id,
64
- title: row.title ?? null,
65
- description: row.description ?? null,
70
+ ...mapConversationDbRow(row),
66
71
  updatedAt: row.deleted_at ?? row.updated_at,
67
- createdAt: row.created_at,
68
- status: row.status,
69
- messageCount: row.message_count ?? 0,
70
- // Pins and knowledge-graph state are irrelevant in the trash and are not
71
- // read here; a restored row picks its real values up on the next list load.
72
- isFavorite: false,
73
- excludeFromKg: row.exclude_from_kg ?? false,
74
- agentId: row.initial_agent_id ?? null,
75
- lastModelId: row.last_model_id ?? null,
76
- sourceApp: row.source_app ?? void 0,
77
- sourceFeature: row.source_feature ?? void 0,
78
72
  deletedAt: row.deleted_at ?? null
79
73
  }));
80
74
  dispatch(setTrashSuccess({ items }));
@@ -101,6 +95,7 @@ const restoreConversation = createAsyncThunk(
101
95
  message: operationFailed("restore this conversation").message
102
96
  });
103
97
  }
98
+ if (item) dispatch(addToTrash({ ...item, deletedAt: null }));
104
99
  }
105
100
  if (wasArchived) {
106
101
  const unarchived = await dispatch(