Share Conversation

A read-only link to a chat as it is now, to copy, update or delete.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/share-conversation

Usage

import { ShareConversation, type SharedLink } from "./ui/uicontext/components/chat/ShareConversation.ts"
const Message = UiSchema.TaggedEnum({	ClosedShare: {},	CreatedLink: { showName: Schema.Boolean },	DeletedLink: {},})// make or refresh the snapshot on your server, then pass the link back as `link`export const ShareChat = (h: Html.H<typeof Message.Type>, chat: { readonly title: string; readonly messages: number; readonly link: SharedLink | null }, open: boolean, now: string) =>	ShareConversation(h, {		props: { open, title: chat.title, messages: chat.messages, link: chat.link, now },		onEmit: {			RequestedClose: () => Message.ClosedShare(),			RequestedLink: ({ showName }) => Message.CreatedLink({ showName }),			RequestedUpdate: ({ showName }) => Message.CreatedLink({ showName }),			RequestedDelete: () => Message.DeletedLink(),		},	})

API reference

Props

ShareConversation props
NameTypeDescription
openrequiredboolean—
titlerequiredstringThe chat's title, for the preview
messagesrequirednumberHow many messages the chat has now
linkrequiredSharedLink | nullThe live link, or null before there is one
nowrequiredstringThe present, ISO, for "created 2 hours ago"
busybooleanA request is on its way: the buttons wait

Events

ShareConversation events
EventPayloadDescription
RequestedClose{}—
RequestedLink{ showName: boolean }Make a link to the chat as it is now
RequestedUpdate{ showName: boolean }Take the snapshot again, with the messages sent since
RequestedDelete{}The link stops working

Source