@athenaintel/react 0.56.0 → 0.57.1
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 +75 -1
- package/dist/agent-runtime/src/inbound-channel.cjs +96 -0
- package/dist/agent-runtime/src/inbound-channel.cjs.map +1 -0
- package/dist/agent-runtime/src/inbound-channel.d.ts +75 -0
- package/dist/agent-runtime/src/inbound-channel.js +96 -0
- package/dist/agent-runtime/src/inbound-channel.js.map +1 -0
- package/dist/agent-runtime/src/index.d.ts +2 -1
- package/dist/agent-runtime/src/interrupts.cjs +45 -3
- package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
- package/dist/agent-runtime/src/interrupts.d.ts +51 -4
- package/dist/agent-runtime/src/interrupts.js +46 -4
- package/dist/agent-runtime/src/interrupts.js.map +1 -1
- package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
- package/dist/agent-runtime/src/offline-status.d.ts +25 -0
- package/dist/agent-runtime/src/offline-status.js.map +1 -1
- package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +8 -8
- package/dist/agent-runtime/src/tool-metadata.cjs +8 -0
- package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-metadata.js +8 -0
- package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
- package/dist/auth/AthenaSSOProvider.cjs +54 -12
- package/dist/auth/AthenaSSOProvider.cjs.map +1 -1
- package/dist/auth/AthenaSSOProvider.d.ts +23 -2
- package/dist/auth/AthenaSSOProvider.js +54 -12
- package/dist/auth/AthenaSSOProvider.js.map +1 -1
- package/dist/auth/index.cjs +2 -0
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/sign-back-in.cjs +141 -0
- package/dist/auth/sign-back-in.cjs.map +1 -0
- package/dist/auth/sign-back-in.d.ts +117 -0
- package/dist/auth/sign-back-in.js +141 -0
- package/dist/auth/sign-back-in.js.map +1 -0
- package/dist/chat/AthenaChat.cjs +21 -3
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.js +21 -3
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.cjs +6 -2
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +8 -1
- package/dist/chat/StatewireApprovalCard.js +7 -3
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat-ui/index.cjs +5 -0
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.d.ts +1 -0
- package/dist/chat-ui/index.js +6 -1
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/messages/inbound-channel-message.cjs +242 -0
- package/dist/chat-ui/messages/inbound-channel-message.cjs.map +1 -0
- package/dist/chat-ui/messages/inbound-channel-message.d.ts +53 -0
- package/dist/chat-ui/messages/inbound-channel-message.js +242 -0
- package/dist/chat-ui/messages/inbound-channel-message.js.map +1 -0
- package/dist/chat-ui/messages/inbound-channel-reader.cjs +184 -0
- package/dist/chat-ui/messages/inbound-channel-reader.cjs.map +1 -0
- package/dist/chat-ui/messages/inbound-channel-reader.d.ts +65 -0
- package/dist/chat-ui/messages/inbound-channel-reader.js +184 -0
- package/dist/chat-ui/messages/inbound-channel-reader.js.map +1 -0
- package/dist/chat-ui/messages/message-components.cjs +32 -15
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.d.ts +7 -0
- package/dist/chat-ui/messages/message-components.js +33 -16
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/composer/sign-back-in-draft.cjs +62 -0
- package/dist/composer/sign-back-in-draft.cjs.map +1 -0
- package/dist/composer/sign-back-in-draft.d.ts +34 -0
- package/dist/composer/sign-back-in-draft.js +62 -0
- package/dist/composer/sign-back-in-draft.js.map +1 -0
- package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
- package/dist/diagnostics/athena-diagnostics.d.ts +6 -1
- package/dist/diagnostics/athena-diagnostics.js.map +1 -1
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/provider/AthenaProvider.cjs +48 -3
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.js +49 -4
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/react/package.json.cjs +1 -1
- package/dist/react/package.json.js +1 -1
- package/dist/runtime/auth.cjs +11 -0
- package/dist/runtime/auth.cjs.map +1 -1
- package/dist/runtime/auth.d.ts +18 -1
- package/dist/runtime/auth.js +11 -0
- package/dist/runtime/auth.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-components.cjs","sources":["../../../src/chat-ui/messages/message-components.tsx"],"sourcesContent":["import {\n ActionBarPrimitive,\n AuiIf,\n BranchPickerPrimitive,\n MessagePrimitive,\n useAuiState,\n useMessagePartText,\n useSmooth,\n type ToolCallMessagePartComponent,\n} from \"@assistant-ui/react\";\nimport {\n CHAT_EDIT_UNREACHABLE_LABEL,\n DEEP_AGENT_COMPOSER_MARKDOWN_KEY,\n hideUnterminatedMarkdownLink,\n isGithubWakeMessage,\n isSubscriptionWakeMessage,\n isVoiceDelegationMessage,\n readDeepAgentComposerMarkdown,\n readRuntimeMessageFromSourceMessages,\n readSoleRuntimeMessageKind,\n useChatOutboxReachable,\n useDeepAgentChatOutboxContext,\n} from \"@athenaintel/agent-runtime\";\nimport {\n ArrowUpIcon,\n CheckIcon,\n ChevronLeftIcon,\n ChevronRightIcon,\n CopyIcon,\n ListPlusIcon,\n PencilIcon,\n RefreshCwIcon,\n} from \"lucide-react\";\nimport {\n type FC,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport { useAthenaRunLive } from \"../../chat/use-athena-run-live\";\nimport type { ComposerAction } from \"../composer/composer-action\";\nimport { cn } from \"../../lib/utils\";\nimport { ChatMessageBody } from \"../rich-text/chat-message-body\";\nimport { AnswerLabel } from \"./answer-label\";\nimport { useMessageActionsReadOnly } from \"./message-actions-config\";\nimport { MessageImageGallery, MessageImagePart } from \"./message-images\";\nimport { RuntimeMessageCard } from \"./runtime-message\";\nimport { hasVisibleContent } from \"./running-indicator\";\nimport { VoiceDelegationMessage } from \"./voice-delegation-card\";\nimport { WakeMarkerMessage } from \"./wake-marker\";\nimport { SmallIconButton } from \"./thread-chrome\";\n\nexport {\n IconButton,\n SmallIconButton,\n THREAD_HEADER_ACTIONS_CLASS,\n THREAD_HEADER_CLASS,\n THREAD_HEADER_ICON_CLASS,\n THREAD_HEADER_PILL_CLASS,\n THREAD_PANEL_CLASS,\n} from \"./thread-chrome\";\n\nexport const BranchPicker: FC = () => (\n <BranchPickerPrimitive.Root\n hideWhenSingleBranch\n className=\"inline-flex items-center gap-0.5 text-xs text-muted-foreground\"\n data-testid=\"chat-branch-picker\"\n >\n <BranchPickerPrimitive.Previous asChild>\n <SmallIconButton\n tooltip=\"Previous branch\"\n data-testid=\"chat-branch-previous\"\n >\n <ChevronLeftIcon className=\"size-3\" />\n </SmallIconButton>\n </BranchPickerPrimitive.Previous>\n <span className=\"font-medium\" data-testid=\"chat-branch-count\">\n <BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />\n </span>\n <BranchPickerPrimitive.Next asChild>\n <SmallIconButton tooltip=\"Next branch\" data-testid=\"chat-branch-next\">\n <ChevronRightIcon className=\"size-3\" />\n </SmallIconButton>\n </BranchPickerPrimitive.Next>\n </BranchPickerPrimitive.Root>\n);\n\nconst CopyActionButton: FC = () => (\n <ActionBarPrimitive.Copy asChild>\n <SmallIconButton tooltip=\"Copy\">\n <AuiIf condition={(state) => state.message.isCopied}>\n <CheckIcon className=\"size-3\" />\n </AuiIf>\n <AuiIf condition={(state) => !state.message.isCopied}>\n <CopyIcon className=\"size-3\" />\n </AuiIf>\n </SmallIconButton>\n </ActionBarPrimitive.Copy>\n);\n\n/**\n * The edit primitive does not check the runtime's edit capability itself —\n * clicking it on a runtime without one throws inside onPress, where no error\n * boundary can catch it — so the button must gate on the capability and, to\n * match the rewind semantics of `run/edit`, stay hidden while a run is live.\n * The read-only context covers threads the capability flags cannot: a host's\n * static `edit: true` still applies to fenced legacy conversations. While the\n * host's chat outbox says Athena can't be reached it is not offered: shown\n * disabled, its tooltip says why, and it comes back once Athena answers.\n */\nconst EditActionButton: FC = () => {\n const allowEdit = useAuiState((s) => s.thread.capabilities.edit);\n const isRunning = useAthenaRunLive();\n const readOnly = useMessageActionsReadOnly();\n const reachable = useChatOutboxReachable(useDeepAgentChatOutboxContext());\n if (!allowEdit || isRunning || readOnly) return null;\n if (!reachable) {\n return (\n <SmallIconButton\n tooltip={CHAT_EDIT_UNREACHABLE_LABEL}\n aria-disabled\n data-testid=\"chat-message-edit-unreachable\"\n className=\"cursor-not-allowed opacity-50 hover:bg-transparent hover:text-muted-foreground\"\n >\n <PencilIcon className=\"size-3\" />\n </SmallIconButton>\n );\n }\n return (\n <ActionBarPrimitive.Edit asChild>\n <SmallIconButton tooltip=\"Edit\" data-testid=\"chat-message-edit\">\n <PencilIcon className=\"size-3\" />\n </SmallIconButton>\n </ActionBarPrimitive.Edit>\n );\n};\n\n/** Regenerate dispatches `run/reload`, so it hides on read-only threads too. */\nconst RegenerateActionButton: FC = () => {\n const readOnly = useMessageActionsReadOnly();\n if (readOnly) return null;\n return (\n <ActionBarPrimitive.Reload asChild>\n <SmallIconButton tooltip=\"Regenerate\">\n <RefreshCwIcon className=\"size-3\" />\n </SmallIconButton>\n </ActionBarPrimitive.Reload>\n );\n};\n\n/**\n * Reveal-on-demand treatment for action bars: invisible and click-through\n * until the surrounding named group is hovered or a control inside receives\n * keyboard focus. The `focus-within` escape hatch is what keeps the hidden\n * controls reachable for keyboard users.\n */\nexport const ACTION_BAR_REVEAL_CLASS =\n \"pointer-events-none opacity-0 transition-opacity focus-within:pointer-events-auto focus-within:opacity-100\";\n\n/** Shared chat body; the reveal holds incomplete links until their URL is complete. */\nexport const MarkdownText: FC = () => {\n const revealed = useSmooth(useMessagePartText(), true);\n const isRunning = revealed.status.type === \"running\";\n const text = isRunning ? hideUnterminatedMarkdownLink(revealed.text) : revealed.text;\n return <ChatMessageBody text={text} isRunning={isRunning} />;\n};\n\n/**\n * A user message's text, shown as it was typed.\n *\n * A composer sends plain text exactly as typed, because the model reads it\n * literally, so the text alone no longer says which characters are\n * formatting: read as Markdown, `List<T>` loses `<T>`, `obj.__init__` shows a\n * bold \"init\" and `a\\\\b` one backslash. A composer send therefore carries the\n * draft it was serialized from (`metadata.composer_markdown`, only when the\n * two differ), and this renders that draft when it is a draft of the\n * message's own text (`readDeepAgentComposerMarkdown`), formatting and\n * mention chips included. Any other text — no draft, or one of other words —\n * renders with the typed reading (`ChatMessageBody typed`), which leaves raw\n * HTML and underscore emphasis as the characters they were typed with, so\n * `List<T>`, `obj.__init__` and `a\\b` show as typed there too.\n *\n * Copy copies the message text, which is the text as sent, and Edit opens it\n * in a plain-text box, so neither reads the draft.\n */\nexport const UserMessageText: FC<{ text: string }> = ({ text }) => {\n const composerMarkdown: unknown = useAuiState(\n (s) => s.message.metadata?.custom?.[DEEP_AGENT_COMPOSER_MARKDOWN_KEY],\n );\n const shown = useMemo(\n () =>\n readDeepAgentComposerMarkdown({\n metadata: { [DEEP_AGENT_COMPOSER_MARKDOWN_KEY]: composerMarkdown },\n text,\n }) ?? text,\n [composerMarkdown, text],\n );\n return <ChatMessageBody text={shown} typed />;\n};\n\n/** A user message's parts: its text as typed, and its pictures, each opening the viewer. */\nconst USER_MESSAGE_PART_COMPONENTS = { Text: UserMessageText, Image: MessageImagePart };\n\nconst UserActionBar: FC = () => (\n <ActionBarPrimitive.Root\n autohide=\"never\"\n className={cn(\n \"flex min-h-6 items-center gap-0.5\",\n ACTION_BAR_REVEAL_CLASS,\n \"group-hover/user-message:pointer-events-auto group-hover/user-message:opacity-100\",\n )}\n >\n <CopyActionButton />\n <EditActionButton />\n </ActionBarPrimitive.Root>\n);\n\nexport const UserMessage: FC = () => {\n // A GitHub wake or a subscription's delivery is an event, not words the\n // user typed: it renders as the compact wake marker instead of a bubble\n // quoting the injected text.\n const isWake = useAuiState(\n (s) =>\n isGithubWakeMessage(s.message.metadata?.custom) ||\n isSubscriptionWakeMessage(s.message.metadata?.custom),\n );\n // A voice delegation's anchor is the ask the live voice model handed to the\n // thread, not words the user typed: it renders as the shared voice-task\n // card on every host instead of a second user bubble under the spoken turn.\n const isVoiceDelegation = useAuiState((s) =>\n isVoiceDelegationMessage({ messageId: s.message.id, custom: s.message.metadata?.custom }),\n );\n if (isWake) {\n return (\n <MessagePrimitive.Root data-message-role=\"user\" className=\"mb-3\">\n <WakeMarkerMessage />\n </MessagePrimitive.Root>\n );\n }\n if (isVoiceDelegation) {\n return (\n <MessagePrimitive.Root data-message-role=\"user\" className=\"mb-3\">\n <VoiceDelegationMessage />\n </MessagePrimitive.Root>\n );\n }\n return (\n <MessagePrimitive.Root\n data-message-role=\"user\"\n className=\"group/user-message mb-3 flex justify-end\"\n >\n <div className=\"flex min-w-0 max-w-[85%] flex-col items-end gap-1\">\n <div className=\"min-w-0 max-w-full rounded-2xl rounded-br-md bg-muted px-3.5 py-2 text-sm text-foreground\">\n <MessageImageGallery>\n <MessagePrimitive.Content components={USER_MESSAGE_PART_COMPONENTS} />\n </MessageImageGallery>\n </div>\n <div className=\"flex min-h-6 items-center gap-1\">\n <BranchPicker />\n <UserActionBar />\n </div>\n </div>\n </MessagePrimitive.Root>\n );\n};\n\nexport interface CreateAssistantMessageOptions {\n /** Host-registered card for tools without a dedicated UI. */\n toolFallback: ToolCallMessagePartComponent;\n /** Extra action-bar controls appended after copy/regenerate. */\n extraActions?: ReactNode;\n /**\n * Renders the message body. Hosts that group content into activity\n * timelines supply their own; the default renders markdown and tool cards.\n */\n content?: FC;\n /**\n * Inline affordance rendered inside a runtime-ending card (e.g. a Continue\n * button). Hosts without one leave it unset.\n */\n runtimeMessageAction?: ReactNode;\n}\n\n/**\n * Builds the assistant bubble. Call this once per host (memoized on its\n * inputs) so the returned component identity stays stable across renders.\n */\nexport function createAssistantMessage({\n toolFallback,\n extraActions,\n content: Content,\n runtimeMessageAction,\n}: CreateAssistantMessageOptions): FC {\n const AssistantActionBar: FC = () => {\n // The latest reply keeps its actions visible; older replies reveal them\n // on hover so a long transcript is not a wall of icon rows.\n const isLast = useAuiState((s) => s.message.isLast);\n return (\n <ActionBarPrimitive.Root\n autohide=\"never\"\n className={cn(\n \"mt-1 flex min-h-6 items-center gap-0.5\",\n !isLast && [\n ACTION_BAR_REVEAL_CLASS,\n \"group-hover/assistant-message:pointer-events-auto group-hover/assistant-message:opacity-100\",\n ],\n )}\n >\n <CopyActionButton />\n <RegenerateActionButton />\n {extraActions}\n </ActionBarPrimitive.Root>\n );\n };\n\n // A run-lifecycle marker or handoff summary is a system event, not\n // assistant speech. When it owns the whole row, render the status card in\n // place of the bubble; when it is chunked in with the assistant's own work\n // (or is a handoff whose text IS the closing summary), keep the body and\n // frame it with the card above.\n const RuntimeEnding: FC<{ placement: \"row\" | \"banner\" }> = ({ placement }) => {\n // Select the message (a stable store reference) and derive from it: the\n // reader allocates a fresh object per call, and `useAuiState` compares\n // snapshots with `Object.is`, so selecting the reader's result directly\n // would re-render on every store update and trip React's update-depth\n // guard.\n const message = useAuiState((s) => s.message);\n const runtime = useMemo(() => readRuntimeMessageFromSourceMessages(message), [message]);\n if (!runtime || runtime.silent) return null;\n if (placement === \"row\" && !runtime.isSoleSourceMessage) return null;\n if (placement === \"banner\" && runtime.isSoleSourceMessage && runtime.kind !== \"handoff\") {\n return null;\n }\n return <RuntimeMessageCard message={runtime} action={runtimeMessageAction} />;\n };\n\n const AssistantMessage: FC = () => {\n // An assistant row exists before its first token streams; showing\n // copy/regenerate against nothing looks broken, so wait for content.\n const showActions = useAuiState((state) =>\n hasVisibleContent(state.message.content),\n );\n // Primitive selector: the reader builds a fresh object per call.\n const soleRuntimeKind = useAuiState((s) => readSoleRuntimeMessageKind(s.message));\n const soleRuntimeSilent = useAuiState(\n (s) => readRuntimeMessageFromSourceMessages(s.message)?.silent === true,\n );\n\n if (soleRuntimeKind && soleRuntimeKind !== \"handoff\") {\n if (soleRuntimeSilent) return null;\n return (\n <MessagePrimitive.Root\n data-message-role=\"assistant\"\n className=\"group group/assistant-message mb-3\"\n >\n <div className=\"max-w-[95%]\">\n <RuntimeEnding placement=\"row\" />\n </div>\n </MessagePrimitive.Root>\n );\n }\n\n return (\n <MessagePrimitive.Root\n data-message-role=\"assistant\"\n className=\"group group/assistant-message mb-3\"\n >\n <div className=\"max-w-[95%]\">\n <AnswerLabel className=\"mb-1\" />\n <RuntimeEnding placement=\"banner\" />\n {Content ? (\n <Content />\n ) : (\n <MessagePrimitive.Content\n components={{\n Text: MarkdownText,\n tools: { Fallback: toolFallback },\n }}\n />\n )}\n {showActions ? (\n <div className=\"flex min-h-6 items-center gap-1\">\n <BranchPicker />\n <AssistantActionBar />\n </div>\n ) : null}\n </div>\n </MessagePrimitive.Root>\n );\n };\n\n return AssistantMessage;\n}\n\n/** Composer chrome: the dock around the composer, its surface and its rows. */\nexport const COMPOSER_DOCK_CLASS = \"bg-background px-2.5 pb-2 pt-1.5\";\nexport const COMPOSER_SURFACE_CLASS =\n \"relative flex flex-col gap-1 rounded-xl border border-neutral-200 bg-white shadow-[0_2px_10px_rgba(54,45,33,0.08)]\";\nexport const COMPOSER_EDITOR_ROW_CLASS = \"px-2.5 pt-1\";\nexport const COMPOSER_TOOLBAR_CLASS =\n \"flex items-center gap-1 border-t border-neutral-100 px-2 py-1.5\";\n/**\n * Paper composer chrome (`ChatComposerDock appearance=\"paper\"`): a card-toned\n * surface with a larger radius, a focus-within ring, a drag-over tint keyed\n * off `data-drag-active`, and a bottom rail — the chrome the SDK's\n * `AthenaChat` thread renders. Hosts on the default chrome above are\n * untouched. The dock carries no padding of its own; the paper host's footer\n * spaces it. The radius and border colour also bind to the `--composer-radius`\n * / `--composer-border` theme variables in `styles.css`.\n */\nexport const COMPOSER_PAPER_DOCK_CLASS = \"aui-composer-dock\";\nexport const COMPOSER_PAPER_SURFACE_CLASS =\n \"aui-composer-root relative flex w-full flex-col rounded-[1.375rem] border border-border bg-card p-2.5 text-card-foreground shadow-[0_1px_2px_rgba(0,0,0,0.04)] outline-none transition-shadow duration-150 focus-within:shadow-[0_8px_24px_-14px_rgba(0,0,0,0.25)] focus-within:ring-2 focus-within:ring-ring/40 data-[drag-active=true]:bg-primary/5 data-[drag-active=true]:ring-2 data-[drag-active=true]:ring-primary/40\";\nexport const COMPOSER_PAPER_EDITOR_ROW_CLASS = \"px-0.5\";\nexport const COMPOSER_PAPER_TOOLBAR_CLASS =\n \"aui-composer-action-wrapper relative flex items-center justify-between gap-1 pt-1\";\nexport const THREAD_SCROLL_TO_BOTTOM_CLASS =\n \"inline-flex items-center justify-center rounded-full border bg-background/80 p-1 shadow-sm backdrop-blur transition-opacity hover:bg-accent disabled:invisible\";\n\nconst ComposerStopIcon: FC = () => (\n <svg\n aria-hidden=\"true\"\n className=\"size-4\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n >\n <rect width=\"10\" height=\"10\" x=\"3\" y=\"3\" rx=\"2\" />\n </svg>\n);\n\nexport interface ComposerStopButtonProps {\n onStop: () => void;\n disabled?: boolean;\n title?: string;\n}\n\nexport interface ComposerSendButtonProps {\n action: Extract<ComposerAction, \"send\" | \"queue\">;\n onSend: () => void;\n disabled?: boolean;\n title?: string;\n}\n\n/** Stop control shown while a run is in flight and there is nothing queued. */\nexport const ComposerStopButton: FC<ComposerStopButtonProps> = ({\n onStop,\n disabled = false,\n title = \"Stop generation\",\n}) => (\n <button\n type=\"button\"\n onClick={onStop}\n disabled={disabled}\n title={title}\n className={cn(\n \"inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-foreground text-background shadow-sm transition-colors hover:bg-foreground/80\",\n disabled && \"cursor-not-allowed opacity-60\",\n )}\n >\n <ComposerStopIcon />\n </button>\n);\n/** Send control, which becomes a queue control while a run is in flight. */\nexport const ComposerSendButton: FC<ComposerSendButtonProps> = ({\n action,\n onSend,\n disabled = false,\n title,\n}) => (\n <button\n type=\"button\"\n onClick={onSend}\n disabled={disabled}\n title={title ?? (action === \"queue\" ? \"Queue message\" : \"Send\")}\n className={cn(\n \"inline-flex size-8 shrink-0 items-center justify-center rounded-full shadow-sm transition-colors\",\n disabled\n ? \"cursor-not-allowed bg-muted text-muted-foreground opacity-60\"\n : \"bg-foreground text-background hover:bg-foreground/80\",\n )}\n >\n {action === \"queue\" ? (\n <ListPlusIcon className=\"size-4\" />\n ) : (\n <ArrowUpIcon className=\"size-4\" />\n )}\n </button>\n);\n"],"names":["jsxs","BranchPickerPrimitive","jsx","SmallIconButton","ChevronLeftIcon","ChevronRightIcon","ActionBarPrimitive","AuiIf","CheckIcon","CopyIcon","useAuiState","useAthenaRunLive","useMessageActionsReadOnly","useChatOutboxReachable","useDeepAgentChatOutboxContext","CHAT_EDIT_UNREACHABLE_LABEL","PencilIcon","RefreshCwIcon","useSmooth","useMessagePartText","hideUnterminatedMarkdownLink","ChatMessageBody","composerMarkdown","DEEP_AGENT_COMPOSER_MARKDOWN_KEY","useMemo","readDeepAgentComposerMarkdown","MessageImagePart","cn","isGithubWakeMessage","isSubscriptionWakeMessage","isVoiceDelegationMessage","MessagePrimitive","WakeMarkerMessage","VoiceDelegationMessage","MessageImageGallery","readRuntimeMessageFromSourceMessages","RuntimeMessageCard","hasVisibleContent","readSoleRuntimeMessageKind","AnswerLabel","ListPlusIcon","ArrowUpIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6DO,MAAM,eAAmB,MAC9BA,2BAAAA;AAAAA,EAACC,MAAAA,sBAAsB;AAAA,EAAtB;AAAA,IACC,sBAAoB;AAAA,IACpB,WAAU;AAAA,IACV,eAAY;AAAA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AAC;AAAA,EAC9D;AAAA,EACA,WAAW;AAAA,EACX,QAAQ;AACV,MACEA,2BAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IACC,MAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,WAAWyB,OAAAA;AAAAA,MACT;AAAA,MACA,YAAY;AAAA,IAAA;AAAA,IAGd,yCAAC,kBAAA,CAAA,CAAiB;AAAA,EAAA;AACpB;AAGK,MAAM,qBAAkD,CAAC;AAAA,EAC9D;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,MACEzB,2BAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IACC,MAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA,OAAO,UAAU,WAAW,UAAU,kBAAkB;AAAA,IACxD,WAAWyB,OAAAA;AAAAA,MACT;AAAA,MACA,WACI,iEACA;AAAA,IAAA;AAAA,IAGL,UAAA,WAAW,UACVzB,2BAAAA,IAACsC,YAAAA,cAAA,EAAa,WAAU,UAAS,IAEjCtC,2BAAAA,IAACuC,YAAAA,aAAA,EAAY,WAAU,SAAA,CAAS;AAAA,EAAA;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"message-components.cjs","sources":["../../../src/chat-ui/messages/message-components.tsx"],"sourcesContent":["import {\n ActionBarPrimitive,\n AuiIf,\n BranchPickerPrimitive,\n MessagePrimitive,\n useAuiState,\n useMessagePartText,\n useSmooth,\n type ToolCallMessagePartComponent,\n} from \"@assistant-ui/react\";\nimport {\n CHAT_EDIT_UNREACHABLE_LABEL,\n DEEP_AGENT_COMPOSER_MARKDOWN_KEY,\n hideUnterminatedMarkdownLink,\n inboundMessageBody,\n isGithubWakeMessage,\n isSubscriptionWakeMessage,\n isVoiceDelegationMessage,\n readDeepAgentComposerMarkdown,\n readRuntimeMessageFromSourceMessages,\n readSoleRuntimeMessageKind,\n useChatOutboxReachable,\n useDeepAgentChatOutboxContext,\n} from \"@athenaintel/agent-runtime\";\nimport {\n ArrowUpIcon,\n CheckIcon,\n ChevronLeftIcon,\n ChevronRightIcon,\n CopyIcon,\n ListPlusIcon,\n PencilIcon,\n RefreshCwIcon,\n} from \"lucide-react\";\nimport {\n type FC,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport { useAthenaRunLive } from \"../../chat/use-athena-run-live\";\nimport type { ComposerAction } from \"../composer/composer-action\";\nimport { cn } from \"../../lib/utils\";\nimport { ChatMessageBody } from \"../rich-text/chat-message-body\";\nimport { AnswerLabel } from \"./answer-label\";\nimport { InboundChannelLine, InboundChannelSubject, useUserMessageCopy } from \"./inbound-channel-message\";\nimport { useMessageActionsReadOnly } from \"./message-actions-config\";\nimport { MessageImageGallery, MessageImagePart } from \"./message-images\";\nimport { RuntimeMessageCard } from \"./runtime-message\";\nimport { hasVisibleContent } from \"./running-indicator\";\nimport { VoiceDelegationMessage } from \"./voice-delegation-card\";\nimport { WakeMarkerMessage } from \"./wake-marker\";\nimport { SmallIconButton } from \"./thread-chrome\";\n\nexport {\n IconButton,\n SmallIconButton,\n THREAD_HEADER_ACTIONS_CLASS,\n THREAD_HEADER_CLASS,\n THREAD_HEADER_ICON_CLASS,\n THREAD_HEADER_PILL_CLASS,\n THREAD_PANEL_CLASS,\n} from \"./thread-chrome\";\n\nexport const BranchPicker: FC = () => (\n <BranchPickerPrimitive.Root\n hideWhenSingleBranch\n className=\"inline-flex items-center gap-0.5 text-xs text-muted-foreground\"\n data-testid=\"chat-branch-picker\"\n >\n <BranchPickerPrimitive.Previous asChild>\n <SmallIconButton\n tooltip=\"Previous branch\"\n data-testid=\"chat-branch-previous\"\n >\n <ChevronLeftIcon className=\"size-3\" />\n </SmallIconButton>\n </BranchPickerPrimitive.Previous>\n <span className=\"font-medium\" data-testid=\"chat-branch-count\">\n <BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />\n </span>\n <BranchPickerPrimitive.Next asChild>\n <SmallIconButton tooltip=\"Next branch\" data-testid=\"chat-branch-next\">\n <ChevronRightIcon className=\"size-3\" />\n </SmallIconButton>\n </BranchPickerPrimitive.Next>\n </BranchPickerPrimitive.Root>\n);\n\nconst CopyActionButton: FC = () => (\n <ActionBarPrimitive.Copy asChild>\n <SmallIconButton tooltip=\"Copy\">\n <AuiIf condition={(state) => state.message.isCopied}>\n <CheckIcon className=\"size-3\" />\n </AuiIf>\n <AuiIf condition={(state) => !state.message.isCopied}>\n <CopyIcon className=\"size-3\" />\n </AuiIf>\n </SmallIconButton>\n </ActionBarPrimitive.Copy>\n);\n\n/**\n * The edit primitive does not check the runtime's edit capability itself —\n * clicking it on a runtime without one throws inside onPress, where no error\n * boundary can catch it — so the button must gate on the capability and, to\n * match the rewind semantics of `run/edit`, stay hidden while a run is live.\n * The read-only context covers threads the capability flags cannot: a host's\n * static `edit: true` still applies to fenced legacy conversations. While the\n * host's chat outbox says Athena can't be reached it is not offered: shown\n * disabled, its tooltip says why, and it comes back once Athena answers.\n */\nconst EditActionButton: FC = () => {\n const allowEdit = useAuiState((s) => s.thread.capabilities.edit);\n const isRunning = useAthenaRunLive();\n const readOnly = useMessageActionsReadOnly();\n const reachable = useChatOutboxReachable(useDeepAgentChatOutboxContext());\n if (!allowEdit || isRunning || readOnly) return null;\n if (!reachable) {\n return (\n <SmallIconButton\n tooltip={CHAT_EDIT_UNREACHABLE_LABEL}\n aria-disabled\n data-testid=\"chat-message-edit-unreachable\"\n className=\"cursor-not-allowed opacity-50 hover:bg-transparent hover:text-muted-foreground\"\n >\n <PencilIcon className=\"size-3\" />\n </SmallIconButton>\n );\n }\n return (\n <ActionBarPrimitive.Edit asChild>\n <SmallIconButton tooltip=\"Edit\" data-testid=\"chat-message-edit\">\n <PencilIcon className=\"size-3\" />\n </SmallIconButton>\n </ActionBarPrimitive.Edit>\n );\n};\n\n/** Regenerate dispatches `run/reload`, so it hides on read-only threads too. */\nconst RegenerateActionButton: FC = () => {\n const readOnly = useMessageActionsReadOnly();\n if (readOnly) return null;\n return (\n <ActionBarPrimitive.Reload asChild>\n <SmallIconButton tooltip=\"Regenerate\">\n <RefreshCwIcon className=\"size-3\" />\n </SmallIconButton>\n </ActionBarPrimitive.Reload>\n );\n};\n\n/**\n * Reveal-on-demand treatment for action bars: invisible and click-through\n * until the surrounding named group is hovered or a control inside receives\n * keyboard focus. The `focus-within` escape hatch is what keeps the hidden\n * controls reachable for keyboard users.\n */\nexport const ACTION_BAR_REVEAL_CLASS =\n \"pointer-events-none opacity-0 transition-opacity focus-within:pointer-events-auto focus-within:opacity-100\";\n\n/** Shared chat body; the reveal holds incomplete links until their URL is complete. */\nexport const MarkdownText: FC = () => {\n const revealed = useSmooth(useMessagePartText(), true);\n const isRunning = revealed.status.type === \"running\";\n const text = isRunning ? hideUnterminatedMarkdownLink(revealed.text) : revealed.text;\n return <ChatMessageBody text={text} isRunning={isRunning} />;\n};\n\n/**\n * A user message's text, shown as it was typed.\n *\n * A composer sends plain text exactly as typed, because the model reads it\n * literally, so the text alone no longer says which characters are\n * formatting: read as Markdown, `List<T>` loses `<T>`, `obj.__init__` shows a\n * bold \"init\" and `a\\\\b` one backslash. A composer send therefore carries the\n * draft it was serialized from (`metadata.composer_markdown`, only when the\n * two differ), and this renders that draft when it is a draft of the\n * message's own text (`readDeepAgentComposerMarkdown`), formatting and\n * mention chips included. Any other text — no draft, or one of other words —\n * renders with the typed reading (`ChatMessageBody typed`), which leaves raw\n * HTML and underscore emphasis as the characters they were typed with, so\n * `List<T>`, `obj.__init__` and `a\\b` show as typed there too.\n *\n * A message that came in over a channel (Slack, email, a text, Teams) starts\n * with the routing block the agent read (`<inbound-message-context>`); it\n * shows without it, as the words that were sent (`inboundMessageBody`), and\n * the line above the bubble opens the block (`InboundChannelSource`). Only a\n * message with the channel's `inbound_channel` envelope is one: tags a person\n * typed at the start of a chat message show as typed.\n *\n * Copy copies the message text, which is the text as sent, and Edit opens it\n * in a plain-text box, so neither reads the draft.\n */\nexport const UserMessageText: FC<{ text: string }> = ({ text }) => {\n const custom = useAuiState((s) => s.message.metadata?.custom);\n const shown = useMemo(() => {\n const body = inboundMessageBody({ custom, text });\n return (\n readDeepAgentComposerMarkdown({\n metadata: { [DEEP_AGENT_COMPOSER_MARKDOWN_KEY]: custom?.[DEEP_AGENT_COMPOSER_MARKDOWN_KEY] },\n text: body,\n }) ?? body\n );\n }, [custom, text]);\n return <ChatMessageBody text={shown} typed />;\n};\n\n/** A user message's parts: its text as typed, and its pictures, each opening the viewer. */\nconst USER_MESSAGE_PART_COMPONENTS = { Text: UserMessageText, Image: MessageImagePart };\n\n/** Copy on a user bubble copies what the bubble shows (`useUserMessageCopy`). */\nconst UserCopyActionButton: FC = () => {\n const { copy, disabled, isCopied } = useUserMessageCopy();\n return (\n <SmallIconButton\n tooltip=\"Copy\"\n onClick={copy}\n disabled={disabled}\n data-copied={isCopied ? \"true\" : undefined}\n >\n {isCopied ? <CheckIcon className=\"size-3\" /> : <CopyIcon className=\"size-3\" />}\n </SmallIconButton>\n );\n};\n\nconst UserActionBar: FC = () => (\n <ActionBarPrimitive.Root\n autohide=\"never\"\n className={cn(\n \"flex min-h-6 items-center gap-0.5\",\n ACTION_BAR_REVEAL_CLASS,\n \"group-hover/user-message:pointer-events-auto group-hover/user-message:opacity-100\",\n )}\n >\n <UserCopyActionButton />\n <EditActionButton />\n </ActionBarPrimitive.Root>\n);\n\nexport const UserMessage: FC = () => {\n // A GitHub wake or a subscription's delivery is an event, not words the\n // user typed: it renders as the compact wake marker instead of a bubble\n // quoting the injected text.\n const isWake = useAuiState(\n (s) =>\n isGithubWakeMessage(s.message.metadata?.custom) ||\n isSubscriptionWakeMessage(s.message.metadata?.custom),\n );\n // A voice delegation's anchor is the ask the live voice model handed to the\n // thread, not words the user typed: it renders as the shared voice-task\n // card on every host instead of a second user bubble under the spoken turn.\n const isVoiceDelegation = useAuiState((s) =>\n isVoiceDelegationMessage({ messageId: s.message.id, custom: s.message.metadata?.custom }),\n );\n if (isWake) {\n return (\n <MessagePrimitive.Root data-message-role=\"user\" className=\"mb-3\">\n <WakeMarkerMessage />\n </MessagePrimitive.Root>\n );\n }\n if (isVoiceDelegation) {\n return (\n <MessagePrimitive.Root data-message-role=\"user\" className=\"mb-3\">\n <VoiceDelegationMessage />\n </MessagePrimitive.Root>\n );\n }\n return (\n <MessagePrimitive.Root\n data-message-role=\"user\"\n className=\"group/user-message mb-3 flex justify-end\"\n >\n <div className=\"flex min-w-0 max-w-[85%] flex-col items-end gap-1\">\n {/* A message that came in over a channel: the line naming the channel\n and the sender, above the words that were sent. */}\n <InboundChannelLine />\n <div className=\"min-w-0 max-w-full rounded-2xl rounded-br-md bg-muted px-3.5 py-2 text-sm text-foreground\">\n <InboundChannelSubject />\n <MessageImageGallery>\n <MessagePrimitive.Content components={USER_MESSAGE_PART_COMPONENTS} />\n </MessageImageGallery>\n </div>\n <div className=\"flex min-h-6 items-center gap-1\">\n <BranchPicker />\n <UserActionBar />\n </div>\n </div>\n </MessagePrimitive.Root>\n );\n};\n\nexport interface CreateAssistantMessageOptions {\n /** Host-registered card for tools without a dedicated UI. */\n toolFallback: ToolCallMessagePartComponent;\n /** Extra action-bar controls appended after copy/regenerate. */\n extraActions?: ReactNode;\n /**\n * Renders the message body. Hosts that group content into activity\n * timelines supply their own; the default renders markdown and tool cards.\n */\n content?: FC;\n /**\n * Inline affordance rendered inside a runtime-ending card (e.g. a Continue\n * button). Hosts without one leave it unset.\n */\n runtimeMessageAction?: ReactNode;\n}\n\n/**\n * Builds the assistant bubble. Call this once per host (memoized on its\n * inputs) so the returned component identity stays stable across renders.\n */\nexport function createAssistantMessage({\n toolFallback,\n extraActions,\n content: Content,\n runtimeMessageAction,\n}: CreateAssistantMessageOptions): FC {\n const AssistantActionBar: FC = () => {\n // The latest reply keeps its actions visible; older replies reveal them\n // on hover so a long transcript is not a wall of icon rows.\n const isLast = useAuiState((s) => s.message.isLast);\n return (\n <ActionBarPrimitive.Root\n autohide=\"never\"\n className={cn(\n \"mt-1 flex min-h-6 items-center gap-0.5\",\n !isLast && [\n ACTION_BAR_REVEAL_CLASS,\n \"group-hover/assistant-message:pointer-events-auto group-hover/assistant-message:opacity-100\",\n ],\n )}\n >\n <CopyActionButton />\n <RegenerateActionButton />\n {extraActions}\n </ActionBarPrimitive.Root>\n );\n };\n\n // A run-lifecycle marker or handoff summary is a system event, not\n // assistant speech. When it owns the whole row, render the status card in\n // place of the bubble; when it is chunked in with the assistant's own work\n // (or is a handoff whose text IS the closing summary), keep the body and\n // frame it with the card above.\n const RuntimeEnding: FC<{ placement: \"row\" | \"banner\" }> = ({ placement }) => {\n // Select the message (a stable store reference) and derive from it: the\n // reader allocates a fresh object per call, and `useAuiState` compares\n // snapshots with `Object.is`, so selecting the reader's result directly\n // would re-render on every store update and trip React's update-depth\n // guard.\n const message = useAuiState((s) => s.message);\n const runtime = useMemo(() => readRuntimeMessageFromSourceMessages(message), [message]);\n if (!runtime || runtime.silent) return null;\n if (placement === \"row\" && !runtime.isSoleSourceMessage) return null;\n if (placement === \"banner\" && runtime.isSoleSourceMessage && runtime.kind !== \"handoff\") {\n return null;\n }\n return <RuntimeMessageCard message={runtime} action={runtimeMessageAction} />;\n };\n\n const AssistantMessage: FC = () => {\n // An assistant row exists before its first token streams; showing\n // copy/regenerate against nothing looks broken, so wait for content.\n const showActions = useAuiState((state) =>\n hasVisibleContent(state.message.content),\n );\n // Primitive selector: the reader builds a fresh object per call.\n const soleRuntimeKind = useAuiState((s) => readSoleRuntimeMessageKind(s.message));\n const soleRuntimeSilent = useAuiState(\n (s) => readRuntimeMessageFromSourceMessages(s.message)?.silent === true,\n );\n\n if (soleRuntimeKind && soleRuntimeKind !== \"handoff\") {\n if (soleRuntimeSilent) return null;\n return (\n <MessagePrimitive.Root\n data-message-role=\"assistant\"\n className=\"group group/assistant-message mb-3\"\n >\n <div className=\"max-w-[95%]\">\n <RuntimeEnding placement=\"row\" />\n </div>\n </MessagePrimitive.Root>\n );\n }\n\n return (\n <MessagePrimitive.Root\n data-message-role=\"assistant\"\n className=\"group group/assistant-message mb-3\"\n >\n <div className=\"max-w-[95%]\">\n <AnswerLabel className=\"mb-1\" />\n <RuntimeEnding placement=\"banner\" />\n {Content ? (\n <Content />\n ) : (\n <MessagePrimitive.Content\n components={{\n Text: MarkdownText,\n tools: { Fallback: toolFallback },\n }}\n />\n )}\n {showActions ? (\n <div className=\"flex min-h-6 items-center gap-1\">\n <BranchPicker />\n <AssistantActionBar />\n </div>\n ) : null}\n </div>\n </MessagePrimitive.Root>\n );\n };\n\n return AssistantMessage;\n}\n\n/** Composer chrome: the dock around the composer, its surface and its rows. */\nexport const COMPOSER_DOCK_CLASS = \"bg-background px-2.5 pb-2 pt-1.5\";\nexport const COMPOSER_SURFACE_CLASS =\n \"relative flex flex-col gap-1 rounded-xl border border-neutral-200 bg-white shadow-[0_2px_10px_rgba(54,45,33,0.08)]\";\nexport const COMPOSER_EDITOR_ROW_CLASS = \"px-2.5 pt-1\";\nexport const COMPOSER_TOOLBAR_CLASS =\n \"flex items-center gap-1 border-t border-neutral-100 px-2 py-1.5\";\n/**\n * Paper composer chrome (`ChatComposerDock appearance=\"paper\"`): a card-toned\n * surface with a larger radius, a focus-within ring, a drag-over tint keyed\n * off `data-drag-active`, and a bottom rail — the chrome the SDK's\n * `AthenaChat` thread renders. Hosts on the default chrome above are\n * untouched. The dock carries no padding of its own; the paper host's footer\n * spaces it. The radius and border colour also bind to the `--composer-radius`\n * / `--composer-border` theme variables in `styles.css`.\n */\nexport const COMPOSER_PAPER_DOCK_CLASS = \"aui-composer-dock\";\nexport const COMPOSER_PAPER_SURFACE_CLASS =\n \"aui-composer-root relative flex w-full flex-col rounded-[1.375rem] border border-border bg-card p-2.5 text-card-foreground shadow-[0_1px_2px_rgba(0,0,0,0.04)] outline-none transition-shadow duration-150 focus-within:shadow-[0_8px_24px_-14px_rgba(0,0,0,0.25)] focus-within:ring-2 focus-within:ring-ring/40 data-[drag-active=true]:bg-primary/5 data-[drag-active=true]:ring-2 data-[drag-active=true]:ring-primary/40\";\nexport const COMPOSER_PAPER_EDITOR_ROW_CLASS = \"px-0.5\";\nexport const COMPOSER_PAPER_TOOLBAR_CLASS =\n \"aui-composer-action-wrapper relative flex items-center justify-between gap-1 pt-1\";\nexport const THREAD_SCROLL_TO_BOTTOM_CLASS =\n \"inline-flex items-center justify-center rounded-full border bg-background/80 p-1 shadow-sm backdrop-blur transition-opacity hover:bg-accent disabled:invisible\";\n\nconst ComposerStopIcon: FC = () => (\n <svg\n aria-hidden=\"true\"\n className=\"size-4\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n >\n <rect width=\"10\" height=\"10\" x=\"3\" y=\"3\" rx=\"2\" />\n </svg>\n);\n\nexport interface ComposerStopButtonProps {\n onStop: () => void;\n disabled?: boolean;\n title?: string;\n}\n\nexport interface ComposerSendButtonProps {\n action: Extract<ComposerAction, \"send\" | \"queue\">;\n onSend: () => void;\n disabled?: boolean;\n title?: string;\n}\n\n/** Stop control shown while a run is in flight and there is nothing queued. */\nexport const ComposerStopButton: FC<ComposerStopButtonProps> = ({\n onStop,\n disabled = false,\n title = \"Stop generation\",\n}) => (\n <button\n type=\"button\"\n onClick={onStop}\n disabled={disabled}\n title={title}\n className={cn(\n \"inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-foreground text-background shadow-sm transition-colors hover:bg-foreground/80\",\n disabled && \"cursor-not-allowed opacity-60\",\n )}\n >\n <ComposerStopIcon />\n </button>\n);\n/** Send control, which becomes a queue control while a run is in flight. */\nexport const ComposerSendButton: FC<ComposerSendButtonProps> = ({\n action,\n onSend,\n disabled = false,\n title,\n}) => (\n <button\n type=\"button\"\n onClick={onSend}\n disabled={disabled}\n title={title ?? (action === \"queue\" ? \"Queue message\" : \"Send\")}\n className={cn(\n \"inline-flex size-8 shrink-0 items-center justify-center rounded-full shadow-sm transition-colors\",\n disabled\n ? \"cursor-not-allowed bg-muted text-muted-foreground opacity-60\"\n : \"bg-foreground text-background hover:bg-foreground/80\",\n )}\n >\n {action === \"queue\" ? (\n <ListPlusIcon className=\"size-4\" />\n ) : (\n <ArrowUpIcon className=\"size-4\" />\n )}\n </button>\n);\n"],"names":["jsxs","BranchPickerPrimitive","jsx","SmallIconButton","ChevronLeftIcon","ChevronRightIcon","ActionBarPrimitive","AuiIf","CheckIcon","CopyIcon","useAuiState","useAthenaRunLive","useMessageActionsReadOnly","useChatOutboxReachable","useDeepAgentChatOutboxContext","CHAT_EDIT_UNREACHABLE_LABEL","PencilIcon","RefreshCwIcon","useSmooth","useMessagePartText","hideUnterminatedMarkdownLink","ChatMessageBody","useMemo","inboundMessageBody","readDeepAgentComposerMarkdown","DEEP_AGENT_COMPOSER_MARKDOWN_KEY","MessageImagePart","useUserMessageCopy","cn","isGithubWakeMessage","isSubscriptionWakeMessage","isVoiceDelegationMessage","MessagePrimitive","WakeMarkerMessage","VoiceDelegationMessage","InboundChannelLine","InboundChannelSubject","MessageImageGallery","readRuntimeMessageFromSourceMessages","RuntimeMessageCard","hasVisibleContent","readSoleRuntimeMessageKind","AnswerLabel","ListPlusIcon","ArrowUpIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DO,MAAM,eAAmB,MAC9BA,2BAAAA;AAAAA,EAACC,MAAAA,sBAAsB;AAAA,EAAtB;AAAA,IACC,sBAAoB;AAAA,IACpB,WAAU;AAAA,IACV,eAAY;AAAA,IAEZ,UAAA;AAAA,MAAAC,2BAAAA,IAACD,MAAAA,sBAAsB,UAAtB,EAA+B,SAAO,MACrC,UAAAC,2BAAAA;AAAAA,QAACC,aAAAA;AAAAA,QAAA;AAAA,UACC,SAAQ;AAAA,UACR,eAAY;AAAA,UAEZ,UAAAD,2BAAAA,IAACE,YAAAA,iBAAA,EAAgB,WAAU,SAAA,CAAS;AAAA,QAAA;AAAA,MAAA,GAExC;AAAA,MACAJ,2BAAAA,KAAC,QAAA,EAAK,WAAU,eAAc,eAAY,qBACxC,UAAA;AAAA,QAAAE,+BAACD,MAAAA,sBAAsB,QAAtB,EAA6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AK,OAAM,MAAK,QAAO,MAAK,GAAE,KAAI,GAAE,KAAI,IAAG,IAAA,CAAI;AAAA,EAAA;AAClD;AAiBK,MAAM,qBAAkD,CAAC;AAAA,EAC9D;AAAA,EACA,WAAW;AAAA,EACX,QAAQ;AACV,MACEA,2BAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IACC,MAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,WAAW0B,OAAAA;AAAAA,MACT;AAAA,MACA,YAAY;AAAA,IAAA;AAAA,IAGd,yCAAC,kBAAA,CAAA,CAAiB;AAAA,EAAA;AACpB;AAGK,MAAM,qBAAkD,CAAC;AAAA,EAC9D;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,MACE1B,2BAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IACC,MAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA,OAAO,UAAU,WAAW,UAAU,kBAAkB;AAAA,IACxD,WAAW0B,OAAAA;AAAAA,MACT;AAAA,MACA,WACI,iEACA;AAAA,IAAA;AAAA,IAGL,UAAA,WAAW,UACV1B,2BAAAA,IAACyC,YAAAA,cAAA,EAAa,WAAU,UAAS,IAEjCzC,2BAAAA,IAAC0C,YAAAA,aAAA,EAAY,WAAU,SAAA,CAAS;AAAA,EAAA;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -27,6 +27,13 @@ export declare const MarkdownText: FC;
|
|
|
27
27
|
* HTML and underscore emphasis as the characters they were typed with, so
|
|
28
28
|
* `List<T>`, `obj.__init__` and `a\b` show as typed there too.
|
|
29
29
|
*
|
|
30
|
+
* A message that came in over a channel (Slack, email, a text, Teams) starts
|
|
31
|
+
* with the routing block the agent read (`<inbound-message-context>`); it
|
|
32
|
+
* shows without it, as the words that were sent (`inboundMessageBody`), and
|
|
33
|
+
* the line above the bubble opens the block (`InboundChannelSource`). Only a
|
|
34
|
+
* message with the channel's `inbound_channel` envelope is one: tags a person
|
|
35
|
+
* typed at the start of a chat message show as typed.
|
|
36
|
+
*
|
|
30
37
|
* Copy copies the message text, which is the text as sent, and Edit opens it
|
|
31
38
|
* in a plain-text box, so neither reads the draft.
|
|
32
39
|
*/
|
|
@@ -5,6 +5,7 @@ import { useMemo } from "react";
|
|
|
5
5
|
import { useAthenaRunLive } from "../../chat/use-athena-run-live.js";
|
|
6
6
|
import { ChatMessageBody } from "../rich-text/chat-message-body.js";
|
|
7
7
|
import { AnswerLabel } from "./answer-label.js";
|
|
8
|
+
import { InboundChannelLine, InboundChannelSubject, useUserMessageCopy } from "./inbound-channel-message.js";
|
|
8
9
|
import { useMessageActionsReadOnly } from "./message-actions-config.js";
|
|
9
10
|
import { MessageImageGallery, MessageImagePart } from "./message-images.js";
|
|
10
11
|
import { RuntimeMessageCard } from "./runtime-message.js";
|
|
@@ -17,7 +18,8 @@ import { hideUnterminatedMarkdownLink } from "../../agent-runtime/src/streaming-
|
|
|
17
18
|
import { isGithubWakeMessage } from "../../agent-runtime/src/github-wake-event.js";
|
|
18
19
|
import { isSubscriptionWakeMessage } from "../../agent-runtime/src/subscription-wake-event.js";
|
|
19
20
|
import { isVoiceDelegationMessage } from "../../agent-runtime/src/voice-presentation.js";
|
|
20
|
-
import {
|
|
21
|
+
import { inboundMessageBody } from "../../agent-runtime/src/inbound-channel.js";
|
|
22
|
+
import { readDeepAgentComposerMarkdown, DEEP_AGENT_COMPOSER_MARKDOWN_KEY } from "../../agent-runtime/src/composer-markdown.js";
|
|
21
23
|
import { readSoleRuntimeMessageKind, readRuntimeMessageFromSourceMessages } from "../../agent-runtime/src/runtime-messages.js";
|
|
22
24
|
import { useChatOutboxReachable, useDeepAgentChatOutboxContext } from "../../agent-runtime/src/use-deep-agent-chat-outbox.js";
|
|
23
25
|
import { CHAT_EDIT_UNREACHABLE_LABEL } from "../../agent-runtime/src/chat-outbox.js";
|
|
@@ -83,22 +85,33 @@ const MarkdownText = () => {
|
|
|
83
85
|
return /* @__PURE__ */ jsx(ChatMessageBody, { text, isRunning });
|
|
84
86
|
};
|
|
85
87
|
const UserMessageText = ({ text }) => {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
[composerMarkdown, text]
|
|
98
|
-
);
|
|
88
|
+
const custom = useAuiState((s) => {
|
|
89
|
+
var _a;
|
|
90
|
+
return (_a = s.message.metadata) == null ? void 0 : _a.custom;
|
|
91
|
+
});
|
|
92
|
+
const shown = useMemo(() => {
|
|
93
|
+
const body = inboundMessageBody({ custom, text });
|
|
94
|
+
return readDeepAgentComposerMarkdown({
|
|
95
|
+
metadata: { [DEEP_AGENT_COMPOSER_MARKDOWN_KEY]: custom == null ? void 0 : custom[DEEP_AGENT_COMPOSER_MARKDOWN_KEY] },
|
|
96
|
+
text: body
|
|
97
|
+
}) ?? body;
|
|
98
|
+
}, [custom, text]);
|
|
99
99
|
return /* @__PURE__ */ jsx(ChatMessageBody, { text: shown, typed: true });
|
|
100
100
|
};
|
|
101
101
|
const USER_MESSAGE_PART_COMPONENTS = { Text: UserMessageText, Image: MessageImagePart };
|
|
102
|
+
const UserCopyActionButton = () => {
|
|
103
|
+
const { copy, disabled, isCopied } = useUserMessageCopy();
|
|
104
|
+
return /* @__PURE__ */ jsx(
|
|
105
|
+
SmallIconButton,
|
|
106
|
+
{
|
|
107
|
+
tooltip: "Copy",
|
|
108
|
+
onClick: copy,
|
|
109
|
+
disabled,
|
|
110
|
+
"data-copied": isCopied ? "true" : void 0,
|
|
111
|
+
children: isCopied ? /* @__PURE__ */ jsx(CheckIcon, { className: "size-3" }) : /* @__PURE__ */ jsx(CopyIcon, { className: "size-3" })
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
};
|
|
102
115
|
const UserActionBar = () => /* @__PURE__ */ jsxs(
|
|
103
116
|
ActionBarPrimitive.Root,
|
|
104
117
|
{
|
|
@@ -109,7 +122,7 @@ const UserActionBar = () => /* @__PURE__ */ jsxs(
|
|
|
109
122
|
"group-hover/user-message:pointer-events-auto group-hover/user-message:opacity-100"
|
|
110
123
|
),
|
|
111
124
|
children: [
|
|
112
|
-
/* @__PURE__ */ jsx(
|
|
125
|
+
/* @__PURE__ */ jsx(UserCopyActionButton, {}),
|
|
113
126
|
/* @__PURE__ */ jsx(EditActionButton, {})
|
|
114
127
|
]
|
|
115
128
|
}
|
|
@@ -139,7 +152,11 @@ const UserMessage = () => {
|
|
|
139
152
|
"data-message-role": "user",
|
|
140
153
|
className: "group/user-message mb-3 flex justify-end",
|
|
141
154
|
children: /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 max-w-[85%] flex-col items-end gap-1", children: [
|
|
142
|
-
/* @__PURE__ */ jsx(
|
|
155
|
+
/* @__PURE__ */ jsx(InboundChannelLine, {}),
|
|
156
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 max-w-full rounded-2xl rounded-br-md bg-muted px-3.5 py-2 text-sm text-foreground", children: [
|
|
157
|
+
/* @__PURE__ */ jsx(InboundChannelSubject, {}),
|
|
158
|
+
/* @__PURE__ */ jsx(MessageImageGallery, { children: /* @__PURE__ */ jsx(MessagePrimitive.Content, { components: USER_MESSAGE_PART_COMPONENTS }) })
|
|
159
|
+
] }),
|
|
143
160
|
/* @__PURE__ */ jsxs("div", { className: "flex min-h-6 items-center gap-1", children: [
|
|
144
161
|
/* @__PURE__ */ jsx(BranchPicker, {}),
|
|
145
162
|
/* @__PURE__ */ jsx(UserActionBar, {})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-components.js","sources":["../../../src/chat-ui/messages/message-components.tsx"],"sourcesContent":["import {\n ActionBarPrimitive,\n AuiIf,\n BranchPickerPrimitive,\n MessagePrimitive,\n useAuiState,\n useMessagePartText,\n useSmooth,\n type ToolCallMessagePartComponent,\n} from \"@assistant-ui/react\";\nimport {\n CHAT_EDIT_UNREACHABLE_LABEL,\n DEEP_AGENT_COMPOSER_MARKDOWN_KEY,\n hideUnterminatedMarkdownLink,\n isGithubWakeMessage,\n isSubscriptionWakeMessage,\n isVoiceDelegationMessage,\n readDeepAgentComposerMarkdown,\n readRuntimeMessageFromSourceMessages,\n readSoleRuntimeMessageKind,\n useChatOutboxReachable,\n useDeepAgentChatOutboxContext,\n} from \"@athenaintel/agent-runtime\";\nimport {\n ArrowUpIcon,\n CheckIcon,\n ChevronLeftIcon,\n ChevronRightIcon,\n CopyIcon,\n ListPlusIcon,\n PencilIcon,\n RefreshCwIcon,\n} from \"lucide-react\";\nimport {\n type FC,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport { useAthenaRunLive } from \"../../chat/use-athena-run-live\";\nimport type { ComposerAction } from \"../composer/composer-action\";\nimport { cn } from \"../../lib/utils\";\nimport { ChatMessageBody } from \"../rich-text/chat-message-body\";\nimport { AnswerLabel } from \"./answer-label\";\nimport { useMessageActionsReadOnly } from \"./message-actions-config\";\nimport { MessageImageGallery, MessageImagePart } from \"./message-images\";\nimport { RuntimeMessageCard } from \"./runtime-message\";\nimport { hasVisibleContent } from \"./running-indicator\";\nimport { VoiceDelegationMessage } from \"./voice-delegation-card\";\nimport { WakeMarkerMessage } from \"./wake-marker\";\nimport { SmallIconButton } from \"./thread-chrome\";\n\nexport {\n IconButton,\n SmallIconButton,\n THREAD_HEADER_ACTIONS_CLASS,\n THREAD_HEADER_CLASS,\n THREAD_HEADER_ICON_CLASS,\n THREAD_HEADER_PILL_CLASS,\n THREAD_PANEL_CLASS,\n} from \"./thread-chrome\";\n\nexport const BranchPicker: FC = () => (\n <BranchPickerPrimitive.Root\n hideWhenSingleBranch\n className=\"inline-flex items-center gap-0.5 text-xs text-muted-foreground\"\n data-testid=\"chat-branch-picker\"\n >\n <BranchPickerPrimitive.Previous asChild>\n <SmallIconButton\n tooltip=\"Previous branch\"\n data-testid=\"chat-branch-previous\"\n >\n <ChevronLeftIcon className=\"size-3\" />\n </SmallIconButton>\n </BranchPickerPrimitive.Previous>\n <span className=\"font-medium\" data-testid=\"chat-branch-count\">\n <BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />\n </span>\n <BranchPickerPrimitive.Next asChild>\n <SmallIconButton tooltip=\"Next branch\" data-testid=\"chat-branch-next\">\n <ChevronRightIcon className=\"size-3\" />\n </SmallIconButton>\n </BranchPickerPrimitive.Next>\n </BranchPickerPrimitive.Root>\n);\n\nconst CopyActionButton: FC = () => (\n <ActionBarPrimitive.Copy asChild>\n <SmallIconButton tooltip=\"Copy\">\n <AuiIf condition={(state) => state.message.isCopied}>\n <CheckIcon className=\"size-3\" />\n </AuiIf>\n <AuiIf condition={(state) => !state.message.isCopied}>\n <CopyIcon className=\"size-3\" />\n </AuiIf>\n </SmallIconButton>\n </ActionBarPrimitive.Copy>\n);\n\n/**\n * The edit primitive does not check the runtime's edit capability itself —\n * clicking it on a runtime without one throws inside onPress, where no error\n * boundary can catch it — so the button must gate on the capability and, to\n * match the rewind semantics of `run/edit`, stay hidden while a run is live.\n * The read-only context covers threads the capability flags cannot: a host's\n * static `edit: true` still applies to fenced legacy conversations. While the\n * host's chat outbox says Athena can't be reached it is not offered: shown\n * disabled, its tooltip says why, and it comes back once Athena answers.\n */\nconst EditActionButton: FC = () => {\n const allowEdit = useAuiState((s) => s.thread.capabilities.edit);\n const isRunning = useAthenaRunLive();\n const readOnly = useMessageActionsReadOnly();\n const reachable = useChatOutboxReachable(useDeepAgentChatOutboxContext());\n if (!allowEdit || isRunning || readOnly) return null;\n if (!reachable) {\n return (\n <SmallIconButton\n tooltip={CHAT_EDIT_UNREACHABLE_LABEL}\n aria-disabled\n data-testid=\"chat-message-edit-unreachable\"\n className=\"cursor-not-allowed opacity-50 hover:bg-transparent hover:text-muted-foreground\"\n >\n <PencilIcon className=\"size-3\" />\n </SmallIconButton>\n );\n }\n return (\n <ActionBarPrimitive.Edit asChild>\n <SmallIconButton tooltip=\"Edit\" data-testid=\"chat-message-edit\">\n <PencilIcon className=\"size-3\" />\n </SmallIconButton>\n </ActionBarPrimitive.Edit>\n );\n};\n\n/** Regenerate dispatches `run/reload`, so it hides on read-only threads too. */\nconst RegenerateActionButton: FC = () => {\n const readOnly = useMessageActionsReadOnly();\n if (readOnly) return null;\n return (\n <ActionBarPrimitive.Reload asChild>\n <SmallIconButton tooltip=\"Regenerate\">\n <RefreshCwIcon className=\"size-3\" />\n </SmallIconButton>\n </ActionBarPrimitive.Reload>\n );\n};\n\n/**\n * Reveal-on-demand treatment for action bars: invisible and click-through\n * until the surrounding named group is hovered or a control inside receives\n * keyboard focus. The `focus-within` escape hatch is what keeps the hidden\n * controls reachable for keyboard users.\n */\nexport const ACTION_BAR_REVEAL_CLASS =\n \"pointer-events-none opacity-0 transition-opacity focus-within:pointer-events-auto focus-within:opacity-100\";\n\n/** Shared chat body; the reveal holds incomplete links until their URL is complete. */\nexport const MarkdownText: FC = () => {\n const revealed = useSmooth(useMessagePartText(), true);\n const isRunning = revealed.status.type === \"running\";\n const text = isRunning ? hideUnterminatedMarkdownLink(revealed.text) : revealed.text;\n return <ChatMessageBody text={text} isRunning={isRunning} />;\n};\n\n/**\n * A user message's text, shown as it was typed.\n *\n * A composer sends plain text exactly as typed, because the model reads it\n * literally, so the text alone no longer says which characters are\n * formatting: read as Markdown, `List<T>` loses `<T>`, `obj.__init__` shows a\n * bold \"init\" and `a\\\\b` one backslash. A composer send therefore carries the\n * draft it was serialized from (`metadata.composer_markdown`, only when the\n * two differ), and this renders that draft when it is a draft of the\n * message's own text (`readDeepAgentComposerMarkdown`), formatting and\n * mention chips included. Any other text — no draft, or one of other words —\n * renders with the typed reading (`ChatMessageBody typed`), which leaves raw\n * HTML and underscore emphasis as the characters they were typed with, so\n * `List<T>`, `obj.__init__` and `a\\b` show as typed there too.\n *\n * Copy copies the message text, which is the text as sent, and Edit opens it\n * in a plain-text box, so neither reads the draft.\n */\nexport const UserMessageText: FC<{ text: string }> = ({ text }) => {\n const composerMarkdown: unknown = useAuiState(\n (s) => s.message.metadata?.custom?.[DEEP_AGENT_COMPOSER_MARKDOWN_KEY],\n );\n const shown = useMemo(\n () =>\n readDeepAgentComposerMarkdown({\n metadata: { [DEEP_AGENT_COMPOSER_MARKDOWN_KEY]: composerMarkdown },\n text,\n }) ?? text,\n [composerMarkdown, text],\n );\n return <ChatMessageBody text={shown} typed />;\n};\n\n/** A user message's parts: its text as typed, and its pictures, each opening the viewer. */\nconst USER_MESSAGE_PART_COMPONENTS = { Text: UserMessageText, Image: MessageImagePart };\n\nconst UserActionBar: FC = () => (\n <ActionBarPrimitive.Root\n autohide=\"never\"\n className={cn(\n \"flex min-h-6 items-center gap-0.5\",\n ACTION_BAR_REVEAL_CLASS,\n \"group-hover/user-message:pointer-events-auto group-hover/user-message:opacity-100\",\n )}\n >\n <CopyActionButton />\n <EditActionButton />\n </ActionBarPrimitive.Root>\n);\n\nexport const UserMessage: FC = () => {\n // A GitHub wake or a subscription's delivery is an event, not words the\n // user typed: it renders as the compact wake marker instead of a bubble\n // quoting the injected text.\n const isWake = useAuiState(\n (s) =>\n isGithubWakeMessage(s.message.metadata?.custom) ||\n isSubscriptionWakeMessage(s.message.metadata?.custom),\n );\n // A voice delegation's anchor is the ask the live voice model handed to the\n // thread, not words the user typed: it renders as the shared voice-task\n // card on every host instead of a second user bubble under the spoken turn.\n const isVoiceDelegation = useAuiState((s) =>\n isVoiceDelegationMessage({ messageId: s.message.id, custom: s.message.metadata?.custom }),\n );\n if (isWake) {\n return (\n <MessagePrimitive.Root data-message-role=\"user\" className=\"mb-3\">\n <WakeMarkerMessage />\n </MessagePrimitive.Root>\n );\n }\n if (isVoiceDelegation) {\n return (\n <MessagePrimitive.Root data-message-role=\"user\" className=\"mb-3\">\n <VoiceDelegationMessage />\n </MessagePrimitive.Root>\n );\n }\n return (\n <MessagePrimitive.Root\n data-message-role=\"user\"\n className=\"group/user-message mb-3 flex justify-end\"\n >\n <div className=\"flex min-w-0 max-w-[85%] flex-col items-end gap-1\">\n <div className=\"min-w-0 max-w-full rounded-2xl rounded-br-md bg-muted px-3.5 py-2 text-sm text-foreground\">\n <MessageImageGallery>\n <MessagePrimitive.Content components={USER_MESSAGE_PART_COMPONENTS} />\n </MessageImageGallery>\n </div>\n <div className=\"flex min-h-6 items-center gap-1\">\n <BranchPicker />\n <UserActionBar />\n </div>\n </div>\n </MessagePrimitive.Root>\n );\n};\n\nexport interface CreateAssistantMessageOptions {\n /** Host-registered card for tools without a dedicated UI. */\n toolFallback: ToolCallMessagePartComponent;\n /** Extra action-bar controls appended after copy/regenerate. */\n extraActions?: ReactNode;\n /**\n * Renders the message body. Hosts that group content into activity\n * timelines supply their own; the default renders markdown and tool cards.\n */\n content?: FC;\n /**\n * Inline affordance rendered inside a runtime-ending card (e.g. a Continue\n * button). Hosts without one leave it unset.\n */\n runtimeMessageAction?: ReactNode;\n}\n\n/**\n * Builds the assistant bubble. Call this once per host (memoized on its\n * inputs) so the returned component identity stays stable across renders.\n */\nexport function createAssistantMessage({\n toolFallback,\n extraActions,\n content: Content,\n runtimeMessageAction,\n}: CreateAssistantMessageOptions): FC {\n const AssistantActionBar: FC = () => {\n // The latest reply keeps its actions visible; older replies reveal them\n // on hover so a long transcript is not a wall of icon rows.\n const isLast = useAuiState((s) => s.message.isLast);\n return (\n <ActionBarPrimitive.Root\n autohide=\"never\"\n className={cn(\n \"mt-1 flex min-h-6 items-center gap-0.5\",\n !isLast && [\n ACTION_BAR_REVEAL_CLASS,\n \"group-hover/assistant-message:pointer-events-auto group-hover/assistant-message:opacity-100\",\n ],\n )}\n >\n <CopyActionButton />\n <RegenerateActionButton />\n {extraActions}\n </ActionBarPrimitive.Root>\n );\n };\n\n // A run-lifecycle marker or handoff summary is a system event, not\n // assistant speech. When it owns the whole row, render the status card in\n // place of the bubble; when it is chunked in with the assistant's own work\n // (or is a handoff whose text IS the closing summary), keep the body and\n // frame it with the card above.\n const RuntimeEnding: FC<{ placement: \"row\" | \"banner\" }> = ({ placement }) => {\n // Select the message (a stable store reference) and derive from it: the\n // reader allocates a fresh object per call, and `useAuiState` compares\n // snapshots with `Object.is`, so selecting the reader's result directly\n // would re-render on every store update and trip React's update-depth\n // guard.\n const message = useAuiState((s) => s.message);\n const runtime = useMemo(() => readRuntimeMessageFromSourceMessages(message), [message]);\n if (!runtime || runtime.silent) return null;\n if (placement === \"row\" && !runtime.isSoleSourceMessage) return null;\n if (placement === \"banner\" && runtime.isSoleSourceMessage && runtime.kind !== \"handoff\") {\n return null;\n }\n return <RuntimeMessageCard message={runtime} action={runtimeMessageAction} />;\n };\n\n const AssistantMessage: FC = () => {\n // An assistant row exists before its first token streams; showing\n // copy/regenerate against nothing looks broken, so wait for content.\n const showActions = useAuiState((state) =>\n hasVisibleContent(state.message.content),\n );\n // Primitive selector: the reader builds a fresh object per call.\n const soleRuntimeKind = useAuiState((s) => readSoleRuntimeMessageKind(s.message));\n const soleRuntimeSilent = useAuiState(\n (s) => readRuntimeMessageFromSourceMessages(s.message)?.silent === true,\n );\n\n if (soleRuntimeKind && soleRuntimeKind !== \"handoff\") {\n if (soleRuntimeSilent) return null;\n return (\n <MessagePrimitive.Root\n data-message-role=\"assistant\"\n className=\"group group/assistant-message mb-3\"\n >\n <div className=\"max-w-[95%]\">\n <RuntimeEnding placement=\"row\" />\n </div>\n </MessagePrimitive.Root>\n );\n }\n\n return (\n <MessagePrimitive.Root\n data-message-role=\"assistant\"\n className=\"group group/assistant-message mb-3\"\n >\n <div className=\"max-w-[95%]\">\n <AnswerLabel className=\"mb-1\" />\n <RuntimeEnding placement=\"banner\" />\n {Content ? (\n <Content />\n ) : (\n <MessagePrimitive.Content\n components={{\n Text: MarkdownText,\n tools: { Fallback: toolFallback },\n }}\n />\n )}\n {showActions ? (\n <div className=\"flex min-h-6 items-center gap-1\">\n <BranchPicker />\n <AssistantActionBar />\n </div>\n ) : null}\n </div>\n </MessagePrimitive.Root>\n );\n };\n\n return AssistantMessage;\n}\n\n/** Composer chrome: the dock around the composer, its surface and its rows. */\nexport const COMPOSER_DOCK_CLASS = \"bg-background px-2.5 pb-2 pt-1.5\";\nexport const COMPOSER_SURFACE_CLASS =\n \"relative flex flex-col gap-1 rounded-xl border border-neutral-200 bg-white shadow-[0_2px_10px_rgba(54,45,33,0.08)]\";\nexport const COMPOSER_EDITOR_ROW_CLASS = \"px-2.5 pt-1\";\nexport const COMPOSER_TOOLBAR_CLASS =\n \"flex items-center gap-1 border-t border-neutral-100 px-2 py-1.5\";\n/**\n * Paper composer chrome (`ChatComposerDock appearance=\"paper\"`): a card-toned\n * surface with a larger radius, a focus-within ring, a drag-over tint keyed\n * off `data-drag-active`, and a bottom rail — the chrome the SDK's\n * `AthenaChat` thread renders. Hosts on the default chrome above are\n * untouched. The dock carries no padding of its own; the paper host's footer\n * spaces it. The radius and border colour also bind to the `--composer-radius`\n * / `--composer-border` theme variables in `styles.css`.\n */\nexport const COMPOSER_PAPER_DOCK_CLASS = \"aui-composer-dock\";\nexport const COMPOSER_PAPER_SURFACE_CLASS =\n \"aui-composer-root relative flex w-full flex-col rounded-[1.375rem] border border-border bg-card p-2.5 text-card-foreground shadow-[0_1px_2px_rgba(0,0,0,0.04)] outline-none transition-shadow duration-150 focus-within:shadow-[0_8px_24px_-14px_rgba(0,0,0,0.25)] focus-within:ring-2 focus-within:ring-ring/40 data-[drag-active=true]:bg-primary/5 data-[drag-active=true]:ring-2 data-[drag-active=true]:ring-primary/40\";\nexport const COMPOSER_PAPER_EDITOR_ROW_CLASS = \"px-0.5\";\nexport const COMPOSER_PAPER_TOOLBAR_CLASS =\n \"aui-composer-action-wrapper relative flex items-center justify-between gap-1 pt-1\";\nexport const THREAD_SCROLL_TO_BOTTOM_CLASS =\n \"inline-flex items-center justify-center rounded-full border bg-background/80 p-1 shadow-sm backdrop-blur transition-opacity hover:bg-accent disabled:invisible\";\n\nconst ComposerStopIcon: FC = () => (\n <svg\n aria-hidden=\"true\"\n className=\"size-4\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n >\n <rect width=\"10\" height=\"10\" x=\"3\" y=\"3\" rx=\"2\" />\n </svg>\n);\n\nexport interface ComposerStopButtonProps {\n onStop: () => void;\n disabled?: boolean;\n title?: string;\n}\n\nexport interface ComposerSendButtonProps {\n action: Extract<ComposerAction, \"send\" | \"queue\">;\n onSend: () => void;\n disabled?: boolean;\n title?: string;\n}\n\n/** Stop control shown while a run is in flight and there is nothing queued. */\nexport const ComposerStopButton: FC<ComposerStopButtonProps> = ({\n onStop,\n disabled = false,\n title = \"Stop generation\",\n}) => (\n <button\n type=\"button\"\n onClick={onStop}\n disabled={disabled}\n title={title}\n className={cn(\n \"inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-foreground text-background shadow-sm transition-colors hover:bg-foreground/80\",\n disabled && \"cursor-not-allowed opacity-60\",\n )}\n >\n <ComposerStopIcon />\n </button>\n);\n/** Send control, which becomes a queue control while a run is in flight. */\nexport const ComposerSendButton: FC<ComposerSendButtonProps> = ({\n action,\n onSend,\n disabled = false,\n title,\n}) => (\n <button\n type=\"button\"\n onClick={onSend}\n disabled={disabled}\n title={title ?? (action === \"queue\" ? \"Queue message\" : \"Send\")}\n className={cn(\n \"inline-flex size-8 shrink-0 items-center justify-center rounded-full shadow-sm transition-colors\",\n disabled\n ? \"cursor-not-allowed bg-muted text-muted-foreground opacity-60\"\n : \"bg-foreground text-background hover:bg-foreground/80\",\n )}\n >\n {action === \"queue\" ? (\n <ListPlusIcon className=\"size-4\" />\n ) : (\n <ArrowUpIcon className=\"size-4\" />\n )}\n </button>\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6DO,MAAM,eAAmB,MAC9B;AAAA,EAAC,sBAAsB;AAAA,EAAtB;AAAA,IACC,sBAAoB;AAAA,IACpB,WAAU;AAAA,IACV,eAAY;AAAA,IAEZ,UAAA;AAAA,MAAA,oBAAC,sBAAsB,UAAtB,EAA+B,SAAO,MACrC,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,SA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,KAAI,GAAE,KAAI,IAAG,IAAA,CAAI;AAAA,EAAA;AAClD;AAiBK,MAAM,qBAAkD,CAAC;AAAA,EAC9D;AAAA,EACA,WAAW;AAAA,EACX,QAAQ;AACV,MACE;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,MAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA,YAAY;AAAA,IAAA;AAAA,IAGd,8BAAC,kBAAA,CAAA,CAAiB;AAAA,EAAA;AACpB;AAGK,MAAM,qBAAkD,CAAC;AAAA,EAC9D;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,MACE;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,MAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA,OAAO,UAAU,WAAW,UAAU,kBAAkB;AAAA,IACxD,WAAW;AAAA,MACT;AAAA,MACA,WACI,iEACA;AAAA,IAAA;AAAA,IAGL,UAAA,WAAW,UACV,oBAAC,cAAA,EAAa,WAAU,UAAS,IAEjC,oBAAC,aAAA,EAAY,WAAU,SAAA,CAAS;AAAA,EAAA;AAEpC;"}
|
|
1
|
+
{"version":3,"file":"message-components.js","sources":["../../../src/chat-ui/messages/message-components.tsx"],"sourcesContent":["import {\n ActionBarPrimitive,\n AuiIf,\n BranchPickerPrimitive,\n MessagePrimitive,\n useAuiState,\n useMessagePartText,\n useSmooth,\n type ToolCallMessagePartComponent,\n} from \"@assistant-ui/react\";\nimport {\n CHAT_EDIT_UNREACHABLE_LABEL,\n DEEP_AGENT_COMPOSER_MARKDOWN_KEY,\n hideUnterminatedMarkdownLink,\n inboundMessageBody,\n isGithubWakeMessage,\n isSubscriptionWakeMessage,\n isVoiceDelegationMessage,\n readDeepAgentComposerMarkdown,\n readRuntimeMessageFromSourceMessages,\n readSoleRuntimeMessageKind,\n useChatOutboxReachable,\n useDeepAgentChatOutboxContext,\n} from \"@athenaintel/agent-runtime\";\nimport {\n ArrowUpIcon,\n CheckIcon,\n ChevronLeftIcon,\n ChevronRightIcon,\n CopyIcon,\n ListPlusIcon,\n PencilIcon,\n RefreshCwIcon,\n} from \"lucide-react\";\nimport {\n type FC,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport { useAthenaRunLive } from \"../../chat/use-athena-run-live\";\nimport type { ComposerAction } from \"../composer/composer-action\";\nimport { cn } from \"../../lib/utils\";\nimport { ChatMessageBody } from \"../rich-text/chat-message-body\";\nimport { AnswerLabel } from \"./answer-label\";\nimport { InboundChannelLine, InboundChannelSubject, useUserMessageCopy } from \"./inbound-channel-message\";\nimport { useMessageActionsReadOnly } from \"./message-actions-config\";\nimport { MessageImageGallery, MessageImagePart } from \"./message-images\";\nimport { RuntimeMessageCard } from \"./runtime-message\";\nimport { hasVisibleContent } from \"./running-indicator\";\nimport { VoiceDelegationMessage } from \"./voice-delegation-card\";\nimport { WakeMarkerMessage } from \"./wake-marker\";\nimport { SmallIconButton } from \"./thread-chrome\";\n\nexport {\n IconButton,\n SmallIconButton,\n THREAD_HEADER_ACTIONS_CLASS,\n THREAD_HEADER_CLASS,\n THREAD_HEADER_ICON_CLASS,\n THREAD_HEADER_PILL_CLASS,\n THREAD_PANEL_CLASS,\n} from \"./thread-chrome\";\n\nexport const BranchPicker: FC = () => (\n <BranchPickerPrimitive.Root\n hideWhenSingleBranch\n className=\"inline-flex items-center gap-0.5 text-xs text-muted-foreground\"\n data-testid=\"chat-branch-picker\"\n >\n <BranchPickerPrimitive.Previous asChild>\n <SmallIconButton\n tooltip=\"Previous branch\"\n data-testid=\"chat-branch-previous\"\n >\n <ChevronLeftIcon className=\"size-3\" />\n </SmallIconButton>\n </BranchPickerPrimitive.Previous>\n <span className=\"font-medium\" data-testid=\"chat-branch-count\">\n <BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />\n </span>\n <BranchPickerPrimitive.Next asChild>\n <SmallIconButton tooltip=\"Next branch\" data-testid=\"chat-branch-next\">\n <ChevronRightIcon className=\"size-3\" />\n </SmallIconButton>\n </BranchPickerPrimitive.Next>\n </BranchPickerPrimitive.Root>\n);\n\nconst CopyActionButton: FC = () => (\n <ActionBarPrimitive.Copy asChild>\n <SmallIconButton tooltip=\"Copy\">\n <AuiIf condition={(state) => state.message.isCopied}>\n <CheckIcon className=\"size-3\" />\n </AuiIf>\n <AuiIf condition={(state) => !state.message.isCopied}>\n <CopyIcon className=\"size-3\" />\n </AuiIf>\n </SmallIconButton>\n </ActionBarPrimitive.Copy>\n);\n\n/**\n * The edit primitive does not check the runtime's edit capability itself —\n * clicking it on a runtime without one throws inside onPress, where no error\n * boundary can catch it — so the button must gate on the capability and, to\n * match the rewind semantics of `run/edit`, stay hidden while a run is live.\n * The read-only context covers threads the capability flags cannot: a host's\n * static `edit: true` still applies to fenced legacy conversations. While the\n * host's chat outbox says Athena can't be reached it is not offered: shown\n * disabled, its tooltip says why, and it comes back once Athena answers.\n */\nconst EditActionButton: FC = () => {\n const allowEdit = useAuiState((s) => s.thread.capabilities.edit);\n const isRunning = useAthenaRunLive();\n const readOnly = useMessageActionsReadOnly();\n const reachable = useChatOutboxReachable(useDeepAgentChatOutboxContext());\n if (!allowEdit || isRunning || readOnly) return null;\n if (!reachable) {\n return (\n <SmallIconButton\n tooltip={CHAT_EDIT_UNREACHABLE_LABEL}\n aria-disabled\n data-testid=\"chat-message-edit-unreachable\"\n className=\"cursor-not-allowed opacity-50 hover:bg-transparent hover:text-muted-foreground\"\n >\n <PencilIcon className=\"size-3\" />\n </SmallIconButton>\n );\n }\n return (\n <ActionBarPrimitive.Edit asChild>\n <SmallIconButton tooltip=\"Edit\" data-testid=\"chat-message-edit\">\n <PencilIcon className=\"size-3\" />\n </SmallIconButton>\n </ActionBarPrimitive.Edit>\n );\n};\n\n/** Regenerate dispatches `run/reload`, so it hides on read-only threads too. */\nconst RegenerateActionButton: FC = () => {\n const readOnly = useMessageActionsReadOnly();\n if (readOnly) return null;\n return (\n <ActionBarPrimitive.Reload asChild>\n <SmallIconButton tooltip=\"Regenerate\">\n <RefreshCwIcon className=\"size-3\" />\n </SmallIconButton>\n </ActionBarPrimitive.Reload>\n );\n};\n\n/**\n * Reveal-on-demand treatment for action bars: invisible and click-through\n * until the surrounding named group is hovered or a control inside receives\n * keyboard focus. The `focus-within` escape hatch is what keeps the hidden\n * controls reachable for keyboard users.\n */\nexport const ACTION_BAR_REVEAL_CLASS =\n \"pointer-events-none opacity-0 transition-opacity focus-within:pointer-events-auto focus-within:opacity-100\";\n\n/** Shared chat body; the reveal holds incomplete links until their URL is complete. */\nexport const MarkdownText: FC = () => {\n const revealed = useSmooth(useMessagePartText(), true);\n const isRunning = revealed.status.type === \"running\";\n const text = isRunning ? hideUnterminatedMarkdownLink(revealed.text) : revealed.text;\n return <ChatMessageBody text={text} isRunning={isRunning} />;\n};\n\n/**\n * A user message's text, shown as it was typed.\n *\n * A composer sends plain text exactly as typed, because the model reads it\n * literally, so the text alone no longer says which characters are\n * formatting: read as Markdown, `List<T>` loses `<T>`, `obj.__init__` shows a\n * bold \"init\" and `a\\\\b` one backslash. A composer send therefore carries the\n * draft it was serialized from (`metadata.composer_markdown`, only when the\n * two differ), and this renders that draft when it is a draft of the\n * message's own text (`readDeepAgentComposerMarkdown`), formatting and\n * mention chips included. Any other text — no draft, or one of other words —\n * renders with the typed reading (`ChatMessageBody typed`), which leaves raw\n * HTML and underscore emphasis as the characters they were typed with, so\n * `List<T>`, `obj.__init__` and `a\\b` show as typed there too.\n *\n * A message that came in over a channel (Slack, email, a text, Teams) starts\n * with the routing block the agent read (`<inbound-message-context>`); it\n * shows without it, as the words that were sent (`inboundMessageBody`), and\n * the line above the bubble opens the block (`InboundChannelSource`). Only a\n * message with the channel's `inbound_channel` envelope is one: tags a person\n * typed at the start of a chat message show as typed.\n *\n * Copy copies the message text, which is the text as sent, and Edit opens it\n * in a plain-text box, so neither reads the draft.\n */\nexport const UserMessageText: FC<{ text: string }> = ({ text }) => {\n const custom = useAuiState((s) => s.message.metadata?.custom);\n const shown = useMemo(() => {\n const body = inboundMessageBody({ custom, text });\n return (\n readDeepAgentComposerMarkdown({\n metadata: { [DEEP_AGENT_COMPOSER_MARKDOWN_KEY]: custom?.[DEEP_AGENT_COMPOSER_MARKDOWN_KEY] },\n text: body,\n }) ?? body\n );\n }, [custom, text]);\n return <ChatMessageBody text={shown} typed />;\n};\n\n/** A user message's parts: its text as typed, and its pictures, each opening the viewer. */\nconst USER_MESSAGE_PART_COMPONENTS = { Text: UserMessageText, Image: MessageImagePart };\n\n/** Copy on a user bubble copies what the bubble shows (`useUserMessageCopy`). */\nconst UserCopyActionButton: FC = () => {\n const { copy, disabled, isCopied } = useUserMessageCopy();\n return (\n <SmallIconButton\n tooltip=\"Copy\"\n onClick={copy}\n disabled={disabled}\n data-copied={isCopied ? \"true\" : undefined}\n >\n {isCopied ? <CheckIcon className=\"size-3\" /> : <CopyIcon className=\"size-3\" />}\n </SmallIconButton>\n );\n};\n\nconst UserActionBar: FC = () => (\n <ActionBarPrimitive.Root\n autohide=\"never\"\n className={cn(\n \"flex min-h-6 items-center gap-0.5\",\n ACTION_BAR_REVEAL_CLASS,\n \"group-hover/user-message:pointer-events-auto group-hover/user-message:opacity-100\",\n )}\n >\n <UserCopyActionButton />\n <EditActionButton />\n </ActionBarPrimitive.Root>\n);\n\nexport const UserMessage: FC = () => {\n // A GitHub wake or a subscription's delivery is an event, not words the\n // user typed: it renders as the compact wake marker instead of a bubble\n // quoting the injected text.\n const isWake = useAuiState(\n (s) =>\n isGithubWakeMessage(s.message.metadata?.custom) ||\n isSubscriptionWakeMessage(s.message.metadata?.custom),\n );\n // A voice delegation's anchor is the ask the live voice model handed to the\n // thread, not words the user typed: it renders as the shared voice-task\n // card on every host instead of a second user bubble under the spoken turn.\n const isVoiceDelegation = useAuiState((s) =>\n isVoiceDelegationMessage({ messageId: s.message.id, custom: s.message.metadata?.custom }),\n );\n if (isWake) {\n return (\n <MessagePrimitive.Root data-message-role=\"user\" className=\"mb-3\">\n <WakeMarkerMessage />\n </MessagePrimitive.Root>\n );\n }\n if (isVoiceDelegation) {\n return (\n <MessagePrimitive.Root data-message-role=\"user\" className=\"mb-3\">\n <VoiceDelegationMessage />\n </MessagePrimitive.Root>\n );\n }\n return (\n <MessagePrimitive.Root\n data-message-role=\"user\"\n className=\"group/user-message mb-3 flex justify-end\"\n >\n <div className=\"flex min-w-0 max-w-[85%] flex-col items-end gap-1\">\n {/* A message that came in over a channel: the line naming the channel\n and the sender, above the words that were sent. */}\n <InboundChannelLine />\n <div className=\"min-w-0 max-w-full rounded-2xl rounded-br-md bg-muted px-3.5 py-2 text-sm text-foreground\">\n <InboundChannelSubject />\n <MessageImageGallery>\n <MessagePrimitive.Content components={USER_MESSAGE_PART_COMPONENTS} />\n </MessageImageGallery>\n </div>\n <div className=\"flex min-h-6 items-center gap-1\">\n <BranchPicker />\n <UserActionBar />\n </div>\n </div>\n </MessagePrimitive.Root>\n );\n};\n\nexport interface CreateAssistantMessageOptions {\n /** Host-registered card for tools without a dedicated UI. */\n toolFallback: ToolCallMessagePartComponent;\n /** Extra action-bar controls appended after copy/regenerate. */\n extraActions?: ReactNode;\n /**\n * Renders the message body. Hosts that group content into activity\n * timelines supply their own; the default renders markdown and tool cards.\n */\n content?: FC;\n /**\n * Inline affordance rendered inside a runtime-ending card (e.g. a Continue\n * button). Hosts without one leave it unset.\n */\n runtimeMessageAction?: ReactNode;\n}\n\n/**\n * Builds the assistant bubble. Call this once per host (memoized on its\n * inputs) so the returned component identity stays stable across renders.\n */\nexport function createAssistantMessage({\n toolFallback,\n extraActions,\n content: Content,\n runtimeMessageAction,\n}: CreateAssistantMessageOptions): FC {\n const AssistantActionBar: FC = () => {\n // The latest reply keeps its actions visible; older replies reveal them\n // on hover so a long transcript is not a wall of icon rows.\n const isLast = useAuiState((s) => s.message.isLast);\n return (\n <ActionBarPrimitive.Root\n autohide=\"never\"\n className={cn(\n \"mt-1 flex min-h-6 items-center gap-0.5\",\n !isLast && [\n ACTION_BAR_REVEAL_CLASS,\n \"group-hover/assistant-message:pointer-events-auto group-hover/assistant-message:opacity-100\",\n ],\n )}\n >\n <CopyActionButton />\n <RegenerateActionButton />\n {extraActions}\n </ActionBarPrimitive.Root>\n );\n };\n\n // A run-lifecycle marker or handoff summary is a system event, not\n // assistant speech. When it owns the whole row, render the status card in\n // place of the bubble; when it is chunked in with the assistant's own work\n // (or is a handoff whose text IS the closing summary), keep the body and\n // frame it with the card above.\n const RuntimeEnding: FC<{ placement: \"row\" | \"banner\" }> = ({ placement }) => {\n // Select the message (a stable store reference) and derive from it: the\n // reader allocates a fresh object per call, and `useAuiState` compares\n // snapshots with `Object.is`, so selecting the reader's result directly\n // would re-render on every store update and trip React's update-depth\n // guard.\n const message = useAuiState((s) => s.message);\n const runtime = useMemo(() => readRuntimeMessageFromSourceMessages(message), [message]);\n if (!runtime || runtime.silent) return null;\n if (placement === \"row\" && !runtime.isSoleSourceMessage) return null;\n if (placement === \"banner\" && runtime.isSoleSourceMessage && runtime.kind !== \"handoff\") {\n return null;\n }\n return <RuntimeMessageCard message={runtime} action={runtimeMessageAction} />;\n };\n\n const AssistantMessage: FC = () => {\n // An assistant row exists before its first token streams; showing\n // copy/regenerate against nothing looks broken, so wait for content.\n const showActions = useAuiState((state) =>\n hasVisibleContent(state.message.content),\n );\n // Primitive selector: the reader builds a fresh object per call.\n const soleRuntimeKind = useAuiState((s) => readSoleRuntimeMessageKind(s.message));\n const soleRuntimeSilent = useAuiState(\n (s) => readRuntimeMessageFromSourceMessages(s.message)?.silent === true,\n );\n\n if (soleRuntimeKind && soleRuntimeKind !== \"handoff\") {\n if (soleRuntimeSilent) return null;\n return (\n <MessagePrimitive.Root\n data-message-role=\"assistant\"\n className=\"group group/assistant-message mb-3\"\n >\n <div className=\"max-w-[95%]\">\n <RuntimeEnding placement=\"row\" />\n </div>\n </MessagePrimitive.Root>\n );\n }\n\n return (\n <MessagePrimitive.Root\n data-message-role=\"assistant\"\n className=\"group group/assistant-message mb-3\"\n >\n <div className=\"max-w-[95%]\">\n <AnswerLabel className=\"mb-1\" />\n <RuntimeEnding placement=\"banner\" />\n {Content ? (\n <Content />\n ) : (\n <MessagePrimitive.Content\n components={{\n Text: MarkdownText,\n tools: { Fallback: toolFallback },\n }}\n />\n )}\n {showActions ? (\n <div className=\"flex min-h-6 items-center gap-1\">\n <BranchPicker />\n <AssistantActionBar />\n </div>\n ) : null}\n </div>\n </MessagePrimitive.Root>\n );\n };\n\n return AssistantMessage;\n}\n\n/** Composer chrome: the dock around the composer, its surface and its rows. */\nexport const COMPOSER_DOCK_CLASS = \"bg-background px-2.5 pb-2 pt-1.5\";\nexport const COMPOSER_SURFACE_CLASS =\n \"relative flex flex-col gap-1 rounded-xl border border-neutral-200 bg-white shadow-[0_2px_10px_rgba(54,45,33,0.08)]\";\nexport const COMPOSER_EDITOR_ROW_CLASS = \"px-2.5 pt-1\";\nexport const COMPOSER_TOOLBAR_CLASS =\n \"flex items-center gap-1 border-t border-neutral-100 px-2 py-1.5\";\n/**\n * Paper composer chrome (`ChatComposerDock appearance=\"paper\"`): a card-toned\n * surface with a larger radius, a focus-within ring, a drag-over tint keyed\n * off `data-drag-active`, and a bottom rail — the chrome the SDK's\n * `AthenaChat` thread renders. Hosts on the default chrome above are\n * untouched. The dock carries no padding of its own; the paper host's footer\n * spaces it. The radius and border colour also bind to the `--composer-radius`\n * / `--composer-border` theme variables in `styles.css`.\n */\nexport const COMPOSER_PAPER_DOCK_CLASS = \"aui-composer-dock\";\nexport const COMPOSER_PAPER_SURFACE_CLASS =\n \"aui-composer-root relative flex w-full flex-col rounded-[1.375rem] border border-border bg-card p-2.5 text-card-foreground shadow-[0_1px_2px_rgba(0,0,0,0.04)] outline-none transition-shadow duration-150 focus-within:shadow-[0_8px_24px_-14px_rgba(0,0,0,0.25)] focus-within:ring-2 focus-within:ring-ring/40 data-[drag-active=true]:bg-primary/5 data-[drag-active=true]:ring-2 data-[drag-active=true]:ring-primary/40\";\nexport const COMPOSER_PAPER_EDITOR_ROW_CLASS = \"px-0.5\";\nexport const COMPOSER_PAPER_TOOLBAR_CLASS =\n \"aui-composer-action-wrapper relative flex items-center justify-between gap-1 pt-1\";\nexport const THREAD_SCROLL_TO_BOTTOM_CLASS =\n \"inline-flex items-center justify-center rounded-full border bg-background/80 p-1 shadow-sm backdrop-blur transition-opacity hover:bg-accent disabled:invisible\";\n\nconst ComposerStopIcon: FC = () => (\n <svg\n aria-hidden=\"true\"\n className=\"size-4\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n >\n <rect width=\"10\" height=\"10\" x=\"3\" y=\"3\" rx=\"2\" />\n </svg>\n);\n\nexport interface ComposerStopButtonProps {\n onStop: () => void;\n disabled?: boolean;\n title?: string;\n}\n\nexport interface ComposerSendButtonProps {\n action: Extract<ComposerAction, \"send\" | \"queue\">;\n onSend: () => void;\n disabled?: boolean;\n title?: string;\n}\n\n/** Stop control shown while a run is in flight and there is nothing queued. */\nexport const ComposerStopButton: FC<ComposerStopButtonProps> = ({\n onStop,\n disabled = false,\n title = \"Stop generation\",\n}) => (\n <button\n type=\"button\"\n onClick={onStop}\n disabled={disabled}\n title={title}\n className={cn(\n \"inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-foreground text-background shadow-sm transition-colors hover:bg-foreground/80\",\n disabled && \"cursor-not-allowed opacity-60\",\n )}\n >\n <ComposerStopIcon />\n </button>\n);\n/** Send control, which becomes a queue control while a run is in flight. */\nexport const ComposerSendButton: FC<ComposerSendButtonProps> = ({\n action,\n onSend,\n disabled = false,\n title,\n}) => (\n <button\n type=\"button\"\n onClick={onSend}\n disabled={disabled}\n title={title ?? (action === \"queue\" ? \"Queue message\" : \"Send\")}\n className={cn(\n \"inline-flex size-8 shrink-0 items-center justify-center rounded-full shadow-sm transition-colors\",\n disabled\n ? \"cursor-not-allowed bg-muted text-muted-foreground opacity-60\"\n : \"bg-foreground text-background hover:bg-foreground/80\",\n )}\n >\n {action === \"queue\" ? (\n <ListPlusIcon className=\"size-4\" />\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AAA,IACT;AAAA,IACA,OAAO,UAAU,WAAW,UAAU,kBAAkB;AAAA,IACxD,WAAW;AAAA,MACT;AAAA,MACA,WACI,iEACA;AAAA,IAAA;AAAA,IAGL,UAAA,WAAW,UACV,oBAAC,cAAA,EAAa,WAAU,UAAS,IAEjC,oBAAC,aAAA,EAAY,WAAU,SAAA,CAAS;AAAA,EAAA;AAEpC;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const SIGN_BACK_IN_DRAFT_KEY = "athena:sign-back-in-draft";
|
|
4
|
+
const SIGN_BACK_IN_DRAFT_TTL_MS = 10 * 60 * 1e3;
|
|
5
|
+
function isKeptDraft(value) {
|
|
6
|
+
if (!value || typeof value !== "object") return false;
|
|
7
|
+
const candidate = value;
|
|
8
|
+
return candidate.v === 1 && typeof candidate.principal === "string" && typeof candidate.threadId === "string" && typeof candidate.isNewChat === "boolean" && typeof candidate.text === "string" && typeof candidate.at === "number" && Number.isFinite(candidate.at);
|
|
9
|
+
}
|
|
10
|
+
function forgetKeptDraft() {
|
|
11
|
+
try {
|
|
12
|
+
window.sessionStorage.removeItem(SIGN_BACK_IN_DRAFT_KEY);
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function keepDraftForSignBackIn({
|
|
17
|
+
principal,
|
|
18
|
+
threadId,
|
|
19
|
+
isNewChat,
|
|
20
|
+
text,
|
|
21
|
+
now = Date.now()
|
|
22
|
+
}) {
|
|
23
|
+
if (typeof window === "undefined" || !principal || text.trim() === "") return;
|
|
24
|
+
const kept = { v: 1, principal, threadId, isNewChat, text, at: now };
|
|
25
|
+
try {
|
|
26
|
+
window.sessionStorage.setItem(SIGN_BACK_IN_DRAFT_KEY, JSON.stringify(kept));
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function takeDraftKeptForSignBackIn({
|
|
31
|
+
principal,
|
|
32
|
+
threadId,
|
|
33
|
+
isNewChat,
|
|
34
|
+
now = Date.now()
|
|
35
|
+
}) {
|
|
36
|
+
if (typeof window === "undefined" || !principal) return null;
|
|
37
|
+
let raw;
|
|
38
|
+
try {
|
|
39
|
+
raw = window.sessionStorage.getItem(SIGN_BACK_IN_DRAFT_KEY);
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (raw === null) return null;
|
|
44
|
+
let kept;
|
|
45
|
+
try {
|
|
46
|
+
kept = JSON.parse(raw);
|
|
47
|
+
} catch {
|
|
48
|
+
kept = null;
|
|
49
|
+
}
|
|
50
|
+
if (!isKeptDraft(kept) || kept.principal !== principal || now - kept.at > SIGN_BACK_IN_DRAFT_TTL_MS || kept.at > now + 6e4) {
|
|
51
|
+
forgetKeptDraft();
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const sameConversation = kept.isNewChat ? isNewChat : kept.threadId === threadId;
|
|
55
|
+
if (!sameConversation) return null;
|
|
56
|
+
forgetKeptDraft();
|
|
57
|
+
return kept.text;
|
|
58
|
+
}
|
|
59
|
+
exports.SIGN_BACK_IN_DRAFT_TTL_MS = SIGN_BACK_IN_DRAFT_TTL_MS;
|
|
60
|
+
exports.keepDraftForSignBackIn = keepDraftForSignBackIn;
|
|
61
|
+
exports.takeDraftKeptForSignBackIn = takeDraftKeptForSignBackIn;
|
|
62
|
+
//# sourceMappingURL=sign-back-in-draft.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-back-in-draft.cjs","sources":["../../src/composer/sign-back-in-draft.ts"],"sourcesContent":["/**\n * The composer's draft across the SDK's own trip through sign-in\n * (`auth/sign-back-in.ts`). Right before the page leaves, the draft is kept in\n * this tab's `sessionStorage`; when the page returns, it goes back into the\n * same conversation's composer, for the same person, once.\n *\n * Kept only for a known person (a sign-in provider above `AthenaProvider`\n * names them) and for {@link SIGN_BACK_IN_DRAFT_TTL_MS} at most. A draft kept\n * for someone else is deleted unread: whoever signs in next in this tab never\n * sees it.\n */\n\nconst SIGN_BACK_IN_DRAFT_KEY = 'athena:sign-back-in-draft';\n\n/** How long a kept draft waits for the page that returns. */\nexport const SIGN_BACK_IN_DRAFT_TTL_MS = 10 * 60 * 1000;\n\ninterface KeptDraft {\n v: 1;\n principal: string;\n threadId: string;\n /** A conversation not started yet: its id is new on every page, so it matches any new chat. */\n isNewChat: boolean;\n text: string;\n at: number;\n}\n\nfunction isKeptDraft(value: unknown): value is KeptDraft {\n if (!value || typeof value !== 'object') return false;\n const candidate = value as Partial<Record<keyof KeptDraft, unknown>>;\n return (\n candidate.v === 1 &&\n typeof candidate.principal === 'string' &&\n typeof candidate.threadId === 'string' &&\n typeof candidate.isNewChat === 'boolean' &&\n typeof candidate.text === 'string' &&\n typeof candidate.at === 'number' &&\n Number.isFinite(candidate.at)\n );\n}\n\nfunction forgetKeptDraft(): void {\n try {\n window.sessionStorage.removeItem(SIGN_BACK_IN_DRAFT_KEY);\n } catch {\n // Nothing was kept where storage is unavailable.\n }\n}\n\n/** Keeps `text` for the page that returns from sign-in; nothing for an empty draft or an unknown person. */\nexport function keepDraftForSignBackIn({\n principal,\n threadId,\n isNewChat,\n text,\n now = Date.now(),\n}: {\n principal: string;\n threadId: string;\n isNewChat: boolean;\n text: string;\n /** Test seam. */\n now?: number;\n}): void {\n if (typeof window === 'undefined' || !principal || text.trim() === '') return;\n const kept: KeptDraft = { v: 1, principal, threadId, isNewChat, text, at: now };\n try {\n window.sessionStorage.setItem(SIGN_BACK_IN_DRAFT_KEY, JSON.stringify(kept));\n } catch {\n // Storage full or unavailable: the draft goes with the page, as it did before.\n }\n}\n\n/**\n * The draft kept for this person and conversation, read once (it is deleted),\n * or `null`. A draft kept for another conversation waits for that one; one\n * that is stale, unreadable, or kept for someone else is deleted unread.\n */\nexport function takeDraftKeptForSignBackIn({\n principal,\n threadId,\n isNewChat,\n now = Date.now(),\n}: {\n principal: string;\n threadId: string;\n isNewChat: boolean;\n /** Test seam. */\n now?: number;\n}): string | null {\n if (typeof window === 'undefined' || !principal) return null;\n let raw: string | null;\n try {\n raw = window.sessionStorage.getItem(SIGN_BACK_IN_DRAFT_KEY);\n } catch {\n return null;\n }\n if (raw === null) return null;\n let kept: unknown;\n try {\n kept = JSON.parse(raw);\n } catch {\n kept = null;\n }\n if (\n !isKeptDraft(kept) ||\n kept.principal !== principal ||\n now - kept.at > SIGN_BACK_IN_DRAFT_TTL_MS ||\n kept.at > now + 60_000\n ) {\n forgetKeptDraft();\n return null;\n }\n const sameConversation = kept.isNewChat ? isNewChat : kept.threadId === threadId;\n if (!sameConversation) return null;\n forgetKeptDraft();\n return kept.text;\n}\n"],"names":[],"mappings":";;AAYA,MAAM,yBAAyB;AAGxB,MAAM,4BAA4B,KAAK,KAAK;AAYnD,SAAS,YAAY,OAAoC;AACvD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,YAAY;AAClB,SACE,UAAU,MAAM,KAChB,OAAO,UAAU,cAAc,YAC/B,OAAO,UAAU,aAAa,YAC9B,OAAO,UAAU,cAAc,aAC/B,OAAO,UAAU,SAAS,YAC1B,OAAO,UAAU,OAAO,YACxB,OAAO,SAAS,UAAU,EAAE;AAEhC;AAEA,SAAS,kBAAwB;AAC/B,MAAI;AACF,WAAO,eAAe,WAAW,sBAAsB;AAAA,EACzD,QAAQ;AAAA,EAER;AACF;AAGO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM,KAAK,IAAA;AACb,GAOS;AACP,MAAI,OAAO,WAAW,eAAe,CAAC,aAAa,KAAK,KAAA,MAAW,GAAI;AACvE,QAAM,OAAkB,EAAE,GAAG,GAAG,WAAW,UAAU,WAAW,MAAM,IAAI,IAAA;AAC1E,MAAI;AACF,WAAO,eAAe,QAAQ,wBAAwB,KAAK,UAAU,IAAI,CAAC;AAAA,EAC5E,QAAQ;AAAA,EAER;AACF;AAOO,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM,KAAK,IAAA;AACb,GAMkB;AAChB,MAAI,OAAO,WAAW,eAAe,CAAC,UAAW,QAAO;AACxD,MAAI;AACJ,MAAI;AACF,UAAM,OAAO,eAAe,QAAQ,sBAAsB;AAAA,EAC5D,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAM,QAAO;AACzB,MAAI;AACJ,MAAI;AACF,WAAO,KAAK,MAAM,GAAG;AAAA,EACvB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MACE,CAAC,YAAY,IAAI,KACjB,KAAK,cAAc,aACnB,MAAM,KAAK,KAAK,6BAChB,KAAK,KAAK,MAAM,KAChB;AACA,oBAAA;AACA,WAAO;AAAA,EACT;AACA,QAAM,mBAAmB,KAAK,YAAY,YAAY,KAAK,aAAa;AACxE,MAAI,CAAC,iBAAkB,QAAO;AAC9B,kBAAA;AACA,SAAO,KAAK;AACd;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The composer's draft across the SDK's own trip through sign-in
|
|
3
|
+
* (`auth/sign-back-in.ts`). Right before the page leaves, the draft is kept in
|
|
4
|
+
* this tab's `sessionStorage`; when the page returns, it goes back into the
|
|
5
|
+
* same conversation's composer, for the same person, once.
|
|
6
|
+
*
|
|
7
|
+
* Kept only for a known person (a sign-in provider above `AthenaProvider`
|
|
8
|
+
* names them) and for {@link SIGN_BACK_IN_DRAFT_TTL_MS} at most. A draft kept
|
|
9
|
+
* for someone else is deleted unread: whoever signs in next in this tab never
|
|
10
|
+
* sees it.
|
|
11
|
+
*/
|
|
12
|
+
/** How long a kept draft waits for the page that returns. */
|
|
13
|
+
export declare const SIGN_BACK_IN_DRAFT_TTL_MS: number;
|
|
14
|
+
/** Keeps `text` for the page that returns from sign-in; nothing for an empty draft or an unknown person. */
|
|
15
|
+
export declare function keepDraftForSignBackIn({ principal, threadId, isNewChat, text, now, }: {
|
|
16
|
+
principal: string;
|
|
17
|
+
threadId: string;
|
|
18
|
+
isNewChat: boolean;
|
|
19
|
+
text: string;
|
|
20
|
+
/** Test seam. */
|
|
21
|
+
now?: number;
|
|
22
|
+
}): void;
|
|
23
|
+
/**
|
|
24
|
+
* The draft kept for this person and conversation, read once (it is deleted),
|
|
25
|
+
* or `null`. A draft kept for another conversation waits for that one; one
|
|
26
|
+
* that is stale, unreadable, or kept for someone else is deleted unread.
|
|
27
|
+
*/
|
|
28
|
+
export declare function takeDraftKeptForSignBackIn({ principal, threadId, isNewChat, now, }: {
|
|
29
|
+
principal: string;
|
|
30
|
+
threadId: string;
|
|
31
|
+
isNewChat: boolean;
|
|
32
|
+
/** Test seam. */
|
|
33
|
+
now?: number;
|
|
34
|
+
}): string | null;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const SIGN_BACK_IN_DRAFT_KEY = "athena:sign-back-in-draft";
|
|
2
|
+
const SIGN_BACK_IN_DRAFT_TTL_MS = 10 * 60 * 1e3;
|
|
3
|
+
function isKeptDraft(value) {
|
|
4
|
+
if (!value || typeof value !== "object") return false;
|
|
5
|
+
const candidate = value;
|
|
6
|
+
return candidate.v === 1 && typeof candidate.principal === "string" && typeof candidate.threadId === "string" && typeof candidate.isNewChat === "boolean" && typeof candidate.text === "string" && typeof candidate.at === "number" && Number.isFinite(candidate.at);
|
|
7
|
+
}
|
|
8
|
+
function forgetKeptDraft() {
|
|
9
|
+
try {
|
|
10
|
+
window.sessionStorage.removeItem(SIGN_BACK_IN_DRAFT_KEY);
|
|
11
|
+
} catch {
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function keepDraftForSignBackIn({
|
|
15
|
+
principal,
|
|
16
|
+
threadId,
|
|
17
|
+
isNewChat,
|
|
18
|
+
text,
|
|
19
|
+
now = Date.now()
|
|
20
|
+
}) {
|
|
21
|
+
if (typeof window === "undefined" || !principal || text.trim() === "") return;
|
|
22
|
+
const kept = { v: 1, principal, threadId, isNewChat, text, at: now };
|
|
23
|
+
try {
|
|
24
|
+
window.sessionStorage.setItem(SIGN_BACK_IN_DRAFT_KEY, JSON.stringify(kept));
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function takeDraftKeptForSignBackIn({
|
|
29
|
+
principal,
|
|
30
|
+
threadId,
|
|
31
|
+
isNewChat,
|
|
32
|
+
now = Date.now()
|
|
33
|
+
}) {
|
|
34
|
+
if (typeof window === "undefined" || !principal) return null;
|
|
35
|
+
let raw;
|
|
36
|
+
try {
|
|
37
|
+
raw = window.sessionStorage.getItem(SIGN_BACK_IN_DRAFT_KEY);
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (raw === null) return null;
|
|
42
|
+
let kept;
|
|
43
|
+
try {
|
|
44
|
+
kept = JSON.parse(raw);
|
|
45
|
+
} catch {
|
|
46
|
+
kept = null;
|
|
47
|
+
}
|
|
48
|
+
if (!isKeptDraft(kept) || kept.principal !== principal || now - kept.at > SIGN_BACK_IN_DRAFT_TTL_MS || kept.at > now + 6e4) {
|
|
49
|
+
forgetKeptDraft();
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const sameConversation = kept.isNewChat ? isNewChat : kept.threadId === threadId;
|
|
53
|
+
if (!sameConversation) return null;
|
|
54
|
+
forgetKeptDraft();
|
|
55
|
+
return kept.text;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
SIGN_BACK_IN_DRAFT_TTL_MS,
|
|
59
|
+
keepDraftForSignBackIn,
|
|
60
|
+
takeDraftKeptForSignBackIn
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=sign-back-in-draft.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-back-in-draft.js","sources":["../../src/composer/sign-back-in-draft.ts"],"sourcesContent":["/**\n * The composer's draft across the SDK's own trip through sign-in\n * (`auth/sign-back-in.ts`). Right before the page leaves, the draft is kept in\n * this tab's `sessionStorage`; when the page returns, it goes back into the\n * same conversation's composer, for the same person, once.\n *\n * Kept only for a known person (a sign-in provider above `AthenaProvider`\n * names them) and for {@link SIGN_BACK_IN_DRAFT_TTL_MS} at most. A draft kept\n * for someone else is deleted unread: whoever signs in next in this tab never\n * sees it.\n */\n\nconst SIGN_BACK_IN_DRAFT_KEY = 'athena:sign-back-in-draft';\n\n/** How long a kept draft waits for the page that returns. */\nexport const SIGN_BACK_IN_DRAFT_TTL_MS = 10 * 60 * 1000;\n\ninterface KeptDraft {\n v: 1;\n principal: string;\n threadId: string;\n /** A conversation not started yet: its id is new on every page, so it matches any new chat. */\n isNewChat: boolean;\n text: string;\n at: number;\n}\n\nfunction isKeptDraft(value: unknown): value is KeptDraft {\n if (!value || typeof value !== 'object') return false;\n const candidate = value as Partial<Record<keyof KeptDraft, unknown>>;\n return (\n candidate.v === 1 &&\n typeof candidate.principal === 'string' &&\n typeof candidate.threadId === 'string' &&\n typeof candidate.isNewChat === 'boolean' &&\n typeof candidate.text === 'string' &&\n typeof candidate.at === 'number' &&\n Number.isFinite(candidate.at)\n );\n}\n\nfunction forgetKeptDraft(): void {\n try {\n window.sessionStorage.removeItem(SIGN_BACK_IN_DRAFT_KEY);\n } catch {\n // Nothing was kept where storage is unavailable.\n }\n}\n\n/** Keeps `text` for the page that returns from sign-in; nothing for an empty draft or an unknown person. */\nexport function keepDraftForSignBackIn({\n principal,\n threadId,\n isNewChat,\n text,\n now = Date.now(),\n}: {\n principal: string;\n threadId: string;\n isNewChat: boolean;\n text: string;\n /** Test seam. */\n now?: number;\n}): void {\n if (typeof window === 'undefined' || !principal || text.trim() === '') return;\n const kept: KeptDraft = { v: 1, principal, threadId, isNewChat, text, at: now };\n try {\n window.sessionStorage.setItem(SIGN_BACK_IN_DRAFT_KEY, JSON.stringify(kept));\n } catch {\n // Storage full or unavailable: the draft goes with the page, as it did before.\n }\n}\n\n/**\n * The draft kept for this person and conversation, read once (it is deleted),\n * or `null`. A draft kept for another conversation waits for that one; one\n * that is stale, unreadable, or kept for someone else is deleted unread.\n */\nexport function takeDraftKeptForSignBackIn({\n principal,\n threadId,\n isNewChat,\n now = Date.now(),\n}: {\n principal: string;\n threadId: string;\n isNewChat: boolean;\n /** Test seam. */\n now?: number;\n}): string | null {\n if (typeof window === 'undefined' || !principal) return null;\n let raw: string | null;\n try {\n raw = window.sessionStorage.getItem(SIGN_BACK_IN_DRAFT_KEY);\n } catch {\n return null;\n }\n if (raw === null) return null;\n let kept: unknown;\n try {\n kept = JSON.parse(raw);\n } catch {\n kept = null;\n }\n if (\n !isKeptDraft(kept) ||\n kept.principal !== principal ||\n now - kept.at > SIGN_BACK_IN_DRAFT_TTL_MS ||\n kept.at > now + 60_000\n ) {\n forgetKeptDraft();\n return null;\n }\n const sameConversation = kept.isNewChat ? isNewChat : kept.threadId === threadId;\n if (!sameConversation) return null;\n forgetKeptDraft();\n return kept.text;\n}\n"],"names":[],"mappings":"AAYA,MAAM,yBAAyB;AAGxB,MAAM,4BAA4B,KAAK,KAAK;AAYnD,SAAS,YAAY,OAAoC;AACvD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,YAAY;AAClB,SACE,UAAU,MAAM,KAChB,OAAO,UAAU,cAAc,YAC/B,OAAO,UAAU,aAAa,YAC9B,OAAO,UAAU,cAAc,aAC/B,OAAO,UAAU,SAAS,YAC1B,OAAO,UAAU,OAAO,YACxB,OAAO,SAAS,UAAU,EAAE;AAEhC;AAEA,SAAS,kBAAwB;AAC/B,MAAI;AACF,WAAO,eAAe,WAAW,sBAAsB;AAAA,EACzD,QAAQ;AAAA,EAER;AACF;AAGO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM,KAAK,IAAA;AACb,GAOS;AACP,MAAI,OAAO,WAAW,eAAe,CAAC,aAAa,KAAK,KAAA,MAAW,GAAI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