@marktiderman/genesis-chat 0.12.0 → 0.13.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.
Files changed (45) hide show
  1. package/README.md +46 -1
  2. package/dist/{chunk-2HNQWDLF.js → chunk-3UNYTK62.js} +3 -3
  3. package/dist/{chunk-2HNQWDLF.js.map → chunk-3UNYTK62.js.map} +1 -1
  4. package/dist/{chunk-VBIYDXL2.js → chunk-GEEJMKQF.js} +22 -3
  5. package/dist/chunk-GEEJMKQF.js.map +1 -0
  6. package/dist/{chunk-K5GYNHNE.js → chunk-H4BRVJJ7.js} +136 -23
  7. package/dist/chunk-H4BRVJJ7.js.map +1 -0
  8. package/dist/{chunk-3HQN2FZ5.js → chunk-SEMN3S6Q.js} +3 -3
  9. package/dist/{chunk-3HQN2FZ5.js.map → chunk-SEMN3S6Q.js.map} +1 -1
  10. package/dist/{client-DJs3ltZc.d.ts → client-DXWyDJ2u.d.ts} +14 -0
  11. package/dist/index.d.ts +4 -4
  12. package/dist/index.js +3 -3
  13. package/dist/native.d.ts +20 -12
  14. package/dist/native.js +40 -32
  15. package/dist/native.js.map +1 -1
  16. package/dist/{outbox-YFTbGIAl.d.ts → outbox-Ctngv6Yz.d.ts} +1 -1
  17. package/dist/push.d.ts +2 -2
  18. package/dist/react.d.ts +73 -4
  19. package/dist/react.js +3 -3
  20. package/dist/server.d.ts +1 -1
  21. package/dist/server.js +1 -1
  22. package/dist/{thread-CgHP00Jw.d.ts → thread-mZsRiIGz.d.ts} +1 -1
  23. package/dist/web.d.ts +24 -7
  24. package/dist/web.js +140 -67
  25. package/dist/web.js.map +1 -1
  26. package/migrations/0007_genesis_chat_unread_and_delete_for_me.sql +455 -0
  27. package/migrations/tests/0007_genesis_chat_unread_and_delete_for_me.test.sql +178 -0
  28. package/package.json +13 -9
  29. package/src/__tests__/inbox-row-actions.test.tsx +251 -0
  30. package/src/__tests__/unread-delete-for-me.test.ts +84 -0
  31. package/src/__tests__/web.test.tsx +5 -2
  32. package/src/core/client.ts +21 -1
  33. package/src/native/__tests__/inbox-screen-actions.test.tsx +131 -0
  34. package/src/native/__tests__/inbox-screen.test.tsx +29 -1
  35. package/src/native/__tests__/thread-layout.test.ts +2 -2
  36. package/src/native/copy.ts +7 -10
  37. package/src/native/inbox-screen.tsx +52 -27
  38. package/src/native/index.ts +1 -1
  39. package/src/react/inbox-actions.ts +121 -0
  40. package/src/react/index.tsx +99 -17
  41. package/src/web/inbox.tsx +120 -11
  42. package/src/web/index.ts +1 -1
  43. package/src/web/memory-client.ts +40 -7
  44. package/dist/chunk-K5GYNHNE.js.map +0 -1
  45. package/dist/chunk-VBIYDXL2.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { b as AttachmentKind, A as AttachmentInput, U as UploadProgress, H as HostedAttachment, i as ChatClient, B as PendingMessage, P as PendingFile, q as ChatMessage, F as SendInput } from './client-DJs3ltZc.js';
1
+ import { b as AttachmentKind, A as AttachmentInput, U as UploadProgress, H as HostedAttachment, i as ChatClient, B as PendingMessage, P as PendingFile, q as ChatMessage, F as SendInput } from './client-DXWyDJ2u.js';
2
2
 
3
3
  /**
4
4
  * @feat:chat
package/dist/push.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { i as ChatClient } from './client-DJs3ltZc.js';
2
- import { O as Outbox, e as OutboxStore, Q as QueuedMessage } from './outbox-YFTbGIAl.js';
1
+ import { i as ChatClient } from './client-DXWyDJ2u.js';
2
+ import { O as Outbox, e as OutboxStore, Q as QueuedMessage } from './outbox-Ctngv6Yz.js';
3
3
  import '@supabase/supabase-js';
4
4
 
5
5
  /**
package/dist/react.d.ts CHANGED
@@ -1,13 +1,71 @@
1
1
  import * as _tanstack_query_core from '@tanstack/query-core';
2
- import { h as ChatAttachment, i as ChatClient, k as ChatConversation, p as ChatMember, t as ChatRole, n as ChatKindRules, q as ChatMessage, g as ChatActivity, F as SendInput, M as MessagePage, C as ChatAvailability, d as AvailabilityInput, v as ChatSignal, m as ChatInboxItem, o as ChatLinkPreview, D as ScheduledMessage, S as ScheduleInput, u as ChatSearchHit, G as StartConversationOptions, x as ChatTopic, T as TopicInput } from './client-DJs3ltZc.js';
2
+ import { m as ChatInboxItem, h as ChatAttachment, i as ChatClient, k as ChatConversation, p as ChatMember, t as ChatRole, n as ChatKindRules, q as ChatMessage, g as ChatActivity, F as SendInput, M as MessagePage, C as ChatAvailability, d as AvailabilityInput, v as ChatSignal, o as ChatLinkPreview, D as ScheduledMessage, S as ScheduleInput, u as ChatSearchHit, G as StartConversationOptions, x as ChatTopic, T as TopicInput } from './client-DXWyDJ2u.js';
3
3
  import * as react from 'react';
4
4
  import { ReactNode } from 'react';
5
- import { e as OutboxStore, S as StorageUpload, H as HostedUpload, L as LocalFile, O as Outbox, Q as QueuedMessage } from './outbox-YFTbGIAl.js';
6
- import { T as ThreadItem } from './thread-CgHP00Jw.js';
5
+ import { RowSwipeAction } from '@marktiderman/genesis-core/row-actions';
6
+ import { e as OutboxStore, S as StorageUpload, H as HostedUpload, L as LocalFile, O as Outbox, Q as QueuedMessage } from './outbox-Ctngv6Yz.js';
7
+ import { T as ThreadItem } from './thread-mZsRiIGz.js';
7
8
  import '@supabase/supabase-js';
8
9
 
10
+ /**
11
+ * The inbox's row actions, built once for web and native (`inboxRowActions`): Messages' Mark as
12
+ * Unread (or Read) and Pin to the leading side, Hide Alerts and Delete for me to the trailing one,
13
+ * Archive in the menu only. ChatInboxScreen (native) and ChatInbox (web) both take them, and an app
14
+ * reshapes them with `rowActions(item, defaults)`.
15
+ *
16
+ * The look is Messages': Unread blue (`info`), Pin orange, Hide Alerts purple, Delete red.
17
+ */
18
+
19
+ /** The words on the inbox's row actions, shared by the native copy and the web inbox. */
20
+ interface ChatInboxActionLabels {
21
+ markRead: string;
22
+ /** Mark as Unread (migration 0007): only you see it. */
23
+ markUnread: string;
24
+ pin: string;
25
+ unpin: string;
26
+ /** Mute from the inbox row, as Messages names it. */
27
+ hideAlerts: string;
28
+ showAlerts: string;
29
+ archive: string;
30
+ /** Delete for me (migration 0007), and its confirmation. */
31
+ deleteConversation: string;
32
+ deleteConversationTitle: string;
33
+ deleteConversationBody: string;
34
+ /** The confirmation's Cancel. */
35
+ cancel: string;
36
+ /** A muted row's bell-slash, for a screen reader. */
37
+ alertsOff: string;
38
+ /** A pinned row's pin, for a screen reader. */
39
+ pinnedMark: string;
40
+ }
41
+ /** The English words, which the native copy starts from too. */
42
+ declare const defaultInboxActionLabels: ChatInboxActionLabels;
43
+ /** Asks before a destructive action: resolves `true` to go ahead. Native passes an Alert, web a dialog. */
44
+ type ChatConfirm = (title: string, body: string, confirmLabel: string) => Promise<boolean>;
45
+ /** What `useInboxActions` returns: your own actions on one inbox row, each the call's promise. */
46
+ interface ChatInboxActions {
47
+ /** Mark as Read when it has unread messages, else Mark as Unread. */
48
+ toggleUnread: (item: ChatInboxItem) => Promise<unknown>;
49
+ togglePinned: (item: ChatInboxItem) => Promise<unknown>;
50
+ /** Show Alerts when muted, else Hide Alerts until `until` (default: until turned back on). */
51
+ toggleMuted: (item: ChatInboxItem, until?: string) => Promise<unknown>;
52
+ setArchived: (item: ChatInboxItem, archived: boolean) => Promise<unknown>;
53
+ /** Delete for me, up to the last message the row showed (`item.lastSeq`). */
54
+ deleteForMe: (item: ChatInboxItem) => Promise<unknown>;
55
+ }
56
+ interface InboxRowActionsOptions {
57
+ /** Asks before Delete for me. */
58
+ confirm: ChatConfirm;
59
+ /** A failed action: say so (an alert, a toast). Default: nothing. */
60
+ onError?: (error: unknown) => void;
61
+ }
62
+ /** One inbox row's actions: Messages' set, in its order and colors. */
63
+ declare function inboxRowActions(item: ChatInboxItem, act: ChatInboxActions, labels: ChatInboxActionLabels, options: InboxRowActionsOptions): RowSwipeAction[];
64
+
9
65
  declare const chatKeys: {
10
66
  all: readonly ["genesis-chat"];
67
+ /** Every inbox list (each `inbox(opts)` is under it). */
68
+ inboxAll: () => readonly ["genesis-chat", "inbox"];
11
69
  inbox: (opts?: object) => readonly ["genesis-chat", "inbox", object];
12
70
  unread: () => readonly ["genesis-chat", "unread"];
13
71
  conversation: (id: string) => readonly ["genesis-chat", "conversation", string];
@@ -20,6 +78,8 @@ declare const chatKeys: {
20
78
  scheduled: (conversationId?: string | null) => readonly ["genesis-chat", "scheduled", string | null];
21
79
  availability: (conversationId: string) => readonly ["genesis-chat", "conversation", string, "availability"];
22
80
  myAvailability: () => readonly ["genesis-chat", "my-availability"];
81
+ /** Every search's results (each `search(query, id)` is under it). */
82
+ searchAll: () => readonly ["genesis-chat", "search"];
23
83
  search: (query: string, conversationId?: string | null) => readonly ["genesis-chat", "search", string | null, string];
24
84
  previews: (messageIds: string[]) => readonly ["genesis-chat", "previews", string[]];
25
85
  /** One message's link previews (useLinkPreviews keeps one query per message). */
@@ -218,6 +278,15 @@ declare function useMessageActions(): {
218
278
  save: (m: ChatMessage, on: boolean, note?: string) => Promise<void>;
219
279
  report: (m: ChatMessage, reason: "spam" | "harassment" | "safety" | "other", note?: string) => Promise<string>;
220
280
  };
281
+ /**
282
+ * Your own actions on one inbox row (Mark as Unread or Read, Pin, Hide Alerts, Archive, Delete for
283
+ * me), refreshing the inbox and badge afterwards. Each takes the row's item and returns the call's
284
+ * promise, so a failure reaches the caller to show. Delete for me reads the row's `lastSeq` (what
285
+ * you saw) and drops the conversation's cached thread, pins and search results, so its deleted
286
+ * history can't show again on this device when a new message brings it back.
287
+ * `inboxRowActions(item, actions, labels, { confirm })` turns them into the row's swipe and menu.
288
+ */
289
+ declare function useInboxActions(): ChatInboxActions;
221
290
  /**
222
291
  * Names and avatars for these people, from the provider's `loadPeople`, fetched as one
223
292
  * batch per set of ids and cached. Unknown ids are left out.
@@ -311,4 +380,4 @@ declare const LINK_PREVIEW_CONCURRENCY = 4;
311
380
  */
312
381
  declare function useLinkPreviews(messageIds: (string | null | undefined)[]): Record<string, ChatLinkPreview[]>;
313
382
 
314
- export { CATCH_UP_MAX_PAGES, CATCH_UP_PAGE, type ChatAttachmentKind, type ChatCardContext, type ChatPerson, ChatProvider, type ChatProviderProps, type ChatVideoUpload, type ConversationState, LINK_PREVIEW_CONCURRENCY, LocalFile, type MessagesData, QueuedMessage, ThreadItem, type UseConversationOptions, belongsTo, chatKeys, hostedUploadFrom, useAvailability, useBroadcast, useChat, useConversation, useDebouncedValue, useFileUrls, useInbox, useLinkPreviews, useMessageActions, usePeople, usePerson, usePins, useScheduled, useSearch, useStartConversation, useTopics, useUnreadTotal };
383
+ export { CATCH_UP_MAX_PAGES, CATCH_UP_PAGE, type ChatAttachmentKind, type ChatCardContext, type ChatConfirm, type ChatInboxActionLabels, type ChatInboxActions, type ChatPerson, ChatProvider, type ChatProviderProps, type ChatVideoUpload, type ConversationState, type InboxRowActionsOptions, LINK_PREVIEW_CONCURRENCY, LocalFile, type MessagesData, QueuedMessage, ThreadItem, type UseConversationOptions, belongsTo, chatKeys, defaultInboxActionLabels, hostedUploadFrom, inboxRowActions, useAvailability, useBroadcast, useChat, useConversation, useDebouncedValue, useFileUrls, useInbox, useInboxActions, useLinkPreviews, useMessageActions, usePeople, usePerson, usePins, useScheduled, useSearch, useStartConversation, useTopics, useUnreadTotal };
package/dist/react.js CHANGED
@@ -1,5 +1,5 @@
1
- export { CATCH_UP_MAX_PAGES, CATCH_UP_PAGE, ChatProvider, LINK_PREVIEW_CONCURRENCY, belongsTo, chatKeys, hostedUploadFrom, useAvailability, useBroadcast, useChat, useConversation, useDebouncedValue, useFileUrls, useInbox, useLinkPreviews, useMessageActions, usePeople, usePerson, usePins, useScheduled, useSearch, useStartConversation, useTopics, useUnreadTotal } from './chunk-K5GYNHNE.js';
2
- import './chunk-2HNQWDLF.js';
3
- import './chunk-VBIYDXL2.js';
1
+ export { CATCH_UP_MAX_PAGES, CATCH_UP_PAGE, ChatProvider, LINK_PREVIEW_CONCURRENCY, belongsTo, chatKeys, defaultInboxActionLabels, hostedUploadFrom, inboxRowActions, useAvailability, useBroadcast, useChat, useConversation, useDebouncedValue, useFileUrls, useInbox, useInboxActions, useLinkPreviews, useMessageActions, usePeople, usePerson, usePins, useScheduled, useSearch, useStartConversation, useTopics, useUnreadTotal } from './chunk-H4BRVJJ7.js';
2
+ import './chunk-3UNYTK62.js';
3
+ import './chunk-GEEJMKQF.js';
4
4
  //# sourceMappingURL=react.js.map
5
5
  //# sourceMappingURL=react.js.map
package/dist/server.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { w as ChatSupabase } from './client-DJs3ltZc.js';
1
+ import { w as ChatSupabase } from './client-DXWyDJ2u.js';
2
2
  export { a as ANTHROPIC_MESSAGES_URL, b as ANTHROPIC_VERSION, c as AnthropicLike, A as AssistantMessage, d as AssistantResult, C as CHAT_ASSISTANT_MODEL, e as ChatAssistant, f as ChatAssistantOptions, D as DraftReplyInput, R as RecapInput, g as createChatAssistant, h as draftPrompt, i as draftSystem, r as recapPrompt, j as recapSystem, t as transcriptLines } from './assistant-DLRCksST.js';
3
3
  import '@supabase/supabase-js';
4
4
 
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CHAT_BUCKET, CHAT_SCHEMA } from './chunk-VBIYDXL2.js';
1
+ import { CHAT_BUCKET, CHAT_SCHEMA } from './chunk-GEEJMKQF.js';
2
2
  import { chatPushPayload } from './chunk-BTG4JWLF.js';
3
3
  export { ANTHROPIC_MESSAGES_URL, ANTHROPIC_VERSION, CHAT_ASSISTANT_MODEL, createChatAssistant, draftPrompt, draftSystem, recapPrompt, recapSystem, transcriptLines } from './chunk-ZHZVQ535.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { q as ChatMessage, B as PendingMessage, g as ChatActivity } from './client-DJs3ltZc.js';
1
+ import { q as ChatMessage, B as PendingMessage, g as ChatActivity } from './client-DXWyDJ2u.js';
2
2
 
3
3
  /**
4
4
  * @feat:chat
package/dist/web.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import * as react from 'react';
2
- import { ComponentType, ReactNode, Ref, Component, ErrorInfo } from 'react';
2
+ import { ReactElement, ComponentType, ReactNode, Ref, Component, ErrorInfo } from 'react';
3
3
  import { SlotOverride } from '@marktiderman/genesis-core/slots';
4
- import { q as ChatMessage, m as ChatInboxItem, o as ChatLinkPreview$1, h as ChatAttachment, k as ChatConversation, p as ChatMember, t as ChatRole, i as ChatClient, g as ChatActivity, C as ChatAvailability, x as ChatTopic, T as TopicInput, u as ChatSearchHit, F as SendInput, A as AttachmentInput } from './client-DJs3ltZc.js';
5
- import { ChatAttachmentKind, ConversationState, ChatVideoUpload } from './react.js';
6
- import { T as ThreadItem } from './thread-CgHP00Jw.js';
7
- import { L as LocalFile } from './outbox-YFTbGIAl.js';
4
+ import { RowSwipeAction } from '@marktiderman/genesis-core/row-actions';
5
+ import { q as ChatMessage, m as ChatInboxItem, o as ChatLinkPreview$1, h as ChatAttachment, k as ChatConversation, p as ChatMember, t as ChatRole, i as ChatClient, g as ChatActivity, C as ChatAvailability, x as ChatTopic, T as TopicInput, u as ChatSearchHit, F as SendInput, A as AttachmentInput } from './client-DXWyDJ2u.js';
6
+ import { ChatInboxActionLabels, ChatConfirm, ChatAttachmentKind, ConversationState, ChatVideoUpload } from './react.js';
7
+ import { T as ThreadItem } from './thread-mZsRiIGz.js';
8
+ import { L as LocalFile } from './outbox-Ctngv6Yz.js';
8
9
  import '@supabase/supabase-js';
9
10
  import '@tanstack/query-core';
10
11
 
@@ -42,6 +43,15 @@ interface ChatInboxProps {
42
43
  archived?: boolean;
43
44
  /** A conversation's title when it has none and isn't two-person. */
44
45
  fallbackTitle?: (item: ChatInboxItem) => string;
46
+ /**
47
+ * Each row's actions in its More menu: receives the conversation and the default set
48
+ * (`inboxRowActions`) and returns the row's; `() => []` turns them off.
49
+ */
50
+ rowActions?: (item: ChatInboxItem, defaults: RowSwipeAction[]) => RowSwipeAction[];
51
+ /** The actions' and the delete confirmation's words. Default English. */
52
+ actionLabels?: Partial<ChatInboxActionLabels>;
53
+ /** A failed action: say so (a toast). Default: nothing. */
54
+ onActionError?: (error: unknown) => void;
45
55
  /** Replace or eject (`null`) the empty state. */
46
56
  slots?: {
47
57
  empty?: SlotOverride<ChatInboxEmptyProps>;
@@ -51,7 +61,12 @@ interface ChatInboxProps {
51
61
  }
52
62
  /** The title an inbox row shows. */
53
63
  declare function inboxTitle(item: ChatInboxItem, resolveUser: ResolveUser, fallback?: (item: ChatInboxItem) => string): string;
54
- declare function ChatInbox({ resolveUser, onSelect, selectedId, kind, archived, fallbackTitle, slots, className, ...rest }: ChatInboxProps): react.JSX.Element;
64
+ /** A `ChatConfirm` drawn as genesis-ui's AlertDialog: the confirm to pass, and the dialog to render. */
65
+ declare function useConfirmDialog(cancelLabel?: string): {
66
+ confirm: ChatConfirm;
67
+ dialog: ReactElement;
68
+ };
69
+ declare function ChatInbox({ resolveUser, onSelect, selectedId, kind, archived, fallbackTitle, rowActions, actionLabels, onActionError, slots, className, ...rest }: ChatInboxProps): react.JSX.Element;
55
70
 
56
71
  /**
57
72
  * Whether a link preview shows its image. The image lives on the linked site, so loading it
@@ -461,6 +476,8 @@ interface MemoryConversationSeed {
461
476
  canPost?: boolean;
462
477
  muted?: boolean;
463
478
  pinned?: boolean;
479
+ /** In your archive: left out of the inbox, listed by `inbox({ archived: true })`. */
480
+ archived?: boolean;
464
481
  messages?: (Partial<Omit<ChatMessage, "attachments">> & {
465
482
  attachments?: Partial<ChatAttachment>[];
466
483
  })[];
@@ -913,4 +930,4 @@ declare function chatDockWindowsThatFit(width: number, count: number): number;
913
930
  */
914
931
  declare function ChatDock({ resolveUser, threadProps, labels: labelOverrides, bubble, className }: ChatDockProps): react.JSX.Element | null;
915
932
 
916
- export { type AttachmentView, ChatAttachmentCard, type ChatAttachmentCardProps, type ChatAttachmentSlotProps, ChatAvailabilitySettings, type ChatAvailabilitySettingsProps, ChatAwayBanner, type ChatAwayBannerProps, ChatBroadcast, type ChatBroadcastProps, ChatComposer, type ChatComposerAccessoryProps, type ChatComposerHandle, type ChatComposerProps, ChatDock, type ChatDockAction, type ChatDockApi, type ChatDockConversation, type ChatDockItem, type ChatDockLabels, type ChatDockPanel, type ChatDockPanelPatch, type ChatDockProps, ChatDockProvider, type ChatDockProviderProps, type ChatDockState, ChatEmojiPicker, type ChatEmojiPickerProps, ChatErrorBoundary, type ChatErrorBoundaryProps, ChatInbox, type ChatInboxEmptyProps, type ChatInboxProps, ChatLinkPreview, type ChatLinkPreviewProps, ChatMarkdown, type ChatMarkdownProps, ChatPanel, type ChatPanelNoSelectionProps, type ChatPanelProps, ChatScheduleMenu, type ChatScheduleMenuProps, ChatScheduledList, type ChatScheduledListProps, ChatSearch, type ChatSearchProps, ChatThread, type ChatThreadEmptyProps, type ChatThreadHeaderProps, type ChatThreadProps, type ChatThreadSlots, ChatTopicBar, type ChatTopicBarProps, type ChatUser, ChatVideoPlayer, type ChatVideoPlayerProps, ChatVideoRecorder, type ChatVideoRecorderProps, FileChip, GenericAttachment, ImageGrid, type ImageGridProps, Lightbox, type LightboxProps, type LinkPreviewImages, type MarkdownNode, type MemoryChatClient, type MemoryChatOptions, type MemoryConversationSeed, MessageAttachments, type MessageAttachmentsProps, MessageRow, type MessageRowProps, type OpenConversationOptions, type OpenPanelInput, QUICK_REACTIONS, type ResolveUser, SearchSnippet, type UseVideoRecorderOptions, type UseVoiceRecorderOptions, VideoAttachment, type VideoRecorder, type VideoRecorderState, type VideoRecording, VoiceNote, type VoiceNoteProps, type VoiceRecorder, type VoiceRecorderState, type VoiceRecording, canPickEmoji, chatDockReducer, chatDockWindowsThatFit, clockTime, createMemoryChatClient, defaultChatDockLabels, emptyChatDock, forgetChatDock, formatBytes, inboxTitle, isSafeHref, linkPreviewImageSrc, messageLabel, muxPosterUrl, muxStreamUrl, parseMarkdown, pickVideoMimeType, pickVoiceMimeType, plainText, relativeTime, toAttachmentView, toLocalInput, uploadVideo, useChatDock, useOptionalChatDock, useVideoRecorder, useVoiceRecorder, videoFile, voiceFile };
933
+ export { type AttachmentView, ChatAttachmentCard, type ChatAttachmentCardProps, type ChatAttachmentSlotProps, ChatAvailabilitySettings, type ChatAvailabilitySettingsProps, ChatAwayBanner, type ChatAwayBannerProps, ChatBroadcast, type ChatBroadcastProps, ChatComposer, type ChatComposerAccessoryProps, type ChatComposerHandle, type ChatComposerProps, ChatDock, type ChatDockAction, type ChatDockApi, type ChatDockConversation, type ChatDockItem, type ChatDockLabels, type ChatDockPanel, type ChatDockPanelPatch, type ChatDockProps, ChatDockProvider, type ChatDockProviderProps, type ChatDockState, ChatEmojiPicker, type ChatEmojiPickerProps, ChatErrorBoundary, type ChatErrorBoundaryProps, ChatInbox, type ChatInboxEmptyProps, type ChatInboxProps, ChatLinkPreview, type ChatLinkPreviewProps, ChatMarkdown, type ChatMarkdownProps, ChatPanel, type ChatPanelNoSelectionProps, type ChatPanelProps, ChatScheduleMenu, type ChatScheduleMenuProps, ChatScheduledList, type ChatScheduledListProps, ChatSearch, type ChatSearchProps, ChatThread, type ChatThreadEmptyProps, type ChatThreadHeaderProps, type ChatThreadProps, type ChatThreadSlots, ChatTopicBar, type ChatTopicBarProps, type ChatUser, ChatVideoPlayer, type ChatVideoPlayerProps, ChatVideoRecorder, type ChatVideoRecorderProps, FileChip, GenericAttachment, ImageGrid, type ImageGridProps, Lightbox, type LightboxProps, type LinkPreviewImages, type MarkdownNode, type MemoryChatClient, type MemoryChatOptions, type MemoryConversationSeed, MessageAttachments, type MessageAttachmentsProps, MessageRow, type MessageRowProps, type OpenConversationOptions, type OpenPanelInput, QUICK_REACTIONS, type ResolveUser, SearchSnippet, type UseVideoRecorderOptions, type UseVoiceRecorderOptions, VideoAttachment, type VideoRecorder, type VideoRecorderState, type VideoRecording, VoiceNote, type VoiceNoteProps, type VoiceRecorder, type VoiceRecorderState, type VoiceRecording, canPickEmoji, chatDockReducer, chatDockWindowsThatFit, clockTime, createMemoryChatClient, defaultChatDockLabels, emptyChatDock, forgetChatDock, formatBytes, inboxTitle, isSafeHref, linkPreviewImageSrc, messageLabel, muxPosterUrl, muxStreamUrl, parseMarkdown, pickVideoMimeType, pickVoiceMimeType, plainText, relativeTime, toAttachmentView, toLocalInput, uploadVideo, useChatDock, useConfirmDialog, useOptionalChatDock, useVideoRecorder, useVoiceRecorder, videoFile, voiceFile };
package/dist/web.js CHANGED
@@ -1,15 +1,15 @@
1
- import { attachmentPreview, ChatErrorBoundary } from './chunk-3HQN2FZ5.js';
2
- export { ChatErrorBoundary } from './chunk-3HQN2FZ5.js';
1
+ import { attachmentPreview, ChatErrorBoundary } from './chunk-SEMN3S6Q.js';
2
+ export { ChatErrorBoundary } from './chunk-SEMN3S6Q.js';
3
3
  import { snippetParts, isHttpsUrl, scheduleQuickPicks, isSchedulable, scheduleLabel, extractLinks, topicKey } from './chunk-BJCE5O7V.js';
4
- import { useChat, useInbox, useSearch, useScheduled, useAvailability, useTopics, useConversation, useMessageActions, usePins, useFileUrls, useLinkPreviews, useBroadcast } from './chunk-K5GYNHNE.js';
5
- import { previewText, summarizeReactions, activityLine, itemSender, startsDay, dayLabel, itemTime, startsGroup, parseMentions } from './chunk-2HNQWDLF.js';
6
- import { fileExtension, formatDuration, nextPlaybackRate, awaySummary, awayLine, WEEKDAYS, CHAT_LIMITS, waveformPeaks, recordingLimitMs, isAllowedExtension, attachmentKindFor, randomId, ChatError } from './chunk-VBIYDXL2.js';
7
- import { createContext, useMemo, useState, useRef, Fragment as Fragment$1, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useReducer, useContext, useSyncExternalStore } from 'react';
4
+ import { useChat, useInbox, useInboxActions, defaultInboxActionLabels, inboxRowActions, useSearch, useScheduled, useAvailability, useTopics, useConversation, useMessageActions, usePins, useFileUrls, useLinkPreviews, useBroadcast } from './chunk-H4BRVJJ7.js';
5
+ import { previewText, summarizeReactions, activityLine, itemSender, startsDay, dayLabel, itemTime, startsGroup, parseMentions } from './chunk-3UNYTK62.js';
6
+ import { fileExtension, formatDuration, nextPlaybackRate, awaySummary, awayLine, WEEKDAYS, CHAT_LIMITS, waveformPeaks, recordingLimitMs, isAllowedExtension, attachmentKindFor, randomId, ChatError } from './chunk-GEEJMKQF.js';
7
+ import { createContext, useState, useRef, useCallback, useEffect, useMemo, Fragment as Fragment$1, useImperativeHandle, useLayoutEffect, useReducer, useContext, useSyncExternalStore } from 'react';
8
8
  import { MessageSquare, Pin, BellOff, AtSign, Search, X, Mic, ClipboardList, ExternalLink, VideoOff, Video, RotateCcw, SendHorizontal, Square, Circle, Pause, Play, Paperclip, FileText, Download, Lock, Ban, EyeOff, ShieldAlert, AlertCircle, Clock, Reply, Copy, Pencil, PinOff, Bookmark, Flag, Trash2, SmilePlus, Plus, MoreHorizontal, ChevronUp, CalendarClock, Moon, RefreshCw, Smile, Hash, LockOpen, ImagePlus, Megaphone, MessageCircle, Link2, ArrowLeft, ChevronDown, Maximize2 } from 'lucide-react';
9
- import { InboxPage, cn, EmptyState, Button, UserAvatar, Badge, Input, Skeleton, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Alert, AlertDescription, Spinner, Collapsible, CollapsibleTrigger, CollapsibleContent, Lightbox as Lightbox$1, Progress, ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuSeparator, ContextMenuItem, Tooltip, Textarea, Popover, PopoverTrigger, PopoverContent, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuSeparator, DropdownMenuItem, DropdownMenuLabel, Label, DialogFooter, toast, Switch, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Toggle, ToggleGroup, ToggleGroupItem, ThreadPage, Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction, RadioGroup, RadioGroupItem, Split, Checkbox } from '@marktiderman/genesis-ui';
9
+ import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction, InboxPage, cn, EmptyState, Button, UserAvatar, Badge, InboxRowMenu, Input, Skeleton, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Alert, AlertDescription, Spinner, Collapsible, CollapsibleTrigger, CollapsibleContent, Lightbox as Lightbox$1, Progress, ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuSeparator, ContextMenuItem, Tooltip, Textarea, Popover, PopoverTrigger, PopoverContent, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuSeparator, DropdownMenuItem, DropdownMenuLabel, Label, DialogFooter, toast, Switch, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Toggle, ToggleGroup, ToggleGroupItem, ThreadPage, Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, RadioGroup, RadioGroupItem, Split, Checkbox } from '@marktiderman/genesis-ui';
10
10
  import { renderSlot } from '@marktiderman/genesis-core/slots';
11
11
  import { relativeTime as relativeTime$1 } from '@marktiderman/genesis-ui/utils';
12
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
12
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
13
  import { EmojiPicker } from 'frimousse';
14
14
  import { useIsMobile } from '@marktiderman/genesis-ui/hooks';
15
15
  import { createLocalStorageAdapter } from '@marktiderman/genesis-core/storage';
@@ -49,9 +49,50 @@ function inboxTitle(item, resolveUser, fallback) {
49
49
  return fallback?.(item) ?? "Conversation";
50
50
  }
51
51
  var formatTime = (date) => relativeTime(date.toISOString());
52
- function ChatInbox({ resolveUser, onSelect, selectedId, kind, archived = false, fallbackTitle, slots, className, ...rest }) {
52
+ function useConfirmDialog(cancelLabel = "Cancel") {
53
+ const [pending, setPending] = useState(null);
54
+ const current = useRef(null);
55
+ const confirm = useCallback(
56
+ (title, body, label) => new Promise((resolve) => {
57
+ current.current?.answer(false);
58
+ const next = { title, body, label, answer: resolve };
59
+ current.current = next;
60
+ setPending(next);
61
+ }),
62
+ []
63
+ );
64
+ useEffect(
65
+ () => () => {
66
+ const p = current.current;
67
+ current.current = null;
68
+ p?.answer(false);
69
+ },
70
+ []
71
+ );
72
+ const answer = (ok) => {
73
+ const p = current.current;
74
+ current.current = null;
75
+ setPending(null);
76
+ p?.answer(ok);
77
+ };
78
+ const dialog = /* @__PURE__ */ jsx(AlertDialog, { open: pending !== null, onOpenChange: (o) => !o && answer(false), children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
79
+ /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
80
+ /* @__PURE__ */ jsx(AlertDialogTitle, { children: pending?.title }),
81
+ /* @__PURE__ */ jsx(AlertDialogDescription, { children: pending?.body })
82
+ ] }),
83
+ /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
84
+ /* @__PURE__ */ jsx(AlertDialogCancel, { children: cancelLabel }),
85
+ /* @__PURE__ */ jsx(AlertDialogAction, { className: "bg-destructive text-destructive-foreground hover:bg-destructive/90", onClick: () => answer(true), "data-testid": "genesis-chat-inbox-confirm", children: pending?.label })
86
+ ] })
87
+ ] }) });
88
+ return { confirm, dialog };
89
+ }
90
+ function ChatInbox({ resolveUser, onSelect, selectedId, kind, archived = false, fallbackTitle, rowActions, actionLabels, onActionError, slots, className, ...rest }) {
53
91
  const { userId: me, attachmentKinds } = useChat();
54
92
  const { items, isLoading, error, refetch } = useInbox({ kind, archived });
93
+ const act = useInboxActions();
94
+ const labels = useMemo(() => ({ ...defaultInboxActionLabels, ...actionLabels }), [actionLabels]);
95
+ const { confirm, dialog } = useConfirmDialog(labels.cancel);
55
96
  const rows = useMemo(
56
97
  () => items.map((item) => {
57
98
  const title = inboxTitle(item, resolveUser, fallbackTitle);
@@ -62,35 +103,44 @@ function ChatInbox({ resolveUser, onSelect, selectedId, kind, archived = false,
62
103
  else if (!item.otherUserId && item.memberCount > 2) preview = `${resolveUser(last.senderId).name}: ${preview}`;
63
104
  }
64
105
  const timestamp = item.lastMessageAt ?? last?.createdAt;
106
+ const defaults = inboxRowActions(item, act, labels, { confirm, ...onActionError ? { onError: onActionError } : {} });
65
107
  return {
66
108
  id: item.conversationId,
67
109
  title,
68
110
  preview,
69
111
  unreadCount: item.unread,
112
+ muted: item.muted,
113
+ pinned: item.pinned,
70
114
  ...timestamp ? { timestamp } : {},
71
115
  chat: item,
72
- avatarUrl: item.otherUserId ? resolveUser(item.otherUserId).avatarUrl : void 0
116
+ avatarUrl: item.otherUserId ? resolveUser(item.otherUserId).avatarUrl : void 0,
117
+ swipeActions: rowActions ? rowActions(item, defaults) : defaults
73
118
  };
74
119
  }),
75
- [items, me, resolveUser, fallbackTitle, attachmentKinds]
120
+ [items, me, resolveUser, fallbackTitle, attachmentKinds, act, labels, confirm, onActionError, rowActions]
76
121
  );
77
122
  const label = rest["aria-label"] ?? "Conversations";
78
- return /* @__PURE__ */ jsx("nav", { "aria-label": label, className: cn("flex min-h-0 flex-col", className), children: /* @__PURE__ */ jsx(
79
- InboxPage,
80
- {
81
- testID: "genesis-chat-inbox",
82
- items: rows,
83
- selectedId,
84
- onSelect,
85
- loading: isLoading,
86
- error: Boolean(error) && rows.length === 0,
87
- label,
88
- loadingLabel: "Loading conversations",
89
- formatTime,
90
- slots: INBOX_SLOTS,
91
- slotProps: { empty: { override: slots?.empty, archived, onRetry: () => void refetch(), failed: Boolean(error) } }
92
- }
93
- ) });
123
+ return /* @__PURE__ */ jsxs("nav", { "aria-label": label, className: cn("flex min-h-0 flex-col", className), children: [
124
+ /* @__PURE__ */ jsx(
125
+ InboxPage,
126
+ {
127
+ testID: "genesis-chat-inbox",
128
+ items: rows,
129
+ selectedId,
130
+ onSelect,
131
+ loading: isLoading,
132
+ error: Boolean(error) && rows.length === 0,
133
+ label,
134
+ loadingLabel: "Loading conversations",
135
+ formatTime,
136
+ mutedLabel: labels.alertsOff,
137
+ pinnedLabel: labels.pinnedMark,
138
+ slots: INBOX_SLOTS,
139
+ slotProps: { empty: { override: slots?.empty, archived, onRetry: () => void refetch(), failed: Boolean(error) } }
140
+ }
141
+ ),
142
+ dialog
143
+ ] });
94
144
  }
95
145
  function InboxEmpty({ override, archived, onRetry, failed }) {
96
146
  if (failed) {
@@ -107,48 +157,54 @@ function InboxEmpty({ override, archived, onRetry, failed }) {
107
157
  return /* @__PURE__ */ jsx(Fragment, { children: renderSlot(DefaultEmpty, override, { archived }) });
108
158
  }
109
159
  function InboxRow(row) {
110
- const { chat: item, title, preview, timeLabel, selected, onPress, rowProps, testID, avatarUrl } = row;
160
+ const { chat: item, title, preview, timeLabel, selected, onPress, rowProps, testID, avatarUrl, swipeActions, moreLabel, mutedLabel, pinnedLabel } = row;
111
161
  const unread = item.unread > 0;
112
162
  const count = item.unread >= 99 ? "99+" : String(item.unread);
113
163
  const label = [
114
164
  title,
115
165
  unread ? `${count} unread` : null,
116
166
  item.mentioned ? "you were mentioned" : null,
117
- item.muted ? "muted" : null,
118
- item.pinned ? "pinned" : null,
167
+ item.pinned ? pinnedLabel : null,
168
+ item.muted ? mutedLabel : null,
119
169
  preview || null,
120
170
  timeLabel || null
121
171
  ].filter(Boolean).join(", ");
122
- return /* @__PURE__ */ jsxs(
123
- "button",
124
- {
125
- type: "button",
126
- ...rowProps,
127
- "aria-current": selected ? "true" : void 0,
128
- "aria-label": label,
129
- onClick: onPress,
130
- className: cn(
131
- "flex w-full items-center gap-3 px-3 py-2.5 text-left transition-colors hover:bg-accent focus-visible:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
132
- selected && "bg-accent"
172
+ return (
173
+ // The wrapper takes the selected highlight from data-selected, so `.bg-accent` stays the selected button's own (conformance names it by that class).
174
+ /* @__PURE__ */ jsxs("div", { "data-selected": selected ? "true" : void 0, className: "group relative flex items-stretch data-[selected=true]:bg-accent", children: [
175
+ /* @__PURE__ */ jsxs(
176
+ "button",
177
+ {
178
+ type: "button",
179
+ ...rowProps,
180
+ "aria-current": selected ? "true" : void 0,
181
+ "aria-label": label,
182
+ onClick: onPress,
183
+ className: cn(
184
+ "flex w-full items-center gap-3 px-3 py-2.5 text-left transition-colors hover:bg-accent focus-visible:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
185
+ selected && "bg-accent"
186
+ ),
187
+ "data-testid": testID,
188
+ children: [
189
+ /* @__PURE__ */ jsx(UserAvatar, { name: title, src: avatarUrl, className: "shrink-0" }),
190
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", "aria-hidden": true, children: [
191
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
192
+ /* @__PURE__ */ jsx("span", { className: cn("min-w-0 flex-1 truncate text-sm", unread ? "font-semibold text-foreground" : "font-medium text-foreground"), children: title }),
193
+ item.pinned ? /* @__PURE__ */ jsx(Pin, { "data-testid": `${testID}-pinned`, className: "size-3.5 shrink-0 text-muted-foreground" }) : null,
194
+ item.muted ? /* @__PURE__ */ jsx(BellOff, { "data-testid": `${testID}-muted`, className: "size-3.5 shrink-0 text-muted-foreground" }) : null,
195
+ /* @__PURE__ */ jsx("span", { className: cn("shrink-0 text-xs tabular-nums", unread && !item.muted ? "font-medium text-primary-text" : "text-muted-foreground"), children: timeLabel })
196
+ ] }),
197
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
198
+ /* @__PURE__ */ jsx("span", { className: cn("min-w-0 flex-1 truncate text-sm", unread ? "text-foreground" : "text-muted-foreground"), children: preview || " " }),
199
+ item.mentioned ? /* @__PURE__ */ jsx("span", { className: "flex size-5 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(AtSign, { className: "size-3" }) }) : null,
200
+ unread ? /* @__PURE__ */ jsx(Badge, { variant: item.muted ? "muted" : "default", className: "h-5 min-w-5 shrink-0 justify-center rounded-full px-1.5 text-[11px] tabular-nums", children: count }) : null
201
+ ] })
202
+ ] })
203
+ ]
204
+ }
133
205
  ),
134
- "data-testid": testID,
135
- children: [
136
- /* @__PURE__ */ jsx(UserAvatar, { name: title, src: avatarUrl, className: "shrink-0" }),
137
- /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", "aria-hidden": true, children: [
138
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
139
- /* @__PURE__ */ jsx("span", { className: cn("min-w-0 flex-1 truncate text-sm", unread ? "font-semibold text-foreground" : "font-medium text-foreground"), children: title }),
140
- /* @__PURE__ */ jsx("span", { className: cn("shrink-0 text-xs tabular-nums", unread && !item.muted ? "font-medium text-primary-text" : "text-muted-foreground"), children: timeLabel })
141
- ] }),
142
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
143
- /* @__PURE__ */ jsx("span", { className: cn("min-w-0 flex-1 truncate text-sm", unread ? "text-foreground" : "text-muted-foreground"), children: preview || " " }),
144
- item.pinned ? /* @__PURE__ */ jsx(Pin, { className: "size-3.5 shrink-0 text-muted-foreground" }) : null,
145
- item.muted ? /* @__PURE__ */ jsx(BellOff, { className: "size-3.5 shrink-0 text-muted-foreground" }) : null,
146
- item.mentioned ? /* @__PURE__ */ jsx("span", { className: "flex size-5 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(AtSign, { className: "size-3" }) }) : null,
147
- unread ? /* @__PURE__ */ jsx(Badge, { variant: item.muted ? "muted" : "default", className: "h-5 min-w-5 shrink-0 justify-center rounded-full px-1.5 text-[11px] tabular-nums", children: count }) : null
148
- ] })
149
- ] })
150
- ]
151
- }
206
+ /* @__PURE__ */ jsx(InboxRowMenu, { actions: swipeActions ?? [], label: `${moreLabel}: ${title}`, testID })
207
+ ] })
152
208
  );
153
209
  }
154
210
  var INBOX_SLOTS = { row: InboxRow, empty: InboxEmpty };
@@ -3494,6 +3550,7 @@ function createMemoryChatClient(options) {
3494
3550
  canPost: seed.canPost ?? true,
3495
3551
  muted: seed.muted ?? false,
3496
3552
  pinned: seed.pinned ?? false,
3553
+ archived: seed.archived ?? false,
3497
3554
  messages: [],
3498
3555
  pins: seed.pins ?? [],
3499
3556
  topics: (seed.topics ?? []).map((t, i) => ({
@@ -3521,7 +3578,7 @@ function createMemoryChatClient(options) {
3521
3578
  }
3522
3579
  throw new ChatError("Message not found", "42501", "message");
3523
3580
  };
3524
- const visible = (c, m) => (m.visibility !== "observers" || c.myRole === "observer") && (m.moderation !== "hidden" || m.senderId === me || c.myRole === "observer");
3581
+ const visible = (c, m) => m.seq > (c.clearedSeq ?? 0) && (m.visibility !== "observers" || c.myRole === "observer") && (m.moderation !== "hidden" || m.senderId === me || c.myRole === "observer");
3525
3582
  const scheduledList = [];
3526
3583
  const availability = new Map(
3527
3584
  Object.entries(options.availability ?? {}).map(([userId, a]) => [
@@ -3541,10 +3598,11 @@ function createMemoryChatClient(options) {
3541
3598
  for (const l of inboxListeners) l({ type: "inbox", conversationId });
3542
3599
  };
3543
3600
  const log = (method, ...args) => calls.push({ method, args });
3601
+ const readableAfter = (c, seq) => c.messages.some((m) => m.seq > seq && !m.threadRootId && !m.deletedAt && visible(c, m));
3544
3602
  function inboxItem(c) {
3545
3603
  const mine = c.members.find((m) => m.userId === me);
3546
3604
  const lastRead = mine?.lastReadSeq ?? 0;
3547
- const seen = c.messages.filter((m) => visible(c, m));
3605
+ const seen = c.messages.filter((m) => visible(c, m) && !m.threadRootId);
3548
3606
  const last = seen[seen.length - 1];
3549
3607
  const others = c.members.filter((m) => m.userId !== me);
3550
3608
  const unreadList = seen.filter((m) => m.seq > lastRead && m.senderId !== me && !m.deletedAt);
@@ -3560,11 +3618,11 @@ function createMemoryChatClient(options) {
3560
3618
  memberCount: c.members.length,
3561
3619
  lastSeq: c.conversation.lastSeq,
3562
3620
  lastReadSeq: lastRead,
3563
- unread: Math.min(99, unreadList.length),
3621
+ unread: Math.min(99, Math.max(unreadList.filter((m) => m.seq > (c.clearedSeq ?? 0)).length, c.markedUnread ? 1 : 0)),
3564
3622
  mentioned: unreadList.some((m) => m.mentions.includes(me)),
3565
3623
  muted: c.muted,
3566
3624
  pinned: c.pinned,
3567
- archived: false,
3625
+ archived: c.archived,
3568
3626
  lastMessageAt: c.conversation.lastMessageAt,
3569
3627
  lastMessage: last ? {
3570
3628
  id: last.id,
@@ -3584,8 +3642,7 @@ function createMemoryChatClient(options) {
3584
3642
  async inbox(opts = {}) {
3585
3643
  log("inbox", opts);
3586
3644
  await wait();
3587
- if (opts.archived) return [];
3588
- return [...convs.values()].filter((c) => keepKind(c.conversation.kind, opts)).map(inboxItem).sort((a, b) => Number(b.pinned) - Number(a.pinned) || (b.lastMessageAt ?? "").localeCompare(a.lastMessageAt ?? ""));
3645
+ return [...convs.values()].filter((c) => c.archived === Boolean(opts.archived)).filter((c) => keepKind(c.conversation.kind, opts) && (c.clearedSeq === void 0 || readableAfter(c, c.clearedSeq))).map(inboxItem).sort((a, b) => Number(b.pinned) - Number(a.pinned) || (b.lastMessageAt ?? "").localeCompare(a.lastMessageAt ?? ""));
3589
3646
  },
3590
3647
  async observed() {
3591
3648
  return [];
@@ -3651,6 +3708,7 @@ function createMemoryChatClient(options) {
3651
3708
  canPost: true,
3652
3709
  muted: false,
3653
3710
  pinned: false,
3711
+ archived: false,
3654
3712
  messages: [],
3655
3713
  pins: [],
3656
3714
  topics: []
@@ -3722,12 +3780,25 @@ function createMemoryChatClient(options) {
3722
3780
  const c = get(conversationId);
3723
3781
  const mine = c.members.find((x) => x.userId === me);
3724
3782
  if (mine) mine.lastReadSeq = Math.max(mine.lastReadSeq, seq ?? c.conversation.lastSeq);
3783
+ c.markedUnread = false;
3725
3784
  return mine?.lastReadSeq ?? 0;
3726
3785
  },
3727
3786
  async setMySettings(conversationId, s) {
3787
+ log("setMySettings", conversationId, s);
3728
3788
  const c = get(conversationId);
3729
3789
  if (s.mutedUntil !== void 0) c.muted = s.mutedUntil !== null;
3730
3790
  if (s.pinned !== void 0) c.pinned = s.pinned;
3791
+ if (s.archived !== void 0) c.archived = s.archived;
3792
+ if (s.markedUnread !== void 0) c.markedUnread = s.markedUnread;
3793
+ },
3794
+ async deleteConversationForMe(conversationId, seq) {
3795
+ log("deleteConversationForMe", conversationId, seq);
3796
+ const c = get(conversationId);
3797
+ const latest = c.conversation.lastSeq;
3798
+ c.clearedSeq = Math.max(c.clearedSeq ?? 0, Math.max(0, Math.min(seq ?? latest, latest)));
3799
+ c.markedUnread = false;
3800
+ c.pinned = false;
3801
+ for (const l of inboxListeners) l({ type: "inbox", conversationId });
3731
3802
  },
3732
3803
  async updateConversation(conversationId, s) {
3733
3804
  const c = get(conversationId);
@@ -3755,7 +3826,9 @@ function createMemoryChatClient(options) {
3755
3826
  emit(c.conversation.id, { type: "conversation", conversationId: c.conversation.id });
3756
3827
  },
3757
3828
  async pins(conversationId) {
3758
- return [...convs.get(conversationId)?.pins ?? []];
3829
+ const c = convs.get(conversationId);
3830
+ if (!c) return [];
3831
+ return c.pins.filter((id) => (c.messages.find((m) => m.id === id)?.seq ?? 0) > (c.clearedSeq ?? 0));
3759
3832
  },
3760
3833
  async save(messageId, on = true, note) {
3761
3834
  log("save", messageId, on, note);
@@ -4623,6 +4696,6 @@ function ChatDock({ resolveUser, threadProps, labels: labelOverrides, bubble = t
4623
4696
  ] });
4624
4697
  }
4625
4698
 
4626
- export { ChatAttachmentCard, ChatAvailabilitySettings, ChatAwayBanner, ChatBroadcast, ChatComposer, ChatDock, ChatDockProvider, ChatEmojiPicker, ChatInbox, ChatLinkPreview, ChatMarkdown, ChatPanel, ChatScheduleMenu, ChatScheduledList, ChatSearch, ChatThread, ChatTopicBar, ChatVideoPlayer, ChatVideoRecorder, FileChip, GenericAttachment, ImageGrid, Lightbox, MessageAttachments, MessageRow, QUICK_REACTIONS, SearchSnippet, VideoAttachment, VoiceNote, canPickEmoji, chatDockReducer, chatDockWindowsThatFit, clockTime, createMemoryChatClient, defaultChatDockLabels, emptyChatDock, forgetChatDock, formatBytes, inboxTitle, isSafeHref, linkPreviewImageSrc, messageLabel, muxPosterUrl, muxStreamUrl, parseMarkdown, pickVideoMimeType, pickVoiceMimeType, plainText, relativeTime, toAttachmentView, toLocalInput, uploadVideo, useChatDock, useOptionalChatDock, useVideoRecorder, useVoiceRecorder, videoFile, voiceFile };
4699
+ export { ChatAttachmentCard, ChatAvailabilitySettings, ChatAwayBanner, ChatBroadcast, ChatComposer, ChatDock, ChatDockProvider, ChatEmojiPicker, ChatInbox, ChatLinkPreview, ChatMarkdown, ChatPanel, ChatScheduleMenu, ChatScheduledList, ChatSearch, ChatThread, ChatTopicBar, ChatVideoPlayer, ChatVideoRecorder, FileChip, GenericAttachment, ImageGrid, Lightbox, MessageAttachments, MessageRow, QUICK_REACTIONS, SearchSnippet, VideoAttachment, VoiceNote, canPickEmoji, chatDockReducer, chatDockWindowsThatFit, clockTime, createMemoryChatClient, defaultChatDockLabels, emptyChatDock, forgetChatDock, formatBytes, inboxTitle, isSafeHref, linkPreviewImageSrc, messageLabel, muxPosterUrl, muxStreamUrl, parseMarkdown, pickVideoMimeType, pickVoiceMimeType, plainText, relativeTime, toAttachmentView, toLocalInput, uploadVideo, useChatDock, useConfirmDialog, useOptionalChatDock, useVideoRecorder, useVoiceRecorder, videoFile, voiceFile };
4627
4700
  //# sourceMappingURL=web.js.map
4628
4701
  //# sourceMappingURL=web.js.map