@tangle-network/ui 11.51.21 → 11.51.22

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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 11.51.22
2
+
3
+ ### Patch Changes
4
+
5
+ - df08ce7: Keep delegated previews readable across their own anchor, content and focused actions. Share the existing scoped CSS time reader with previews, canvas consumers and clipboard feedback; preserve zero and missing budgets and resolve scoped calc() values.
6
+ - 5219d82: Export the existing native event-stream lifecycle from hooks so imperative adapters share the hook's cursor, reconnect, terminal-event and cleanup behavior. Native retries now back off during outages; buffered streams retain their configured policy.
7
+
8
+ Delegated hover anchors that attach after pointer entry now open through the same token delay as direct triggers.
9
+
1
10
  ## 11.51.21
2
11
 
3
12
  ### Patch Changes
@@ -11,5 +11,15 @@ export interface EventStreamHandlers {
11
11
  onStart?: () => void;
12
12
  onLiveChange?: (live: boolean) => void;
13
13
  }
14
+ type NativePolicy = EventStreamHandlers & {
15
+ terminalEvent?: string;
16
+ onConnecting?: (attempt: number) => void;
17
+ retryDelay?: (attempt: number) => number | undefined;
18
+ };
19
+ /** The sole native EventSource lifecycle, shared by buffered and producer-owned streams. */
20
+ export declare function openNativeStream(url: string | (() => string), handlers: NativePolicy): {
21
+ close(): void;
22
+ };
14
23
  /** Producer-owned named events; host transports keep their authenticated reconnect lifecycle. */
15
- export declare function useEventStream(url: string | (() => string) | undefined, handlers: EventStreamHandlers): void;
24
+ export declare function useEventStream(url: string | (() => string) | undefined, handlers: EventStreamHandlers): void;
25
+ export {};
@@ -34,7 +34,12 @@ function openNativeStream(url, handlers) {
34
34
  connection.close();
35
35
  if (stopped || source !== connection) return;
36
36
  live(false);
37
- const delay = handlers.retryDelay ? handlers.retryDelay(attempt++) : 1e3;
37
+ const delay = handlers.retryDelay ? handlers.retryDelay(attempt++) : [
38
+ 1e3,
39
+ 2e3,
40
+ 5e3,
41
+ 1e4
42
+ ][Math.min(attempt++, 3)];
38
43
  if (delay !== void 0) retry = setTimeout(open, delay);
39
44
  };
40
45
  }
package/dist/hooks.d.ts CHANGED
@@ -8,7 +8,7 @@ import { AuthUser, UseAuthOptions, UseAuthResult, createAuthFetcher, useApiKey,
8
8
  import { AppendUserMessageOptions, ApplySdkEventOptions, BeginAssistantMessageOptions, CompleteAssistantMessageOptions, SdkSessionAttachment, SdkSessionEvent, SdkSessionSeed, UseSdkSessionOptions, UseSdkSessionReturn, useSdkSession } from "./hooks/use-sdk-session.js";
9
9
  import { RealtimeSessionOptions, RealtimeSessionRegistry, RealtimeSessionRegistryProps, RealtimeSessionState, RealtimeSessionTarget, useRealtimeSession } from "./hooks/use-realtime-session.js";
10
10
  import { AgentStreamEvent, AutomationStreamEvent, BotStreamEvent, ConnectionState, SSEEvent, TaskStreamEvent, TerminalStreamEvent, UseSSEStreamOptions, UseSSEStreamResult, useSSEStream } from "./hooks/use-sse-stream.js";
11
- import { EventStreamHandlers, EventStreamOpener, EventStreamSource, useEventStream } from "./hooks/use-event-stream.js";
11
+ import { EventStreamHandlers, EventStreamOpener, EventStreamSource, openNativeStream, useEventStream } from "./hooks/use-event-stream.js";
12
12
  import { useFollowTail } from "./hooks/use-follow-tail.js";
13
13
  import { PHONE_MEDIA, usePhone } from "./hooks/use-phone.js";
14
- export { AgentStreamEvent, AppendUserMessageOptions, ApplySdkEventOptions, AuthUser, AutomationStreamEvent, BeginAssistantMessageOptions, BotStreamEvent, CompleteAssistantMessageOptions, ConnectionState, type EventStreamHandlers, type EventStreamOpener, type EventStreamSource, PHONE_MEDIA, RealtimeSessionOptions, RealtimeSessionRegistry, RealtimeSessionRegistryProps, RealtimeSessionState, RealtimeSessionTarget, SSEEvent, SdkSessionAttachment, SdkSessionEvent, SdkSessionSeed, TaskStreamEvent, TerminalStreamEvent, UseAuthOptions, UseAuthResult, UseRunGroupsOptions, UseSSEStreamOptions, UseSSEStreamResult, UseSdkSessionOptions, UseSdkSessionReturn, UseToolCallStreamReturn, createAuthFetcher, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useEventStream, useFollowTail, useLiveTime, usePhone, useRealtimeSession, useRunCollapseState, useRunGroups, useRunNow, useSSEStream, useSdkSession, useToolCallStream };
14
+ export { AgentStreamEvent, AppendUserMessageOptions, ApplySdkEventOptions, AuthUser, AutomationStreamEvent, BeginAssistantMessageOptions, BotStreamEvent, CompleteAssistantMessageOptions, ConnectionState, type EventStreamHandlers, type EventStreamOpener, type EventStreamSource, PHONE_MEDIA, RealtimeSessionOptions, RealtimeSessionRegistry, RealtimeSessionRegistryProps, RealtimeSessionState, RealtimeSessionTarget, SSEEvent, SdkSessionAttachment, SdkSessionEvent, SdkSessionSeed, TaskStreamEvent, TerminalStreamEvent, UseAuthOptions, UseAuthResult, UseRunGroupsOptions, UseSSEStreamOptions, UseSSEStreamResult, UseSdkSessionOptions, UseSdkSessionReturn, UseToolCallStreamReturn, createAuthFetcher, openNativeStream, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useEventStream, useFollowTail, useLiveTime, usePhone, useRealtimeSession, useRunCollapseState, useRunGroups, useRunNow, useSSEStream, useSdkSession, useToolCallStream };
package/dist/hooks.js CHANGED
@@ -8,7 +8,7 @@ import { useToolCallStream } from "./hooks/use-tool-call-stream.js";
8
8
  import { createAuthFetcher, useApiKey, useAuth } from "./hooks/use-auth.js";
9
9
  import { RealtimeSessionRegistry, useRealtimeSession } from "./hooks/use-realtime-session.js";
10
10
  import { useSdkSession } from "./hooks/use-sdk-session.js";
11
- import { useEventStream } from "./hooks/use-event-stream.js";
11
+ import { openNativeStream, useEventStream } from "./hooks/use-event-stream.js";
12
12
  import { useSSEStream } from "./hooks/use-sse-stream.js";
13
13
  import { PHONE_MEDIA, usePhone } from "./hooks/use-phone.js";
14
- export { PHONE_MEDIA, RealtimeSessionRegistry, createAuthFetcher, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useEventStream, useFollowTail, useLiveTime, usePhone, useRealtimeSession, useRunCollapseState, useRunGroups, useRunNow, useSSEStream, useSdkSession, useToolCallStream };
14
+ export { PHONE_MEDIA, RealtimeSessionRegistry, createAuthFetcher, openNativeStream, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useEventStream, useFollowTail, useLiveTime, usePhone, useRealtimeSession, useRunCollapseState, useRunGroups, useRunNow, useSSEStream, useSdkSession, useToolCallStream };
package/dist/index.d.ts CHANGED
@@ -49,7 +49,7 @@ import { AppendUserMessageOptions, ApplySdkEventOptions, BeginAssistantMessageOp
49
49
  import { ActiveProjectActivity, ActiveSessionActivityOptions, ActiveSessionConnectionOptions, ActiveSessionConnectionState, ActiveSessionReconnectState, ActiveSessionRecord, ActiveSessionStatus, ActiveSessionTransportMode, ActiveSessionsState, RegisterActiveSessionOptions, SessionProjectKey, activeSessionsAtom, bumpActiveSessionActivity, getActiveSession, getAllActiveSessions, getAllProjectActivity, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getTotalRunningSessionCount, hasBackgroundRunningSessions, registerActiveSession, resetActiveSessions, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, unregisterActiveSession, updateActiveSessionMeta, useActiveSession, useActiveSessions, useActiveSessionsState, useHasBackgroundRunningSessions, useNavbarSessions, useProjectActivity, useProjectSessions, useSessionsByActivity, useTotalRunningSessions } from "./stores/active-sessions-store.js";
50
50
  import { RealtimeSessionOptions, RealtimeSessionRegistry, RealtimeSessionRegistryProps, RealtimeSessionState, RealtimeSessionTarget, useRealtimeSession } from "./hooks/use-realtime-session.js";
51
51
  import { AgentStreamEvent, AutomationStreamEvent, BotStreamEvent, ConnectionState, SSEEvent, TaskStreamEvent, TerminalStreamEvent, UseSSEStreamOptions, UseSSEStreamResult, useSSEStream } from "./hooks/use-sse-stream.js";
52
- import { EventStreamHandlers, EventStreamOpener, EventStreamSource, useEventStream } from "./hooks/use-event-stream.js";
52
+ import { EventStreamHandlers, EventStreamOpener, EventStreamSource, openNativeStream, useEventStream } from "./hooks/use-event-stream.js";
53
53
  import { useFollowTail } from "./hooks/use-follow-tail.js";
54
54
  import { PHONE_MEDIA, usePhone } from "./hooks/use-phone.js";
55
55
  import "./hooks.js";
@@ -136,6 +136,7 @@ import "./types.js";
136
136
  import { copyText } from "./utils/copy-text.js";
137
137
  import { formatAxisDuration, formatBytes, formatClock, formatCompact, formatCost, formatCount, formatDuration as formatSpanDuration, formatUtcTime, plainTextFromMarkdown, truncateText } from "./utils/format.js";
138
138
  import { timeAgo } from "./utils/time-ago.js";
139
+ import { tokenMilliseconds } from "./utils/token-milliseconds.js";
139
140
  import { TOOL_CATEGORY_ICONS, getToolCategory, getToolDisplayMetadata, getToolErrorText } from "./utils/tool-display.js";
140
141
  import { cn } from "./lib/utils.js";
141
142
  import { focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset } from "./lib/focus.js";
@@ -149,4 +150,4 @@ import { QuestionPreview, QuestionPreviewProps } from "./tool-previews/question-
149
150
  import { DiffPreview, DiffPreviewProps } from "./tool-previews/diff-preview.js";
150
151
  import { RedactedDocSegment, RedactedDocument, RedactedDocumentData, RedactedDocumentProps, RevealResult } from "./redaction/redacted-document.js";
151
152
  import "./redaction.js";
152
- export { ActiveProjectActivity, ActiveSessionActivityOptions, ActiveSessionConnectionOptions, ActiveSessionConnectionState, ActiveSessionReconnectState, ActiveSessionRecord, ActiveSessionStatus, ActiveSessionTransportMode, ActiveSessionsState, AgentBranding, AgentStreamEvent, AgentTimeline, type AgentTimelineArtifactItem, AgentTimelineColumn, type AgentTimelineCustomItem, type AgentTimelineFoldItem, type AgentTimelineItem, type AgentTimelineMessageItem, type AgentTimelineProps, type AgentTimelineStatusItem, AgentTimelineStep, type AgentTimelineStepKind, type AgentTimelineStepProps, type AgentTimelineTone, type AgentTimelineToolGroupItem, type AgentTimelineToolItem, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, type AlertProps, AlertTitle, type AlertTone, ApiSchema, type ApiSchemaProps, AppendUserMessageOptions, ApplySdkEventOptions, ApprovalCard, type ApprovalCardProps, type ApprovalDiffFile, ApprovalDiffSummary, type ApprovalPlanStep, ArtifactPane, type ArtifactPaneProps, AuthHeader, type AuthHeaderProps, AuthUser, AutomationStreamEvent, Avatar, AvatarFallback, AvatarImage, type AvatarProps, Badge, type BadgeProps, BeginAssistantMessageOptions, BotStreamEvent, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, type ButtonProps, CATEGORY_TONES, CSV_PREVIEW_ROW_LIMIT, Calendar, type CalendarDate, type CalendarProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CardTitleProps, type CategoryTone, type ChartReferenceLine, ChatAuthor, ChatContainer, type ChatContainerProps, ChatMessage, type ChatMessageProps, Checkbox, Chip, type ChipProps, CodeBlock, type CodeBlockProps, Collapsible, CollapsibleContent, CollapsibleTrigger, CommandPreview, type CommandPreviewProps, CompleteAssistantMessageOptions, ComplianceBadge, type ComplianceBadgeProps, type ComplianceProduct, type ComplianceStatus, ConnectionState, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, type CopyButtonProps, CustomToolRenderer, DatePicker, type DatePickerProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffPreview, type DiffPreviewProps, DisplayVariant, DropZone, type DropZoneProps, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, type EmptyStateProps, type EventStreamHandlers, type EventStreamOpener, type EventStreamSource, ExpandablePanel, type ExpandablePanelProps, ExpandedToolDetail, type ExpandedToolDetailProps, type FeedSegment, Field, type FieldProps, FileArtifactPane, type FileArtifactPaneProps, FileCard, type FileCardProps, type FileDetails, type FileFormat, FileList, type FileListItem, type FileListProps, type FileNode, FilePreview, type FilePreviewKind, type FilePreviewProps, type FileTabData, FileTabs, type FileTabsProps, FileTree, type FileTreeProps, type FileTreeVisibilityOptions, type FileUploader, FilterField, type FilterFieldProps, FinalTextPart, GitHubLoginButton, type GitHubLoginButtonProps, GlobResultsPreview, type GlobResultsPreviewProps, GrepResultsPreview, type GrepResultsPreviewProps, GroupedMessage, Heading, type HeadingProps, type HeadingVariant, HelpText, type HelpTextProps, HoverCard, HoverCardContent, HoverCardDescription, HoverCardHeader, HoverCardTitle, HoverCardTrigger, IconTile, type IconTileProps, InlineCode, type InlineCodeProps, InlineThinkingItem, type InlineThinkingItemProps, InlineToolItem, type InlineToolItemProps, Input, type InputProps, Label, LiveDuration, LoginLayout, type LoginLayoutProps, Logo, type LogoProps, Markdown, type MarkdownLinkChip, type MarkdownLinkChipResolver, type MarkdownProps, MessageAuthor, type MessageAuthorProps, MessageList, type MessageListProps, type MessageRole, MessageRun, MessageUser, Metric, MetricChart, type MetricChartProps, type MetricProps, MetricStrip, type MetricStripProps, OPENUI_NODE_JSON_SCHEMA, OPENUI_NODE_TYPES, type OpenUIAction, type OpenUIActionsNode, OpenUIArtifactRenderer, type OpenUIArtifactRendererProps, type OpenUIBadgeNode, type OpenUICardNode, type OpenUICodeNode, type OpenUIComponentNode, type OpenUIGridNode, type OpenUIHeadingNode, type OpenUIKeyValueNode, type OpenUIMarkdownNode, type OpenUIPrimitive, type OpenUISchemaIssue, type OpenUISchemaValidation, type OpenUISeparatorNode, type OpenUIStackNode, type OpenUIStatNode, type OpenUITableNode, type OpenUITextNode, PHONE_MEDIA, PageHeader, type PageHeaderProps, PageShell, type PageShellProps, Pagination, type PaginationProps, PdfViewer, type PdfViewerConfig, type PdfViewerProps, type PeriodDelta, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, QuestionPreview, type QuestionPreviewProps, RadioGroup, RadioGroupItem, RealtimeSessionOptions, RealtimeSessionRegistry, RealtimeSessionRegistryProps, RealtimeSessionState, RealtimeSessionTarget, ReasoningPart, type RedactedDocSegment, RedactedDocument, type RedactedDocumentData, type RedactedDocumentProps, RegisterActiveSessionOptions, type RevealResult, RichFileTree, type RichFileTreeGitEntry, type RichFileTreeGitStatus, type RichFileTreeProps, type RichFileTreeThemeVars, Run, RunGroup, type RunGroupProps, type RunPhase, RunPhaseList, RunRowShell, type RunRowShellProps, type RunRowStatus, RunRowStatusDot, RunStats, type RunStatus, RunStatusIcon, type RunStatusIconProps, SSEEvent, SdkSessionAttachment, SdkSessionEvent, SdkSessionSeed, SegmentedControl, type SegmentedControlOption, type SegmentedControlProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, type SeriesExtent, type SeriesPoint, type SeriesPointInput, type SeriesScale, SeriesSparkline, type SeriesSparklineProps, SessionMessage, SessionPart, SessionProjectKey, type SessionUser, SettingsList, type SettingsListAction, type SettingsListColumns, SettingsListItem, type SettingsListItemProps, type SettingsListMenuItem, type SettingsListProps, SettingsNote, type SettingsNoteProps, SettingsRow, type SettingsRowLayout, type SettingsRowProps, SettingsSection, type SettingsSectionProps, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, SidebarDropZone, type SidebarDropZoneProps, Skeleton, SkeletonCard, SkeletonTable, Slider, type Speaker, SpeakerHeader, type SpeakerHeaderProps, type SpeakerPart, type SpeakerSection, type SpeakerState, StatCard, type StatCardProps, type StatusMeta, StatusPill, type StatusPillProps, type StatusTone, Switch, TONE_CLASSES, TOOL_CATEGORY_ICONS, TRANSCRIPT_TEXT, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, type TableHeadProps, TableHeader, type TableProps, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, type TagProps, TangleKnot, TaskList, type TaskListItem, type TaskListProps, type TaskStatus, TaskStreamEvent, TerminalCursor, TerminalDisplay, TerminalInput, TerminalLine, TerminalStreamEvent, TextPart, TextShimmer, type TextShimmerProps, Textarea, type TextareaProps, type ThemeControllerOptions, ThemeToggle, ThinkingIndicator, type ThinkingIndicatorProps, TimeSelect, type TimeSelectProps, type Toast, ToastContainer, ToastProvider, type Tone, type ToneClasses, type ToolCallData, ToolCallFeed, type ToolCallFeedProps, type ToolCallStatus, type ToolCallType, ToolCategory, ToolDisplayMetadata, ToolPart, ToolState, ToolStatus, ToolTime, Toolbar, type ToolbarProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UploadFile, UploadProgress, type UploadProgressProps, UseAuthOptions, UseAuthResult, UseRunGroupsOptions, UseSSEStreamOptions, UseSSEStreamResult, UseSdkSessionOptions, UseSdkSessionReturn, UseToolCallStreamReturn, UserMenu, type UserMenuProps, UserMessage, type UserMessageProps, WebSearchPreview, type WebSearchPreviewProps, Wizard, type WizardProps, WizardStep, type WizardStepProps, WriteFilePreview, type WriteFilePreviewProps, activeSessionsAtom, addMessage, addParts, agentTimelineStepKind, badgeVariants, bumpActiveSessionActivity, buttonVariants, clearChat, cn, codeBlockGrammar, configurePdfViewer, copyText, createAuthFetcher, createThemeController, detectFileFormat, fenceInfo, fieldMessageId, fileExtension, filterFileTree, findUnsupportedOpenUINode, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, foldSummary, formatAxisDuration, formatBytes, formatCalendarDate, formatClock, formatCompact, formatCost, formatCount, formatSpanDuration as formatDuration, formatSpanDuration, formatSpanDuration as formatUptime, formatUtcTime, getActiveSession, getAllActiveSessions, getAllProjectActivity, getCodeLanguage, getFormatLabel, getSanitizedMarkdownHeadingIdFromRawFragment, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getSyntaxLanguage, getToolCategory, getToolDisplayMetadata, getToolErrorText, getTotalRunningSessionCount, hasBackgroundRunningSessions, initialsOf, isOpen, isStreamingAtom, isViewerMessage, ixControl, ixControlAfter, ixControlSoft, ixField, ixRow, ixSelected, ixTabUnderline, localToday, messagesAtom, normalizeSeries, numericColumns, parseCalendarDate, parseCsv, parseToolEvent, partMapAtom, partitionBySpeaker, periodDelta, plainTextFromMarkdown, registerActiveSession, resetActiveSessions, resolveFilePreviewKind, runStatus, seriesAreaPath, seriesExtent, seriesLinePath, seriesMean, seriesScale, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, showsTaskPriority, statusMeta, tableCsv, taskProgress, taskStatus, timeAgo, toneFor, truncateText, unregisterActiveSession, updateActiveSessionMeta, updatePart, useActiveSession, useActiveSessions, useActiveSessionsState, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useEventStream, useFollowTail, useHasBackgroundRunningSessions, useLiveTime, useNavbarSessions, usePhone, useProjectActivity, useProjectSessions, useRealtimeSession, useRunCollapseState, useRunGroups, useRunNow, useSSEStream, useSdkSession, useSessionsByActivity, useTheme, useToast, useToolCallStream, useTotalRunningSessions, validateOpenUIJsonArtifact, validateOpenUIJsonNode };
153
+ export { ActiveProjectActivity, ActiveSessionActivityOptions, ActiveSessionConnectionOptions, ActiveSessionConnectionState, ActiveSessionReconnectState, ActiveSessionRecord, ActiveSessionStatus, ActiveSessionTransportMode, ActiveSessionsState, AgentBranding, AgentStreamEvent, AgentTimeline, type AgentTimelineArtifactItem, AgentTimelineColumn, type AgentTimelineCustomItem, type AgentTimelineFoldItem, type AgentTimelineItem, type AgentTimelineMessageItem, type AgentTimelineProps, type AgentTimelineStatusItem, AgentTimelineStep, type AgentTimelineStepKind, type AgentTimelineStepProps, type AgentTimelineTone, type AgentTimelineToolGroupItem, type AgentTimelineToolItem, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, type AlertProps, AlertTitle, type AlertTone, ApiSchema, type ApiSchemaProps, AppendUserMessageOptions, ApplySdkEventOptions, ApprovalCard, type ApprovalCardProps, type ApprovalDiffFile, ApprovalDiffSummary, type ApprovalPlanStep, ArtifactPane, type ArtifactPaneProps, AuthHeader, type AuthHeaderProps, AuthUser, AutomationStreamEvent, Avatar, AvatarFallback, AvatarImage, type AvatarProps, Badge, type BadgeProps, BeginAssistantMessageOptions, BotStreamEvent, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, type ButtonProps, CATEGORY_TONES, CSV_PREVIEW_ROW_LIMIT, Calendar, type CalendarDate, type CalendarProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CardTitleProps, type CategoryTone, type ChartReferenceLine, ChatAuthor, ChatContainer, type ChatContainerProps, ChatMessage, type ChatMessageProps, Checkbox, Chip, type ChipProps, CodeBlock, type CodeBlockProps, Collapsible, CollapsibleContent, CollapsibleTrigger, CommandPreview, type CommandPreviewProps, CompleteAssistantMessageOptions, ComplianceBadge, type ComplianceBadgeProps, type ComplianceProduct, type ComplianceStatus, ConnectionState, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, type CopyButtonProps, CustomToolRenderer, DatePicker, type DatePickerProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffPreview, type DiffPreviewProps, DisplayVariant, DropZone, type DropZoneProps, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, type EmptyStateProps, type EventStreamHandlers, type EventStreamOpener, type EventStreamSource, ExpandablePanel, type ExpandablePanelProps, ExpandedToolDetail, type ExpandedToolDetailProps, type FeedSegment, Field, type FieldProps, FileArtifactPane, type FileArtifactPaneProps, FileCard, type FileCardProps, type FileDetails, type FileFormat, FileList, type FileListItem, type FileListProps, type FileNode, FilePreview, type FilePreviewKind, type FilePreviewProps, type FileTabData, FileTabs, type FileTabsProps, FileTree, type FileTreeProps, type FileTreeVisibilityOptions, type FileUploader, FilterField, type FilterFieldProps, FinalTextPart, GitHubLoginButton, type GitHubLoginButtonProps, GlobResultsPreview, type GlobResultsPreviewProps, GrepResultsPreview, type GrepResultsPreviewProps, GroupedMessage, Heading, type HeadingProps, type HeadingVariant, HelpText, type HelpTextProps, HoverCard, HoverCardContent, HoverCardDescription, HoverCardHeader, HoverCardTitle, HoverCardTrigger, IconTile, type IconTileProps, InlineCode, type InlineCodeProps, InlineThinkingItem, type InlineThinkingItemProps, InlineToolItem, type InlineToolItemProps, Input, type InputProps, Label, LiveDuration, LoginLayout, type LoginLayoutProps, Logo, type LogoProps, Markdown, type MarkdownLinkChip, type MarkdownLinkChipResolver, type MarkdownProps, MessageAuthor, type MessageAuthorProps, MessageList, type MessageListProps, type MessageRole, MessageRun, MessageUser, Metric, MetricChart, type MetricChartProps, type MetricProps, MetricStrip, type MetricStripProps, OPENUI_NODE_JSON_SCHEMA, OPENUI_NODE_TYPES, type OpenUIAction, type OpenUIActionsNode, OpenUIArtifactRenderer, type OpenUIArtifactRendererProps, type OpenUIBadgeNode, type OpenUICardNode, type OpenUICodeNode, type OpenUIComponentNode, type OpenUIGridNode, type OpenUIHeadingNode, type OpenUIKeyValueNode, type OpenUIMarkdownNode, type OpenUIPrimitive, type OpenUISchemaIssue, type OpenUISchemaValidation, type OpenUISeparatorNode, type OpenUIStackNode, type OpenUIStatNode, type OpenUITableNode, type OpenUITextNode, PHONE_MEDIA, PageHeader, type PageHeaderProps, PageShell, type PageShellProps, Pagination, type PaginationProps, PdfViewer, type PdfViewerConfig, type PdfViewerProps, type PeriodDelta, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, QuestionPreview, type QuestionPreviewProps, RadioGroup, RadioGroupItem, RealtimeSessionOptions, RealtimeSessionRegistry, RealtimeSessionRegistryProps, RealtimeSessionState, RealtimeSessionTarget, ReasoningPart, type RedactedDocSegment, RedactedDocument, type RedactedDocumentData, type RedactedDocumentProps, RegisterActiveSessionOptions, type RevealResult, RichFileTree, type RichFileTreeGitEntry, type RichFileTreeGitStatus, type RichFileTreeProps, type RichFileTreeThemeVars, Run, RunGroup, type RunGroupProps, type RunPhase, RunPhaseList, RunRowShell, type RunRowShellProps, type RunRowStatus, RunRowStatusDot, RunStats, type RunStatus, RunStatusIcon, type RunStatusIconProps, SSEEvent, SdkSessionAttachment, SdkSessionEvent, SdkSessionSeed, SegmentedControl, type SegmentedControlOption, type SegmentedControlProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, type SeriesExtent, type SeriesPoint, type SeriesPointInput, type SeriesScale, SeriesSparkline, type SeriesSparklineProps, SessionMessage, SessionPart, SessionProjectKey, type SessionUser, SettingsList, type SettingsListAction, type SettingsListColumns, SettingsListItem, type SettingsListItemProps, type SettingsListMenuItem, type SettingsListProps, SettingsNote, type SettingsNoteProps, SettingsRow, type SettingsRowLayout, type SettingsRowProps, SettingsSection, type SettingsSectionProps, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, SidebarDropZone, type SidebarDropZoneProps, Skeleton, SkeletonCard, SkeletonTable, Slider, type Speaker, SpeakerHeader, type SpeakerHeaderProps, type SpeakerPart, type SpeakerSection, type SpeakerState, StatCard, type StatCardProps, type StatusMeta, StatusPill, type StatusPillProps, type StatusTone, Switch, TONE_CLASSES, TOOL_CATEGORY_ICONS, TRANSCRIPT_TEXT, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, type TableHeadProps, TableHeader, type TableProps, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, type TagProps, TangleKnot, TaskList, type TaskListItem, type TaskListProps, type TaskStatus, TaskStreamEvent, TerminalCursor, TerminalDisplay, TerminalInput, TerminalLine, TerminalStreamEvent, TextPart, TextShimmer, type TextShimmerProps, Textarea, type TextareaProps, type ThemeControllerOptions, ThemeToggle, ThinkingIndicator, type ThinkingIndicatorProps, TimeSelect, type TimeSelectProps, type Toast, ToastContainer, ToastProvider, type Tone, type ToneClasses, type ToolCallData, ToolCallFeed, type ToolCallFeedProps, type ToolCallStatus, type ToolCallType, ToolCategory, ToolDisplayMetadata, ToolPart, ToolState, ToolStatus, ToolTime, Toolbar, type ToolbarProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UploadFile, UploadProgress, type UploadProgressProps, UseAuthOptions, UseAuthResult, UseRunGroupsOptions, UseSSEStreamOptions, UseSSEStreamResult, UseSdkSessionOptions, UseSdkSessionReturn, UseToolCallStreamReturn, UserMenu, type UserMenuProps, UserMessage, type UserMessageProps, WebSearchPreview, type WebSearchPreviewProps, Wizard, type WizardProps, WizardStep, type WizardStepProps, WriteFilePreview, type WriteFilePreviewProps, activeSessionsAtom, addMessage, addParts, agentTimelineStepKind, badgeVariants, bumpActiveSessionActivity, buttonVariants, clearChat, cn, codeBlockGrammar, configurePdfViewer, copyText, createAuthFetcher, createThemeController, detectFileFormat, fenceInfo, fieldMessageId, fileExtension, filterFileTree, findUnsupportedOpenUINode, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, foldSummary, formatAxisDuration, formatBytes, formatCalendarDate, formatClock, formatCompact, formatCost, formatCount, formatSpanDuration as formatDuration, formatSpanDuration, formatSpanDuration as formatUptime, formatUtcTime, getActiveSession, getAllActiveSessions, getAllProjectActivity, getCodeLanguage, getFormatLabel, getSanitizedMarkdownHeadingIdFromRawFragment, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getSyntaxLanguage, getToolCategory, getToolDisplayMetadata, getToolErrorText, getTotalRunningSessionCount, hasBackgroundRunningSessions, initialsOf, isOpen, isStreamingAtom, isViewerMessage, ixControl, ixControlAfter, ixControlSoft, ixField, ixRow, ixSelected, ixTabUnderline, localToday, messagesAtom, normalizeSeries, numericColumns, openNativeStream, parseCalendarDate, parseCsv, parseToolEvent, partMapAtom, partitionBySpeaker, periodDelta, plainTextFromMarkdown, registerActiveSession, resetActiveSessions, resolveFilePreviewKind, runStatus, seriesAreaPath, seriesExtent, seriesLinePath, seriesMean, seriesScale, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, showsTaskPriority, statusMeta, tableCsv, taskProgress, taskStatus, timeAgo, tokenMilliseconds, toneFor, truncateText, unregisterActiveSession, updateActiveSessionMeta, updatePart, useActiveSession, useActiveSessions, useActiveSessionsState, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useEventStream, useFollowTail, useHasBackgroundRunningSessions, useLiveTime, useNavbarSessions, usePhone, useProjectActivity, useProjectSessions, useRealtimeSession, useRunCollapseState, useRunGroups, useRunNow, useSSEStream, useSdkSession, useSessionsByActivity, useTheme, useToast, useToolCallStream, useTotalRunningSessions, validateOpenUIJsonArtifact, validateOpenUIJsonNode };
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@ import { formatAxisDuration, formatBytes, formatClock, formatCompact, formatCost
42
42
  import { UploadProgress } from "./primitives/upload-progress.js";
43
43
  import { SidebarDropZone } from "./primitives/sidebar-drop-zone.js";
44
44
  import { ArtifactPane } from "./primitives/artifact-pane.js";
45
+ import { tokenMilliseconds } from "./utils/token-milliseconds.js";
45
46
  import { codeBlockGrammar } from "./lib/code-presentation.js";
46
47
  import { CodeBlock, CopyButton } from "./markdown/code-block.js";
47
48
  import { InlineCode } from "./primitives/code-block.js";
@@ -126,11 +127,11 @@ import { createAuthFetcher, useApiKey, useAuth } from "./hooks/use-auth.js";
126
127
  import { activeSessionsAtom, bumpActiveSessionActivity, getActiveSession, getAllActiveSessions, getAllProjectActivity, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getTotalRunningSessionCount, hasBackgroundRunningSessions, registerActiveSession, resetActiveSessions, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, unregisterActiveSession, updateActiveSessionMeta, useActiveSession, useActiveSessions, useActiveSessionsState, useHasBackgroundRunningSessions, useNavbarSessions, useProjectActivity, useProjectSessions, useSessionsByActivity, useTotalRunningSessions } from "./stores/active-sessions-store.js";
127
128
  import { RealtimeSessionRegistry, useRealtimeSession } from "./hooks/use-realtime-session.js";
128
129
  import { useSdkSession } from "./hooks/use-sdk-session.js";
129
- import { useEventStream } from "./hooks/use-event-stream.js";
130
+ import { openNativeStream, useEventStream } from "./hooks/use-event-stream.js";
130
131
  import { useSSEStream } from "./hooks/use-sse-stream.js";
131
132
  import { PHONE_MEDIA, usePhone } from "./hooks/use-phone.js";
132
133
  import { addMessage, addParts, clearChat, isStreamingAtom, messagesAtom, partMapAtom, updatePart } from "./stores/chat-store.js";
133
134
  import { copyText } from "./utils/copy-text.js";
134
135
  import { timeAgo } from "./utils/time-ago.js";
135
136
  import { RedactedDocument } from "./redaction/redacted-document.js";
136
- export { AgentTimeline, AgentTimelineColumn, AgentTimelineStep, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, ApiSchema, ApprovalCard, ApprovalDiffSummary, ArtifactPane, AuthHeader, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, CATEGORY_TONES, CSV_PREVIEW_ROW_LIMIT, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChatContainer, ChatMessage, Checkbox, Chip, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, CommandPreview, ComplianceBadge, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffPreview, DropZone, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, ExpandablePanel, ExpandedToolDetail, Field, FileArtifactPane, FileCard, FileList, FilePreview, FileTabs, FileTree, FilterField, GitHubLoginButton, GlobResultsPreview, GrepResultsPreview, Heading, HelpText, HoverCard, HoverCardContent, HoverCardDescription, HoverCardHeader, HoverCardTitle, HoverCardTrigger, IconTile, InlineCode, InlineThinkingItem, InlineToolItem, Input, Label, LiveDuration, LoginLayout, Logo, Markdown, MessageAuthor, MessageList, Metric, MetricChart, MetricStrip, OPENUI_NODE_JSON_SCHEMA, OPENUI_NODE_TYPES, OpenUIArtifactRenderer, PHONE_MEDIA, PageHeader, PageShell, Pagination, PdfViewer, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, QuestionPreview, RadioGroup, RadioGroupItem, RealtimeSessionRegistry, RedactedDocument, RichFileTree, RunGroup, RunPhaseList, RunRowShell, RunRowStatusDot, RunStatusIcon, SegmentedControl, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SeriesSparkline, SettingsList, SettingsListItem, SettingsNote, SettingsRow, SettingsSection, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, SidebarDropZone, Skeleton, SkeletonCard, SkeletonTable, Slider, SpeakerHeader, StatCard, StatusPill, Switch, TONE_CLASSES, TOOL_CATEGORY_ICONS, TRANSCRIPT_TEXT, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TangleKnot, TaskList, TerminalCursor, TerminalDisplay, TerminalInput, TerminalLine, TextShimmer, Textarea, ThemeToggle, ThinkingIndicator, TimeSelect, ToastContainer, ToastProvider, ToolCallFeed, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UploadProgress, UserMenu, UserMessage, WebSearchPreview, Wizard, WizardStep, WriteFilePreview, activeSessionsAtom, addMessage, addParts, agentTimelineStepKind, badgeVariants, bumpActiveSessionActivity, buttonVariants, clearChat, cn, codeBlockGrammar, configurePdfViewer, copyText, createAuthFetcher, createThemeController, detectFileFormat, fenceInfo, fieldMessageId, fileExtension, filterFileTree, findUnsupportedOpenUINode, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, foldSummary, formatAxisDuration, formatBytes, formatCalendarDate, formatClock, formatCompact, formatCost, formatCount, formatSpanDuration as formatDuration, formatSpanDuration, formatSpanDuration as formatUptime, formatUtcTime, getActiveSession, getAllActiveSessions, getAllProjectActivity, getCodeLanguage, getFormatLabel, getSanitizedMarkdownHeadingIdFromRawFragment, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getSyntaxLanguage, getToolCategory, getToolDisplayMetadata, getToolErrorText, getTotalRunningSessionCount, hasBackgroundRunningSessions, initialsOf, isOpen, isStreamingAtom, isViewerMessage, ixControl, ixControlAfter, ixControlSoft, ixField, ixRow, ixSelected, ixTabUnderline, localToday, messagesAtom, normalizeSeries, numericColumns, parseCalendarDate, parseCsv, parseToolEvent, partMapAtom, partitionBySpeaker, periodDelta, plainTextFromMarkdown, registerActiveSession, resetActiveSessions, resolveFilePreviewKind, runStatus, seriesAreaPath, seriesExtent, seriesLinePath, seriesMean, seriesScale, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, showsTaskPriority, statusMeta, tableCsv, taskProgress, taskStatus, timeAgo, toneFor, truncateText, unregisterActiveSession, updateActiveSessionMeta, updatePart, useActiveSession, useActiveSessions, useActiveSessionsState, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useEventStream, useFollowTail, useHasBackgroundRunningSessions, useLiveTime, useNavbarSessions, usePhone, useProjectActivity, useProjectSessions, useRealtimeSession, useRunCollapseState, useRunGroups, useRunNow, useSSEStream, useSdkSession, useSessionsByActivity, useTheme, useToast, useToolCallStream, useTotalRunningSessions, validateOpenUIJsonArtifact, validateOpenUIJsonNode };
137
+ export { AgentTimeline, AgentTimelineColumn, AgentTimelineStep, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, ApiSchema, ApprovalCard, ApprovalDiffSummary, ArtifactPane, AuthHeader, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, CATEGORY_TONES, CSV_PREVIEW_ROW_LIMIT, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChatContainer, ChatMessage, Checkbox, Chip, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, CommandPreview, ComplianceBadge, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffPreview, DropZone, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, ExpandablePanel, ExpandedToolDetail, Field, FileArtifactPane, FileCard, FileList, FilePreview, FileTabs, FileTree, FilterField, GitHubLoginButton, GlobResultsPreview, GrepResultsPreview, Heading, HelpText, HoverCard, HoverCardContent, HoverCardDescription, HoverCardHeader, HoverCardTitle, HoverCardTrigger, IconTile, InlineCode, InlineThinkingItem, InlineToolItem, Input, Label, LiveDuration, LoginLayout, Logo, Markdown, MessageAuthor, MessageList, Metric, MetricChart, MetricStrip, OPENUI_NODE_JSON_SCHEMA, OPENUI_NODE_TYPES, OpenUIArtifactRenderer, PHONE_MEDIA, PageHeader, PageShell, Pagination, PdfViewer, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, QuestionPreview, RadioGroup, RadioGroupItem, RealtimeSessionRegistry, RedactedDocument, RichFileTree, RunGroup, RunPhaseList, RunRowShell, RunRowStatusDot, RunStatusIcon, SegmentedControl, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SeriesSparkline, SettingsList, SettingsListItem, SettingsNote, SettingsRow, SettingsSection, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, SidebarDropZone, Skeleton, SkeletonCard, SkeletonTable, Slider, SpeakerHeader, StatCard, StatusPill, Switch, TONE_CLASSES, TOOL_CATEGORY_ICONS, TRANSCRIPT_TEXT, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TangleKnot, TaskList, TerminalCursor, TerminalDisplay, TerminalInput, TerminalLine, TextShimmer, Textarea, ThemeToggle, ThinkingIndicator, TimeSelect, ToastContainer, ToastProvider, ToolCallFeed, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UploadProgress, UserMenu, UserMessage, WebSearchPreview, Wizard, WizardStep, WriteFilePreview, activeSessionsAtom, addMessage, addParts, agentTimelineStepKind, badgeVariants, bumpActiveSessionActivity, buttonVariants, clearChat, cn, codeBlockGrammar, configurePdfViewer, copyText, createAuthFetcher, createThemeController, detectFileFormat, fenceInfo, fieldMessageId, fileExtension, filterFileTree, findUnsupportedOpenUINode, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, foldSummary, formatAxisDuration, formatBytes, formatCalendarDate, formatClock, formatCompact, formatCost, formatCount, formatSpanDuration as formatDuration, formatSpanDuration, formatSpanDuration as formatUptime, formatUtcTime, getActiveSession, getAllActiveSessions, getAllProjectActivity, getCodeLanguage, getFormatLabel, getSanitizedMarkdownHeadingIdFromRawFragment, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getSyntaxLanguage, getToolCategory, getToolDisplayMetadata, getToolErrorText, getTotalRunningSessionCount, hasBackgroundRunningSessions, initialsOf, isOpen, isStreamingAtom, isViewerMessage, ixControl, ixControlAfter, ixControlSoft, ixField, ixRow, ixSelected, ixTabUnderline, localToday, messagesAtom, normalizeSeries, numericColumns, openNativeStream, parseCalendarDate, parseCsv, parseToolEvent, partMapAtom, partitionBySpeaker, periodDelta, plainTextFromMarkdown, registerActiveSession, resetActiveSessions, resolveFilePreviewKind, runStatus, seriesAreaPath, seriesExtent, seriesLinePath, seriesMean, seriesScale, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, showsTaskPriority, statusMeta, tableCsv, taskProgress, taskStatus, timeAgo, tokenMilliseconds, toneFor, truncateText, unregisterActiveSession, updateActiveSessionMeta, updatePart, useActiveSession, useActiveSessions, useActiveSessionsState, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useEventStream, useFollowTail, useHasBackgroundRunningSessions, useLiveTime, useNavbarSessions, usePhone, useProjectActivity, useProjectSessions, useRealtimeSession, useRunCollapseState, useRunGroups, useRunNow, useSSEStream, useSdkSession, useSessionsByActivity, useTheme, useToast, useToolCallStream, useTotalRunningSessions, validateOpenUIJsonArtifact, validateOpenUIJsonNode };
@@ -1,4 +1,5 @@
1
1
  import { tabsPresentation } from "../presentation.js";
2
+ import { tokenMilliseconds } from "../utils/token-milliseconds.js";
2
3
  // src/lib/code-presentation.ts
3
4
  const SYNTAX = {
4
5
  comment: "var(--syntax-comment, currentColor)",
@@ -242,28 +243,13 @@ async function writeClipboard(text) {
242
243
  const COPY_FEEDBACK_MS = 2e3;
243
244
  /** Resolve scoped Brand times, including calc(), without duplicating token values. */
244
245
  function interactionBudgets(scope) {
245
- const view = scope.ownerDocument.defaultView;
246
- if (!view) return {};
247
- const probe = scope.ownerDocument.createElement("i");
248
- probe.hidden = true;
249
- scope.append(probe);
250
- const read = (role) => {
251
- const name = `--interaction-${role}`;
252
- if (!view.getComputedStyle(scope).getPropertyValue(name).trim()) return void 0;
253
- probe.style.animationDuration = `var(${name})`;
254
- const time = /^(\d+(?:\.\d+)?)(ms|s)$/.exec(view.getComputedStyle(probe).animationDuration);
255
- return time ? Number(time[1]) * (time[2] === "s" ? 1e3 : 1) : void 0;
256
- };
257
- try {
258
- return {
259
- feedback: read("feedback-budget"),
260
- pending: read("pending-delay"),
261
- longWork: read("long-work-delay"),
262
- mutation: read("mutation-budget")
263
- };
264
- } finally {
265
- probe.remove();
266
- }
246
+ const read = (role) => tokenMilliseconds(`--interaction-${role}`, scope);
247
+ return scope.ownerDocument.defaultView ? {
248
+ feedback: read("feedback-budget"),
249
+ pending: read("pending-delay"),
250
+ longWork: read("long-work-delay"),
251
+ mutation: read("mutation-budget")
252
+ } : {};
267
253
  }
268
254
  /** Owns one accepted write, scoped delays and cleanup for both renderers. */
269
255
  function createCopyFeedback(change, write = writeClipboard, scope) {
@@ -9,7 +9,6 @@ type HoverCardProps = React.ComponentProps<typeof Popover> & {
9
9
  openDelay?: number;
10
10
  closeDelay?: number;
11
11
  };
12
- /** One hover policy and Popover's keyboard/focus behavior; delays follow the trigger's fast token. */
13
12
  export declare function HoverCard({ anchor, open: controlled, defaultOpen, onOpenChange, openDelay, closeDelay, children, ...props }: HoverCardProps): React.JSX.Element;
14
13
  export declare const HoverCardTrigger: React.ForwardRefExoticComponent<React.AnchorHTMLAttributes<HTMLAnchorElement> & {
15
14
  asChild?: boolean;
@@ -1,64 +1,69 @@
1
1
  import { cn } from "../lib/utils.js";
2
2
  import { Popover, PopoverAnchor, PopoverContent } from "./popover.js";
3
+ import { tokenMilliseconds } from "../utils/token-milliseconds.js";
3
4
  import { Slot } from "@radix-ui/react-slot";
4
5
  import * as React from "react";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
7
  // src/primitives/hover-card.tsx
7
8
  const HoverIntent = React.createContext({
9
+ content: { current: null },
8
10
  enter: (_target) => {},
9
- leave: () => {},
11
+ leave: (_event) => {},
10
12
  restore: () => {},
11
- press: () => {}
13
+ press: () => {},
14
+ owns: (_target) => false
12
15
  });
13
- /** One hover policy and Popover's keyboard/focus behavior; delays follow the trigger's fast token. */
14
16
  function HoverCard({ anchor, open: controlled, defaultOpen = false, onOpenChange, openDelay, closeDelay, children, ...props }) {
15
17
  const element = anchor && ("contextElement" in anchor ? anchor.contextElement : anchor);
16
18
  const [own, setOwn] = React.useState({
17
19
  anchor: element,
18
20
  open: defaultOpen
19
21
  });
20
- const intent = React.useRef({});
22
+ const intent = React.useRef({ content: { current: null } });
23
+ intent.current.onOpenChange = onOpenChange;
21
24
  if (element) intent.current.target = element;
22
25
  const change = React.useCallback((next) => {
23
26
  clearTimeout(intent.current.timer);
24
- if (controlled === void 0) setOwn({
27
+ if (controlled === void 0) setOwn((current) => current.anchor === element && current.open === next ? current : {
25
28
  anchor: element,
26
29
  open: next
27
30
  });
28
- onOpenChange?.(next);
29
- }, [
30
- controlled,
31
- onOpenChange,
32
- element
33
- ]);
34
- const delay = (target) => {
35
- const value = getComputedStyle(target ?? document.documentElement).getPropertyValue("--duration-fast").trim();
36
- return (parseFloat(value) || 0) * (value.endsWith("ms") ? 1 : 1e3);
37
- };
31
+ intent.current.onOpenChange?.(next);
32
+ }, [controlled, element]);
33
+ const owns = React.useCallback((target) => target instanceof Node && (!!(element ?? intent.current.target)?.contains(target) || !!intent.current.content.current?.contains(target)), [element]);
38
34
  const enter = React.useCallback((target) => {
39
- if (intent.current.restoring || intent.current.pressed && target.closest("[data-hover-card]")) return;
35
+ if (intent.current.restoring || intent.current.pressed && target === intent.current.content.current) return;
40
36
  intent.current.pressed = false;
41
- if (!target.closest("[data-hover-card]")) intent.current.target = target;
37
+ if (target !== intent.current.content.current) intent.current.target = target;
42
38
  clearTimeout(intent.current.timer);
43
- intent.current.timer = setTimeout(() => change(true), openDelay ?? delay(target));
39
+ intent.current.timer = setTimeout(() => change(true), openDelay ?? tokenMilliseconds("--duration-fast", target));
44
40
  }, [change, openDelay]);
45
- const leave = React.useCallback(() => {
41
+ const leave = React.useCallback((event) => {
42
+ if (owns(event?.relatedTarget ?? null)) return;
46
43
  clearTimeout(intent.current.timer);
47
- intent.current.timer = setTimeout(() => change(false), closeDelay ?? delay(element ?? intent.current.target));
44
+ intent.current.timer = setTimeout(() => {
45
+ if (!owns(document.activeElement) || !intent.current.content.current?.contains(document.activeElement) && !document.activeElement?.matches(":focus-visible")) change(false);
46
+ }, closeDelay ?? tokenMilliseconds("--duration-fast", element ?? intent.current.target));
48
47
  }, [
49
48
  change,
50
49
  closeDelay,
51
- element
50
+ element,
51
+ owns
52
52
  ]);
53
53
  React.useEffect(() => {
54
- if (!element) return () => clearTimeout(intent.current.timer);
55
- const show = () => enter(element), blur = (event) => {
56
- if (!(event.relatedTarget instanceof Element && event.relatedTarget.closest("[data-hover-card]"))) leave();
57
- };
54
+ if (!element) {
55
+ if (anchor === null) setOwn((current) => current.open ? {
56
+ anchor: element,
57
+ open: false
58
+ } : current);
59
+ return () => clearTimeout(intent.current.timer);
60
+ }
61
+ const show = () => enter(element), blur = (event) => leave(event);
58
62
  element.addEventListener("pointerenter", show);
59
63
  element.addEventListener("pointerleave", leave);
60
64
  element.addEventListener("focusin", show);
61
65
  element.addEventListener("focusout", blur);
66
+ if (element.matches(":hover,:focus-within")) show();
62
67
  return () => {
63
68
  clearTimeout(intent.current.timer);
64
69
  element.removeEventListener("pointerenter", show);
@@ -67,7 +72,6 @@ function HoverCard({ anchor, open: controlled, defaultOpen = false, onOpenChange
67
72
  element.removeEventListener("focusout", blur);
68
73
  };
69
74
  }, [
70
- anchor,
71
75
  element,
72
76
  enter,
73
77
  leave
@@ -81,13 +85,15 @@ function HoverCard({ anchor, open: controlled, defaultOpen = false, onOpenChange
81
85
  };
82
86
  return /* @__PURE__ */ jsx(HoverIntent.Provider, {
83
87
  value: {
88
+ content: intent.current.content,
84
89
  enter,
85
90
  leave,
86
91
  restore,
87
92
  press: () => {
88
93
  intent.current.pressed = true;
89
94
  change(false);
90
- }
95
+ },
96
+ owns
91
97
  },
92
98
  children: /* @__PURE__ */ jsxs(Popover, {
93
99
  ...props,
@@ -111,7 +117,7 @@ const HoverCardTrigger = React.forwardRef(({ className, onPointerEnter, onPointe
111
117
  },
112
118
  onPointerLeave: (event) => {
113
119
  onPointerLeave?.(event);
114
- if (!event.defaultPrevented) intent.leave();
120
+ if (!event.defaultPrevented) intent.leave(event);
115
121
  },
116
122
  onFocus: (event) => {
117
123
  onFocus?.(event);
@@ -124,39 +130,46 @@ const HoverCardTrigger = React.forwardRef(({ className, onPointerEnter, onPointe
124
130
  },
125
131
  onBlur: (event) => {
126
132
  onBlur?.(event);
127
- if (!event.defaultPrevented && !(event.relatedTarget instanceof Element && event.relatedTarget.closest("[data-hover-card]"))) intent.leave();
133
+ if (!event.defaultPrevented) intent.leave(event);
128
134
  },
129
135
  ...props
130
136
  })
131
137
  });
132
138
  });
133
139
  HoverCardTrigger.displayName = "HoverCardTrigger";
134
- const HoverCardContent = React.forwardRef(({ className, onPointerEnter, onPointerLeave, onOpenAutoFocus, onCloseAutoFocus, ...props }, ref) => {
140
+ const HoverCardContent = React.forwardRef(({ className, onPointerEnter, onPointerLeave, onOpenAutoFocus, onCloseAutoFocus, onFocusOutside, ...props }, ref) => {
135
141
  const intent = React.useContext(HoverIntent);
136
- return /* @__PURE__ */ jsx(PopoverContent, {
137
- ref,
138
- "data-hover-card": true,
139
- className: cn("w-64", className),
140
- onOpenAutoFocus: (event) => {
141
- onOpenAutoFocus?.(event);
142
- event.preventDefault();
143
- },
144
- onCloseAutoFocus: (event) => {
145
- onCloseAutoFocus?.(event);
146
- if (!event.defaultPrevented) {
142
+ return /* @__PURE__ */ jsx(Slot, {
143
+ ref: intent.content,
144
+ children: /* @__PURE__ */ jsx(PopoverContent, {
145
+ ref,
146
+ "data-hover-card": true,
147
+ className: cn("w-64", className),
148
+ onOpenAutoFocus: (event) => {
149
+ onOpenAutoFocus?.(event);
147
150
  event.preventDefault();
148
- intent.restore();
149
- }
150
- },
151
- onPointerEnter: (event) => {
152
- onPointerEnter?.(event);
153
- if (!event.defaultPrevented) intent.enter(event.currentTarget);
154
- },
155
- onPointerLeave: (event) => {
156
- onPointerLeave?.(event);
157
- if (!event.defaultPrevented) intent.leave();
158
- },
159
- ...props
151
+ },
152
+ onCloseAutoFocus: (event) => {
153
+ onCloseAutoFocus?.(event);
154
+ if (!event.defaultPrevented) {
155
+ event.preventDefault();
156
+ intent.restore();
157
+ }
158
+ },
159
+ onFocusOutside: (event) => {
160
+ onFocusOutside?.(event);
161
+ if (intent.owns(event.detail.originalEvent.target)) event.preventDefault();
162
+ },
163
+ onPointerEnter: (event) => {
164
+ onPointerEnter?.(event);
165
+ if (!event.defaultPrevented) intent.enter(event.currentTarget);
166
+ },
167
+ onPointerLeave: (event) => {
168
+ onPointerLeave?.(event);
169
+ if (!event.defaultPrevented) intent.leave(event);
170
+ },
171
+ ...props
172
+ })
160
173
  });
161
174
  });
162
175
  HoverCardContent.displayName = "HoverCardContent";
@@ -0,0 +1,2 @@
1
+ /** Resolve a scoped CSS time, including calc(); absent tokens remain unknown. */
2
+ export declare function tokenMilliseconds(token: string, element?: Element | null): number | undefined;
@@ -0,0 +1,17 @@
1
+ // src/utils/token-milliseconds.ts
2
+ /** Resolve a scoped CSS time, including calc(); absent tokens remain unknown. */
3
+ function tokenMilliseconds(token, element) {
4
+ const scope = element ?? (typeof document === "undefined" ? void 0 : document.documentElement), view = scope?.ownerDocument.defaultView;
5
+ if (!scope || !view || !view.getComputedStyle(scope).getPropertyValue(token).trim()) return void 0;
6
+ const probe = scope.ownerDocument.createElement("i");
7
+ probe.hidden = true;
8
+ scope.append(probe);
9
+ try {
10
+ probe.style.animationDuration = `var(${token})`;
11
+ const time = /^(\d+(?:\.\d+)?)(ms|s)$/.exec(view.getComputedStyle(probe).animationDuration);
12
+ return time ? Number(time[1]) * (time[2] === "s" ? 1e3 : 1) : void 0;
13
+ } finally {
14
+ probe.remove();
15
+ }
16
+ }
17
+ export { tokenMilliseconds };
package/dist/utils.d.ts CHANGED
@@ -2,7 +2,8 @@ import { ixControl, ixControlAfter, ixControlSoft, ixField, ixRow, ixSelected, i
2
2
  import { copyText } from "./utils/copy-text.js";
3
3
  import { formatAxisDuration, formatBytes, formatClock, formatCompact, formatCost, formatCount, formatDuration as formatSpanDuration, formatUtcTime, plainTextFromMarkdown, truncateText } from "./utils/format.js";
4
4
  import { timeAgo } from "./utils/time-ago.js";
5
+ import { tokenMilliseconds } from "./utils/token-milliseconds.js";
5
6
  import { TOOL_CATEGORY_ICONS, getToolCategory, getToolDisplayMetadata, getToolErrorText } from "./utils/tool-display.js";
6
7
  import { cn } from "./lib/utils.js";
7
8
  import { focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset } from "./lib/focus.js";
8
- export { TOOL_CATEGORY_ICONS, cn, copyText, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, formatAxisDuration, formatBytes, formatClock, formatCompact, formatCost, formatCount, formatSpanDuration as formatDuration, formatSpanDuration, formatSpanDuration as formatUptime, formatUtcTime, getToolCategory, getToolDisplayMetadata, getToolErrorText, ixControl, ixControlAfter, ixControlSoft, ixField, ixRow, ixSelected, ixTabUnderline, plainTextFromMarkdown, timeAgo, truncateText };
9
+ export { TOOL_CATEGORY_ICONS, cn, copyText, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, formatAxisDuration, formatBytes, formatClock, formatCompact, formatCost, formatCount, formatSpanDuration as formatDuration, formatSpanDuration, formatSpanDuration as formatUptime, formatUtcTime, getToolCategory, getToolDisplayMetadata, getToolErrorText, ixControl, ixControlAfter, ixControlSoft, ixField, ixRow, ixSelected, ixTabUnderline, plainTextFromMarkdown, timeAgo, tokenMilliseconds, truncateText };
package/dist/utils.js CHANGED
@@ -2,7 +2,8 @@ import { ixControl, ixControlAfter, ixControlSoft, ixField, ixRow, ixSelected, i
2
2
  import { focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset } from "./lib/focus.js";
3
3
  import { cn } from "./lib/utils.js";
4
4
  import { formatAxisDuration, formatBytes, formatClock, formatCompact, formatCost, formatCount, formatDuration as formatSpanDuration, formatUtcTime, plainTextFromMarkdown, truncateText } from "./utils/format.js";
5
+ import { tokenMilliseconds } from "./utils/token-milliseconds.js";
5
6
  import { TOOL_CATEGORY_ICONS, getToolCategory, getToolDisplayMetadata, getToolErrorText } from "./utils/tool-display.js";
6
7
  import { copyText } from "./utils/copy-text.js";
7
8
  import { timeAgo } from "./utils/time-ago.js";
8
- export { TOOL_CATEGORY_ICONS, cn, copyText, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, formatAxisDuration, formatBytes, formatClock, formatCompact, formatCost, formatCount, formatSpanDuration as formatDuration, formatSpanDuration, formatSpanDuration as formatUptime, formatUtcTime, getToolCategory, getToolDisplayMetadata, getToolErrorText, ixControl, ixControlAfter, ixControlSoft, ixField, ixRow, ixSelected, ixTabUnderline, plainTextFromMarkdown, timeAgo, truncateText };
9
+ export { TOOL_CATEGORY_ICONS, cn, copyText, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, formatAxisDuration, formatBytes, formatClock, formatCompact, formatCost, formatCount, formatSpanDuration as formatDuration, formatSpanDuration, formatSpanDuration as formatUptime, formatUtcTime, getToolCategory, getToolDisplayMetadata, getToolErrorText, ixControl, ixControlAfter, ixControlSoft, ixField, ixRow, ixSelected, ixTabUnderline, plainTextFromMarkdown, timeAgo, tokenMilliseconds, truncateText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/ui",
3
- "version": "11.51.21",
3
+ "version": "11.51.22",
4
4
  "description": "Generic React UI components for Tangle products — primitives, chat, run, files, editor, markdown.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -216,7 +216,7 @@
216
216
  "peerDependencies": {
217
217
  "@hocuspocus/provider": ">=2.15.0 <5.0.0",
218
218
  "@nanostores/react": ">=0.8.4 <3.0.0",
219
- "@tangle-network/brand": "^1.31.8",
219
+ "@tangle-network/brand": "^1.31.11",
220
220
  "@tiptap/core": ">=3.20.4 <4.0.0",
221
221
  "@tiptap/extension-collaboration": ">=3.20.4 <4.0.0",
222
222
  "@tiptap/extension-collaboration-caret": ">=3.7.0 <4.0.0",
@@ -9,6 +9,6 @@ export * from "./use-realtime-session";
9
9
  export * from "./use-sdk-session";
10
10
  export * from "./use-sse-stream";
11
11
 
12
- export { useEventStream, type EventStreamHandlers, type EventStreamSource, type EventStreamOpener } from "./use-event-stream";
12
+ export { openNativeStream, useEventStream, type EventStreamHandlers, type EventStreamSource, type EventStreamOpener } from "./use-event-stream";
13
13
  export { useFollowTail } from "./use-follow-tail";
14
14
  export { usePhone, PHONE_MEDIA } from "./use-phone";
@@ -15,7 +15,6 @@ export interface EventStreamHandlers {
15
15
  onLiveChange?: (live: boolean) => void
16
16
  }
17
17
 
18
- /** Internal policy preserves the buffered hook's existing bounded exponential retries. */
19
18
  type NativePolicy = EventStreamHandlers & { terminalEvent?: string; onConnecting?: (attempt: number) => void; retryDelay?: (attempt: number) => number | undefined }
20
19
 
21
20
  /** The sole native EventSource lifecycle, shared by buffered and producer-owned streams. */
@@ -42,7 +41,7 @@ export function openNativeStream(url: string | (() => string), handlers: NativeP
42
41
  connection.close()
43
42
  if (stopped || source !== connection) return
44
43
  live(false)
45
- const delay = handlers.retryDelay ? handlers.retryDelay(attempt++) : 1_000
44
+ const delay = handlers.retryDelay ? handlers.retryDelay(attempt++) : [1_000, 2_000, 5_000, 10_000][Math.min(attempt++, 3)]
46
45
  if (delay !== undefined) retry = setTimeout(open, delay)
47
46
  }
48
47
  }
@@ -1,3 +1,4 @@
1
+ import { tokenMilliseconds } from "../utils/token-milliseconds";
1
2
  import { tabsPresentation } from "../presentation";
2
3
  import type { HighlighterCore, LanguageRegistration, ThemedToken } from "shiki/core";
3
4
  // Leave variables unresolved: the browser resolves them on each token span,
@@ -171,17 +172,8 @@ const COPY_FEEDBACK_MS=2000;
171
172
  export interface InteractionBudgets { feedback?:number; pending?:number; longWork?:number; mutation?:number; }
172
173
  /** Resolve scoped Brand times, including calc(), without duplicating token values. */
173
174
  export function interactionBudgets(scope:HTMLElement):InteractionBudgets {
174
- const view=scope.ownerDocument.defaultView;if(!view)return {};
175
- const probe=scope.ownerDocument.createElement("i");probe.hidden=true;scope.append(probe);
176
- const read=(role:string)=>{
177
- const name=`--interaction-${role}`;
178
- if(!view.getComputedStyle(scope).getPropertyValue(name).trim())return undefined;
179
- probe.style.animationDuration=`var(${name})`;
180
- const time=/^(\d+(?:\.\d+)?)(ms|s)$/.exec(view.getComputedStyle(probe).animationDuration);
181
- return time?Number(time[1])*(time[2]==="s"?1000:1):undefined;
182
- };
183
- try{return {feedback:read("feedback-budget"),pending:read("pending-delay"),longWork:read("long-work-delay"),mutation:read("mutation-budget")};}
184
- finally{probe.remove();}
175
+ const read=(role:string)=>tokenMilliseconds(`--interaction-${role}`,scope);
176
+ return scope.ownerDocument.defaultView?{feedback:read("feedback-budget"),pending:read("pending-delay"),longWork:read("long-work-delay"),mutation:read("mutation-budget")} : {};
185
177
  }
186
178
  export interface CopyFeedback {
187
179
  copied:boolean;status:string;pending:boolean;loading?:boolean;longRunning?:boolean;elapsedMs?:number;
@@ -2,8 +2,9 @@ import { cn } from "../lib/utils";
2
2
  import * as React from "react";
3
3
  import { Slot } from "@radix-ui/react-slot";
4
4
  import { Popover, PopoverAnchor, PopoverContent } from "./popover";
5
+ import { tokenMilliseconds } from "../utils/token-milliseconds";
5
6
 
6
- const HoverIntent = React.createContext({ enter: (_target: Element) => {}, leave: () => {}, restore: () => {}, press: () => {} });
7
+ const HoverIntent = React.createContext({ content: { current: null as HTMLDivElement | null }, enter: (_target: Element) => {}, leave: (_event?: { relatedTarget: EventTarget | null }) => {}, restore: () => {}, press: () => {}, owns: (_target: EventTarget | null) => false });
7
8
  type HoverCardProps = React.ComponentProps<typeof Popover> & {
8
9
  /** Existing DOM trigger for delegated canvas or virtual-list previews. */
9
10
  anchor?: HTMLElement | { getBoundingClientRect: () => DOMRect; contextElement: HTMLElement } | null;
@@ -11,31 +12,29 @@ type HoverCardProps = React.ComponentProps<typeof Popover> & {
11
12
  closeDelay?: number;
12
13
  };
13
14
 
14
- /** One hover policy and Popover's keyboard/focus behavior; delays follow the trigger's fast token. */
15
15
  export function HoverCard({ anchor, open: controlled, defaultOpen = false, onOpenChange, openDelay, closeDelay, children, ...props }: HoverCardProps) {
16
16
  const element = anchor && ("contextElement" in anchor ? anchor.contextElement : anchor);
17
17
  const [own, setOwn] = React.useState({ anchor: element, open: defaultOpen });
18
- const intent = React.useRef<{ timer?: ReturnType<typeof setTimeout>; target?: Element; restoring?: boolean; pressed?: boolean }>({});
18
+ const intent = React.useRef<{ timer?: ReturnType<typeof setTimeout>; target?: Element; content: { current: HTMLDivElement | null }; restoring?: boolean; pressed?: boolean; onOpenChange?: HoverCardProps["onOpenChange"] }>({ content: { current: null } });
19
+ intent.current.onOpenChange = onOpenChange;
19
20
  if (element) intent.current.target = element;
20
- const change = React.useCallback((next: boolean) => { clearTimeout(intent.current.timer); if (controlled === undefined) setOwn({ anchor: element, open: next }); onOpenChange?.(next); }, [controlled, onOpenChange, element]);
21
- const delay = (target: Element | null | undefined) => {
22
- const value = getComputedStyle(target ?? document.documentElement).getPropertyValue("--duration-fast").trim();
23
- return (parseFloat(value) || 0) * (value.endsWith("ms") ? 1 : 1000);
24
- };
25
- const enter = React.useCallback((target: Element) => { if (intent.current.restoring || (intent.current.pressed && target.closest("[data-hover-card]"))) return; intent.current.pressed = false; if (!target.closest("[data-hover-card]")) intent.current.target = target; clearTimeout(intent.current.timer); intent.current.timer = setTimeout(() => change(true), openDelay ?? delay(target)); }, [change, openDelay]);
26
- const leave = React.useCallback(() => { clearTimeout(intent.current.timer); intent.current.timer = setTimeout(() => change(false), closeDelay ?? delay(element ?? intent.current.target)); }, [change, closeDelay, element]);
21
+ const change = React.useCallback((next: boolean) => { clearTimeout(intent.current.timer); if (controlled === undefined) setOwn(current => current.anchor === element && current.open === next ? current : { anchor: element, open: next }); intent.current.onOpenChange?.(next); }, [controlled, element]);
22
+ const owns = React.useCallback((target: EventTarget | null) => target instanceof Node && (!!(element ?? intent.current.target)?.contains(target) || !!intent.current.content.current?.contains(target)), [element]);
23
+ const enter = React.useCallback((target: Element) => { if (intent.current.restoring || (intent.current.pressed && target === intent.current.content.current)) return; intent.current.pressed = false; if (target !== intent.current.content.current) intent.current.target = target; clearTimeout(intent.current.timer); intent.current.timer = setTimeout(() => change(true), openDelay ?? tokenMilliseconds("--duration-fast", target)); }, [change, openDelay]);
24
+ const leave = React.useCallback((event?: { relatedTarget: EventTarget | null }) => { if (owns(event?.relatedTarget ?? null)) return; clearTimeout(intent.current.timer); intent.current.timer = setTimeout(() => { if (!owns(document.activeElement) || (!intent.current.content.current?.contains(document.activeElement) && !document.activeElement?.matches(":focus-visible"))) change(false); }, closeDelay ?? tokenMilliseconds("--duration-fast", element ?? intent.current.target)); }, [change, closeDelay, element, owns]);
27
25
  React.useEffect(() => {
28
- if (!element) return () => clearTimeout(intent.current.timer);
29
- const show = () => enter(element), blur = (event: FocusEvent) => { if (!(event.relatedTarget instanceof Element && event.relatedTarget.closest("[data-hover-card]"))) leave(); };
26
+ if (!element) { if (anchor === null) setOwn(current => current.open ? { anchor: element, open: false } : current); return () => clearTimeout(intent.current.timer); }
27
+ const show = () => enter(element), blur = (event: FocusEvent) => leave(event);
30
28
  element.addEventListener("pointerenter", show); element.addEventListener("pointerleave", leave); element.addEventListener("focusin", show); element.addEventListener("focusout", blur);
29
+ if (element.matches(":hover,:focus-within")) show();
31
30
  return () => { clearTimeout(intent.current.timer); element.removeEventListener("pointerenter", show); element.removeEventListener("pointerleave", leave); element.removeEventListener("focusin", show); element.removeEventListener("focusout", blur); };
32
- }, [anchor, element, enter, leave]);
31
+ }, [element, enter, leave]);
33
32
  const restore = () => {
34
33
  intent.current.restoring = true;
35
34
  if (document.activeElement === document.body && intent.current.target instanceof HTMLElement) intent.current.target.focus({ preventScroll: true });
36
35
  queueMicrotask(() => { intent.current.restoring = false; });
37
36
  };
38
- return <HoverIntent.Provider value={{ enter, leave, restore, press: () => { intent.current.pressed = true; change(false); } }}><Popover {...props} open={anchor === null ? false : controlled ?? (own.anchor === element && own.open)} onOpenChange={change}>
37
+ return <HoverIntent.Provider value={{ content: intent.current.content, enter, leave, restore, press: () => { intent.current.pressed = true; change(false); }, owns }}><Popover {...props} open={anchor === null ? false : controlled ?? (own.anchor === element && own.open)} onOpenChange={change}>
39
38
  {anchor && <PopoverAnchor virtualRef={{ current: anchor }} />}{children}
40
39
  </Popover></HoverIntent.Provider>;
41
40
  }
@@ -46,22 +45,23 @@ export const HoverCardTrigger = React.forwardRef<HTMLAnchorElement, React.Anchor
46
45
  const Trigger = asChild ? Slot : "a";
47
46
  return <PopoverAnchor asChild><Trigger ref={ref} tabIndex={0} className={cn("cursor-pointer underline-offset-4 hover:underline", className)}
48
47
  onPointerEnter={event => { onPointerEnter?.(event); if (!event.defaultPrevented && event.pointerType !== "touch") intent.enter(event.currentTarget); }}
49
- onPointerLeave={event => { onPointerLeave?.(event); if (!event.defaultPrevented) intent.leave(); }}
48
+ onPointerLeave={event => { onPointerLeave?.(event); if (!event.defaultPrevented) intent.leave(event); }}
50
49
  onFocus={event => { onFocus?.(event); if (!event.defaultPrevented && event.target.matches(":focus-visible")) intent.enter(event.currentTarget); }}
51
50
  onClickCapture={event => { onClickCapture?.(event); const action = event.target instanceof Element ? event.target.closest('a,button,input,select,textarea,[role="button"]') : null; if (!event.defaultPrevented && action && action !== event.currentTarget) intent.press(); }}
52
- onBlur={event => { onBlur?.(event); if (!event.defaultPrevented && !(event.relatedTarget instanceof Element && event.relatedTarget.closest("[data-hover-card]"))) intent.leave(); }} {...props} /></PopoverAnchor>;
51
+ onBlur={event => { onBlur?.(event); if (!event.defaultPrevented) intent.leave(event); }} {...props} /></PopoverAnchor>;
53
52
  },
54
53
  );
55
54
  HoverCardTrigger.displayName = "HoverCardTrigger";
56
55
 
57
56
  export const HoverCardContent = React.forwardRef<React.ElementRef<typeof PopoverContent>, React.ComponentPropsWithoutRef<typeof PopoverContent>>(
58
- ({ className, onPointerEnter, onPointerLeave, onOpenAutoFocus, onCloseAutoFocus, ...props }, ref) => {
57
+ ({ className, onPointerEnter, onPointerLeave, onOpenAutoFocus, onCloseAutoFocus, onFocusOutside, ...props }, ref) => {
59
58
  const intent = React.useContext(HoverIntent);
60
- return <PopoverContent ref={ref} data-hover-card className={cn("w-64", className)}
59
+ return <Slot ref={intent.content}><PopoverContent ref={ref} data-hover-card className={cn("w-64", className)}
61
60
  onOpenAutoFocus={event => { onOpenAutoFocus?.(event); event.preventDefault(); }}
62
61
  onCloseAutoFocus={event => { onCloseAutoFocus?.(event); if (!event.defaultPrevented) { event.preventDefault(); intent.restore(); } }}
62
+ onFocusOutside={event => { onFocusOutside?.(event); if (intent.owns(event.detail.originalEvent.target)) event.preventDefault(); }}
63
63
  onPointerEnter={event => { onPointerEnter?.(event); if (!event.defaultPrevented) intent.enter(event.currentTarget); }}
64
- onPointerLeave={event => { onPointerLeave?.(event); if (!event.defaultPrevented) intent.leave(); }} {...props} />;
64
+ onPointerLeave={event => { onPointerLeave?.(event); if (!event.defaultPrevented) intent.leave(event); }} {...props} /></Slot>;
65
65
  },
66
66
  );
67
67
  HoverCardContent.displayName = "HoverCardContent";
@@ -1,6 +1,7 @@
1
1
  export { copyText } from './copy-text';
2
2
  export * from './format';
3
3
  export { timeAgo } from './time-ago';
4
+ export { tokenMilliseconds } from './token-milliseconds';
4
5
  export {
5
6
  getToolCategory,
6
7
  getToolDisplayMetadata,
@@ -0,0 +1,11 @@
1
+ /** Resolve a scoped CSS time, including calc(); absent tokens remain unknown. */
2
+ export function tokenMilliseconds(token: string, element?: Element | null) {
3
+ const scope = element ?? (typeof document === 'undefined' ? undefined : document.documentElement), view = scope?.ownerDocument.defaultView
4
+ if (!scope || !view || !view.getComputedStyle(scope).getPropertyValue(token).trim()) return undefined
5
+ const probe = scope.ownerDocument.createElement('i'); probe.hidden = true; scope.append(probe)
6
+ try {
7
+ probe.style.animationDuration = `var(${token})`
8
+ const time = /^(\d+(?:\.\d+)?)(ms|s)$/.exec(view.getComputedStyle(probe).animationDuration)
9
+ return time ? Number(time[1]) * (time[2] === 's' ? 1000 : 1) : undefined
10
+ } finally { probe.remove() }
11
+ }