@frontera-sdk/chat-ui 1.53.30 → 1.53.32

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.
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { Sheet, SheetContent, SheetHeader, SheetTitle, Popover, PopoverTrigger, PopoverContent, MagnifyingGlassIcon } from './chunk-OONQIDAU.js';
3
- import { useIsMobile, useTranslation } from './chunk-XJ2UK4WV.js';
3
+ import { useIsMobile, useTranslation } from './chunk-7LCV3BV2.js';
4
4
  import { CrossMediumIcon } from './chunk-37WYG6VG.js';
5
5
  import { AgentAvatar } from './chunk-RCWVJD7G.js';
6
6
  import { cn, Checkmark1Icon } from './chunk-LGVMMBL3.js';
@@ -5,11 +5,20 @@ import { FronteraClient } from '@frontera-sdk/core/client';
5
5
  import { createTokenSession } from '@frontera-sdk/chat/token-session';
6
6
  import { mintPublicChatToken } from '@frontera-sdk/chat/public-token';
7
7
 
8
+ function usable(client) {
9
+ if (!client) return false;
10
+ try {
11
+ void client.config;
12
+ return true;
13
+ } catch {
14
+ return false;
15
+ }
16
+ }
8
17
  function useChatCredential(props) {
9
18
  const suppliedClient = props.client;
10
19
  const [ready, setReady] = useState(() => {
11
20
  if (!suppliedClient) return false;
12
- return typeof suppliedClient === "function" ? !!suppliedClient() : true;
21
+ return usable(typeof suppliedClient === "function" ? suppliedClient() : suppliedClient);
13
22
  });
14
23
  const [error, setError] = useState(null);
15
24
  const [openingMessage, setOpeningMessage] = useState(null);
@@ -24,10 +33,27 @@ function useChatCredential(props) {
24
33
  if (!suppliedClient) return null;
25
34
  return typeof suppliedClient === "function" ? suppliedClient : () => suppliedClient;
26
35
  }, [suppliedClient]);
27
- const pendingGetter = typeof suppliedClient === "function" && !ready;
36
+ const pending = !!staticClient && !ready;
28
37
  useEffect(() => {
29
- if (!pendingGetter) return;
30
- if (suppliedClient()) setReady(true);
38
+ if (!pending) return;
39
+ const client = staticClient();
40
+ if (!client) return;
41
+ if (usable(client)) {
42
+ setReady(true);
43
+ return;
44
+ }
45
+ let current = true;
46
+ void client.whenConnected().then(
47
+ () => {
48
+ if (current) setReady(true);
49
+ },
50
+ (failure) => {
51
+ if (current) setError(failure instanceof Error ? failure : new Error(String(failure)));
52
+ }
53
+ );
54
+ return () => {
55
+ current = false;
56
+ };
31
57
  });
32
58
  useEffect(() => {
33
59
  if (staticClient) {
@@ -95,7 +121,10 @@ function useChatCredential(props) {
95
121
  };
96
122
  }, [staticClient, staticToken, apiBaseUrl, tokenEndpoint, getToken, publishableKey]);
97
123
  const getClient = useMemo(
98
- () => staticClient ? () => staticClient() : () => sessionRef.current?.getClient() ?? clientRef.current,
124
+ () => staticClient ? () => {
125
+ const client = staticClient();
126
+ return usable(client) ? client : null;
127
+ } : () => sessionRef.current?.getClient() ?? clientRef.current,
99
128
  [staticClient]
100
129
  );
101
130
  const refresh = useCallback(async () => sessionRef.current?.refresh(), []);
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useTranslation } from './chunk-XJ2UK4WV.js';
2
+ import { useTranslation } from './chunk-7LCV3BV2.js';
3
3
  import { Skeleton } from './chunk-UWKO24VT.js';
4
4
  import { useRef, useState, useEffect } from 'react';
5
5
  import { jsx, jsxs } from 'react/jsx-runtime';
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { getToolMeta } from './chunk-K7AIK7TA.js';
2
+ import { getToolMeta } from './chunk-6YDDHBQC.js';
3
3
  import { Button } from './chunk-UWKO24VT.js';
4
4
  import { ChevronDownMediumIcon, CrossMediumIcon } from './chunk-EZX3E3BB.js';
5
5
  import { useChatClientOptional } from './chunk-6JLWE7M3.js';
@@ -1,8 +1,8 @@
1
1
  'use client';
2
- import { usePlugins, useChatCapabilityEnabled, resolvePluginLanguage, renderPluginBlock, AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, ActionMenu, useArtifactStore, ArtifactActionsMenu, DotGrid1x3HorizontalTightIcon, useArtifact, resolveArtifactIconFormat, artifactFormatIcon, useArtifactFileObjectUrl, artifactFormatSubtitle, ChatImageLightbox, ArrowsShowIcon, FileDownloadIcon, useClient, processMessageParts, getMessageDisplayTimestampValue, getMessageCreatedAtMs, isApprovalRequested, extractCitationsFromSteps, useSourcesEnrichment, extractImagesFromSteps, dedupeImageResults, getDocumentStreamArtifacts, getToolOutput, useCanvasStore, ImageResultsGallery, MessageDecisionCards, useChatCapabilities, useOptionalWorkspaceContext, useCitationViewer, useCitedDocument, useChatOverviewStore, dedup, extractDomain, sourceKind, SourceFavicon, Input, exportDocumentPdf, FilePdfIcon, StudioDisplayIcon, WorldIcon, MessageStepsGroup, getToolState, getToolInput, getToolErrorText, useChatOptInEnabled, ArrowRightIcon, formatFileSize, FileThumbnail, attachmentFileOf, MobileScreenSheet, useAgentHistorySource, treatyErrorMessage, useRouter, useBasePath, useAgentPanelStore, AgentRoutineForm, getFileCategory, unwrap, unwrapData, unwrapDataDeep, formatDecisionTime, DecisionCard, LoaderIcon, formatRelativeTime, CircleCheckIcon, agentRoutineKeys, useOptionalAgentsContext, avatarMotionForStream, AGENT_AVATAR_SIZE } from './chunk-HWZY3ZTZ.js';
2
+ import { usePlugins, useChatCapabilityEnabled, resolvePluginLanguage, renderPluginBlock, AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, ActionMenu, useArtifactStore, ArtifactActionsMenu, DotGrid1x3HorizontalTightIcon, useArtifact, resolveArtifactIconFormat, artifactFormatIcon, useArtifactFileObjectUrl, artifactFormatSubtitle, ChatImageLightbox, ArrowsShowIcon, FileDownloadIcon, useClient, processMessageParts, getMessageDisplayTimestampValue, getMessageCreatedAtMs, isApprovalRequested, extractCitationsFromSteps, useSourcesEnrichment, extractImagesFromSteps, dedupeImageResults, getDocumentStreamArtifacts, getToolOutput, useCanvasStore, ImageResultsGallery, MessageDecisionCards, useChatCapabilities, useOptionalWorkspaceContext, useCitationViewer, useCitedDocument, useChatOverviewStore, dedup, extractDomain, sourceKind, SourceFavicon, Input, exportDocumentPdf, FilePdfIcon, StudioDisplayIcon, WorldIcon, MessageStepsGroup, getToolState, getToolInput, getToolErrorText, useChatOptInEnabled, ArrowRightIcon, formatFileSize, FileThumbnail, attachmentFileOf, MobileScreenSheet, useAgentHistorySource, treatyErrorMessage, useRouter, useBasePath, useAgentPanelStore, AgentRoutineForm, getFileCategory, unwrap, unwrapData, unwrapDataDeep, formatDecisionTime, DecisionCard, LoaderIcon, formatRelativeTime, CircleCheckIcon, agentRoutineKeys, useOptionalAgentsContext, avatarMotionForStream, AGENT_AVATAR_SIZE } from './chunk-652HXKK6.js';
3
3
  import { Sheet, SheetTrigger, SheetContent, SheetHeader, SheetTitle, SheetDescription, Popover, PopoverTrigger, PopoverContent } from './chunk-OONQIDAU.js';
4
- import { useIsMobile, useTranslation } from './chunk-XJ2UK4WV.js';
5
- import { MessageToolbar, MessageResponse, SquareArrowTopRightIcon, FileTextIcon, Shimmer, ClipboardIcon, Message, MessageContent, PencilIcon, deferDuringLayoutMotion, HoverCard, HoverCardTrigger, HoverCardContent, Collapse, Icon, CircleXIcon, ClockIcon } from './chunk-K7AIK7TA.js';
4
+ import { useIsMobile, useTranslation } from './chunk-7LCV3BV2.js';
5
+ import { MessageToolbar, MessageResponse, SquareArrowTopRightIcon, FileTextIcon, Shimmer, ClipboardIcon, Message, MessageContent, PencilIcon, deferDuringLayoutMotion, HoverCard, HoverCardTrigger, HoverCardContent, Collapse, Icon, CircleXIcon, ClockIcon } from './chunk-6YDDHBQC.js';
6
6
  import { ChevronDownMediumIcon, Button, ScrollArea, Skeleton } from './chunk-UWKO24VT.js';
7
7
  import { CrossMediumIcon } from './chunk-37WYG6VG.js';
8
8
  import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent } from './chunk-C3HW5S2Z.js';
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { describeToolRow, Code2Icon, getToolMeta, Shimmer, Collapse } from './chunk-K7AIK7TA.js';
2
+ import { describeToolRow, Code2Icon, getToolMeta, Shimmer, Collapse } from './chunk-6YDDHBQC.js';
3
3
  import { ChevronDownMediumIcon } from './chunk-UWKO24VT.js';
4
4
  import { cn } from './chunk-LGVMMBL3.js';
5
5
  import { memo, useState, useMemo } from 'react';
package/dist/client.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  export { capabilitiesOfChatToken, subjectOfChatToken } from './chunk-CCVPZVFK.js';
3
- import { useChatCredential } from './chunk-6BCUAPW3.js';
4
- export { useChatCredential } from './chunk-6BCUAPW3.js';
3
+ import { useChatCredential } from './chunk-LPQ4JQOB.js';
4
+ export { useChatCredential } from './chunk-LPQ4JQOB.js';
5
5
  import './chunk-WDYCLC4F.js';
6
6
  export { ChatClientContext, useChatClientOptional } from './chunk-6JLWE7M3.js';
7
7
  import './chunk-PR4QN5HX.js';
@@ -1,4 +1,4 @@
1
1
  'use client';
2
- export { useChatCredential } from './chunk-6BCUAPW3.js';
2
+ export { useChatCredential } from './chunk-LPQ4JQOB.js';
3
3
  import './chunk-WDYCLC4F.js';
4
4
  import './chunk-PR4QN5HX.js';
package/dist/header.js CHANGED
@@ -1,11 +1,11 @@
1
1
  'use client';
2
- export { ChatHeader, ChatHeaderActions } from './chunk-UTQYV6P4.js';
3
- import './chunk-HWZY3ZTZ.js';
2
+ export { ChatHeader, ChatHeaderActions } from './chunk-2UXCKWKS.js';
3
+ import './chunk-652HXKK6.js';
4
4
  import './chunk-CWAOLMFS.js';
5
5
  import './chunk-OONQIDAU.js';
6
- import './chunk-XJ2UK4WV.js';
7
- import './chunk-R3ONYPUB.js';
8
- import './chunk-K7AIK7TA.js';
6
+ import './chunk-7LCV3BV2.js';
7
+ import './chunk-YZ4Z5J3J.js';
8
+ import './chunk-6YDDHBQC.js';
9
9
  import './chunk-UWKO24VT.js';
10
10
  import './chunk-37WYG6VG.js';
11
11
  import './chunk-CDTES65T.js';
package/dist/message.js CHANGED
@@ -1,11 +1,11 @@
1
1
  'use client';
2
- export { Message, Thinking } from './chunk-EJGKAA5I.js';
3
- import './chunk-HWZY3ZTZ.js';
2
+ export { Message, Thinking } from './chunk-X7TU7KKX.js';
3
+ import './chunk-652HXKK6.js';
4
4
  import './chunk-CWAOLMFS.js';
5
5
  import './chunk-OONQIDAU.js';
6
- import './chunk-XJ2UK4WV.js';
7
- import './chunk-R3ONYPUB.js';
8
- import './chunk-K7AIK7TA.js';
6
+ import './chunk-7LCV3BV2.js';
7
+ import './chunk-YZ4Z5J3J.js';
8
+ import './chunk-6YDDHBQC.js';
9
9
  import './chunk-UWKO24VT.js';
10
10
  import './chunk-37WYG6VG.js';
11
11
  import './chunk-CDTES65T.js';
@@ -1,7 +1,7 @@
1
1
  'use client';
2
- export { DEFAULT_SHORTCUTS, NewSessionPrompt, buildDefaultShortcuts } from './chunk-RSMFWOHL.js';
2
+ export { DEFAULT_SHORTCUTS, NewSessionPrompt, buildDefaultShortcuts } from './chunk-CEHOSQNR.js';
3
3
  import './chunk-OONQIDAU.js';
4
- import './chunk-XJ2UK4WV.js';
4
+ import './chunk-7LCV3BV2.js';
5
5
  import './chunk-37WYG6VG.js';
6
6
  import './chunk-RCWVJD7G.js';
7
7
  import './chunk-LGVMMBL3.js';
package/dist/parts.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import { ToolCallItem } from './chunk-R3ONYPUB.js';
3
- import './chunk-K7AIK7TA.js';
2
+ import { ToolCallItem } from './chunk-YZ4Z5J3J.js';
3
+ import './chunk-6YDDHBQC.js';
4
4
  import './chunk-UWKO24VT.js';
5
5
  import './chunk-37WYG6VG.js';
6
6
  import './chunk-EZX3E3BB.js';
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
  import { DeckNotesCard, deckOwnsArrowKeys } from './chunk-4FRTPVJT.js';
3
- import { resolveStageWidth, zoomPercent, DECK_ZOOM_LEVELS, LazyThumb, ArtifactSkeleton } from './chunk-C5A27Q6W.js';
3
+ import { resolveStageWidth, zoomPercent, DECK_ZOOM_LEVELS, LazyThumb, ArtifactSkeleton } from './chunk-MSRHFPQ5.js';
4
4
  import { ChevronLeftIcon } from './chunk-CWAOLMFS.js';
5
- import { useTranslation, useIsMobile } from './chunk-XJ2UK4WV.js';
5
+ import { useTranslation, useIsMobile } from './chunk-7LCV3BV2.js';
6
6
  import { Button, ChevronDownMediumIcon, ScrollArea } from './chunk-UWKO24VT.js';
7
7
  import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, ChevronRightIcon } from './chunk-C3HW5S2Z.js';
8
8
  import { cn } from './chunk-LGVMMBL3.js';
@@ -1,7 +1,7 @@
1
1
  'use client';
2
- import { zoomPercent, DECK_ZOOM_LEVELS, ArtifactSkeleton, LazyThumb } from './chunk-C5A27Q6W.js';
2
+ import { zoomPercent, DECK_ZOOM_LEVELS, ArtifactSkeleton, LazyThumb } from './chunk-MSRHFPQ5.js';
3
3
  import { ChevronLeftIcon } from './chunk-CWAOLMFS.js';
4
- import { useTranslation, useIsMobile } from './chunk-XJ2UK4WV.js';
4
+ import { useTranslation, useIsMobile } from './chunk-7LCV3BV2.js';
5
5
  import { Button, ChevronDownMediumIcon, ScrollArea } from './chunk-UWKO24VT.js';
6
6
  import { ChevronRightIcon, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem } from './chunk-C3HW5S2Z.js';
7
7
  import { cn } from './chunk-LGVMMBL3.js';
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- export { PendingCards } from './chunk-A4GIIAMQ.js';
3
- import './chunk-K7AIK7TA.js';
2
+ export { PendingCards } from './chunk-UHZ64AHN.js';
3
+ import './chunk-6YDDHBQC.js';
4
4
  import './chunk-UWKO24VT.js';
5
5
  import './chunk-37WYG6VG.js';
6
6
  import './chunk-EZX3E3BB.js';