@ttt-productions/chat-react 0.12.14 → 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 (52) hide show
  1. package/README.md +8 -8
  2. package/dist/hooks/useChatMessages.d.ts.map +1 -1
  3. package/dist/hooks/useChatMessages.js +0 -1
  4. package/dist/hooks/useChatMessages.js.map +1 -1
  5. package/dist/index.d.ts +2 -6
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +0 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/realtime/channel-client.d.ts +6 -13
  10. package/dist/realtime/channel-client.d.ts.map +1 -1
  11. package/dist/realtime/channel-client.js +17 -56
  12. package/dist/realtime/channel-client.js.map +1 -1
  13. package/dist/realtime/diagnostics.d.ts +0 -2
  14. package/dist/realtime/diagnostics.d.ts.map +1 -1
  15. package/dist/realtime/diagnostics.js +7 -5
  16. package/dist/realtime/diagnostics.js.map +1 -1
  17. package/dist/realtime/map.d.ts +4 -7
  18. package/dist/realtime/map.d.ts.map +1 -1
  19. package/dist/realtime/map.js +4 -41
  20. package/dist/realtime/map.js.map +1 -1
  21. package/dist/realtime/wire.d.ts +5 -5
  22. package/dist/realtime/wire.d.ts.map +1 -1
  23. package/dist/realtime/wire.js.map +1 -1
  24. package/dist/types.d.ts +0 -41
  25. package/dist/types.d.ts.map +1 -1
  26. package/dist/types.js.map +1 -1
  27. package/dist/ui/ChatShell.d.ts +2 -4
  28. package/dist/ui/ChatShell.d.ts.map +1 -1
  29. package/dist/ui/ChatShell.js +2 -13
  30. package/dist/ui/ChatShell.js.map +1 -1
  31. package/dist/ui/Composer.d.ts +5 -28
  32. package/dist/ui/Composer.d.ts.map +1 -1
  33. package/dist/ui/Composer.js +8 -104
  34. package/dist/ui/Composer.js.map +1 -1
  35. package/dist/ui/MessageItemDefault.d.ts +0 -5
  36. package/dist/ui/MessageItemDefault.d.ts.map +1 -1
  37. package/dist/ui/MessageItemDefault.js +6 -75
  38. package/dist/ui/MessageItemDefault.js.map +1 -1
  39. package/dist/ui/MessageList.d.ts +0 -3
  40. package/dist/ui/MessageList.d.ts.map +1 -1
  41. package/dist/ui/MessageList.js +2 -2
  42. package/dist/ui/MessageList.js.map +1 -1
  43. package/package.json +3 -6
  44. package/src/styles/chat.css +0 -139
  45. package/dist/context/ChatAttachmentMediaContext.d.ts +0 -37
  46. package/dist/context/ChatAttachmentMediaContext.d.ts.map +0 -1
  47. package/dist/context/ChatAttachmentMediaContext.js +0 -17
  48. package/dist/context/ChatAttachmentMediaContext.js.map +0 -1
  49. package/dist/context/ChatAttachmentUrlContext.d.ts +0 -25
  50. package/dist/context/ChatAttachmentUrlContext.d.ts.map +0 -1
  51. package/dist/context/ChatAttachmentUrlContext.js +0 -21
  52. package/dist/context/ChatAttachmentUrlContext.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # @ttt-productions/chat-react
2
2
 
3
3
  Chat **React UI** for TTT Productions apps: chat shell, composer, message list,
4
- attachment UI, the generic mention autocomplete UI, the name-resolver context,
5
- and the realtime-newest-window + infinite-older hooks.
4
+ the generic mention autocomplete UI, the name-resolver context, and the
5
+ realtime-newest-window + infinite-older hooks. Chat is TEXT-only — a
6
+ conversation's files live in the consuming app's Conversation Files surface,
7
+ never in the message timeline.
6
8
 
7
9
  Built on the pure [`@ttt-productions/chat-core`](../chat-core) package
8
10
  (contracts, mention parser/serializer, grouping). A non-React consumer (a Cloud
@@ -12,9 +14,8 @@ in none of this frontend tree.
12
14
  ## Entry points
13
15
 
14
16
  - `.` — React components, hooks, the Firebase-client adapter config types
15
- (`ChatCoreConfig`, `ChatAttachmentConfig`, `ChatUploadAdapter`,
16
- `ChatMentionConfig`), and the React render types (`MessageRenderer`,
17
- `RenderableMentionProvider`, `MentionResultRenderer`).
17
+ (`ChatCoreConfig`, `ChatMentionConfig`), and the React render types
18
+ (`MessageRenderer`, `RenderableMentionProvider`, `MentionResultRenderer`).
18
19
  - `./styles` — chat CSS. Import once in your app layout:
19
20
  `import "@ttt-productions/chat-react/styles";`
20
21
 
@@ -26,6 +27,5 @@ are optional peers — provided by the consuming app.
26
27
  ## Boundary
27
28
 
28
29
  `chat-react` does not import `ttt-core`, does not hardcode TTT origins, and does
29
- not build TTT storage paths. Consumers pass a chat upload adapter with opaque
30
- origin id, upload path builder, and optional metadata builder. TTT mention
31
- kinds, permissions, provider lists, routing, and search live in TTT code.
30
+ not build TTT storage paths — it runs no upload path at all. TTT mention kinds,
31
+ permissions, provider lists, routing, and search live in TTT code.
@@ -1 +1 @@
1
- {"version":3,"file":"useChatMessages.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatMessages.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAyCF,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,qBAAqB,CAuF7E"}
1
+ {"version":3,"file":"useChatMessages.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatMessages.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAwCF,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,qBAAqB,CAuF7E"}
@@ -29,7 +29,6 @@ function mapMsg(data, threadId) {
29
29
  senderId: d.senderId,
30
30
  text: d.text ?? "",
31
31
  type: d.type,
32
- attachment: d.attachment ?? undefined,
33
32
  replyTo,
34
33
  isSystemMessage: d.isSystemMessage ?? undefined,
35
34
  // Moderation tombstone flag (backend-written) — carried through so renderers
@@ -1 +1 @@
1
- {"version":3,"file":"useChatMessages.js","sourceRoot":"","sources":["../../src/hooks/useChatMessages.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAG7E,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AAEpF,4CAA4C;AAC5C,MAAM,aAAa,GAAG,GAAG,CAAC;AAW1B,SAAS,MAAM,CACb,IAAmC,EACnC,QAAgB;IAEhB,MAAM,CAAC,GAAG,IAAW,CAAC;IAEtB,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAExC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oDAAoD,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;IAC5F,CAAC;IAED,2EAA2E;IAC3E,4EAA4E;IAC5E,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO;QACvB,CAA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C,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;IAE/E,sEAAsE;IACtE,6DAA6D;IAC7D,MAAM,WAAW,GAAG,2BAA2B,EAAE,CAAC;IAClD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACnC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;QAC9B,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;YACpB,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ;gBAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,WAAW,EAAE,OAAO,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjD,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;IAE7B,OAAO;QACL,OAAO;QACP,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK;QACpD,QAAQ;QACR,UAAU;QACV,QAAQ;QACR,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport type { DocumentData } from \"firebase/firestore\";\nimport { toMillis } from \"@ttt-productions/firebase-helpers\";\nimport { useFirestoreLiveInfinite } from \"@ttt-productions/query-core/react\";\nimport type { ChatMessageV1 } from \"@ttt-productions/chat-core\";\nimport type { ChatCoreConfig } from \"../types.js\";\nimport { canAccessThread } from \"./useChatThreadAccess.js\";\nimport { messagesColPath } from \"../firestore/queries.js\";\nimport { useOptionalChatNameResolver } from \"../context/ChatNameResolverContext.js\";\n\n// Safety limit to prevent memory exhaustion\nconst MAX_PAGE_SIZE = 100;\n\nexport type UseChatMessagesResult = {\n allowed: boolean;\n isInitialLoading: boolean;\n messages: ChatMessageV1[];\n fetchOlder: () => Promise<void>;\n hasOlder: boolean;\n isFetchingOlder: boolean;\n};\n\nfunction mapMsg(\n data: DocumentData & { id: string },\n threadId: string\n): ChatMessageV1 {\n const d = data as any;\n\n const createdAt = toMillis(d.createdAt);\n\n if (!createdAt) {\n console.error('[useChatMessages] Message missing valid createdAt:', data.id, d.createdAt);\n }\n\n // replyTo: the new shape uses senderId, not senderUsername. Tolerate older\n // docs that still have senderUsername — drop the name and keep what we can.\n const replyTo = d.replyTo\n ? {\n messageId: d.replyTo.messageId,\n senderId: d.replyTo.senderId ?? \"\",\n messagePreview: d.replyTo.messagePreview,\n }\n : undefined;\n\n return {\n messageId: data.id,\n threadId,\n createdAt: createdAt || 0,\n senderId: d.senderId,\n text: d.text ?? \"\",\n type: d.type,\n attachment: d.attachment ?? undefined,\n replyTo,\n isSystemMessage: d.isSystemMessage ?? undefined,\n // Moderation tombstone flag (backend-written) — carried through so renderers\n // can tombstone the content.\n hidden: d.hidden ?? undefined,\n meta: d.meta,\n };\n}\n\nexport function useChatMessages(config: ChatCoreConfig): UseChatMessagesResult {\n const {\n chatCollectionPath,\n messagesSubcollection = \"messages\",\n threadId,\n pageSize: requestedPageSize = 20,\n currentUserId,\n isAdmin,\n accessMode,\n threadAllowedUserIds,\n createdAtField = \"createdAt\",\n } = config;\n\n const pageSize = Math.min(requestedPageSize, MAX_PAGE_SIZE);\n\n if (requestedPageSize > MAX_PAGE_SIZE) {\n console.warn(\n `[useChatMessages] Requested pageSize ${requestedPageSize} exceeds maximum ${MAX_PAGE_SIZE}. Using ${MAX_PAGE_SIZE}.`\n );\n }\n\n const allowed = React.useMemo(\n () =>\n canAccessThread({\n accessMode,\n isAdmin,\n currentUserId,\n allowedUserIds: threadAllowedUserIds,\n }),\n [accessMode, isAdmin, currentUserId, threadAllowedUserIds]\n );\n\n // Stable key segment for the message collection path (string | string[]).\n const pathKey = React.useMemo(\n () =>\n JSON.stringify(\n Array.isArray(chatCollectionPath) ? chatCollectionPath : [chatCollectionPath]\n ),\n [chatCollectionPath]\n );\n\n // Slash-joined collection path for the generic hook (handles nested paths).\n const collectionPath = React.useMemo(\n () => messagesColPath(chatCollectionPath, threadId, messagesSubcollection).join(\"/\"),\n [chatCollectionPath, threadId, messagesSubcollection]\n );\n\n const { items, isInitialLoading, fetchOlder, hasOlder, isFetchingOlder } =\n useFirestoreLiveInfinite<ChatMessageV1>({\n collectionPath,\n queryKey: [\"chat-core\", \"messages\", pathKey, threadId, messagesSubcollection, pageSize],\n orderByField: createdAtField,\n pageSize,\n enabled: allowed,\n sort: \"asc\",\n select: (data) => mapMsg(data, threadId),\n getSortValue: (data) => toMillis(data.createdAt) ?? 0,\n });\n\n const messages = React.useMemo(() => (allowed ? items : []), [allowed, items]);\n\n // Pre-warm name cache for all visible senders (and reply-to senders).\n // Optional resolver: silent no-op if no provider is wrapped.\n const resolverCtx = useOptionalChatNameResolver();\n const senderIds = React.useMemo(() => {\n const set = new Set<string>();\n for (const m of messages) {\n set.add(m.senderId);\n if (m.replyTo?.senderId) set.add(m.replyTo.senderId);\n }\n return Array.from(set);\n }, [messages]);\n\n React.useEffect(() => {\n if (resolverCtx?.prewarm && senderIds.length > 0) {\n resolverCtx.prewarm(senderIds);\n }\n }, [resolverCtx, senderIds]);\n\n return {\n allowed,\n isInitialLoading: allowed ? isInitialLoading : false,\n messages,\n fetchOlder,\n hasOlder,\n isFetchingOlder,\n };\n}"]}
1
+ {"version":3,"file":"useChatMessages.js","sourceRoot":"","sources":["../../src/hooks/useChatMessages.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;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,CAAC;IAEf,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,WAAW,EAAE,OAAO,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjD,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;IAE7B,OAAO;QACL,OAAO;QACP,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK;QACpD,QAAQ;QACR,UAAU;QACV,QAAQ;QACR,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport type { DocumentData } from \"firebase/firestore\";\nimport { toMillis } from \"@ttt-productions/firebase-helpers\";\nimport { useFirestoreLiveInfinite } from \"@ttt-productions/query-core/react\";\nimport type { ChatMessageV1 } from \"@ttt-productions/chat-core\";\nimport type { ChatCoreConfig } from \"../types.js\";\nimport { canAccessThread } from \"./useChatThreadAccess.js\";\nimport { messagesColPath } from \"../firestore/queries.js\";\nimport { useOptionalChatNameResolver } from \"../context/ChatNameResolverContext.js\";\n\n// Safety limit to prevent memory exhaustion\nconst MAX_PAGE_SIZE = 100;\n\nexport type UseChatMessagesResult = {\n allowed: boolean;\n isInitialLoading: boolean;\n messages: ChatMessageV1[];\n fetchOlder: () => Promise<void>;\n hasOlder: boolean;\n isFetchingOlder: boolean;\n};\n\nfunction mapMsg(\n data: DocumentData & { id: string },\n threadId: string\n): ChatMessageV1 {\n const d = data as any;\n\n const createdAt = toMillis(d.createdAt);\n\n if (!createdAt) {\n console.error('[useChatMessages] Message missing valid createdAt:', data.id, d.createdAt);\n }\n\n // replyTo: the new shape uses senderId, not senderUsername. Tolerate older\n // docs that still have senderUsername — drop the name and keep what we can.\n const replyTo = d.replyTo\n ? {\n messageId: d.replyTo.messageId,\n senderId: d.replyTo.senderId ?? \"\",\n messagePreview: d.replyTo.messagePreview,\n }\n : undefined;\n\n return {\n messageId: data.id,\n threadId,\n createdAt: createdAt || 0,\n senderId: d.senderId,\n text: d.text ?? \"\",\n type: d.type,\n replyTo,\n isSystemMessage: d.isSystemMessage ?? undefined,\n // Moderation tombstone flag (backend-written) — carried through so renderers\n // can tombstone the content.\n hidden: d.hidden ?? undefined,\n meta: d.meta,\n };\n}\n\nexport function useChatMessages(config: ChatCoreConfig): UseChatMessagesResult {\n const {\n chatCollectionPath,\n messagesSubcollection = \"messages\",\n threadId,\n pageSize: requestedPageSize = 20,\n currentUserId,\n isAdmin,\n accessMode,\n threadAllowedUserIds,\n createdAtField = \"createdAt\",\n } = config;\n\n const pageSize = Math.min(requestedPageSize, MAX_PAGE_SIZE);\n\n if (requestedPageSize > MAX_PAGE_SIZE) {\n console.warn(\n `[useChatMessages] Requested pageSize ${requestedPageSize} exceeds maximum ${MAX_PAGE_SIZE}. Using ${MAX_PAGE_SIZE}.`\n );\n }\n\n const allowed = React.useMemo(\n () =>\n canAccessThread({\n accessMode,\n isAdmin,\n currentUserId,\n allowedUserIds: threadAllowedUserIds,\n }),\n [accessMode, isAdmin, currentUserId, threadAllowedUserIds]\n );\n\n // Stable key segment for the message collection path (string | string[]).\n const pathKey = React.useMemo(\n () =>\n JSON.stringify(\n Array.isArray(chatCollectionPath) ? chatCollectionPath : [chatCollectionPath]\n ),\n [chatCollectionPath]\n );\n\n // Slash-joined collection path for the generic hook (handles nested paths).\n const collectionPath = React.useMemo(\n () => messagesColPath(chatCollectionPath, threadId, messagesSubcollection).join(\"/\"),\n [chatCollectionPath, threadId, messagesSubcollection]\n );\n\n const { items, isInitialLoading, fetchOlder, hasOlder, isFetchingOlder } =\n useFirestoreLiveInfinite<ChatMessageV1>({\n collectionPath,\n queryKey: [\"chat-core\", \"messages\", pathKey, threadId, messagesSubcollection, pageSize],\n orderByField: createdAtField,\n pageSize,\n enabled: allowed,\n sort: \"asc\",\n select: (data) => mapMsg(data, threadId),\n getSortValue: (data) => toMillis(data.createdAt) ?? 0,\n });\n\n const messages = React.useMemo(() => (allowed ? items : []), [allowed, items]);\n\n // Pre-warm name cache for all visible senders (and reply-to senders).\n // Optional resolver: silent no-op if no provider is wrapped.\n const resolverCtx = useOptionalChatNameResolver();\n const senderIds = React.useMemo(() => {\n const set = new Set<string>();\n for (const m of messages) {\n set.add(m.senderId);\n if (m.replyTo?.senderId) set.add(m.replyTo.senderId);\n }\n return Array.from(set);\n }, [messages]);\n\n React.useEffect(() => {\n if (resolverCtx?.prewarm && senderIds.length > 0) {\n resolverCtx.prewarm(senderIds);\n }\n }, [resolverCtx, senderIds]);\n\n return {\n allowed,\n isInitialLoading: allowed ? isInitialLoading : false,\n messages,\n fetchOlder,\n hasOlder,\n isFetchingOlder,\n };\n}"]}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,4 @@
1
- export type { ChatCoreConfig, ChatTransportMode, ChatRealtimeTransportConfig, ChatAttachmentConfig, ChatUploadAdapter, ChatMentionConfig, MessageRenderer, MessageRendererRegistry, RenderableMentionProvider, MentionResultRenderer, } from "./types.js";
2
- export type { ChatAttachmentUrlResolver, ChatAttachmentUrlProviderProps, } from "./context/ChatAttachmentUrlContext.js";
3
- export { ChatAttachmentUrlProvider, useChatAttachmentUrlResolver, } from "./context/ChatAttachmentUrlContext.js";
4
- export type { ChatAttachmentMediaComponent, ChatAttachmentMediaProviderProps, } from "./context/ChatAttachmentMediaContext.js";
5
- export { ChatAttachmentMediaProvider, useChatAttachmentMediaComponent, } from "./context/ChatAttachmentMediaContext.js";
1
+ export type { ChatCoreConfig, ChatTransportMode, ChatRealtimeTransportConfig, ChatMentionConfig, MessageRenderer, MessageRendererRegistry, RenderableMentionProvider, MentionResultRenderer, } from "./types.js";
6
2
  export type { ChatNameResolverProviderProps } from "./context/ChatNameResolverContext.js";
7
3
  export { ChatNameResolverProvider, useChatNameResolver, useOptionalChatNameResolver, useResolvedSenderName, } from "./context/ChatNameResolverContext.js";
8
4
  export type { UseChatMessagesResult } from "./hooks/useChatMessages.js";
@@ -13,7 +9,7 @@ export type { RealtimeChatClient, RealtimeTransportConfig, ChatClientDiagnostics
13
9
  export type { ChatShellProps } from "./ui/ChatShell.js";
14
10
  export { ChatShell } from "./ui/ChatShell.js";
15
11
  export { MessageList } from "./ui/MessageList.js";
16
- export type { ComposerProps, ComposerHandle } from "./ui/Composer.js";
12
+ export type { ComposerProps } from "./ui/Composer.js";
17
13
  export { Composer } from "./ui/Composer.js";
18
14
  export type { MessageItemDefaultProps } from "./ui/MessageItemDefault.js";
19
15
  export { MessageItemDefault } from "./ui/MessageItemDefault.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,uCAAuC,CAAC;AAM/C,YAAY,EACV,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AAGjD,YAAY,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAE9C,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAKjE,OAAO,EACL,w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AAqB,CAAC;AAClD,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,YAAY,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,sBAAsB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,wCAAwC,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,4 @@
1
1
  "use client";
2
- export { ChatAttachmentUrlProvider, useChatAttachmentUrlResolver, } from "./context/ChatAttachmentUrlContext.js";
3
- export { ChatAttachmentMediaProvider, useChatAttachmentMediaComponent, } from "./context/ChatAttachmentMediaContext.js";
4
2
  export { ChatNameResolverProvider, useChatNameResolver, useOptionalChatNameResolver, useResolvedSenderName, } from "./context/ChatNameResolverContext.js";
5
3
  export { useChatMessages } from "./hooks/useChatMessages.js";
6
4
  export { canAccessThread } from "./hooks/useChatThreadAccess.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AA2Bb,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,uCAAuC,CAAC;AAU/C,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AAIjD,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,+EAA+E;AAC/E,kFAAkF;AAClF,oFAAoF;AACpF,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAkC7B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAyB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EACL,mBAAmB,GAEpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,sBAAsB,GAKvB,MAAM,wCAAwC,CAAC","sourcesContent":["\"use client\";\n\n// @ttt-productions/chat-react — chat React UI, hooks, the Firebase-client\n// adapter config types, and React render types. Depends on the pure\n// @ttt-productions/chat-core for contracts, parser, and grouping.\n//\n// Apps import chat CSS via \"@ttt-productions/chat-react/styles\".\n\n// React-coupled config + render types (previously on chat-core root).\nexport type {\n ChatCoreConfig,\n ChatTransportMode,\n ChatRealtimeTransportConfig,\n ChatAttachmentConfig,\n ChatUploadAdapter,\n ChatMentionConfig,\n MessageRenderer,\n MessageRendererRegistry,\n RenderableMentionProvider,\n MentionResultRenderer,\n} from \"./types.js\";\n\n// Attachment-URL resolver context (render-time URL building from mediaAssetId).\nexport type {\n ChatAttachmentUrlResolver,\n ChatAttachmentUrlProviderProps,\n} from \"./context/ChatAttachmentUrlContext.js\";\nexport {\n ChatAttachmentUrlProvider,\n useChatAttachmentUrlResolver,\n} from \"./context/ChatAttachmentUrlContext.js\";\n\n// Attachment media-component injection (optional) — the app hands chat its own\n// display-path wrapper (recovery adapter, diagnostics, telemetry) so chat\n// media rides the same pipeline as every other surface; default stays the\n// package MediaViewer.\nexport type {\n ChatAttachmentMediaComponent,\n ChatAttachmentMediaProviderProps,\n} from \"./context/ChatAttachmentMediaContext.js\";\nexport {\n ChatAttachmentMediaProvider,\n useChatAttachmentMediaComponent,\n} from \"./context/ChatAttachmentMediaContext.js\";\n\n// Name-resolver context.\nexport type { ChatNameResolverProviderProps } from \"./context/ChatNameResolverContext.js\";\nexport {\n ChatNameResolverProvider,\n useChatNameResolver,\n useOptionalChatNameResolver,\n useResolvedSenderName,\n} from \"./context/ChatNameResolverContext.js\";\n\nexport type { UseChatMessagesResult } from \"./hooks/useChatMessages.js\";\nexport { useChatMessages } from \"./hooks/useChatMessages.js\";\nexport { canAccessThread } from \"./hooks/useChatThreadAccess.js\";\n\n// Realtime (Cloudflare Durable Object) transport — the client half of the chat\n// worker wire protocol. Opt-in via `ChatCoreConfig.transport === 'realtime'`; the\n// firestore transport stays the unchanged default. See docs/packages/chat-react.md.\nexport {\n createRealtimeChatClient,\n createInboxClient,\n ChannelClient,\n InboxClient,\n useRealtimeChatMessages,\n browserSocketFactory,\n ChatAccessDeniedError,\n isChatAccessDeniedError,\n CHAT_SUBPROTOCOL,\n CHAT_CLOSE_CODES,\n CLIENT_FRAME,\n SERVER_FRAME,\n buildFrame,\n parseFrame,\n CHAT_CLIENT_DIAGNOSTIC_EVENTS,\n} from \"./realtime/index.js\";\nexport type {\n RealtimeChatClient,\n RealtimeTransportConfig,\n ChatClientDiagnosticsOption,\n ChatClientDiagnosticsSink,\n ChatClientDiagnosticEventName,\n ChannelClientState,\n ChannelClientConfig,\n InboxClientState,\n InboxClientConfig,\n UseRealtimeChatMessagesResult,\n GrantProvider,\n TransportTimers,\n RealtimeStatus,\n RealtimeSocket,\n SocketFactory,\n SocketHandlers,\n ChannelRefTuple,\n WireMessageRow,\n WireInboxSnapshot,\n WireRegistryEntry,\n ServerFrame,\n} from \"./realtime/index.js\";\n\n// TODO (re-export when a consumer needs them): the moderation-overlay helpers\n// `RevisionKind`, `ModerationOverlay`, `applyModerationOverlay`, `overlayFromRow`,\n// and `MODERATION_REDACTED_TEXT` live in `./realtime` but are intentionally NOT\n// re-exported from this package root yet — the consuming app's renderer reads moderation\n// state off `message.meta` (the realtime client applies the overlay internally), so\n// nothing imports them from here today. Add them to the block above when a consumer\n// genuinely needs to apply the overlay directly. (Comment-only; rides the next publish.)\n\nexport type { ChatShellProps } from \"./ui/ChatShell.js\";\nexport { ChatShell } from \"./ui/ChatShell.js\";\nexport { MessageList } from \"./ui/MessageList.js\";\nexport type { ComposerProps, ComposerHandle } from \"./ui/Composer.js\";\nexport { Composer } from \"./ui/Composer.js\";\nexport type { MessageItemDefaultProps } from \"./ui/MessageItemDefault.js\";\nexport { MessageItemDefault } from \"./ui/MessageItemDefault.js\";\nexport { MessageActions, ThreadActions } from \"./ui/menus.js\";\nexport { MessageText, type MessageTextProps } from \"./mentions/MessageText.js\";\nexport {\n MentionAutocomplete,\n type MentionAutocompleteProps,\n} from \"./mentions/MentionAutocomplete.js\";\nexport {\n useMentionAutocomplete,\n type UseMentionAutocompleteArgs,\n type UseMentionAutocompleteResult,\n type AutocompleteState,\n type AutocompleteResultGroup,\n} from \"./mentions/use-mention-autocomplete.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAsBb,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,+EAA+E;AAC/E,kFAAkF;AAClF,oFAAoF;AACpF,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAkC7B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAyB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EACL,mBAAmB,GAEpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,sBAAsB,GAKvB,MAAM,wCAAwC,CAAC","sourcesContent":["\"use client\";\n\n// @ttt-productions/chat-react — chat React UI, hooks, the Firebase-client\n// adapter config types, and React render types. Depends on the pure\n// @ttt-productions/chat-core for contracts, parser, and grouping.\n//\n// Apps import chat CSS via \"@ttt-productions/chat-react/styles\".\n\n// React-coupled config + render types (previously on chat-core root).\nexport type {\n ChatCoreConfig,\n ChatTransportMode,\n ChatRealtimeTransportConfig,\n ChatMentionConfig,\n MessageRenderer,\n MessageRendererRegistry,\n RenderableMentionProvider,\n MentionResultRenderer,\n} from \"./types.js\";\n\n// Name-resolver context.\nexport type { ChatNameResolverProviderProps } from \"./context/ChatNameResolverContext.js\";\nexport {\n ChatNameResolverProvider,\n useChatNameResolver,\n useOptionalChatNameResolver,\n useResolvedSenderName,\n} from \"./context/ChatNameResolverContext.js\";\n\nexport type { UseChatMessagesResult } from \"./hooks/useChatMessages.js\";\nexport { useChatMessages } from \"./hooks/useChatMessages.js\";\nexport { canAccessThread } from \"./hooks/useChatThreadAccess.js\";\n\n// Realtime (Cloudflare Durable Object) transport — the client half of the chat\n// worker wire protocol. Opt-in via `ChatCoreConfig.transport === 'realtime'`; the\n// firestore transport stays the unchanged default. See docs/packages/chat-react.md.\nexport {\n createRealtimeChatClient,\n createInboxClient,\n ChannelClient,\n InboxClient,\n useRealtimeChatMessages,\n browserSocketFactory,\n ChatAccessDeniedError,\n isChatAccessDeniedError,\n CHAT_SUBPROTOCOL,\n CHAT_CLOSE_CODES,\n CLIENT_FRAME,\n SERVER_FRAME,\n buildFrame,\n parseFrame,\n CHAT_CLIENT_DIAGNOSTIC_EVENTS,\n} from \"./realtime/index.js\";\nexport type {\n RealtimeChatClient,\n RealtimeTransportConfig,\n ChatClientDiagnosticsOption,\n ChatClientDiagnosticsSink,\n ChatClientDiagnosticEventName,\n ChannelClientState,\n ChannelClientConfig,\n InboxClientState,\n InboxClientConfig,\n UseRealtimeChatMessagesResult,\n GrantProvider,\n TransportTimers,\n RealtimeStatus,\n RealtimeSocket,\n SocketFactory,\n SocketHandlers,\n ChannelRefTuple,\n WireMessageRow,\n WireInboxSnapshot,\n WireRegistryEntry,\n ServerFrame,\n} from \"./realtime/index.js\";\n\n// TODO (re-export when a consumer needs them): the moderation-overlay helpers\n// `RevisionKind`, `ModerationOverlay`, `applyModerationOverlay`, `overlayFromRow`,\n// and `MODERATION_REDACTED_TEXT` live in `./realtime` but are intentionally NOT\n// re-exported from this package root yet — the consuming app's renderer reads moderation\n// state off `message.meta` (the realtime client applies the overlay internally), so\n// nothing imports them from here today. Add them to the block above when a consumer\n// genuinely needs to apply the overlay directly. (Comment-only; rides the next publish.)\n\nexport type { ChatShellProps } from \"./ui/ChatShell.js\";\nexport { ChatShell } from \"./ui/ChatShell.js\";\nexport { MessageList } from \"./ui/MessageList.js\";\nexport type { ComposerProps } from \"./ui/Composer.js\";\nexport { Composer } from \"./ui/Composer.js\";\nexport type { MessageItemDefaultProps } from \"./ui/MessageItemDefault.js\";\nexport { MessageItemDefault } from \"./ui/MessageItemDefault.js\";\nexport { MessageActions, ThreadActions } from \"./ui/menus.js\";\nexport { MessageText, type MessageTextProps } from \"./mentions/MessageText.js\";\nexport {\n MentionAutocomplete,\n type MentionAutocompleteProps,\n} from \"./mentions/MentionAutocomplete.js\";\nexport {\n useMentionAutocomplete,\n type UseMentionAutocompleteArgs,\n type UseMentionAutocompleteResult,\n type AutocompleteState,\n type AutocompleteResultGroup,\n} from \"./mentions/use-mention-autocomplete.js\";\n"]}
@@ -246,17 +246,15 @@ export declare class ChannelClient {
246
246
  * the decision the client made about it.
247
247
  *
248
248
  * Diagnostics bounding: a LIVE frame always emits one `chat_client_frame_applied`
249
- * line; a DELTA row emits one only when it is materially interesting (carries an
250
- * attachment state, carries a moderation kind, or reconciles one of our optimistic
251
- * sends) — a 500-row backlog is otherwise summarized by `chat_client_resume_result`
252
- * rather than spamming 500 lines. Attachment transitions ALWAYS emit, from either
253
- * source, because an in-place attachment mutation is the exact event this
254
- * instrumentation exists to prove.
249
+ * line; a DELTA row emits one only when it is materially interesting (carries a
250
+ * moderation kind, or reconciles one of our optimistic sends) — a 500-row backlog
251
+ * is otherwise summarized by `chat_client_resume_result` rather than spamming 500
252
+ * lines.
255
253
  */
256
254
  private applyMessage;
257
255
  /**
258
- * The pre-merge view of a row's seq: whether we already hold that seq, its current
259
- * attachment state, and whether this row reconciles a live optimistic send.
256
+ * The pre-merge view of a row's seq: whether we already hold that seq, and whether
257
+ * this row reconciles a live optimistic send.
260
258
  * Diagnostics-only — never called when diagnostics are off.
261
259
  */
262
260
  private priorRowFacts;
@@ -268,11 +266,6 @@ export declare class ChannelClient {
268
266
  private mergeMessage;
269
267
  private applyAck;
270
268
  private applyHistoryPage;
271
- /**
272
- * A seq -> attachmentState map of the rows currently held (diagnostics-only, so a
273
- * later in-place mutation can be reported as an explicit `old -> new` transition).
274
- */
275
- private snapshotAttachmentStates;
276
269
  private applyTyping;
277
270
  private sendFrame;
278
271
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"channel-client.d.ts","sourceRoot":"","sources":["../../src/realtime/channel-client.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAahE,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AASjE,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAKL,KAAK,2BAA2B,EACjC,MAAM,kBAAkB,CAAC;AA6C1B,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,cAAc,CAAC;IACvB,mFAAmF;IACnF,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,4EAA4E;IAC5E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,6DAA6D;IAC7D,eAAe,EAAE,OAAO,CAAC;IACzB,2FAA2F;IAC3F,QAAQ,EAAE,OAAO,CAAC;IAClB,kGAAkG;IAClG,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;;;;;;OASG;IACH,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,iGAAiG;IACjG,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,aAAa,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,aAAa,EAAE,aAAa,CAAC;IAC7B,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,6DAA6D;IAC7D,SAAS,CAAC,EAAE;QAAE,WAAW,CA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+ case 'heartbeat-ack':
642
+ // The DO runtime's hibernation AUTO-RESPONSE to our 20s `heartbeat`. Per
643
+ // Contract C liveness is tracked SERVER-side (the auto-response timestamp
644
+ // the dueWork sweep reads), so the client heartbeat is fire-and-forget: the
645
+ // ack needs no state change and the next tick is already scheduled. Explicit
646
+ // no-op — and deliberately NO diagnostic, not even frame_applied: at ~20s
647
+ // this is the one frame that recurs forever, so logging it would violate the
648
+ // bounded "one line per DECISION, never per heartbeat" contract and drown the
649
+ // frame_dropped signal that distinguishes "never arrived" from "dropped".
650
+ return;
641
651
  default:
642
652
  // unknown/optional types tolerated (forward compat)
643
653
  this.diag?.(DIAG.FRAME_DROPPED, { kind: safeDiagnosticLabel(frame.type), reason: 'unknown-type' });
@@ -797,12 +807,10 @@ export class ChannelClient {
797
807
  * the decision the client made about it.
798
808
  *
799
809
  * Diagnostics bounding: a LIVE frame always emits one `chat_client_frame_applied`
800
- * line; a DELTA row emits one only when it is materially interesting (carries an
801
- * attachment state, carries a moderation kind, or reconciles one of our optimistic
802
- * sends) — a 500-row backlog is otherwise summarized by `chat_client_resume_result`
803
- * rather than spamming 500 lines. Attachment transitions ALWAYS emit, from either
804
- * source, because an in-place attachment mutation is the exact event this
805
- * instrumentation exists to prove.
810
+ * line; a DELTA row emits one only when it is materially interesting (carries a
811
+ * moderation kind, or reconciles one of our optimistic sends) — a 500-row backlog
812
+ * is otherwise summarized by `chat_client_resume_result` rather than spamming 500
813
+ * lines.
806
814
  */
807
815
  applyMessage(row, source) {
808
816
  if (!row || typeof row.seq !== 'number') {
@@ -818,18 +826,7 @@ export class ChannelClient {
818
826
  this.resumeSeq = row.seq;
819
827
  if (!this.diag || !prior)
820
828
  return;
821
- const attachmentState = typeof row.attachmentState === 'string' ? row.attachmentState : null;
822
- // Emit a transition for a real change only: first arrival of an attachment row
823
- // (null -> pending) and every later in-place mutation (pending -> ready/failed).
824
- if (attachmentState !== prior.attachmentState && (attachmentState != null || prior.hadRow)) {
825
- this.diag(DIAG.ATTACHMENT_TRANSITION, {
826
- seq: row.seq,
827
- from: prior.attachmentState,
828
- to: attachmentState,
829
- source,
830
- });
831
- }
832
- const notable = attachmentState != null || row.moderationKind != null || prior.reconciledOptimistic;
829
+ const notable = row.moderationKind != null || prior.reconciledOptimistic;
833
830
  if (source === 'delta' && !notable)
834
831
  return;
835
832
  this.diag(DIAG.FRAME_APPLIED, {
@@ -837,7 +834,6 @@ export class ChannelClient {
837
834
  source,
838
835
  seq: row.seq,
839
836
  hasClientMessageId: Boolean(row.clientMessageId),
840
- attachmentState,
841
837
  moderationKind: row.moderationKind ?? null,
842
838
  op: prior.reconciledOptimistic ? 'optimistic-reconcile' : prior.hadRow ? 'replace-by-seq' : 'insert',
843
839
  cursorBefore,
@@ -845,17 +841,15 @@ export class ChannelClient {
845
841
  });
846
842
  }
847
843
  /**
848
- * The pre-merge view of a row's seq: whether we already hold that seq, its current
849
- * attachment state, and whether this row reconciles a live optimistic send.
844
+ * The pre-merge view of a row's seq: whether we already hold that seq, and whether
845
+ * this row reconciles a live optimistic send.
850
846
  * Diagnostics-only — never called when diagnostics are off.
851
847
  */
852
848
  priorRowFacts(row) {
853
849
  const messageId = seqToMessageId(row.seq);
854
850
  const existing = this.state.messages.find((m) => m.messageId === messageId);
855
- const raw = existing?.meta?.attachmentState;
856
851
  return {
857
852
  hadRow: existing != null,
858
- attachmentState: typeof raw === 'string' ? raw : null,
859
853
  reconciledOptimistic: Boolean(row.clientMessageId &&
860
854
  this.state.messages.some((m) => m.meta?.optimistic && m.meta?.clientMessageId === row.clientMessageId)),
861
855
  };
@@ -913,11 +907,6 @@ export class ChannelClient {
913
907
  }
914
908
  applyHistoryPage(rows) {
915
909
  const cursorBefore = this.resumeSeq;
916
- // Pre-page attachment states for the seqs we already hold — a history page that
917
- // carries a DIFFERENT state for a row we already rendered is an in-place mutation
918
- // the client learned about by re-fetching, which is exactly the reveal path under
919
- // investigation. Diagnostics-only, so only built when they are on.
920
- const priorAttachment = this.diag ? this.snapshotAttachmentStates() : null;
921
910
  const mapped = rows.map((r) => this.renderRow(r));
922
911
  // Mirror mergeMessage's optimistic reconciliation: a history row carrying a
923
912
  // clientMessageId we still hold as an optimistic placeholder IS that send (the
@@ -955,19 +944,6 @@ export class ChannelClient {
955
944
  });
956
945
  if (!this.diag)
957
946
  return;
958
- if (priorAttachment) {
959
- for (const r of rows) {
960
- if (typeof r.seq !== 'number')
961
- continue;
962
- const before = priorAttachment.get(r.seq);
963
- if (before === undefined)
964
- continue; // a row we did not hold — not a transition
965
- const after = typeof r.attachmentState === 'string' ? r.attachmentState : null;
966
- if (before !== after) {
967
- this.diag(DIAG.ATTACHMENT_TRANSITION, { seq: r.seq, from: before, to: after, source: 'history' });
968
- }
969
- }
970
- }
971
947
  const seqs = rows.map((r) => r.seq).filter((s) => typeof s === 'number');
972
948
  this.diag(DIAG.HISTORY_PAGE, {
973
949
  count: rows.length,
@@ -980,21 +956,6 @@ export class ChannelClient {
980
956
  total: merged.length,
981
957
  });
982
958
  }
983
- /**
984
- * A seq -> attachmentState map of the rows currently held (diagnostics-only, so a
985
- * later in-place mutation can be reported as an explicit `old -> new` transition).
986
- */
987
- snapshotAttachmentStates() {
988
- const out = new Map();
989
- for (const m of this.state.messages) {
990
- const seq = m.meta?.seq;
991
- if (typeof seq !== 'number')
992
- continue;
993
- const raw = m.meta?.attachmentState;
994
- out.set(seq, typeof raw === 'string' ? raw : null);
995
- }
996
- return out;
997
- }
998
959
  applyTyping(uid) {
999
960
  if (!uid || uid === this.config.currentUserId)
1000
961
  return;