@ttt-productions/chat-react 0.13.14 → 0.13.16
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/README.md +3 -3
- package/dist/context/ChatNameResolverContext.d.ts +3 -3
- package/dist/context/ChatNameResolverContext.d.ts.map +1 -1
- package/dist/context/ChatNameResolverContext.js +3 -3
- package/dist/context/ChatNameResolverContext.js.map +1 -1
- package/dist/firestore/queries.js +1 -1
- package/dist/firestore/queries.js.map +1 -1
- package/dist/hooks/useChatMessages.d.ts +3 -3
- package/dist/hooks/useChatMessages.d.ts.map +1 -1
- package/dist/hooks/useChatMessages.js +20 -12
- package/dist/hooks/useChatMessages.js.map +1 -1
- package/dist/index.d.ts +32 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -11
- package/dist/index.js.map +1 -1
- package/dist/realtime/channel-client.d.ts.map +1 -1
- package/dist/realtime/channel-client.js +97 -32
- package/dist/realtime/channel-client.js.map +1 -1
- package/dist/realtime/inbox-client.d.ts.map +1 -1
- package/dist/realtime/inbox-client.js +29 -11
- package/dist/realtime/inbox-client.js.map +1 -1
- package/dist/realtime/initial-load-budget.d.ts.map +1 -1
- package/dist/realtime/initial-load-budget.js.map +1 -1
- package/dist/realtime/map.d.ts +0 -2
- package/dist/realtime/map.d.ts.map +1 -1
- package/dist/realtime/map.js +3 -4
- package/dist/realtime/map.js.map +1 -1
- package/dist/realtime/shared.d.ts +0 -1
- package/dist/realtime/shared.d.ts.map +1 -1
- package/dist/realtime/shared.js +2 -6
- package/dist/realtime/shared.js.map +1 -1
- package/dist/realtime/socket.d.ts.map +1 -1
- package/dist/realtime/socket.js +1 -11
- package/dist/realtime/socket.js.map +1 -1
- package/dist/realtime/transport.d.ts +1 -2
- package/dist/realtime/transport.d.ts.map +1 -1
- package/dist/realtime/transport.js +1 -1
- package/dist/realtime/transport.js.map +1 -1
- package/dist/realtime/useRealtimeChatMessages.d.ts +4 -4
- package/dist/realtime/useRealtimeChatMessages.d.ts.map +1 -1
- package/dist/realtime/useRealtimeChatMessages.js +5 -5
- package/dist/realtime/useRealtimeChatMessages.js.map +1 -1
- package/dist/realtime/wire.d.ts +0 -2
- package/dist/realtime/wire.d.ts.map +1 -1
- package/dist/realtime/wire.js +0 -6
- package/dist/realtime/wire.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.js.map +1 -1
- package/dist/ui/ChatShell.d.ts +5 -5
- package/dist/ui/ChatShell.d.ts.map +1 -1
- package/dist/ui/ChatShell.js +37 -34
- package/dist/ui/ChatShell.js.map +1 -1
- package/dist/ui/Composer.d.ts +1 -1
- package/dist/ui/Composer.js +12 -12
- package/dist/ui/Composer.js.map +1 -1
- package/dist/ui/MessageItemDefault.d.ts +2 -2
- package/dist/ui/MessageItemDefault.d.ts.map +1 -1
- package/dist/ui/MessageItemDefault.js +26 -24
- package/dist/ui/MessageItemDefault.js.map +1 -1
- package/dist/ui/MessageList.d.ts +3 -3
- package/dist/ui/MessageList.d.ts.map +1 -1
- package/dist/ui/MessageList.js +13 -16
- package/dist/ui/MessageList.js.map +1 -1
- package/dist/ui/SenderName.js +3 -3
- package/dist/ui/SenderName.js.map +1 -1
- package/dist/ui/menus.d.ts +1 -1
- package/dist/ui/menus.d.ts.map +1 -1
- package/dist/ui/menus.js +4 -4
- package/dist/ui/menus.js.map +1 -1
- package/package.json +10 -10
- package/dist/realtime/index.d.ts +0 -19
- package/dist/realtime/index.d.ts.map +0 -1
- package/dist/realtime/index.js +0 -15
- package/dist/realtime/index.js.map +0 -1
package/dist/ui/ChatShell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatShell.js","sourceRoot":"","sources":["../../src/ui/ChatShell.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,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;QAAE,OAAO,IAAI,CAAC;IAClE,OAAO,CACL,cACE,SAAS,EAAC,yEAAyE,EACnF,IAAI,EAAC,QAAQ,eACH,QAAQ,YAEjB,MAAM,KAAK,cAAc;YACxB,CAAC,CAAC,wCAAwC;YAC1C,CAAC,CAAC,6CAA6C,GAC7C,CACP,CAAC;AACJ,CAAC;AAED;0EAC0E;AAC1E,SAAS,eAAe,CAAC,EAAE,MAAM,EAAyB;IACxD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD,OAAO,CACL,cAAK,SAAS,EAAC,sCAAsC,eAAW,QAAQ,YACrE,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,4BAA4B,GACtE,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport type { ChatMessageGroupKey, ChatMessageV1, ModerationHandlers } from \"@ttt-productions/chat-core\";\nimport type {\n ChatCoreConfig,\n MessageRendererRegistry,\n} from \"../types.js\";\nimport { Card, CardHeader, CardContent, CardFooter, Skeleton, Spinner } from \"@ttt-productions/ui-core/react\";\nimport { KeyboardAvoidingView } from \"@ttt-productions/mobile-core/react\";\nimport { useChatMessages } from \"../hooks/useChatMessages.js\";\nimport { useRealtimeChatMessages } from \"../realtime/useRealtimeChatMessages.js\";\nimport type { RealtimeChatClient } from \"../realtime/transport.js\";\nimport { MessageList, type ChatScrollContainerProps } from \"./MessageList.js\";\nimport { Composer } from \"./Composer.js\";\nimport { ThreadActions } from \"./menus.js\";\n\n/**\n * A read the chat could not complete, handed to the app's `renderLoadError`:\n * - `initial` — nothing loaded: the first open failed (the realtime client's attempts\n * failed for its budget, or the Firestore listener failed before any message). It\n * takes the place of the message list.\n * - `live` — the Firestore listener failed after messages loaded. The messages stay,\n * with this band above them.\n * - `older` — an older page failed to load. It renders at the top of the list, which\n * stops asking for older pages until `retry`.\n * `error` is the read's own error (null on the realtime transport); `retry` re-runs what\n * failed — the realtime transport also keeps retrying in the background. `retrying` is true\n * while a retry of this failure is running and the failure is still shown (an older page being\n * read again), so the app's Retry shows its pending state. A retried initial or live failure\n * gives way to the opening state instead.\n */\nexport type ChatLoadFailure = {\n scope: \"initial\" | \"live\" | \"older\";\n error: Error | null;\n retry: () => void;\n retrying: boolean;\n};\n\nexport type ChatShellProps = {\n config: ChatCoreConfig;\n\n /**\n * Renders every failed read (see {@link ChatLoadFailure}) — the app's own error state and\n * copy. Required: a chat that cannot load must say so, and the words are the app's.\n */\n renderLoadError: (failure: ChatLoadFailure) => React.ReactNode;\n\n // Header\n header?: React.ReactNode;\n\n // Send handler — text-only. On the realtime transport this is OPTIONAL: the\n // shell sends through the DO socket. If provided, it is still called (so a\n // consumer can mirror to analytics), but the socket send is authoritative.\n onSend?: (text: string) => Promise<void>;\n\n // Message rendering\n renderMessage?: (m: any) => React.ReactNode;\n messageRenderers?: MessageRendererRegistry;\n handlers?: ModerationHandlers;\n\n composerPlaceholder?: string;\n autoFocus?: boolean;\n\n // Three render slots\n renderAboveMessages?: () => React.ReactNode;\n renderBelowMessages?: () => React.ReactNode;\n /** If provided, replaces the Composer entirely */\n renderFooter?: () => React.ReactNode;\n\n // Sender interaction\n onSenderClick?: (senderId: string) => void;\n /** The app's per-message grouping fact and its sender-line adornment (forwarded to MessageList). */\n messageGroupKey?: ChatMessageGroupKey;\n renderSenderAdornment?: (m: ChatMessageV1) => React.ReactNode;\n\n // Disable\n composerDisabled?: boolean;\n\n /** Fill the parent's height instead of the default fixed-height card. Lays the Card out\n * as `flex flex-col h-full` with the message list flexing to fill (scrolls inside), so a\n * full-height page panel doesn't grow unbounded or waste space on a fixed 400px box.\n * The consumer must give ChatShell a bounded-height parent (e.g. an `h-full` panel). */\n fillHeight?: boolean;\n /**\n * Called with whether the conversation is READY — its access allowed, its initial data loaded\n * with no failure, and (realtime) the channel current since its socket last opened — each time\n * that changes, and with `false` when the shell unmounts. A consumer that lets someone act on\n * what the conversation says (an agreement, an offer) offers and accepts that action only while\n * it is true; reading the conversation needs no readiness.\n */\n onReadinessChange?: (ready: boolean) => void;\n /** Advanced override for the scrollable region's class (forwarded to MessageList).\n * Usually unnecessary — prefer `fillHeight`. */\n scrollClassName?: string;\n /** Renders the scrollable message region (forwarded to MessageList) in place of the default div,\n * so the consumer can give it its own surface component. */\n scrollContainer?: React.ComponentType<ChatScrollContainerProps>;\n};\n\n/** The resolved data a transport hook hands the presentational view. */\ntype ResolvedChat = {\n allowed: boolean;\n isInitialLoading: boolean;\n /** The transport's own readiness beyond loaded-and-allowed (realtime: the channel is current). */\n transportCurrent: boolean;\n messages: ChatMessageV1[];\n fetchOlder: () => Promise<void>;\n hasOlder: boolean;\n isFetchingOlder: boolean;\n /** The failed read that replaces or annotates the list (initial / live), or null. */\n loadFailure: ChatLoadFailure | null;\n /** The failed older page, or null. */\n olderFailure: ChatLoadFailure | null;\n /** The send handler the Composer calls (socket send on realtime, prop on firestore). */\n send: (text: string) => Promise<void>;\n /** Retry a failed realtime send by its original clientMessageId (realtime only;\n * absent on firestore). Wired to MessageItemDefault's failed-bubble retry. */\n retrySend?: (clientMessageId: string) => void;\n /** Advance the authoritative read cursor (realtime only; absent on the firestore path).\n * Returns whether the ack was actually sent so the caller advances its local cursor only on success (M2). */\n readAck?: (latestSeq: number, focused: boolean) => boolean;\n /** Realtime connection status — drives the disconnected banner (R13). Absent on firestore. */\n status?: string;\n /** uids currently typing (realtime only) — drives the typing indicator (R14). */\n typing?: string[];\n /** Signal the local user is typing (coalesced by the transport). Wired to the Composer (R14). */\n signalTyping?: () => void;\n};\n\n/**\n * ChatShell dispatches on `config.transport`. Hooks must be unconditional, so the\n * two transports live in separate inner components (each calls exactly ONE data\n * hook) and both render the shared presentational `ChatShellView`. The default\n * (undefined / 'firestore') transport is byte-for-byte the previous behavior.\n */\nexport function ChatShell(props: ChatShellProps) {\n if (props.config.transport === \"realtime\") {\n return <RealtimeChatShell {...props} />;\n }\n return <FirestoreChatShell {...props} />;\n}\n\nfunction FirestoreChatShell(props: ChatShellProps) {\n const { config, onSend } = props;\n const r = useChatMessages(config);\n const send = React.useCallback(\n async (text: string) => {\n if (onSend) await onSend(text);\n },\n [onSend],\n );\n const { error, olderError, retry, messages, isFetchingOlder } = r;\n const loadFailure = React.useMemo<ChatLoadFailure | null>(\n () => (error ? { scope: messages.length > 0 ? \"live\" : \"initial\", error, retry, retrying: false } : null),\n [error, messages.length, retry],\n );\n const olderFailure = React.useMemo<ChatLoadFailure | null>(\n () => (olderError ? { scope: \"older\", error: olderError, retry, retrying: isFetchingOlder } : null),\n [olderError, retry, isFetchingOlder],\n );\n return (\n <ChatShellView\n {...props}\n resolved={{\n allowed: r.allowed,\n isInitialLoading: r.isInitialLoading,\n transportCurrent: true,\n messages: r.messages,\n fetchOlder: r.fetchOlder,\n hasOlder: r.hasOlder,\n isFetchingOlder: r.isFetchingOlder,\n loadFailure,\n olderFailure,\n send,\n }}\n />\n );\n}\n\nfunction RealtimeChatShell(props: ChatShellProps) {\n const { config, onSend } = props;\n const client = config.realtime?.client as RealtimeChatClient | undefined;\n if (!client) {\n throw new Error(\n \"[ChatShell] transport 'realtime' requires config.realtime.client (createRealtimeChatClient(...))\",\n );\n }\n const r = useRealtimeChatMessages(client);\n const { initialLoadFailed, retry } = r;\n const loadFailure = React.useMemo<ChatLoadFailure | null>(\n () => (initialLoadFailed ? { scope: \"initial\", error: null, retry, retrying: false } : null),\n [initialLoadFailed, retry],\n );\n const send = React.useCallback(\n async (text: string) => {\n const ok = r.send(text);\n // C-B8: surface a closed-socket failure so the Composer keeps the user's text\n // instead of clearing it on a no-op send.\n if (!ok) throw new Error(\"chat-send-failed\");\n if (onSend) await onSend(text); // optional mirror\n },\n [r, onSend],\n );\n return (\n <ChatShellView\n {...props}\n resolved={{\n // The app's access fact AND the grant's: a terminal denial closes it either way.\n allowed: config.allowed && r.allowed,\n isInitialLoading: r.isInitialLoading,\n transportCurrent: r.isSynced,\n messages: r.messages,\n fetchOlder: r.fetchOlder,\n hasOlder: r.hasOlder,\n isFetchingOlder: r.isFetchingOlder,\n loadFailure,\n olderFailure: null,\n send,\n retrySend: r.retrySend,\n readAck: r.readAck,\n status: r.status,\n typing: r.typing,\n signalTyping: r.signalTyping,\n }}\n />\n );\n}\n\nfunction ChatShellView(props: ChatShellProps & { resolved: ResolvedChat }) {\n const {\n config,\n header,\n renderMessage,\n messageRenderers,\n handlers,\n composerPlaceholder,\n autoFocus = false,\n renderAboveMessages,\n renderBelowMessages,\n renderFooter,\n onSenderClick,\n messageGroupKey,\n renderSenderAdornment,\n composerDisabled,\n fillHeight = false,\n scrollClassName,\n scrollContainer,\n renderLoadError,\n onReadinessChange,\n resolved,\n } = props;\n\n const { allowed, isInitialLoading, messages, fetchOlder, hasOlder, isFetchingOlder, loadFailure, olderFailure, send, retrySend, readAck, status, typing, signalTyping } = resolved;\n // Nothing loaded and the read failed: the failure takes the list's place.\n const initialFailure = loadFailure?.scope === \"initial\" ? loadFailure : null;\n\n const ready = allowed && !isInitialLoading && loadFailure === null && resolved.transportCurrent;\n const readinessListener = React.useRef(onReadinessChange);\n React.useEffect(() => {\n readinessListener.current = onReadinessChange;\n });\n React.useEffect(() => {\n readinessListener.current?.(ready);\n }, [ready]);\n React.useEffect(() => () => readinessListener.current?.(false), []);\n\n const [showScrollToBottom, setShowScrollToBottom] = React.useState(false);\n const [atBottom, setAtBottom] = React.useState(true);\n const [focused, setFocused] = React.useState(true);\n const lastAckedRef = React.useRef(0);\n const leaseHeldRef = React.useRef(false);\n\n // The latest authoritative seq currently rendered (optimistic rows have no seq).\n const latestSeq = React.useMemo(() => {\n let max = 0;\n for (const m of messages) {\n const seq = typeof m.meta?.seq === \"number\" ? (m.meta?.seq as number) : 0;\n if (seq > max) max = seq;\n }\n return max;\n }, [messages]);\n\n // Track tab focus/visibility so the read-ack \"focused\" lease releases on blur/hide.\n React.useEffect(() => {\n const compute = () =>\n typeof document === \"undefined\" ||\n (document.visibilityState !== \"hidden\" && (typeof document.hasFocus !== \"function\" || document.hasFocus()));\n setFocused(compute());\n const onChange = () => setFocused(compute());\n window.addEventListener(\"focus\", onChange);\n window.addEventListener(\"blur\", onChange);\n document.addEventListener(\"visibilitychange\", onChange);\n return () => {\n window.removeEventListener(\"focus\", onChange);\n window.removeEventListener(\"blur\", onChange);\n document.removeEventListener(\"visibilitychange\", onChange);\n };\n }, []);\n\n // C-B6: advance the authoritative read cursor when the reader is actually at the\n // latest message (channel mounted + tab focused + scrolled to bottom); release the\n // focus lease exactly once when they stop. No-op on the firestore path (no readAck).\n React.useEffect(() => {\n if (!readAck || latestSeq <= 0) return;\n if (focused && atBottom) {\n leaseHeldRef.current = true;\n if (latestSeq > lastAckedRef.current) {\n // Advance the local marker ONLY if the frame was actually sent — a drop during a\n // disconnect window must stay un-acked so it retries (the client also re-sends the\n // cursor on reconnect). (M2)\n if (readAck(latestSeq, true)) lastAckedRef.current = latestSeq;\n }\n } else if (leaseHeldRef.current) {\n leaseHeldRef.current = false;\n readAck(latestSeq, false);\n }\n }, [readAck, latestSeq, atBottom, focused]);\n\n // In fill mode the Card flexes to its parent's height and the message list fills the\n // space between header and composer; otherwise it's the default natural-height card.\n const cardClassName = fillHeight ? \"w-full flex flex-col h-full min-h-0\" : \"w-full\";\n const contentClassName = fillHeight ? \"p-0 flex-1 min-h-0 flex flex-col\" : \"p-0\";\n\n if (!allowed) {\n return <div className=\"p-4 text-sm opacity-70\">You don't have access to this thread.</div>;\n }\n\n if (isInitialLoading || initialFailure) {\n // Before the first authoritative snapshot/history result, show an HONEST working\n // state — a visible \"Opening chat…\" spinner in a polite live region — NOT a blank\n // parchment/skeleton box (which read as an empty chat) and NOT the reconnect banner\n // (which must not compete with the initial-opening message). Only the MessageList\n // region is replaced: the consumer's header + actions + the three render-slots +\n // footer still render, and `onReadinessChange` tells a consumer whose slots carry\n // actions that the conversation is not ready to act on.\n return (\n <Card className={cardClassName}>\n {(header || handlers) && (\n <CardHeader className=\"flex flex-row items-start justify-between gap-4 space-y-0\">\n <div>{header}</div>\n <div className=\"flex flex-col items-end gap-2\">\n <ThreadActions threadId={config.threadId} isAdmin={config.isAdmin} handlers={handlers} />\n </div>\n </CardHeader>\n )}\n {(() => {\n // The wrapper (and its border) renders only when the slot actually\n // produced content — a slot returning null (e.g. a collapsed\n // conversation-files section) must not paint an empty bordered strip.\n const aboveMessages = renderAboveMessages?.() ?? null;\n return aboveMessages != null && aboveMessages !== false ? (\n <div className=\"border-b\">{aboveMessages}</div>\n ) : null;\n })()}\n <CardContent className={contentClassName}>\n {initialFailure ? (\n renderLoadError(initialFailure)\n ) : (\n <div\n className=\"flex flex-col items-center justify-center gap-2 py-12 text-sm text-muted-foreground\"\n role=\"status\"\n aria-live=\"polite\"\n >\n <Spinner size=\"sm\" />\n <span>Opening chat…</span>\n </div>\n )}\n </CardContent>\n {renderBelowMessages && (\n <div className=\"border-t\">{renderBelowMessages()}</div>\n )}\n {renderFooter ? (\n <CardFooter className=\"border-t\">{renderFooter()}</CardFooter>\n ) : (\n <CardFooter className=\"border-t\">\n <Skeleton className=\"h-10 w-full\" />\n </CardFooter>\n )}\n </Card>\n );\n }\n\n return (\n <Card className={cardClassName}>\n {(header || handlers) && (\n <CardHeader className=\"flex flex-row items-start justify-between gap-4 space-y-0\">\n <div>{header}</div>\n <div className=\"flex flex-col items-end gap-2\">\n <ThreadActions threadId={config.threadId} isAdmin={config.isAdmin} handlers={handlers} />\n </div>\n </CardHeader>\n )}\n\n {/* R13: a disconnected/reconnecting banner so a configured-but-unreachable Worker\n never presents a healthy-looking empty thread. Only the realtime path sets `status`. */}\n <ChatConnectionBanner status={status} />\n\n {renderAboveMessages && (\n <div className=\"border-b\">{renderAboveMessages()}</div>\n )}\n\n {/* The listener failed after messages loaded: they stay, with the failure above them. */}\n {loadFailure?.scope === \"live\" && <div className=\"border-b\">{renderLoadError(loadFailure)}</div>}\n\n <CardContent className={contentClassName}>\n <MessageList\n messages={messages}\n currentUserId={config.currentUserId}\n isAdmin={config.isAdmin}\n isFetchingOlder={isFetchingOlder}\n hasOlder={hasOlder}\n onLoadOlder={() => fetchOlder()}\n renderMessage={renderMessage}\n messageRenderers={messageRenderers}\n showScrollToBottom={showScrollToBottom}\n onScrollToBottom={() => setShowScrollToBottom(false)}\n onAtBottomChange={setAtBottom}\n fillHeight={fillHeight}\n scrollClassName={scrollClassName}\n scrollContainer={scrollContainer}\n handlers={handlers}\n onSenderClick={onSenderClick}\n messageGroupKey={messageGroupKey}\n renderSenderAdornment={renderSenderAdornment}\n onRetrySend={retrySend}\n olderLoadErrorRow={olderFailure ? renderLoadError(olderFailure) : null}\n />\n </CardContent>\n\n {renderBelowMessages && (\n <div className=\"border-t\">{renderBelowMessages()}</div>\n )}\n\n {renderFooter ? (\n <CardFooter className=\"border-t\">\n {renderFooter()}\n </CardFooter>\n ) : (\n <CardFooter className=\"border-t flex-col items-stretch gap-1\">\n {/* R14: typing dots above the composer (realtime only — `typing` is undefined on firestore). */}\n <TypingIndicator typing={typing} />\n <KeyboardAvoidingView padding offset={8} className=\"w-full\">\n <Composer\n onSend={send}\n onTyping={signalTyping}\n disabled={composerDisabled}\n autoFocus={autoFocus}\n placeholder={composerPlaceholder}\n />\n </KeyboardAvoidingView>\n </CardFooter>\n )}\n </Card>\n );\n}\n\n/**\n * R13 — connection-state banner. The realtime path sets `status`; once the first\n * snapshot has loaded (ChatShellView is past `isInitialLoading`), a dropped/unreachable\n * socket surfaces here instead of a silently-empty thread. Renders nothing on the\n * firestore path (`status` undefined) or while live (`open`).\n */\nfunction ChatConnectionBanner({ status }: { status?: string }) {\n if (status !== \"reconnecting\" && status !== \"closed\") return null;\n return (\n <div\n className=\"px-3 py-1.5 text-xs text-center bg-muted text-muted-foreground border-b\"\n role=\"status\"\n aria-live=\"polite\"\n >\n {status === \"reconnecting\"\n ? \"Reconnecting… messages may be delayed.\"\n : \"Disconnected — messages may be out of date.\"}\n </div>\n );\n}\n\n/** R14 — typing indicator. `typing` is the set of OTHER users typing (the transport\n * excludes the local user). Generic copy (no name resolution) for v1. */\nfunction TypingIndicator({ typing }: { typing?: string[] }) {\n if (!typing || typing.length === 0) return null;\n return (\n <div className=\"text-xs italic text-muted-foreground\" aria-live=\"polite\">\n {typing.length === 1 ? \"Someone is typing…\" : \"Several people are typing…\"}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ChatShell.js","sourceRoot":"","sources":["../../src/ui/ChatShell.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,GACR,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,EAAE,WAAW,EAAiC,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAmH3C;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;QAC1C,OAAO,KAAC,iBAAiB,OAAK,KAAK,GAAI,CAAC;IAC1C,CAAC;IACD,OAAO,KAAC,kBAAkB,OAAK,KAAK,GAAI,CAAC;AAC3C,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAqB;IAC/C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACjC,MAAM,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CA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,IAAC,OAAO,QAAC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAC,QAAQ,YACzD,KAAC,QAAQ,IACP,MAAM,EAAE,IAAI,EACZ,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,mBAAmB,GAChC,GACmB,IACZ,CACd,IACI,CACR,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,EAAE,MAAM,EAAuB;IAC3D,IAAI,MAAM,KAAK,cAAc,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAClE,OAAO,CACL,cACE,SAAS,EAAC,yEAAyE,EACnF,IAAI,EAAC,QAAQ,eACH,QAAQ,YAEjB,MAAM,KAAK,cAAc;YACxB,CAAC,CAAC,wCAAwC;YAC1C,CAAC,CAAC,6CAA6C,GAC7C,CACP,CAAC;AACJ,CAAC;AAED;0EAC0E;AAC1E,SAAS,eAAe,CAAC,EAAE,MAAM,EAAyB;IACxD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD,OAAO,CACL,cAAK,SAAS,EAAC,sCAAsC,eAAW,QAAQ,YACrE,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,4BAA4B,GACtE,CACP,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type {\n ChatMessageGroupKey,\n ChatMessageV1,\n ModerationHandlers,\n} from '@ttt-productions/chat-core';\nimport type { ChatCoreConfig, MessageRendererRegistry } from '../types.js';\nimport {\n Card,\n CardHeader,\n CardContent,\n CardFooter,\n Skeleton,\n Spinner,\n} from '@ttt-productions/ui-core/react';\nimport { KeyboardAvoidingView } from '@ttt-productions/mobile-core/react';\nimport { useChatMessages } from '../hooks/useChatMessages.js';\nimport { useRealtimeChatMessages } from '../realtime/useRealtimeChatMessages.js';\nimport type { RealtimeChatClient } from '../realtime/transport.js';\nimport { MessageList, type ChatScrollContainerProps } from './MessageList.js';\nimport { Composer } from './Composer.js';\nimport { ThreadActions } from './menus.js';\n\n/**\n * A read the chat could not complete, handed to the app's `renderLoadError`:\n * - `initial` — nothing loaded: the first open failed (the realtime client's attempts\n * failed for its budget, or the Firestore listener failed before any message). It\n * takes the place of the message list.\n * - `live` — the Firestore listener failed after messages loaded. The messages stay,\n * with this band above them.\n * - `older` — an older page failed to load. It renders at the top of the list, which\n * stops asking for older pages until `retry`.\n * `error` is the read's own error (null on the realtime transport); `retry` re-runs what\n * failed — the realtime transport also keeps retrying in the background. `retrying` is true\n * while a retry of this failure is running and the failure is still shown (an older page being\n * read again), so the app's Retry shows its pending state. A retried initial or live failure\n * gives way to the opening state instead.\n */\nexport type ChatLoadFailure = {\n scope: 'initial' | 'live' | 'older';\n error: Error | null;\n retry: () => void;\n retrying: boolean;\n};\n\nexport type ChatShellProps = {\n config: ChatCoreConfig;\n\n /**\n * Renders every failed read (see {@link ChatLoadFailure}) — the app's own error state and\n * copy. Required: a chat that cannot load must say so, and the words are the app's.\n */\n renderLoadError: (failure: ChatLoadFailure) => React.ReactNode;\n\n // Header\n header?: React.ReactNode;\n\n // Send handler — text-only. On the realtime transport this is OPTIONAL: the\n // shell sends through the DO socket. If provided, it is still called (so a\n // consumer can mirror to analytics), but the socket send is authoritative.\n onSend?: (text: string) => Promise<void>;\n\n // Message rendering\n renderMessage?: (m: any) => React.ReactNode;\n messageRenderers?: MessageRendererRegistry;\n handlers?: ModerationHandlers;\n\n composerPlaceholder?: string;\n autoFocus?: boolean;\n\n // Three render slots\n renderAboveMessages?: () => React.ReactNode;\n renderBelowMessages?: () => React.ReactNode;\n /** If provided, replaces the Composer entirely */\n renderFooter?: () => React.ReactNode;\n\n // Sender interaction\n onSenderClick?: (senderId: string) => void;\n /** The app's per-message grouping fact and its sender-line adornment (forwarded to MessageList). */\n messageGroupKey?: ChatMessageGroupKey;\n renderSenderAdornment?: (m: ChatMessageV1) => React.ReactNode;\n\n // Disable\n composerDisabled?: boolean;\n\n /** Fill the parent's height instead of the default fixed-height card. Lays the Card out\n * as `flex flex-col h-full` with the message list flexing to fill (scrolls inside), so a\n * full-height page panel doesn't grow unbounded or waste space on a fixed 400px box.\n * The consumer must give ChatShell a bounded-height parent (e.g. an `h-full` panel). */\n fillHeight?: boolean;\n /**\n * Called with whether the conversation is READY — its access allowed, its initial data loaded\n * with no failure, and (realtime) the channel current since its socket last opened — each time\n * that changes, and with `false` when the shell unmounts. A consumer that lets someone act on\n * what the conversation says (an agreement, an offer) offers and accepts that action only while\n * it is true; reading the conversation needs no readiness.\n */\n onReadinessChange?: (ready: boolean) => void;\n /** Advanced override for the scrollable region's class (forwarded to MessageList).\n * Usually unnecessary — prefer `fillHeight`. */\n scrollClassName?: string;\n /** Renders the scrollable message region (forwarded to MessageList) in place of the default div,\n * so the consumer can give it its own surface component. */\n scrollContainer?: React.ComponentType<ChatScrollContainerProps>;\n};\n\n/** The resolved data a transport hook hands the presentational view. */\ntype ResolvedChat = {\n allowed: boolean;\n isInitialLoading: boolean;\n /** The transport's own readiness beyond loaded-and-allowed (realtime: the channel is current). */\n transportCurrent: boolean;\n messages: ChatMessageV1[];\n fetchOlder: () => Promise<void>;\n hasOlder: boolean;\n isFetchingOlder: boolean;\n /** The failed read that replaces or annotates the list (initial / live), or null. */\n loadFailure: ChatLoadFailure | null;\n /** The failed older page, or null. */\n olderFailure: ChatLoadFailure | null;\n /** The send handler the Composer calls (socket send on realtime, prop on firestore). */\n send: (text: string) => Promise<void>;\n /** Retry a failed realtime send by its original clientMessageId (realtime only;\n * absent on firestore). Wired to MessageItemDefault's failed-bubble retry. */\n retrySend?: (clientMessageId: string) => void;\n /** Advance the authoritative read cursor (realtime only; absent on the firestore path).\n * Returns whether the ack was actually sent so the caller advances its local cursor only on success (M2). */\n readAck?: (latestSeq: number, focused: boolean) => boolean;\n /** Realtime connection status — drives the disconnected banner (R13). Absent on firestore. */\n status?: string;\n /** uids currently typing (realtime only) — drives the typing indicator (R14). */\n typing?: string[];\n /** Signal the local user is typing (coalesced by the transport). Wired to the Composer (R14). */\n signalTyping?: () => void;\n};\n\n/**\n * ChatShell dispatches on `config.transport`. Hooks must be unconditional, so the\n * two transports live in separate inner components (each calls exactly ONE data\n * hook) and both render the shared presentational `ChatShellView`. The default\n * (undefined / 'firestore') transport is byte-for-byte the previous behavior.\n */\nexport function ChatShell(props: ChatShellProps) {\n if (props.config.transport === 'realtime') {\n return <RealtimeChatShell {...props} />;\n }\n return <FirestoreChatShell {...props} />;\n}\n\nfunction FirestoreChatShell(props: ChatShellProps) {\n const { config, onSend } = props;\n const r = useChatMessages(config);\n const send = React.useCallback(\n async (text: string) => {\n if (onSend) await onSend(text);\n },\n [onSend],\n );\n const { error, olderError, retry, messages, isFetchingOlder } = r;\n const loadFailure = React.useMemo<ChatLoadFailure | null>(\n () =>\n error\n ? { scope: messages.length > 0 ? 'live' : 'initial', error, retry, retrying: false }\n : null,\n [error, messages.length, retry],\n );\n const olderFailure = React.useMemo<ChatLoadFailure | null>(\n () =>\n olderError ? { scope: 'older', error: olderError, retry, retrying: isFetchingOlder } : null,\n [olderError, retry, isFetchingOlder],\n );\n return (\n <ChatShellView\n {...props}\n resolved={{\n allowed: r.allowed,\n isInitialLoading: r.isInitialLoading,\n transportCurrent: true,\n messages: r.messages,\n fetchOlder: r.fetchOlder,\n hasOlder: r.hasOlder,\n isFetchingOlder: r.isFetchingOlder,\n loadFailure,\n olderFailure,\n send,\n }}\n />\n );\n}\n\nfunction RealtimeChatShell(props: ChatShellProps) {\n const { config, onSend } = props;\n const client = config.realtime?.client as RealtimeChatClient | undefined;\n if (!client) {\n throw new Error(\n \"[ChatShell] transport 'realtime' requires config.realtime.client (createRealtimeChatClient(...))\",\n );\n }\n const r = useRealtimeChatMessages(client);\n const { initialLoadFailed, retry } = r;\n const loadFailure = React.useMemo<ChatLoadFailure | null>(\n () => (initialLoadFailed ? { scope: 'initial', error: null, retry, retrying: false } : null),\n [initialLoadFailed, retry],\n );\n const send = React.useCallback(\n async (text: string) => {\n const ok = r.send(text);\n // C-B8: surface a closed-socket failure so the Composer keeps the user's text\n // instead of clearing it on a no-op send.\n if (!ok) throw new Error('chat-send-failed');\n if (onSend) await onSend(text); // optional mirror\n },\n [r, onSend],\n );\n return (\n <ChatShellView\n {...props}\n resolved={{\n // The app's access fact AND the grant's: a terminal denial closes it either way.\n allowed: config.allowed && r.allowed,\n isInitialLoading: r.isInitialLoading,\n transportCurrent: r.isSynced,\n messages: r.messages,\n fetchOlder: r.fetchOlder,\n hasOlder: r.hasOlder,\n isFetchingOlder: r.isFetchingOlder,\n loadFailure,\n olderFailure: null,\n send,\n retrySend: r.retrySend,\n readAck: r.readAck,\n status: r.status,\n typing: r.typing,\n signalTyping: r.signalTyping,\n }}\n />\n );\n}\n\nfunction ChatShellView(props: ChatShellProps & { resolved: ResolvedChat }) {\n const {\n config,\n header,\n renderMessage,\n messageRenderers,\n handlers,\n composerPlaceholder,\n autoFocus = false,\n renderAboveMessages,\n renderBelowMessages,\n renderFooter,\n onSenderClick,\n messageGroupKey,\n renderSenderAdornment,\n composerDisabled,\n fillHeight = false,\n scrollClassName,\n scrollContainer,\n renderLoadError,\n onReadinessChange,\n resolved,\n } = props;\n\n const {\n allowed,\n isInitialLoading,\n messages,\n fetchOlder,\n hasOlder,\n isFetchingOlder,\n loadFailure,\n olderFailure,\n send,\n retrySend,\n readAck,\n status,\n typing,\n signalTyping,\n } = resolved;\n // Nothing loaded and the read failed: the failure takes the list's place.\n const initialFailure = loadFailure?.scope === 'initial' ? loadFailure : null;\n\n const ready = allowed && !isInitialLoading && loadFailure === null && resolved.transportCurrent;\n const readinessListener = React.useRef(onReadinessChange);\n React.useEffect(() => {\n readinessListener.current = onReadinessChange;\n });\n React.useEffect(() => {\n readinessListener.current?.(ready);\n }, [ready]);\n React.useEffect(() => () => readinessListener.current?.(false), []);\n\n const [showScrollToBottom, setShowScrollToBottom] = React.useState(false);\n const [atBottom, setAtBottom] = React.useState(true);\n const [focused, setFocused] = React.useState(true);\n const lastAckedRef = React.useRef(0);\n const leaseHeldRef = React.useRef(false);\n\n // The latest authoritative seq currently rendered (optimistic rows have no seq).\n const latestSeq = React.useMemo(() => {\n let max = 0;\n for (const m of messages) {\n const seq = typeof m.meta?.seq === 'number' ? (m.meta?.seq as number) : 0;\n if (seq > max) max = seq;\n }\n return max;\n }, [messages]);\n\n // Track tab focus/visibility so the read-ack \"focused\" lease releases on blur/hide.\n React.useEffect(() => {\n const compute = () =>\n typeof document === 'undefined' ||\n (document.visibilityState !== 'hidden' &&\n (typeof document.hasFocus !== 'function' || document.hasFocus()));\n setFocused(compute());\n const onChange = () => setFocused(compute());\n window.addEventListener('focus', onChange);\n window.addEventListener('blur', onChange);\n document.addEventListener('visibilitychange', onChange);\n return () => {\n window.removeEventListener('focus', onChange);\n window.removeEventListener('blur', onChange);\n document.removeEventListener('visibilitychange', onChange);\n };\n }, []);\n\n // C-B6: advance the authoritative read cursor when the reader is actually at the\n // latest message (channel mounted + tab focused + scrolled to bottom); release the\n // focus lease exactly once when they stop. No-op on the firestore path (no readAck).\n React.useEffect(() => {\n if (!readAck || latestSeq <= 0) return;\n if (focused && atBottom) {\n leaseHeldRef.current = true;\n if (latestSeq > lastAckedRef.current) {\n // Advance the local marker ONLY if the frame was actually sent — a drop during a\n // disconnect window must stay un-acked so it retries (the client also re-sends the\n // cursor on reconnect). (M2)\n if (readAck(latestSeq, true)) lastAckedRef.current = latestSeq;\n }\n } else if (leaseHeldRef.current) {\n leaseHeldRef.current = false;\n readAck(latestSeq, false);\n }\n }, [readAck, latestSeq, atBottom, focused]);\n\n // In fill mode the Card flexes to its parent's height and the message list fills the\n // space between header and composer; otherwise it's the default natural-height card.\n const cardClassName = fillHeight ? 'w-full flex flex-col h-full min-h-0' : 'w-full';\n const contentClassName = fillHeight ? 'p-0 flex-1 min-h-0 flex flex-col' : 'p-0';\n\n if (!allowed) {\n return <div className=\"p-4 text-sm opacity-70\">You don't have access to this thread.</div>;\n }\n\n if (isInitialLoading || initialFailure) {\n // Before the first authoritative snapshot/history result, show an HONEST working\n // state — a visible \"Opening chat…\" spinner in a polite live region — NOT a blank\n // parchment/skeleton box (which read as an empty chat) and NOT the reconnect banner\n // (which must not compete with the initial-opening message). Only the MessageList\n // region is replaced: the consumer's header + actions + the three render-slots +\n // footer still render, and `onReadinessChange` tells a consumer whose slots carry\n // actions that the conversation is not ready to act on.\n return (\n <Card className={cardClassName}>\n {(header || handlers) && (\n <CardHeader className=\"flex flex-row items-start justify-between gap-4 space-y-0\">\n <div>{header}</div>\n <div className=\"flex flex-col items-end gap-2\">\n <ThreadActions\n threadId={config.threadId}\n isAdmin={config.isAdmin}\n handlers={handlers}\n />\n </div>\n </CardHeader>\n )}\n {(() => {\n // The wrapper (and its border) renders only when the slot actually\n // produced content — a slot returning null (e.g. a collapsed\n // conversation-files section) must not paint an empty bordered strip.\n const aboveMessages = renderAboveMessages?.() ?? null;\n return aboveMessages != null && aboveMessages !== false ? (\n <div className=\"border-b\">{aboveMessages}</div>\n ) : null;\n })()}\n <CardContent className={contentClassName}>\n {initialFailure ? (\n renderLoadError(initialFailure)\n ) : (\n <div\n className=\"flex flex-col items-center justify-center gap-2 py-12 text-sm text-muted-foreground\"\n role=\"status\"\n aria-live=\"polite\"\n >\n <Spinner size=\"sm\" />\n <span>Opening chat…</span>\n </div>\n )}\n </CardContent>\n {renderBelowMessages && <div className=\"border-t\">{renderBelowMessages()}</div>}\n {renderFooter ? (\n <CardFooter className=\"border-t\">{renderFooter()}</CardFooter>\n ) : (\n <CardFooter className=\"border-t\">\n <Skeleton className=\"h-10 w-full\" />\n </CardFooter>\n )}\n </Card>\n );\n }\n\n return (\n <Card className={cardClassName}>\n {(header || handlers) && (\n <CardHeader className=\"flex flex-row items-start justify-between gap-4 space-y-0\">\n <div>{header}</div>\n <div className=\"flex flex-col items-end gap-2\">\n <ThreadActions\n threadId={config.threadId}\n isAdmin={config.isAdmin}\n handlers={handlers}\n />\n </div>\n </CardHeader>\n )}\n\n {/* R13: a disconnected/reconnecting banner so a configured-but-unreachable Worker\n never presents a healthy-looking empty thread. Only the realtime path sets `status`. */}\n <ChatConnectionBanner status={status} />\n\n {renderAboveMessages && <div className=\"border-b\">{renderAboveMessages()}</div>}\n\n {/* The listener failed after messages loaded: they stay, with the failure above them. */}\n {loadFailure?.scope === 'live' && (\n <div className=\"border-b\">{renderLoadError(loadFailure)}</div>\n )}\n\n <CardContent className={contentClassName}>\n <MessageList\n messages={messages}\n currentUserId={config.currentUserId}\n isAdmin={config.isAdmin}\n isFetchingOlder={isFetchingOlder}\n hasOlder={hasOlder}\n onLoadOlder={() => fetchOlder()}\n renderMessage={renderMessage}\n messageRenderers={messageRenderers}\n showScrollToBottom={showScrollToBottom}\n onScrollToBottom={() => setShowScrollToBottom(false)}\n onAtBottomChange={setAtBottom}\n fillHeight={fillHeight}\n scrollClassName={scrollClassName}\n scrollContainer={scrollContainer}\n handlers={handlers}\n onSenderClick={onSenderClick}\n messageGroupKey={messageGroupKey}\n renderSenderAdornment={renderSenderAdornment}\n onRetrySend={retrySend}\n olderLoadErrorRow={olderFailure ? renderLoadError(olderFailure) : null}\n />\n </CardContent>\n\n {renderBelowMessages && <div className=\"border-t\">{renderBelowMessages()}</div>}\n\n {renderFooter ? (\n <CardFooter className=\"border-t\">{renderFooter()}</CardFooter>\n ) : (\n <CardFooter className=\"border-t flex-col items-stretch gap-1\">\n {/* R14: typing dots above the composer (realtime only — `typing` is undefined on firestore). */}\n <TypingIndicator typing={typing} />\n <KeyboardAvoidingView padding offset={8} className=\"w-full\">\n <Composer\n onSend={send}\n onTyping={signalTyping}\n disabled={composerDisabled}\n autoFocus={autoFocus}\n placeholder={composerPlaceholder}\n />\n </KeyboardAvoidingView>\n </CardFooter>\n )}\n </Card>\n );\n}\n\n/**\n * R13 — connection-state banner. The realtime path sets `status`; once the first\n * snapshot has loaded (ChatShellView is past `isInitialLoading`), a dropped/unreachable\n * socket surfaces here instead of a silently-empty thread. Renders nothing on the\n * firestore path (`status` undefined) or while live (`open`).\n */\nfunction ChatConnectionBanner({ status }: { status?: string }) {\n if (status !== 'reconnecting' && status !== 'closed') return null;\n return (\n <div\n className=\"px-3 py-1.5 text-xs text-center bg-muted text-muted-foreground border-b\"\n role=\"status\"\n aria-live=\"polite\"\n >\n {status === 'reconnecting'\n ? 'Reconnecting… messages may be delayed.'\n : 'Disconnected — messages may be out of date.'}\n </div>\n );\n}\n\n/** R14 — typing indicator. `typing` is the set of OTHER users typing (the transport\n * excludes the local user). Generic copy (no name resolution) for v1. */\nfunction TypingIndicator({ typing }: { typing?: string[] }) {\n if (!typing || typing.length === 0) return null;\n return (\n <div className=\"text-xs italic text-muted-foreground\" aria-live=\"polite\">\n {typing.length === 1 ? 'Someone is typing…' : 'Several people are typing…'}\n </div>\n );\n}\n"]}
|
package/dist/ui/Composer.d.ts
CHANGED
package/dist/ui/Composer.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from
|
|
4
|
-
import { Button, Textarea } from
|
|
5
|
-
import { cn } from
|
|
6
|
-
import { useOptionalLocalUploadGuard } from
|
|
7
|
-
import { CHAT_MESSAGE_TEXT_INPUT, CHAT_MESSAGE_TEXT_MAX_LENGTH, judgeChatMessageText, } from
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Button, Textarea } from '@ttt-productions/ui-core/react';
|
|
5
|
+
import { cn } from '@ttt-productions/ui-core';
|
|
6
|
+
import { useOptionalLocalUploadGuard } from '@ttt-productions/upload-ui/react/guard';
|
|
7
|
+
import { CHAT_MESSAGE_TEXT_INPUT, CHAT_MESSAGE_TEXT_MAX_LENGTH, judgeChatMessageText, } from '@ttt-productions/chat-schemas';
|
|
8
8
|
function genId() {
|
|
9
9
|
return `${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
|
|
10
10
|
}
|
|
11
11
|
export function Composer(props) {
|
|
12
|
-
const { onSend, onTyping, disabled, autoFocus = false, placeholder =
|
|
13
|
-
const [text, setText] = React.useState(
|
|
12
|
+
const { onSend, onTyping, disabled, autoFocus = false, placeholder = 'Type a message...', } = props;
|
|
13
|
+
const [text, setText] = React.useState('');
|
|
14
14
|
const [isSending, setIsSending] = React.useState(false);
|
|
15
15
|
const [sendError, setSendError] = React.useState(null);
|
|
16
16
|
const ref = React.useRef(null);
|
|
@@ -39,14 +39,14 @@ export function Composer(props) {
|
|
|
39
39
|
navigationGuard?.registerUpload(sendGuardId);
|
|
40
40
|
try {
|
|
41
41
|
await onSend(judged.text);
|
|
42
|
-
setText(
|
|
42
|
+
setText('');
|
|
43
43
|
}
|
|
44
44
|
catch (err) {
|
|
45
45
|
// C-B8: a failed send (e.g. the realtime socket was closed) must NOT clear the
|
|
46
46
|
// user's text — `setText("")` only runs on the success path above — and must NOT
|
|
47
47
|
// re-throw into the click handler (an unhandled rejection). Surface it so the
|
|
48
48
|
// user can retry with their text intact.
|
|
49
|
-
console.error(
|
|
49
|
+
console.error('[Composer] Send failed:', err);
|
|
50
50
|
setSendError("Couldn't send. Check your connection and try again.");
|
|
51
51
|
}
|
|
52
52
|
finally {
|
|
@@ -62,8 +62,8 @@ export function Composer(props) {
|
|
|
62
62
|
// R14: broadcast a typing signal (transport-coalesced) while there is content.
|
|
63
63
|
if (onTyping && e.target.value.trim().length > 0)
|
|
64
64
|
onTyping();
|
|
65
|
-
}, placeholder: placeholder, disabled: isDisabled, rows: 1, className: cn(
|
|
66
|
-
if (e.key ===
|
|
65
|
+
}, placeholder: placeholder, disabled: isDisabled, rows: 1, className: cn('min-h-[40px] resize-none'), onKeyDown: (e) => {
|
|
66
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
67
67
|
e.preventDefault();
|
|
68
68
|
send();
|
|
69
69
|
}
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,IACvC,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Button, Textarea } from '@ttt-productions/ui-core/react';\nimport { cn } from '@ttt-productions/ui-core';\nimport { useOptionalLocalUploadGuard } from '@ttt-productions/upload-ui/react/guard';\nimport {\n CHAT_MESSAGE_TEXT_INPUT,\n CHAT_MESSAGE_TEXT_MAX_LENGTH,\n judgeChatMessageText,\n} from '@ttt-productions/chat-schemas';\n\nfunction genId(): string {\n return `${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;\n}\n\nexport type ComposerProps = {\n /**\n * Text send — the composer's ONE argument. The composer is PLAIN-TEXT-ONLY:\n * files are shared through the conversation's Conversation Files surface,\n * never through the message timeline, so there is no attachment path here;\n * message text carries no inline token grammar, so what the user typed is what\n * is sent; and there is no reply-target picker, so a send never names another\n * message (DJ ruling 2026-07-29).\n */\n onSend: (text: string) => Promise<void>;\n\n /**\n * Signal the local user is typing (R14). Called as the user edits the textarea; the\n * realtime transport coalesces to ≤1 frame per ~2s, so calling per keystroke is safe.\n * Optional — absent on the firestore transport (no typing broadcast).\n */\n onTyping?: () => void;\n\n disabled?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n};\n\nexport function Composer(props: ComposerProps) {\n const {\n onSend,\n onTyping,\n disabled,\n autoFocus = false,\n placeholder = 'Type a message...',\n } = props;\n\n const [text, setText] = React.useState('');\n const [isSending, setIsSending] = React.useState(false);\n const [sendError, setSendError] = React.useState<string | null>(null);\n const ref = React.useRef<HTMLTextAreaElement>(null);\n // Navigation guard for the in-flight send: a send that has left the composer\n // but not yet committed is killable by navigation/sign-out with zero warning\n // (observed live: the callable aborted, the message silently never delivered).\n // Registering with the app's one guarded-navigation system makes beforeunload\n // fire on hard navs and lets GuardedLink-style navigation confirm first.\n // Optional accessor — consumers without the provider degrade to old behavior.\n const navigationGuard = useOptionalLocalUploadGuard();\n const counterId = React.useId();\n\n // focus stability: never steal focus unless explicitly enabled\n React.useEffect(() => {\n if (!autoFocus) return;\n ref.current?.focus();\n }, [autoFocus]);\n\n // The same judgement the Worker applies: a blank text is never sent, and what is sent is trimmed.\n const judged = judgeChatMessageText(text);\n\n const send = async () => {\n if (!judged.ok) return;\n\n setIsSending(true);\n setSendError(null);\n const sendGuardId = `chat-send-${genId()}`;\n navigationGuard?.registerUpload(sendGuardId);\n\n try {\n await onSend(judged.text);\n setText('');\n } catch (err) {\n // C-B8: a failed send (e.g. the realtime socket was closed) must NOT clear the\n // user's text — `setText(\"\")` only runs on the success path above — and must NOT\n // re-throw into the click handler (an unhandled rejection). Surface it so the\n // user can retry with their text intact.\n console.error('[Composer] Send failed:', err);\n setSendError(\"Couldn't send. Check your connection and try again.\");\n } finally {\n navigationGuard?.unregisterUpload(sendGuardId);\n setIsSending(false);\n }\n };\n\n const isDisabled = disabled || isSending;\n\n return (\n <div className=\"chat-composer\">\n {sendError && (\n <div className=\"px-1 pb-1 text-sm text-destructive\" role=\"alert\">\n {sendError}\n </div>\n )}\n\n <div className=\"flex items-end gap-2\">\n <Textarea\n ref={ref}\n value={text}\n inputFormat={CHAT_MESSAGE_TEXT_INPUT}\n aria-describedby={text.length > 0 ? counterId : undefined}\n onChange={(e) => {\n setText(e.target.value);\n if (sendError) setSendError(null);\n // R14: broadcast a typing signal (transport-coalesced) while there is content.\n if (onTyping && e.target.value.trim().length > 0) onTyping();\n }}\n placeholder={placeholder}\n disabled={isDisabled}\n rows={1}\n className={cn('min-h-[40px] resize-none')}\n onKeyDown={(e) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n send();\n }\n }}\n />\n <Button\n type=\"button\"\n variant=\"default\"\n disabled={isDisabled || !judged.ok}\n pending={isSending}\n onClick={send}\n >\n Send\n </Button>\n </div>\n {text.length > 0 && (\n <div id={counterId} className=\"px-1 pt-1 text-xs text-right text-muted-foreground\">\n {text.length}/{CHAT_MESSAGE_TEXT_MAX_LENGTH}\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ReactNode } from
|
|
2
|
-
import type { ChatMessageV1, ModerationHandlers } from
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ChatMessageV1, ModerationHandlers } from '@ttt-productions/chat-core';
|
|
3
3
|
export type MessageItemDefaultProps = {
|
|
4
4
|
m: ChatMessageV1;
|
|
5
5
|
currentUserId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageItemDefault.d.ts","sourceRoot":"","sources":["../../src/ui/MessageItemDefault.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAoEpF,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,EAAE,aAAa,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAG9B,cAAc,CAAC,EAAE,OAAO,CAAC;IAGzB,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,uGAAuG;IACvG,eAAe,CAAC,EAAE,SAAS,CAAC;IAE5B;;0DAEsD;IACtD,WAAW,CAAC,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,+
|
|
1
|
+
{"version":3,"file":"MessageItemDefault.d.ts","sourceRoot":"","sources":["../../src/ui/MessageItemDefault.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAoEpF,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,EAAE,aAAa,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAG9B,cAAc,CAAC,EAAE,OAAO,CAAC;IAGzB,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,uGAAuG;IACvG,eAAe,CAAC,EAAE,SAAS,CAAC;IAE5B;;0DAEsD;IACtD,WAAW,CAAC,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,+BAsHhE"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { MessageText } from
|
|
4
|
-
import { cn } from
|
|
5
|
-
import { Button, Spinner } from
|
|
6
|
-
import { AlertTriangle } from
|
|
7
|
-
import { MessageActions } from
|
|
8
|
-
import { SenderName } from
|
|
9
|
-
import { useSenderNameResolution } from
|
|
3
|
+
import { MessageText } from './MessageText.js';
|
|
4
|
+
import { cn } from '@ttt-productions/ui-core';
|
|
5
|
+
import { Button, Spinner } from '@ttt-productions/ui-core/react';
|
|
6
|
+
import { AlertTriangle } from 'lucide-react';
|
|
7
|
+
import { MessageActions } from './menus.js';
|
|
8
|
+
import { SenderName } from './SenderName.js';
|
|
9
|
+
import { useSenderNameResolution } from '../context/ChatNameResolverContext.js';
|
|
10
10
|
// A chat message renders TEXT (plus its send-state rows). Files live in the
|
|
11
11
|
// conversation's Conversation Files surface, never in the timeline — there is no
|
|
12
12
|
// attachment body here. There is no reply-quote body either: no chat surface has
|
|
@@ -19,13 +19,13 @@ import { useSenderNameResolution } from "../context/ChatNameResolverContext.js";
|
|
|
19
19
|
// by the realtime channel client). A failed send with no code (a transport/exhausted
|
|
20
20
|
// reconnect failure) falls back to the neutral "Couldn't send".
|
|
21
21
|
const SEND_FAILURE_COPY = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
'blocked-word': 'Message contains blocked language',
|
|
23
|
+
archived: 'This channel is read-only',
|
|
24
|
+
deleted: 'This channel is read-only',
|
|
25
|
+
'membership-pending': 'Chat is still preparing',
|
|
26
|
+
'wordlist-unavailable': 'Chat safety check is temporarily unavailable',
|
|
27
|
+
flood: 'Please wait before sending again',
|
|
28
|
+
'slow-mode': 'Please wait before sending again',
|
|
29
29
|
};
|
|
30
30
|
function sendFailureCopy(code) {
|
|
31
31
|
return (code && SEND_FAILURE_COPY[code]) || "Couldn't send";
|
|
@@ -46,13 +46,13 @@ function isRetryableFailure(meta) {
|
|
|
46
46
|
// System lines are the conversation's action record (agreed / retracted / offer updated /
|
|
47
47
|
// finalized…), so each carries its time — same hour:minute format as the message bubbles.
|
|
48
48
|
function SystemMessage({ m }) {
|
|
49
|
-
return (_jsxs("div", { className: "chat-system-message", children: [m.text && _jsx("span", { children: m.text }), _jsx("span", { className: "chat-system-message-time", children: new Date(m.createdAt).toLocaleTimeString([], { hour:
|
|
49
|
+
return (_jsxs("div", { className: "chat-system-message", children: [m.text && _jsx("span", { children: m.text }), _jsx("span", { className: "chat-system-message-time", children: new Date(m.createdAt).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }) })] }));
|
|
50
50
|
}
|
|
51
51
|
export function MessageItemDefault(props) {
|
|
52
|
-
const { m, currentUserId, isAdmin, handlers, isContinuation, onSenderClick: senderClick, senderAdornment, onRetrySend } = props;
|
|
52
|
+
const { m, currentUserId, isAdmin, handlers, isContinuation, onSenderClick: senderClick, senderAdornment, onRetrySend, } = props;
|
|
53
53
|
// Only a resolved name is a click target: the app's unresolved state (a Retry included) is never
|
|
54
54
|
// nested inside a button.
|
|
55
|
-
const nameResolved = useSenderNameResolution(m.senderId).status ===
|
|
55
|
+
const nameResolved = useSenderNameResolution(m.senderId).status === 'resolved';
|
|
56
56
|
const onSenderClick = nameResolved ? senderClick : undefined;
|
|
57
57
|
// System messages render differently
|
|
58
58
|
if (m.isSystemMessage) {
|
|
@@ -65,14 +65,16 @@ export function MessageItemDefault(props) {
|
|
|
65
65
|
// dedups, so a retry can never double-send).
|
|
66
66
|
const sendFailed = m.meta?.sendFailed === true;
|
|
67
67
|
const sendPending = m.meta?.optimistic === true && !sendFailed;
|
|
68
|
-
const clientMessageId = typeof m.meta?.clientMessageId ===
|
|
68
|
+
const clientMessageId = typeof m.meta?.clientMessageId === 'string' ? m.meta.clientMessageId : null;
|
|
69
69
|
// Correlated rejection reason (from the `send-rejected` frame), if any — drives
|
|
70
70
|
// both the failure copy and whether a Retry affordance is offered.
|
|
71
|
-
const sendFailureCode = typeof m.meta?.sendFailureCode ===
|
|
71
|
+
const sendFailureCode = typeof m.meta?.sendFailureCode === 'string' ? m.meta.sendFailureCode : null;
|
|
72
72
|
const showRetry = sendFailed && isRetryableFailure(m.meta);
|
|
73
|
-
return (_jsxs("div", { className: cn(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
return (_jsxs("div", { className: cn('flex flex-col w-fit max-w-[85%]', mine ? 'ml-auto items-end' : 'mr-auto items-start', isContinuation ? 'chat-continuation-gap' : 'chat-group-gap'), children: [_jsxs("div", { className: cn('chat-bubble', mine ? 'chat-bubble--mine' : 'chat-bubble--theirs', sendPending && 'chat-bubble--pending', sendFailed && 'chat-bubble--failed'), children: [!isContinuation && (_jsxs("div", { className: "flex items-center gap-2 text-xs opacity-80 mb-1", children: [_jsx("span", { className: cn('font-medium', onSenderClick && 'cursor-pointer hover:underline'), onClick: onSenderClick ? () => onSenderClick(m.senderId) : undefined, role: onSenderClick ? 'button' : undefined, tabIndex: onSenderClick ? 0 : undefined, onKeyDown: onSenderClick
|
|
74
|
+
? (e) => {
|
|
75
|
+
if (e.key === 'Enter' || e.key === ' ')
|
|
76
|
+
onSenderClick(m.senderId);
|
|
77
|
+
}
|
|
78
|
+
: undefined, children: _jsx(SenderName, { senderId: m.senderId }) }), senderAdornment, _jsx("span", { children: "\u00B7" }), _jsx("span", { children: new Date(m.createdAt).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }) })] })), m.text && (_jsx("p", { className: "text-sm whitespace-pre-wrap", children: _jsx(MessageText, { text: m.text }) }))] }), sendPending && (_jsxs("div", { className: "chat-send-status mt-0.5", role: "status", "aria-live": "polite", children: [_jsx(Spinner, { size: "xs", className: "shrink-0" }), _jsx("span", { children: "Sending\u2026" })] })), sendFailed && (_jsxs("div", { className: "chat-send-status chat-send-status--failed mt-0.5", role: "alert", children: [_jsx(AlertTriangle, { className: "h-3 w-3 shrink-0" }), _jsx("span", { children: sendFailureCopy(sendFailureCode) }), showRetry && onRetrySend && clientMessageId && (_jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "h-5 px-1.5 text-[0.6875rem]", onClick: () => onRetrySend(clientMessageId), children: "Retry" }))] })), !isContinuation && (_jsx("div", { className: "mt-1", children: _jsx(MessageActions, { messageId: m.messageId, isAdmin: isAdmin, handlers: handlers }) }))] }));
|
|
77
79
|
}
|
|
78
80
|
//# sourceMappingURL=MessageItemDefault.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageItemDefault.js","sourceRoot":"","sources":["../../src/ui/MessageItemDefault.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB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EA,CAAC,CAAC,IAAI,IAAI,CACT,YAAG,SAAS,EAAC,6BAA6B,YACxC,KAAC,WAAW,IAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAI,GAC3B,CACL,IACG,EAIL,WAAW,IAAI,CACd,eAAK,SAAS,EAAC,yBAAyB,EAAC,IAAI,EAAC,QAAQ,eAAW,QAAQ,aACvE,KAAC,OAAO,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,UAAU,GAAG,EAC1C,2CAAqB,IACjB,CACP,EACA,UAAU,IAAI,CACb,eAAK,SAAS,EAAC,kDAAkD,EAAC,IAAI,EAAC,OAAO,aAC5E,KAAC,aAAa,IAAC,SAAS,EAAC,kBAAkB,GAAG,EAC9C,yBAAO,eAAe,CAAC,eAAe,CAAC,GAAQ,EAC9C,SAAS,IAAI,WAAW,IAAI,eAAe,IAAI,CAC9C,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,IAAI,EACT,SAAS,EAAC,6BAA6B,EACvC,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,eAAe,CAAC,sBAGpC,CACV,IACG,CACP,EAEA,CAAC,cAAc,IAAI,CAClB,cAAK,SAAS,EAAC,MAAM,YACnB,KAAC,cAAc,IAAC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAI,GAC5E,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport type { ChatMessageV1, ModerationHandlers } from \"@ttt-productions/chat-core\";\nimport { MessageText } from \"./MessageText.js\";\nimport { cn } from \"@ttt-productions/ui-core\";\nimport { Button, Spinner } from \"@ttt-productions/ui-core/react\";\nimport { AlertTriangle } from \"lucide-react\";\nimport { MessageActions } from \"./menus.js\";\nimport { SenderName } from \"./SenderName.js\";\nimport { useSenderNameResolution } from \"../context/ChatNameResolverContext.js\";\n\n// A chat message renders TEXT (plus its send-state rows). Files live in the\n// conversation's Conversation Files surface, never in the timeline — there is no\n// attachment body here. There is no reply-quote body either: no chat surface has\n// an authoring affordance for replying to a specific message, so a quote\n// renderer would be unreachable machinery.\n\n// ============================================\n// Correlated send-rejection copy + retry policy\n// ============================================\n\n// User-facing copy per correlated `send-rejected` code (stamped on meta.sendFailureCode\n// by the realtime channel client). A failed send with no code (a transport/exhausted\n// reconnect failure) falls back to the neutral \"Couldn't send\".\nconst SEND_FAILURE_COPY: Record<string, string> = {\n \"blocked-word\": \"Message contains blocked language\",\n \"archived\": \"This channel is read-only\",\n \"deleted\": \"This channel is read-only\",\n \"membership-pending\": \"Chat is still preparing\",\n \"wordlist-unavailable\": \"Chat safety check is temporarily unavailable\",\n \"flood\": \"Please wait before sending again\",\n \"slow-mode\": \"Please wait before sending again\",\n};\n\nfunction sendFailureCopy(code: string | null): string {\n return (code && SEND_FAILURE_COPY[code]) || \"Couldn't send\";\n}\n\n// Retry policy comes from meta.sendRetryable, stamped by the channel client from\n// the wire contract's canonical retryability table (chat-schemas enforces the\n// frame's `retryable` matches the table, so this is the ONE source of truth —\n// never a second hardcoded code list here, which would have to move in lockstep\n// with the contract). `false` = terminal (an unchanged resend is guaranteed to\n// fail — no Retry action); `true` or ABSENT (a code-less transport/exhausted\n// reconnect failure) keeps Retry, reusing the ORIGINAL clientMessageId.\nfunction isRetryableFailure(meta: Record<string, unknown> | undefined): boolean {\n return meta?.sendRetryable !== false;\n}\n\n// ============================================\n// System message\n// ============================================\n\n// System lines are the conversation's action record (agreed / retracted / offer updated /\n// finalized…), so each carries its time — same hour:minute format as the message bubbles.\nfunction SystemMessage({ m }: { m: ChatMessageV1 }) {\n return (\n <div className=\"chat-system-message\">\n {m.text && <span>{m.text}</span>}\n <span className=\"chat-system-message-time\">\n {new Date(m.createdAt).toLocaleTimeString([], { hour: \"numeric\", minute: \"2-digit\" })}\n </span>\n </div>\n );\n}\n\n// ============================================\n// Default message item\n// ============================================\n\nexport type MessageItemDefaultProps = {\n m: ChatMessageV1;\n currentUserId: string;\n isAdmin: boolean;\n handlers?: ModerationHandlers;\n\n // Grouping\n isContinuation?: boolean;\n\n // Sender interaction — the app resolves anything it needs about the sender from the id.\n onSenderClick?: (senderId: string) => void;\n /** The app's adornment beside the sender name; shown with the sender line, never on a continuation. */\n senderAdornment?: ReactNode;\n\n /** Retry a failed realtime send by its original clientMessageId (wired by\n * ChatShell on the realtime transport; absent on firestore). Enables the\n * retry affordance on a `meta.sendFailed` bubble. */\n onRetrySend?: (clientMessageId: string) => void;\n};\n\nexport function MessageItemDefault(props: MessageItemDefaultProps) {\n const { m, currentUserId, isAdmin, handlers, isContinuation, onSenderClick: senderClick, senderAdornment, onRetrySend } = props;\n // Only a resolved name is a click target: the app's unresolved state (a Retry included) is never\n // nested inside a button.\n const nameResolved = useSenderNameResolution(m.senderId).status === \"resolved\";\n const onSenderClick = nameResolved ? senderClick : undefined;\n\n // System messages render differently\n if (m.isSystemMessage) {\n return <SystemMessage m={m} />;\n }\n\n const mine = m.senderId === currentUserId;\n\n // Realtime optimistic-send lifecycle (meta is stamped by the channel client):\n // an un-acked echo renders subtly pending; one past the retry/age cap renders a\n // visibly failed bubble with a retry affordance (same clientMessageId — the DO\n // dedups, so a retry can never double-send).\n const sendFailed = m.meta?.sendFailed === true;\n const sendPending = m.meta?.optimistic === true && !sendFailed;\n const clientMessageId =\n typeof m.meta?.clientMessageId === \"string\" ? m.meta.clientMessageId : null;\n // Correlated rejection reason (from the `send-rejected` frame), if any — drives\n // both the failure copy and whether a Retry affordance is offered.\n const sendFailureCode =\n typeof m.meta?.sendFailureCode === \"string\" ? m.meta.sendFailureCode : null;\n const showRetry = sendFailed && isRetryableFailure(m.meta);\n\n return (\n <div\n className={cn(\n \"flex flex-col w-fit max-w-[85%]\",\n mine ? \"ml-auto items-end\" : \"mr-auto items-start\",\n isContinuation ? \"chat-continuation-gap\" : \"chat-group-gap\"\n )}\n >\n <div\n className={cn(\n \"chat-bubble\",\n mine ? \"chat-bubble--mine\" : \"chat-bubble--theirs\",\n sendPending && \"chat-bubble--pending\",\n sendFailed && \"chat-bubble--failed\"\n )}\n >\n {!isContinuation && (\n <div className=\"flex items-center gap-2 text-xs opacity-80 mb-1\">\n <span\n className={cn(\"font-medium\", onSenderClick && \"cursor-pointer hover:underline\")}\n onClick={onSenderClick ? () => onSenderClick(m.senderId) : undefined}\n role={onSenderClick ? \"button\" : undefined}\n tabIndex={onSenderClick ? 0 : undefined}\n onKeyDown={onSenderClick ? (e) => {\n if (e.key === \"Enter\" || e.key === \" \") onSenderClick(m.senderId);\n } : undefined}\n >\n <SenderName senderId={m.senderId} />\n </span>\n {senderAdornment}\n <span>·</span>\n <span>{new Date(m.createdAt).toLocaleTimeString([], { hour: \"numeric\", minute: \"2-digit\" })}</span>\n </div>\n )}\n\n {m.text && (\n <p className=\"text-sm whitespace-pre-wrap\">\n <MessageText text={m.text} />\n </p>\n )}\n </div>\n\n {/* Send-state status rows render regardless of grouping — a pending/failed\n send must never be indistinguishable from a delivered one. */}\n {sendPending && (\n <div className=\"chat-send-status mt-0.5\" role=\"status\" aria-live=\"polite\">\n <Spinner size=\"xs\" className=\"shrink-0\" />\n <span>Sending…</span>\n </div>\n )}\n {sendFailed && (\n <div className=\"chat-send-status chat-send-status--failed mt-0.5\" role=\"alert\">\n <AlertTriangle className=\"h-3 w-3 shrink-0\" />\n <span>{sendFailureCopy(sendFailureCode)}</span>\n {showRetry && onRetrySend && clientMessageId && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-5 px-1.5 text-[0.6875rem]\"\n onClick={() => onRetrySend(clientMessageId)}\n >\n Retry\n </Button>\n )}\n </div>\n )}\n\n {!isContinuation && (\n <div className=\"mt-1\">\n <MessageActions messageId={m.messageId} isAdmin={isAdmin} handlers={handlers} />\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MessageItemDefault.js","sour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AE,QAAQ,EAAE,QAAQ,GAAI,GAC5E,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport type { ChatMessageV1, ModerationHandlers } from '@ttt-productions/chat-core';\nimport { MessageText } from './MessageText.js';\nimport { cn } from '@ttt-productions/ui-core';\nimport { Button, Spinner } from '@ttt-productions/ui-core/react';\nimport { AlertTriangle } from 'lucide-react';\nimport { MessageActions } from './menus.js';\nimport { SenderName } from './SenderName.js';\nimport { useSenderNameResolution } from '../context/ChatNameResolverContext.js';\n\n// A chat message renders TEXT (plus its send-state rows). Files live in the\n// conversation's Conversation Files surface, never in the timeline — there is no\n// attachment body here. There is no reply-quote body either: no chat surface has\n// an authoring affordance for replying to a specific message, so a quote\n// renderer would be unreachable machinery.\n\n// ============================================\n// Correlated send-rejection copy + retry policy\n// ============================================\n\n// User-facing copy per correlated `send-rejected` code (stamped on meta.sendFailureCode\n// by the realtime channel client). A failed send with no code (a transport/exhausted\n// reconnect failure) falls back to the neutral \"Couldn't send\".\nconst SEND_FAILURE_COPY: Record<string, string> = {\n 'blocked-word': 'Message contains blocked language',\n archived: 'This channel is read-only',\n deleted: 'This channel is read-only',\n 'membership-pending': 'Chat is still preparing',\n 'wordlist-unavailable': 'Chat safety check is temporarily unavailable',\n flood: 'Please wait before sending again',\n 'slow-mode': 'Please wait before sending again',\n};\n\nfunction sendFailureCopy(code: string | null): string {\n return (code && SEND_FAILURE_COPY[code]) || \"Couldn't send\";\n}\n\n// Retry policy comes from meta.sendRetryable, stamped by the channel client from\n// the wire contract's canonical retryability table (chat-schemas enforces the\n// frame's `retryable` matches the table, so this is the ONE source of truth —\n// never a second hardcoded code list here, which would have to move in lockstep\n// with the contract). `false` = terminal (an unchanged resend is guaranteed to\n// fail — no Retry action); `true` or ABSENT (a code-less transport/exhausted\n// reconnect failure) keeps Retry, reusing the ORIGINAL clientMessageId.\nfunction isRetryableFailure(meta: Record<string, unknown> | undefined): boolean {\n return meta?.sendRetryable !== false;\n}\n\n// ============================================\n// System message\n// ============================================\n\n// System lines are the conversation's action record (agreed / retracted / offer updated /\n// finalized…), so each carries its time — same hour:minute format as the message bubbles.\nfunction SystemMessage({ m }: { m: ChatMessageV1 }) {\n return (\n <div className=\"chat-system-message\">\n {m.text && <span>{m.text}</span>}\n <span className=\"chat-system-message-time\">\n {new Date(m.createdAt).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' })}\n </span>\n </div>\n );\n}\n\n// ============================================\n// Default message item\n// ============================================\n\nexport type MessageItemDefaultProps = {\n m: ChatMessageV1;\n currentUserId: string;\n isAdmin: boolean;\n handlers?: ModerationHandlers;\n\n // Grouping\n isContinuation?: boolean;\n\n // Sender interaction — the app resolves anything it needs about the sender from the id.\n onSenderClick?: (senderId: string) => void;\n /** The app's adornment beside the sender name; shown with the sender line, never on a continuation. */\n senderAdornment?: ReactNode;\n\n /** Retry a failed realtime send by its original clientMessageId (wired by\n * ChatShell on the realtime transport; absent on firestore). Enables the\n * retry affordance on a `meta.sendFailed` bubble. */\n onRetrySend?: (clientMessageId: string) => void;\n};\n\nexport function MessageItemDefault(props: MessageItemDefaultProps) {\n const {\n m,\n currentUserId,\n isAdmin,\n handlers,\n isContinuation,\n onSenderClick: senderClick,\n senderAdornment,\n onRetrySend,\n } = props;\n // Only a resolved name is a click target: the app's unresolved state (a Retry included) is never\n // nested inside a button.\n const nameResolved = useSenderNameResolution(m.senderId).status === 'resolved';\n const onSenderClick = nameResolved ? senderClick : undefined;\n\n // System messages render differently\n if (m.isSystemMessage) {\n return <SystemMessage m={m} />;\n }\n\n const mine = m.senderId === currentUserId;\n\n // Realtime optimistic-send lifecycle (meta is stamped by the channel client):\n // an un-acked echo renders subtly pending; one past the retry/age cap renders a\n // visibly failed bubble with a retry affordance (same clientMessageId — the DO\n // dedups, so a retry can never double-send).\n const sendFailed = m.meta?.sendFailed === true;\n const sendPending = m.meta?.optimistic === true && !sendFailed;\n const clientMessageId =\n typeof m.meta?.clientMessageId === 'string' ? m.meta.clientMessageId : null;\n // Correlated rejection reason (from the `send-rejected` frame), if any — drives\n // both the failure copy and whether a Retry affordance is offered.\n const sendFailureCode =\n typeof m.meta?.sendFailureCode === 'string' ? m.meta.sendFailureCode : null;\n const showRetry = sendFailed && isRetryableFailure(m.meta);\n\n return (\n <div\n className={cn(\n 'flex flex-col w-fit max-w-[85%]',\n mine ? 'ml-auto items-end' : 'mr-auto items-start',\n isContinuation ? 'chat-continuation-gap' : 'chat-group-gap',\n )}\n >\n <div\n className={cn(\n 'chat-bubble',\n mine ? 'chat-bubble--mine' : 'chat-bubble--theirs',\n sendPending && 'chat-bubble--pending',\n sendFailed && 'chat-bubble--failed',\n )}\n >\n {!isContinuation && (\n <div className=\"flex items-center gap-2 text-xs opacity-80 mb-1\">\n <span\n className={cn('font-medium', onSenderClick && 'cursor-pointer hover:underline')}\n onClick={onSenderClick ? () => onSenderClick(m.senderId) : undefined}\n role={onSenderClick ? 'button' : undefined}\n tabIndex={onSenderClick ? 0 : undefined}\n onKeyDown={\n onSenderClick\n ? (e) => {\n if (e.key === 'Enter' || e.key === ' ') onSenderClick(m.senderId);\n }\n : undefined\n }\n >\n <SenderName senderId={m.senderId} />\n </span>\n {senderAdornment}\n <span>·</span>\n <span>\n {new Date(m.createdAt).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' })}\n </span>\n </div>\n )}\n\n {m.text && (\n <p className=\"text-sm whitespace-pre-wrap\">\n <MessageText text={m.text} />\n </p>\n )}\n </div>\n\n {/* Send-state status rows render regardless of grouping — a pending/failed\n send must never be indistinguishable from a delivered one. */}\n {sendPending && (\n <div className=\"chat-send-status mt-0.5\" role=\"status\" aria-live=\"polite\">\n <Spinner size=\"xs\" className=\"shrink-0\" />\n <span>Sending…</span>\n </div>\n )}\n {sendFailed && (\n <div className=\"chat-send-status chat-send-status--failed mt-0.5\" role=\"alert\">\n <AlertTriangle className=\"h-3 w-3 shrink-0\" />\n <span>{sendFailureCopy(sendFailureCode)}</span>\n {showRetry && onRetrySend && clientMessageId && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-5 px-1.5 text-[0.6875rem]\"\n onClick={() => onRetrySend(clientMessageId)}\n >\n Retry\n </Button>\n )}\n </div>\n )}\n\n {!isContinuation && (\n <div className=\"mt-1\">\n <MessageActions messageId={m.messageId} isAdmin={isAdmin} handlers={handlers} />\n </div>\n )}\n </div>\n );\n}\n"]}
|
package/dist/ui/MessageList.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import type { ChatMessageGroupKey, ChatMessageV1, ModerationHandlers } from
|
|
3
|
-
import type { MessageRendererRegistry } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ChatMessageGroupKey, ChatMessageV1, ModerationHandlers } from '@ttt-productions/chat-core';
|
|
3
|
+
import type { MessageRendererRegistry } from '../types.js';
|
|
4
4
|
/** What `MessageList` hands a custom scroll container: the element it must render as the scrollable
|
|
5
5
|
* message region, with this ref, class, scroll handler, and children. */
|
|
6
6
|
export type ChatScrollContainerProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../src/ui/MessageList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../src/ui/MessageList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAI3D;0EAC0E;AAC1E,MAAM,MAAM,wBAAwB,GAAG;IACrC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,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,CAAC;IAChD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACrC,qBAiNA"}
|
package/dist/ui/MessageList.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from
|
|
4
|
-
import { isContinuation } from
|
|
5
|
-
import { Button, Spinner } from
|
|
6
|
-
import { MessageItemDefault } from
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { isContinuation } from '@ttt-productions/chat-core';
|
|
5
|
+
import { Button, Spinner } from '@ttt-productions/ui-core/react';
|
|
6
|
+
import { MessageItemDefault } from './MessageItemDefault.js';
|
|
7
7
|
/** The default scroll container: a plain div. */
|
|
8
8
|
function DefaultScrollContainer({ ref, className, onScroll, children }) {
|
|
9
9
|
return (_jsx("div", { ref: ref, className: className, onScroll: onScroll, children: children }));
|
|
@@ -11,8 +11,8 @@ function DefaultScrollContainer({ ref, className, onScroll, children }) {
|
|
|
11
11
|
export function MessageList(props) {
|
|
12
12
|
const { messages, currentUserId, isAdmin, isFetchingOlder, hasOlder, onLoadOlder, renderMessage, messageRenderers, showScrollToBottom, onScrollToBottom, onAtBottomChange, scrollClassName, scrollContainer: ScrollContainer = DefaultScrollContainer, fillHeight = false, handlers, onSenderClick, messageGroupKey, renderSenderAdornment, onRetrySend, olderLoadErrorRow, } = props;
|
|
13
13
|
const olderLoadFailed = olderLoadErrorRow != null;
|
|
14
|
-
const scrollClass = scrollClassName ?? (fillHeight ?
|
|
15
|
-
const outerClass = fillHeight ?
|
|
14
|
+
const scrollClass = scrollClassName ?? (fillHeight ? 'flex-1 min-h-0' : 'h-[400px]');
|
|
15
|
+
const outerClass = fillHeight ? 'relative flex flex-col flex-1 min-h-0' : 'relative';
|
|
16
16
|
const scrollRef = React.useRef(null);
|
|
17
17
|
const topSentinelRef = React.useRef(null);
|
|
18
18
|
const isAtBottomRef = React.useRef(true);
|
|
@@ -36,7 +36,7 @@ export function MessageList(props) {
|
|
|
36
36
|
const target = topSentinelRef.current;
|
|
37
37
|
if (!root || !target)
|
|
38
38
|
return;
|
|
39
|
-
if (typeof IntersectionObserver ===
|
|
39
|
+
if (typeof IntersectionObserver === 'undefined')
|
|
40
40
|
return;
|
|
41
41
|
const io = new IntersectionObserver((entries) => {
|
|
42
42
|
const e = entries[0];
|
|
@@ -64,7 +64,7 @@ export function MessageList(props) {
|
|
|
64
64
|
el.scrollTop = el.scrollHeight;
|
|
65
65
|
// Restore page scroll if the browser moved it
|
|
66
66
|
if (window.scrollY !== savedScrollY) {
|
|
67
|
-
window.scrollTo({ top: savedScrollY, behavior:
|
|
67
|
+
window.scrollTo({ top: savedScrollY, behavior: 'instant' });
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
isAtBottomRef.current = true;
|
|
@@ -82,7 +82,7 @@ export function MessageList(props) {
|
|
|
82
82
|
const savedScrollY = window.scrollY;
|
|
83
83
|
el.scrollTop = el.scrollHeight;
|
|
84
84
|
if (window.scrollY !== savedScrollY) {
|
|
85
|
-
window.scrollTo({ top: savedScrollY, behavior:
|
|
85
|
+
window.scrollTo({ top: savedScrollY, behavior: 'instant' });
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -111,14 +111,11 @@ export function MessageList(props) {
|
|
|
111
111
|
// Date separators always break grouping
|
|
112
112
|
const continuation = showDay ? false : isContinuation(prevMsg, m, messageGroupKey);
|
|
113
113
|
const byType = m.type && messageRenderers?.[m.type] ? messageRenderers[m.type](m) : null;
|
|
114
|
-
const body = renderMessage?.(m) ??
|
|
115
|
-
byType ?? (_jsx(MessageItemDefault, { m: m, currentUserId: currentUserId, isAdmin: isAdmin, handlers: handlers, isContinuation: continuation, onSenderClick: onSenderClick, senderAdornment: renderSenderAdornment?.(m), onRetrySend: onRetrySend }));
|
|
114
|
+
const body = renderMessage?.(m) ?? byType ?? (_jsx(MessageItemDefault, { m: m, currentUserId: currentUserId, isAdmin: isAdmin, handlers: handlers, isContinuation: continuation, onSenderClick: onSenderClick, senderAdornment: renderSenderAdornment?.(m), onRetrySend: onRetrySend }));
|
|
116
115
|
return (_jsxs(React.Fragment, { children: [showDay && (_jsx("div", { className: "my-2 flex justify-center", children: _jsx("div", { className: "chat-date-separator", children: new Date(m.createdAt).toLocaleDateString() }) })), body] }, m.messageId));
|
|
117
|
-
}) }))] }), (unseenCount > 0 || showScrollToBottom) && (_jsx(Button, { type: "button", variant: "outline", size: "sm", "aria-label": unseenCount > 0 ? `${unseenCount} new messages, scroll to latest` :
|
|
116
|
+
}) }))] }), (unseenCount > 0 || showScrollToBottom) && (_jsx(Button, { type: "button", variant: "outline", size: "sm", "aria-label": unseenCount > 0 ? `${unseenCount} new messages, scroll to latest` : 'Scroll to latest', className: "absolute bottom-4 left-1/2 -translate-x-1/2 rounded-full elevation-raised gap-1", onClick: () => {
|
|
118
117
|
scrollToBottom();
|
|
119
118
|
onScrollToBottom?.();
|
|
120
|
-
}, children: unseenCount > 0
|
|
121
|
-
? `${unseenCount} new message${unseenCount > 1 ? "s" : ""} ↓`
|
|
122
|
-
: "↓" }))] }));
|
|
119
|
+
}, children: unseenCount > 0 ? `${unseenCount} new message${unseenCount > 1 ? 's' : ''} ↓` : '↓' }))] }));
|
|
123
120
|
}
|
|
124
121
|
//# sourceMappingURL=MessageList.js.map
|