@ai-matrx/messaging 0.14.0 → 0.15.0

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.d.cts CHANGED
@@ -1122,11 +1122,18 @@ interface MessagingSnapshot {
1122
1122
  } | null;
1123
1123
  /** Conversations whose last open failed, keyed by id. Cleared on the next open. */
1124
1124
  readonly conversationReadFailures: ReadonlyMap<ConversationId, ConversationReadFailure>;
1125
+ /**
1126
+ * The inbox read FAILED (and no later read succeeded). Without it a failed
1127
+ * first read left `hasLoadedConversations` false forever — a skeleton that
1128
+ * never resolves is a screen telling a lie (RC-B12 round 11).
1129
+ */
1130
+ readonly conversationsLoadError: string | null;
1125
1131
  }
1126
1132
  interface MessagingStore {
1127
1133
  snapshot(): MessagingSnapshot;
1128
1134
  subscribe(listener: (snapshot: MessagingSnapshot) => void): () => void;
1129
1135
  setConversations(items: readonly ConversationSummary[], hasMore: boolean): void;
1136
+ setConversationsLoadError(message: string | null): void;
1130
1137
  /**
1131
1138
  * Switch the archive axis. Clears the list and marks it UNLOADED: the rows
1132
1139
  * on screen belong to the old filter, and leaving them there while the new
@@ -1236,6 +1243,8 @@ interface MessagingEngine {
1236
1243
  * refreshes the archived count the reveal label prints.
1237
1244
  */
1238
1245
  setArchiveFilter(next: MessagingArchiveFilter): Promise<void>;
1246
+ /** Read the inbox again (the failed-read view's Try again). Never throws; a failure lands in the snapshot. */
1247
+ refreshInbox(): Promise<void>;
1239
1248
  /** Re-read how many archived conversations exist, for the reveal's label. */
1240
1249
  refreshArchivedCount(): Promise<void>;
1241
1250
  /** Open a conversation: load its thread and subscribe to its channel. */
package/dist/index.d.ts CHANGED
@@ -1122,11 +1122,18 @@ interface MessagingSnapshot {
1122
1122
  } | null;
1123
1123
  /** Conversations whose last open failed, keyed by id. Cleared on the next open. */
1124
1124
  readonly conversationReadFailures: ReadonlyMap<ConversationId, ConversationReadFailure>;
1125
+ /**
1126
+ * The inbox read FAILED (and no later read succeeded). Without it a failed
1127
+ * first read left `hasLoadedConversations` false forever — a skeleton that
1128
+ * never resolves is a screen telling a lie (RC-B12 round 11).
1129
+ */
1130
+ readonly conversationsLoadError: string | null;
1125
1131
  }
1126
1132
  interface MessagingStore {
1127
1133
  snapshot(): MessagingSnapshot;
1128
1134
  subscribe(listener: (snapshot: MessagingSnapshot) => void): () => void;
1129
1135
  setConversations(items: readonly ConversationSummary[], hasMore: boolean): void;
1136
+ setConversationsLoadError(message: string | null): void;
1130
1137
  /**
1131
1138
  * Switch the archive axis. Clears the list and marks it UNLOADED: the rows
1132
1139
  * on screen belong to the old filter, and leaving them there while the new
@@ -1236,6 +1243,8 @@ interface MessagingEngine {
1236
1243
  * refreshes the archived count the reveal label prints.
1237
1244
  */
1238
1245
  setArchiveFilter(next: MessagingArchiveFilter): Promise<void>;
1246
+ /** Read the inbox again (the failed-read view's Try again). Never throws; a failure lands in the snapshot. */
1247
+ refreshInbox(): Promise<void>;
1239
1248
  /** Re-read how many archived conversations exist, for the reveal's label. */
1240
1249
  refreshArchivedCount(): Promise<void>;
1241
1250
  /** Open a conversation: load its thread and subscribe to its channel. */
package/dist/index.js CHANGED
@@ -975,6 +975,7 @@ function createMessagingStore() {
975
975
  let threads = /* @__PURE__ */ new Map();
976
976
  let activeConversationId = null;
977
977
  let conversationReadFailures = /* @__PURE__ */ new Map();
978
+ let conversationsLoadError = null;
978
979
  const listeners = /* @__PURE__ */ new Set();
979
980
  let cached = null;
980
981
  function snapshot() {
@@ -988,7 +989,8 @@ function createMessagingStore() {
988
989
  totalUnreadConversations: conversations.filter((item) => item.unreadCount > 0).length,
989
990
  archiveFilter,
990
991
  archivedCount,
991
- conversationReadFailures
992
+ conversationReadFailures,
993
+ conversationsLoadError
992
994
  };
993
995
  return cached;
994
996
  }
@@ -1033,6 +1035,12 @@ function createMessagingStore() {
1033
1035
  conversations = normalizeConversations(items);
1034
1036
  hasMoreConversations = hasMore;
1035
1037
  hasLoadedConversations = true;
1038
+ conversationsLoadError = null;
1039
+ emit();
1040
+ },
1041
+ setConversationsLoadError(message) {
1042
+ if (message === conversationsLoadError) return;
1043
+ conversationsLoadError = message;
1036
1044
  emit();
1037
1045
  },
1038
1046
  setArchiveFilter(next) {
@@ -1265,10 +1273,20 @@ function createMessagingEngine(options) {
1265
1273
  }
1266
1274
  async function reloadInbox() {
1267
1275
  if (disposed) return;
1268
- const page = await repository.listConversations({
1269
- limit: conversationPageSize,
1270
- archived: store.snapshot().archiveFilter
1271
- });
1276
+ let page;
1277
+ try {
1278
+ page = await repository.listConversations({
1279
+ limit: conversationPageSize,
1280
+ archived: store.snapshot().archiveFilter
1281
+ });
1282
+ } catch (error) {
1283
+ if (!disposed) {
1284
+ store.setConversationsLoadError(
1285
+ error instanceof Error ? error.message : typeof error === "string" ? error : "The conversation list could not be read."
1286
+ );
1287
+ }
1288
+ throw error;
1289
+ }
1272
1290
  if (disposed) return;
1273
1291
  conversationCursor = page.nextCursor;
1274
1292
  store.setConversations(page.items, page.hasMore);
@@ -1353,6 +1371,13 @@ function createMessagingEngine(options) {
1353
1371
  }
1354
1372
  });
1355
1373
  },
1374
+ async refreshInbox() {
1375
+ try {
1376
+ await reloadInbox();
1377
+ } catch (error) {
1378
+ reportError(error, "inboxRefresh");
1379
+ }
1380
+ },
1356
1381
  async setArchiveFilter(next) {
1357
1382
  if (next === store.snapshot().archiveFilter) return;
1358
1383
  store.setArchiveFilter(next);