rift-ds 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/behaviors/useFocusScope.d.ts +12 -6
- package/behaviors/useFocusScope.js +12 -2
- package/behaviors/useLayer.d.ts +39 -15
- package/behaviors/useLayer.js +23 -11
- package/bin/templates/chat/app/api/chat/route.ts +3 -0
- package/chat/AssistantTurn.d.ts +18 -1
- package/chat/AssistantTurn.js +25 -5
- package/chat/ChatAgentPane.d.ts +22 -4
- package/chat/ChatAgentPane.js +20 -6
- package/chat/ChatArtifactPane.d.ts +16 -1
- package/chat/ChatArtifactPane.js +12 -10
- package/chat/ChatLauncher.d.ts +12 -5
- package/chat/ChatLauncher.js +3 -1
- package/chat/ChatProvider.d.ts +5 -4
- package/chat/ChatProvider.js +1 -1
- package/chat/ChatTabs.d.ts +6 -1
- package/chat/ChatTabs.js +3 -2
- package/chat/ChatThreads.d.ts +19 -4
- package/chat/ChatThreads.js +22 -3
- package/chat/ChatWidget.css +5 -4
- package/chat/ChatWidget.d.ts +119 -5
- package/chat/ChatWidget.js +159 -70
- package/chat/DemoWelcome.js +17 -5
- package/chat/FollowupSuggestions.d.ts +10 -4
- package/chat/FollowupSuggestions.js +13 -5
- package/chat/ResponseActions.d.ts +14 -0
- package/chat/ResponseActions.js +15 -6
- package/chat/TurnQuestion.d.ts +24 -0
- package/chat/TurnQuestion.js +46 -0
- package/chat/demo-card-components.js +2 -1
- package/chat/demo-script.js +256 -50
- package/chat/followups.d.ts +2 -2
- package/chat/followups.js +1 -0
- package/chat/index.d.ts +3 -2
- package/chat/index.js +11 -0
- package/chat/queries.d.ts +2 -2
- package/chat/queries.js +3 -2
- package/chat/questions.d.ts +97 -0
- package/chat/questions.js +140 -0
- package/chat/registry.json.d.ts +3 -2
- package/chat/registry.json.js +1 -1
- package/chat/server.d.ts +19 -0
- package/chat/server.js +45 -1
- package/chat/sim.d.ts +12 -1
- package/chat/sim.js +19 -3
- package/chat/threads.d.ts +17 -0
- package/chat/threads.js +22 -14
- package/chat/types.d.ts +58 -1
- package/chat/types.js +1 -0
- package/chat/useChat.d.ts +24 -3
- package/chat/useChat.js +42 -4
- package/components/Accordion/Accordion.d.ts +18 -3
- package/components/Accordion/Accordion.js +71 -69
- package/components/AgentPlan/AgentPlan.d.ts +16 -0
- package/components/AgentPlan/AgentPlan.js +8 -3
- package/components/AgentRail/AgentRail.d.ts +24 -4
- package/components/AgentRail/AgentRail.js +13 -6
- package/components/AgentStatus/AgentStatus.css +1 -0
- package/components/AiButton/AiButton.css +3 -1
- package/components/AiButton/AiButton.d.ts +7 -1
- package/components/AiButton/AiButton.js +6 -3
- package/components/Alert/Alert.d.ts +15 -4
- package/components/Alert/Alert.js +46 -40
- package/components/AlertDialog/AlertDialog.css +1 -1
- package/components/AlertDialog/AlertDialog.d.ts +21 -5
- package/components/AlertDialog/AlertDialog.js +34 -15
- package/components/AnchorNav/AnchorNav.css +1 -1
- package/components/AnchorNav/AnchorNav.d.ts +4 -1
- package/components/AnchorNav/AnchorNav.js +8 -8
- package/components/AppLayout/AppLayout.d.ts +10 -2
- package/components/AppLayout/AppLayout.js +55 -42
- package/components/AppSidebar/AppSidebar.css +9 -9
- package/components/AppSidebar/AppSidebar.d.ts +27 -2
- package/components/AppSidebar/AppSidebar.js +30 -15
- package/components/ArtifactPanel/ArtifactPanel.d.ts +3 -0
- package/components/ArtifactPanel/ArtifactPanel.js +6 -5
- package/components/Attachment/Attachment.css +4 -1
- package/components/Attachment/AttachmentGroup.d.ts +6 -0
- package/components/Attachment/AttachmentGroup.js +10 -1
- package/components/Attachment/AttachmentTile.d.ts +2 -0
- package/components/Attachment/AttachmentTile.js +3 -2
- package/components/Attachment/AttachmentViewer.js +4 -4
- package/components/Attachment/fileTypes.d.ts +8 -0
- package/components/Avatar/Avatar.css +3 -3
- package/components/Avatar/Avatar.d.ts +11 -3
- package/components/Avatar/Avatar.js +56 -51
- package/components/AvatarGroup/AvatarGroup.css +3 -3
- package/components/AvatarGroup/AvatarGroup.d.ts +6 -3
- package/components/AvatarGroup/AvatarGroup.js +5 -2
- package/components/Badge/Badge.d.ts +9 -2
- package/components/Badge/Badge.js +10 -10
- package/components/Banner/Banner.d.ts +2 -0
- package/components/Banner/Banner.js +2 -1
- package/components/BentoTile/BentoTile.css +527 -0
- package/components/BentoTile/BentoTile.d.ts +64 -0
- package/components/BentoTile/BentoTile.js +303 -0
- package/components/BentoTile/BentoTileArt.d.ts +28 -0
- package/components/BentoTile/BentoTileArt.js +19 -0
- package/components/BottomNav/BottomNav.css +3 -3
- package/components/BottomNav/BottomNav.d.ts +6 -0
- package/components/BottomNav/BottomNav.js +3 -1
- package/components/Breadcrumb/Breadcrumb.d.ts +16 -5
- package/components/Breadcrumb/Breadcrumb.js +32 -33
- package/components/Button/Button.css +123 -20
- package/components/Button/Button.d.ts +18 -3
- package/components/Button/Button.js +19 -2
- package/components/ButtonGroup/ButtonGroup.d.ts +17 -3
- package/components/ButtonGroup/ButtonGroup.js +24 -24
- package/components/CardStack/CardStack.d.ts +5 -0
- package/components/CardStack/CardStack.js +3 -7
- package/components/Carousel/Carousel.d.ts +33 -3
- package/components/Carousel/Carousel.js +178 -137
- package/components/Chart/AreaChart.d.ts +11 -3
- package/components/Chart/AreaChart.js +20 -11
- package/components/Chart/BarChart.d.ts +11 -3
- package/components/Chart/BarChart.js +19 -9
- package/components/Chart/Chart.css +1 -0
- package/components/Chart/ComboChart.d.ts +11 -3
- package/components/Chart/ComboChart.js +21 -11
- package/components/Chart/LineChart.d.ts +11 -3
- package/components/Chart/LineChart.js +19 -10
- package/components/Chart/PieChart.d.ts +11 -3
- package/components/Chart/PieChart.js +18 -9
- package/components/Chart/RadarChart.d.ts +11 -3
- package/components/Chart/RadarChart.js +20 -11
- package/components/Chart/RadialChart.d.ts +11 -3
- package/components/Chart/RadialChart.js +18 -9
- package/components/Chart/ScatterChart.d.ts +11 -3
- package/components/Chart/ScatterChart.js +23 -11
- package/components/Chart/StackedBarChart.d.ts +11 -3
- package/components/Chart/StackedBarChart.js +19 -10
- package/components/Chart/Treemap.d.ts +13 -3
- package/components/Chart/Treemap.js +23 -13
- package/components/Chart/palette.d.ts +9 -0
- package/components/Chart/palette.js +8 -1
- package/components/Chart/useChartAnimation.d.ts +42 -0
- package/components/Chart/useChartAnimation.js +32 -0
- package/components/ChatMessage/ChatMessage.css +1 -0
- package/components/ChatThread/ChatThread.css +21 -0
- package/components/ChatThread/ChatThread.d.ts +12 -1
- package/components/ChatThread/ChatThread.js +48 -1
- package/components/Checkbox/Checkbox.d.ts +12 -2
- package/components/Checkbox/Checkbox.js +13 -3
- package/components/Chip/Chip.css +24 -1
- package/components/Chip/Chip.d.ts +28 -7
- package/components/Chip/Chip.js +80 -64
- package/components/CircularButton/CircularButton.css +127 -1
- package/components/CircularButton/CircularButton.d.ts +18 -4
- package/components/CircularButton/CircularButton.js +14 -2
- package/components/CodeBlock/CodeBlock.d.ts +24 -3
- package/components/CodeBlock/CodeBlock.js +93 -80
- package/components/CodeDiff/CodeDiff.d.ts +30 -4
- package/components/CodeDiff/CodeDiff.js +64 -20
- package/components/ColorPicker/ColorPicker.css +1 -1
- package/components/ColorPicker/ColorPicker.d.ts +18 -0
- package/components/ColorPicker/ColorPicker.js +27 -21
- package/components/ColourSwatch/ColourSwatch.css +1 -1
- package/components/Combobox/Combobox.css +2 -1
- package/components/Combobox/Combobox.d.ts +26 -8
- package/components/Combobox/Combobox.js +30 -17
- package/components/CommandPalette/CommandPalette.css +13 -1
- package/components/CommandPalette/CommandPalette.d.ts +27 -4
- package/components/CommandPalette/CommandPalette.js +108 -70
- package/components/Composer/Composer.css +2 -1
- package/components/Composer/Composer.d.ts +10 -0
- package/components/Composer/Composer.js +7 -0
- package/components/ContactCard/ContactCard.css +1 -1
- package/components/ContactCard/ContactCard.d.ts +34 -5
- package/components/ContactCard/ContactCard.js +72 -58
- package/components/ContextMenu/ContextMenu.css +4 -4
- package/components/ContextMenu/ContextMenu.js +7 -10
- package/components/ContributionGraph/ContributionGraph.d.ts +37 -3
- package/components/ContributionGraph/ContributionGraph.js +32 -31
- package/components/DataTable/DataTable.d.ts +29 -0
- package/components/DataTable/DataTable.js +15 -10
- package/components/DateInput/DateInput.js +2 -2
- package/components/DatePicker/DatePicker.css +19 -4
- package/components/DatePicker/DatePicker.d.ts +31 -0
- package/components/DatePicker/DatePicker.js +145 -61
- package/components/Dialog/Dialog.css +1 -1
- package/components/Dialog/Dialog.d.ts +2 -0
- package/components/Dialog/Dialog.js +4 -3
- package/components/Divider/Divider.d.ts +10 -2
- package/components/Divider/Divider.js +56 -25
- package/components/DocumentChip/DocumentChip.d.ts +3 -1
- package/components/DocumentChip/DocumentChip.js +3 -2
- package/components/Drawer/Drawer.css +2 -1
- package/components/Drawer/Drawer.d.ts +2 -0
- package/components/Drawer/Drawer.js +4 -3
- package/components/Dropdown/Dropdown.css +1 -1
- package/components/Dropdown/Dropdown.d.ts +9 -2
- package/components/Dropdown/Dropdown.js +26 -16
- package/components/DropdownMenu/DropdownMenu.css +5 -5
- package/components/DropdownMenu/DropdownMenu.d.ts +13 -4
- package/components/DropdownMenu/DropdownMenu.js +41 -22
- package/components/EmptyState/EmptyState.d.ts +12 -4
- package/components/EmptyState/EmptyState.js +30 -26
- package/components/EntityCard/EntityCard.d.ts +7 -2
- package/components/EntityCard/EntityCard.js +19 -21
- package/components/EventCalendar/EventCalendar.d.ts +28 -0
- package/components/EventCalendar/EventCalendar.js +29 -27
- package/components/Figure/Figure.d.ts +14 -5
- package/components/Figure/Figure.js +19 -21
- package/components/FileInput/FileInput.d.ts +6 -0
- package/components/FileInput/FileInput.js +9 -9
- package/components/FilterBar/FilterBar.css +3 -3
- package/components/FilterBar/FilterBar.d.ts +6 -1
- package/components/FilterBar/FilterBar.js +15 -11
- package/components/FunnelChart/FunnelChart.d.ts +13 -1
- package/components/FunnelChart/FunnelChart.js +8 -1
- package/components/GanttChart/GanttChart.css +1 -1
- package/components/GanttChart/GanttChart.d.ts +19 -2
- package/components/GanttChart/GanttChart.js +17 -8
- package/components/Gauge/Gauge.d.ts +4 -1
- package/components/Globe/Globe.css +23 -0
- package/components/Globe/Globe.d.ts +19 -2
- package/components/Globe/Globe.js +66 -19
- package/components/HoverCard/HoverCard.css +1 -1
- package/components/HoverCard/HoverCard.d.ts +4 -1
- package/components/HoverCard/HoverCard.js +26 -15
- package/components/ImageCompare/ImageCompare.d.ts +4 -0
- package/components/ImageCompare/ImageCompare.js +4 -2
- package/components/Input/Input.js +2 -2
- package/components/Inspector/Inspector.css +55 -38
- package/components/Inspector/InspectorDropdown.d.ts +6 -1
- package/components/Inspector/InspectorDropdown.js +2 -0
- package/components/Inspector/InspectorSegmentedControl.d.ts +4 -3
- package/components/Inspector/InspectorSegmentedControl.js +63 -11
- package/components/Inspector/InspectorToggleSwitch.d.ts +4 -3
- package/components/Inspector/InspectorToggleSwitch.js +35 -2
- package/components/Instructions/Instructions.css +1 -1
- package/components/Instructions/Instructions.d.ts +16 -5
- package/components/Instructions/Instructions.js +31 -26
- package/components/InterruptCard/InterruptCard.d.ts +13 -2
- package/components/InterruptCard/InterruptCard.js +9 -7
- package/components/Lightbox/Lightbox.css +1 -1
- package/components/Lightbox/Lightbox.d.ts +8 -0
- package/components/Lightbox/Lightbox.js +10 -6
- package/components/LinkList/LinkList.css +2 -2
- package/components/LinkList/LinkList.d.ts +11 -2
- package/components/LinkList/LinkList.js +40 -36
- package/components/Mention/Mention.d.ts +4 -1
- package/components/MessageActions/MessageActions.css +8 -0
- package/components/MessageActions/MessageActions.d.ts +2 -0
- package/components/MessageActions/MessageActions.js +2 -1
- package/components/MessageCard/MessageCard.d.ts +4 -1
- package/components/Meter/Meter.d.ts +5 -1
- package/components/ModelPicker/ModelPicker.css +2 -2
- package/components/ModelPicker/ModelPicker.d.ts +12 -1
- package/components/ModelPicker/ModelPicker.js +27 -16
- package/components/MotionSwatch/MotionSwatch.d.ts +3 -1
- package/components/MotionSwatch/MotionSwatch.js +2 -1
- package/components/Nav/Nav.d.ts +2 -2
- package/components/Nav/Nav.js +17 -21
- package/components/NavList/NavList.d.ts +4 -0
- package/components/NavList/NavList.js +3 -1
- package/components/NotificationCenter/NotificationCenter.css +1 -1
- package/components/NotificationCenter/NotificationCenter.d.ts +48 -5
- package/components/NotificationCenter/NotificationCenter.js +32 -15
- package/components/NumberInput/NumberInput.d.ts +4 -0
- package/components/NumberInput/NumberInput.js +4 -2
- package/components/Pagination/Pagination.d.ts +33 -7
- package/components/Pagination/Pagination.js +67 -55
- package/components/PinInput/PinInput.d.ts +6 -0
- package/components/PinInput/PinInput.js +3 -1
- package/components/Popover/Popover.css +1 -1
- package/components/Popover/Popover.d.ts +21 -5
- package/components/Popover/Popover.js +102 -97
- package/components/ProgressBar/ProgressBar.d.ts +10 -3
- package/components/ProgressBar/ProgressBar.js +34 -22
- package/components/PromptSuggestions/PromptSuggestions.css +67 -0
- package/components/PromptSuggestions/PromptSuggestions.d.ts +10 -0
- package/components/PromptSuggestions/PromptSuggestions.js +41 -26
- package/components/QuestionCard/QuestionCard.css +358 -0
- package/components/QuestionCard/QuestionCard.d.ts +138 -0
- package/components/QuestionCard/QuestionCard.js +378 -0
- package/components/Quote/Quote.d.ts +8 -3
- package/components/Quote/Quote.js +18 -21
- package/components/RadioButton/RadioButton.d.ts +6 -1
- package/components/RadioButton/RadioButton.js +7 -2
- package/components/Rating/Rating.d.ts +6 -0
- package/components/Rating/Rating.js +4 -2
- package/components/Reasoning/Reasoning.css +1 -0
- package/components/Reasoning/Reasoning.d.ts +7 -1
- package/components/Reasoning/Reasoning.js +4 -1
- package/components/RichDropdown/RichDropdown.css +1 -1
- package/components/RichDropdown/RichDropdown.d.ts +3 -1
- package/components/RichDropdown/RichDropdown.js +20 -15
- package/components/SectionTitle/SectionTitle.d.ts +15 -3
- package/components/SectionTitle/SectionTitle.js +15 -17
- package/components/SegmentedControl/SegmentedControl.css +3 -2
- package/components/SegmentedControl/SegmentedControl.d.ts +49 -7
- package/components/SegmentedControl/SegmentedControl.js +248 -223
- package/components/SelectionCard/SelectionCard.d.ts +7 -1
- package/components/SelectionCard/SelectionCard.js +16 -2
- package/components/ShaderField/ShaderField.js +2 -1
- package/components/ShaderField/useShaderField.js +3 -2
- package/components/SidebarPanel/SidebarPanel.d.ts +6 -1
- package/components/SidebarPanel/SidebarPanel.js +2 -1
- package/components/Skeleton/Skeleton.d.ts +12 -3
- package/components/Skeleton/Skeleton.js +53 -19
- package/components/Slider/Slider.d.ts +11 -2
- package/components/Slider/Slider.js +11 -6
- package/components/SourceChip/SourceChip.css +1 -1
- package/components/SourceChip/SourceChip.d.ts +5 -2
- package/components/SourceChip/SourceChip.js +14 -13
- package/components/SourceTrail/SourceTrail.d.ts +15 -0
- package/components/SourceTrail/SourceTrail.js +10 -4
- package/components/Sparkline/Sparkline.d.ts +4 -3
- package/components/Sparkline/Sparkline.js +2 -1
- package/components/Spinner/Spinner.d.ts +21 -4
- package/components/Spinner/Spinner.js +38 -37
- package/components/SplitButton/SplitButton.d.ts +10 -1
- package/components/SplitButton/SplitButton.js +13 -3
- package/components/Stat/Stat.d.ts +7 -2
- package/components/Stat/Stat.js +30 -25
- package/components/StatusDot/StatusDot.css +1 -0
- package/components/Stepper/Stepper.css +13 -0
- package/components/Stepper/Stepper.d.ts +6 -0
- package/components/Stepper/Stepper.js +2 -0
- package/components/StreamingText/StreamingText.d.ts +4 -4
- package/components/StreamingText/StreamingText.js +3 -2
- package/components/Tabs/Tabs.d.ts +41 -6
- package/components/Tabs/Tabs.js +99 -69
- package/components/TagInput/TagInput.d.ts +2 -0
- package/components/TagInput/TagInput.js +7 -2
- package/components/Textarea/Textarea.d.ts +6 -1
- package/components/Textarea/Textarea.js +11 -5
- package/components/ThreadPanel/ThreadPanel.css +1 -1
- package/components/ThreadPanel/ThreadPanel.d.ts +11 -4
- package/components/ThreadPanel/ThreadPanel.js +3 -1
- package/components/ThreadTabs/ThreadTabs.d.ts +7 -2
- package/components/ThreadTabs/ThreadTabs.js +1 -1
- package/components/TimePicker/TimePicker.css +1 -1
- package/components/TimePicker/TimePicker.d.ts +14 -1
- package/components/TimePicker/TimePicker.js +22 -17
- package/components/Timeline/Timeline.css +2 -2
- package/components/Timeline/Timeline.d.ts +11 -2
- package/components/Timeline/Timeline.js +37 -26
- package/components/Toast/Toast.css +2 -2
- package/components/Toast/Toast.d.ts +24 -6
- package/components/Toast/Toast.js +50 -41
- package/components/ToggleGroup/ToggleGroup.css +3 -2
- package/components/ToggleGroup/ToggleGroup.d.ts +26 -4
- package/components/ToggleGroup/ToggleGroup.js +12 -5
- package/components/ToggleSwitch/ToggleSwitch.d.ts +6 -1
- package/components/ToggleSwitch/ToggleSwitch.js +7 -2
- package/components/ToolCall/ToolCall.js +1 -1
- package/components/Tooltip/Tooltip.css +5 -5
- package/components/Tooltip/Tooltip.d.ts +15 -4
- package/components/Tooltip/Tooltip.js +80 -61
- package/components/TopAppBar/TopAppBar.css +1 -1
- package/components/TopAppBar/TopAppBar.d.ts +9 -1
- package/components/TopAppBar/TopAppBar.js +3 -1
- package/components/TypographySwatch/TypographySwatch.css +1 -1
- package/components/UsageCard/UsageCard.d.ts +4 -1
- package/components/Waveform/Waveform.css +1 -0
- package/components/Waveform/Waveform.d.ts +1 -1
- package/components/WorldMap/WorldMap.d.ts +12 -0
- package/components/WorldMap/WorldMap.js +11 -5
- package/components/registry.json +44 -19
- package/components/registry.json.d.ts +44 -19
- package/components/registry.json.js +1 -1
- package/index.d.ts +3 -0
- package/index.js +7 -0
- package/package.json +5 -1
- package/tokens/breakpoints.d.ts +60 -0
- package/tokens/breakpoints.js +92 -0
- package/tokens/motion.d.ts +14 -0
- package/tokens/motion.js +15 -1
- package/tokens/registry.d.ts +1 -1
- package/tokens/registry.json +21 -0
- package/tokens/registry.json.d.ts +21 -0
- package/tokens/registry.json.js +1 -1
- package/tokens/tokens-dark.css +7 -0
- package/tokens/tokens-light.css +41 -0
package/chat/ChatWidget.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo, useRef, useEffect, useSyncExternalStore, useState, useId } from "react";
|
|
4
4
|
import { AttachmentDropZone } from "../components/Attachment/AttachmentDropZone.js";
|
|
5
5
|
import { AttachmentGroup } from "../components/Attachment/AttachmentGroup.js";
|
|
6
6
|
import { useAttachments } from "../components/Attachment/useAttachments.js";
|
|
@@ -22,16 +22,22 @@ import { ChatArtifactPane } from "./ChatArtifactPane.js";
|
|
|
22
22
|
import { ChatTabs } from "./ChatTabs.js";
|
|
23
23
|
import { ChatThreads } from "./ChatThreads.js";
|
|
24
24
|
import { useChatWidget, ArtifactSeatContext } from "./context.js";
|
|
25
|
-
import { subscribeClock,
|
|
25
|
+
import { DEFAULT_GREETING_COPY, subscribeClock, greetingFor, serverGreeting } from "./greeting.js";
|
|
26
26
|
import { CHAT_PLACEMENTS, chatPlacement } from "./placement.js";
|
|
27
27
|
import { ASIDE_WITH_THREADS_MIN_WIDTH, ARTIFACT_MIN_COLUMN_WIDTH, THREADS_RAIL_MIN_WIDTH, ASIDE_RAIL_MIN_WIDTH } from "./queries.js";
|
|
28
28
|
import { fitsChip } from "./suggestions.js";
|
|
29
29
|
import { TurnCard } from "./TurnContent.js";
|
|
30
|
+
import { isBlockingQuestion } from "./questions.js";
|
|
31
|
+
import { ReplyBody } from "./TurnQuestion.js";
|
|
32
|
+
import { ResponseActionsLabelsContext } from "./ResponseActions.js";
|
|
33
|
+
import { FollowupSuggestionsLabelContext } from "./FollowupSuggestions.js";
|
|
30
34
|
import "./ChatWidget.css";
|
|
31
35
|
const DEFAULT_MAX_ATTACHMENTS = 10;
|
|
32
36
|
const DEFAULT_MAX_ATTACHMENT_BYTES = 50 * 1024 * 1024;
|
|
33
37
|
const LONG_PASTE_CHARS = 1200;
|
|
34
38
|
const formatBytes = (bytes) => bytes >= 1024 * 1024 * 1024 ? `${Math.round(bytes / (1024 * 1024 * 1024))} GB` : `${Math.round(bytes / (1024 * 1024))} MB`;
|
|
39
|
+
const defaultAttachHint = (maxSize, maxFiles) => `Up to ${maxSize} each · ${maxFiles} files max`;
|
|
40
|
+
const defaultContextNote = (title) => `Looking at “${title}”`;
|
|
35
41
|
const withAgentMark = (profile, title) => profile.avatar || profile.avatarSrc ? profile : { ...profile, avatar: /* @__PURE__ */ jsx(PixelAvatar, { name: title, size: "lg", label: title }) };
|
|
36
42
|
function ChatWidget({
|
|
37
43
|
fullscreenEnabled = true,
|
|
@@ -40,7 +46,9 @@ function ChatWidget({
|
|
|
40
46
|
compact = false,
|
|
41
47
|
phone = false,
|
|
42
48
|
title = "Assistant",
|
|
49
|
+
flow = "top-down",
|
|
43
50
|
placeholder = "Ask anything",
|
|
51
|
+
questionsPlaceholder = "Answer the questions above, or skip them",
|
|
44
52
|
showStarters = true,
|
|
45
53
|
logo = null,
|
|
46
54
|
tagline = "How can I help you today?",
|
|
@@ -61,11 +69,74 @@ function ChatWidget({
|
|
|
61
69
|
agent,
|
|
62
70
|
artifacts = false,
|
|
63
71
|
contextLabel,
|
|
72
|
+
contextNote = defaultContextNote,
|
|
73
|
+
attachHint: attachHintText = defaultAttachHint,
|
|
74
|
+
greetings,
|
|
75
|
+
placementLabels,
|
|
76
|
+
agentStatus = "Connected",
|
|
77
|
+
artifactPanelTitle = "Artifacts",
|
|
78
|
+
artifactEmptyTitle = "Nothing here yet",
|
|
79
|
+
artifactEmptyDescription = "What the chat makes for you, like a dashboard or a page, opens in this panel.",
|
|
64
80
|
widgets,
|
|
65
81
|
widgetsLayout = "fit",
|
|
66
82
|
widgetsWidth = "column",
|
|
67
|
-
disclaimer = "Answers may be wrong."
|
|
83
|
+
disclaimer = "Answers may be wrong.",
|
|
84
|
+
startersLabel = "Conversation starters",
|
|
85
|
+
newChatLabel = "New chat",
|
|
86
|
+
showAgentLabel = "Show the agent panel",
|
|
87
|
+
hideAgentLabel = "Hide the agent panel",
|
|
88
|
+
closeAgentLabel = "Close the agent panel",
|
|
89
|
+
showArtifactLabel = "Show the artifact panel",
|
|
90
|
+
hideArtifactLabel = "Hide the artifact panel",
|
|
91
|
+
closeArtifactLabel = "Close the artifact panel",
|
|
92
|
+
placementLabel = "Chat position",
|
|
93
|
+
enterFullscreenLabel = "Enter full screen",
|
|
94
|
+
exitFullscreenLabel = "Exit full screen",
|
|
95
|
+
closeLabel = "Close chat",
|
|
96
|
+
openThreadsLabel = "Open the chat history",
|
|
97
|
+
closeThreadsLabel = "Close the chat history",
|
|
98
|
+
modelPickerLabel = "Choose a model",
|
|
99
|
+
sendLabel = "Send",
|
|
100
|
+
copyResponseLabel = "Copy response",
|
|
101
|
+
copiedResponseLabel = "Copied",
|
|
102
|
+
copiedAnnouncementLabel = "Copied to clipboard",
|
|
103
|
+
goodResponseLabel = "Good response",
|
|
104
|
+
badResponseLabel = "Bad response",
|
|
105
|
+
followupsLabel = "Follow-up questions",
|
|
106
|
+
pastedTextLabel,
|
|
107
|
+
reasoningLabel,
|
|
108
|
+
tabsProps,
|
|
109
|
+
composerLabels,
|
|
110
|
+
attachmentDropZoneLabels,
|
|
111
|
+
attachmentGroupLabels,
|
|
112
|
+
chatThreadLabels,
|
|
113
|
+
modelPickerLabels,
|
|
114
|
+
artifactPanelLabels,
|
|
115
|
+
agentRailLabels,
|
|
116
|
+
questionCardLabels,
|
|
117
|
+
questionSummaryLabels,
|
|
118
|
+
codeBlockLabels,
|
|
119
|
+
promptSuggestionsLabels
|
|
68
120
|
}) {
|
|
121
|
+
const responseActionsLabels = useMemo(
|
|
122
|
+
() => ({
|
|
123
|
+
copy: copyResponseLabel,
|
|
124
|
+
copied: copiedResponseLabel,
|
|
125
|
+
copiedAnnouncement: copiedAnnouncementLabel,
|
|
126
|
+
good: goodResponseLabel,
|
|
127
|
+
bad: badResponseLabel
|
|
128
|
+
}),
|
|
129
|
+
[copyResponseLabel, copiedResponseLabel, copiedAnnouncementLabel, goodResponseLabel, badResponseLabel]
|
|
130
|
+
);
|
|
131
|
+
const turnLabels = useMemo(
|
|
132
|
+
() => ({
|
|
133
|
+
codeBlock: codeBlockLabels,
|
|
134
|
+
reasoning: reasoningLabel,
|
|
135
|
+
questionCard: questionCardLabels,
|
|
136
|
+
promptSuggestions: promptSuggestionsLabels
|
|
137
|
+
}),
|
|
138
|
+
[codeBlockLabels, reasoningLabel, questionCardLabels, promptSuggestionsLabels]
|
|
139
|
+
);
|
|
69
140
|
const {
|
|
70
141
|
turns,
|
|
71
142
|
live,
|
|
@@ -91,6 +162,14 @@ function ChatWidget({
|
|
|
91
162
|
openArtifact,
|
|
92
163
|
closeArtifact
|
|
93
164
|
} = useChatWidget();
|
|
165
|
+
const questionsOpen = isBlockingQuestion(turns[turns.length - 1], live !== null);
|
|
166
|
+
const questionsWereOpen = useRef(questionsOpen);
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (questionsWereOpen.current && !questionsOpen) {
|
|
169
|
+
composerRef.current?.focus({ preventScroll: true });
|
|
170
|
+
}
|
|
171
|
+
questionsWereOpen.current = questionsOpen;
|
|
172
|
+
}, [questionsOpen]);
|
|
94
173
|
const lockedValues = modelPolicy?.locked ?? [];
|
|
95
174
|
const pick = chosenModel && !lockedValues.includes(chosenModel) ? chosenModel : null;
|
|
96
175
|
const pickerValue = pick ?? modelPolicy?.default ?? defaultModel ?? models?.[0]?.value;
|
|
@@ -100,7 +179,12 @@ function ChatWidget({
|
|
|
100
179
|
description: lockedValues.includes(option.value) ? lockedModelDescription : option.description,
|
|
101
180
|
disabled: lockedValues.includes(option.value)
|
|
102
181
|
}));
|
|
103
|
-
const
|
|
182
|
+
const greetingCopy = { ...DEFAULT_GREETING_COPY, ...greetings };
|
|
183
|
+
const greeting = useSyncExternalStore(
|
|
184
|
+
subscribeClock,
|
|
185
|
+
() => greetingFor((/* @__PURE__ */ new Date()).getHours(), greetingCopy),
|
|
186
|
+
serverGreeting
|
|
187
|
+
);
|
|
104
188
|
const starters = (startersInput ?? []).filter((starter) => fitsChip(starter.label));
|
|
105
189
|
const composerRef = useRef(null);
|
|
106
190
|
const focusComposer = () => composerRef.current?.focus({ preventScroll: true });
|
|
@@ -108,7 +192,7 @@ function ChatWidget({
|
|
|
108
192
|
if (open) focusComposer();
|
|
109
193
|
}, [open]);
|
|
110
194
|
const queue = useAttachments({ maxCount: maxAttachments, maxSize: maxAttachmentBytes });
|
|
111
|
-
const attachHint =
|
|
195
|
+
const attachHint = attachHintText(formatBytes(maxAttachmentBytes), maxAttachments, maxAttachmentBytes);
|
|
112
196
|
const handleSubmit = (value) => {
|
|
113
197
|
if (fileAttachments && queue.items.length > 0) {
|
|
114
198
|
const ready = queue.items.filter((item) => item.status === "ready");
|
|
@@ -136,13 +220,15 @@ function ChatWidget({
|
|
|
136
220
|
const renderAside = aside ?? (agent ? (ctx) => /* @__PURE__ */ jsx(
|
|
137
221
|
ChatAgentPane,
|
|
138
222
|
{
|
|
139
|
-
profile: withAgentMark(agent.profile ?? { name: title, status:
|
|
223
|
+
profile: withAgentMark(agent.profile ?? { name: title, status: agentStatus }, title),
|
|
140
224
|
tabs: agent.tabs,
|
|
225
|
+
closeLabel: closeAgentLabel,
|
|
226
|
+
agentRailLabels,
|
|
141
227
|
overlay: ctx.overlay,
|
|
142
228
|
onClose: ctx.close
|
|
143
229
|
}
|
|
144
230
|
) : void 0);
|
|
145
|
-
const tabsNode = tabs === true ? /* @__PURE__ */ jsx(ChatTabs, {}) : tabs || null;
|
|
231
|
+
const tabsNode = tabs === true ? /* @__PURE__ */ jsx(ChatTabs, { ...tabsProps }) : tabs || null;
|
|
146
232
|
const hasRails = Boolean(renderThreads || renderAside || artifacts);
|
|
147
233
|
const [threadsOpen, setThreadsOpen] = useState(false);
|
|
148
234
|
const [asideOpen, setAsideOpen] = useState(Boolean(agent?.defaultOpen));
|
|
@@ -280,7 +366,7 @@ function ChatWidget({
|
|
|
280
366
|
PromptSuggestions,
|
|
281
367
|
{
|
|
282
368
|
layout: "stack",
|
|
283
|
-
ariaLabel:
|
|
369
|
+
ariaLabel: startersLabel,
|
|
284
370
|
pending: startersThinking,
|
|
285
371
|
entrance: startersEntrance,
|
|
286
372
|
suggestions: starters,
|
|
@@ -301,7 +387,7 @@ function ChatWidget({
|
|
|
301
387
|
{
|
|
302
388
|
icon: "edit_square",
|
|
303
389
|
variant: "tertiary",
|
|
304
|
-
ariaLabel:
|
|
390
|
+
ariaLabel: newChatLabel,
|
|
305
391
|
tooltipPosition: "bottom",
|
|
306
392
|
onClick: () => {
|
|
307
393
|
reset();
|
|
@@ -316,7 +402,7 @@ function ChatWidget({
|
|
|
316
402
|
icon: /* @__PURE__ */ jsx(PixelAvatar, { name: title, size: "sm" }),
|
|
317
403
|
variant: "tertiary",
|
|
318
404
|
className: asideShown ? "ds-chat-widget__agent-toggle--on" : void 0,
|
|
319
|
-
ariaLabel: asideShown ?
|
|
405
|
+
ariaLabel: asideShown ? hideAgentLabel : showAgentLabel,
|
|
320
406
|
tooltipPosition: "bottom",
|
|
321
407
|
"aria-expanded": asideShown,
|
|
322
408
|
"aria-controls": asideShown ? asideId : void 0,
|
|
@@ -329,7 +415,7 @@ function ChatWidget({
|
|
|
329
415
|
icon: artifactShown ? "right_panel_close" : "right_panel_open",
|
|
330
416
|
variant: "tertiary",
|
|
331
417
|
className: artifactShown ? "ds-chat-widget__agent-toggle--on" : void 0,
|
|
332
|
-
ariaLabel: artifactShown ?
|
|
418
|
+
ariaLabel: artifactShown ? hideArtifactLabel : showArtifactLabel,
|
|
333
419
|
tooltipPosition: "bottom",
|
|
334
420
|
"aria-expanded": artifactShown,
|
|
335
421
|
"aria-controls": artifactShown ? artifactId : void 0,
|
|
@@ -340,51 +426,40 @@ function ChatWidget({
|
|
|
340
426
|
}
|
|
341
427
|
}
|
|
342
428
|
),
|
|
343
|
-
placementEnabled && /* @__PURE__ */ jsx(
|
|
344
|
-
|
|
429
|
+
placementEnabled && /* @__PURE__ */ jsx("span", { className: "ds-chat-widget__placement-menu", children: /* @__PURE__ */ jsx(
|
|
430
|
+
DropdownMenu,
|
|
345
431
|
{
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
432
|
+
align: "end",
|
|
433
|
+
trigger: /* @__PURE__ */ jsx(
|
|
434
|
+
CircularButton,
|
|
435
|
+
{
|
|
436
|
+
icon: chatPlacement(placement).icon,
|
|
437
|
+
variant: "tertiary",
|
|
438
|
+
ariaLabel: placementLabel,
|
|
439
|
+
tooltipPosition: "bottom",
|
|
440
|
+
disabled: isFull
|
|
350
441
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
DropdownMenu,
|
|
442
|
+
),
|
|
443
|
+
items: [
|
|
354
444
|
{
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
disabled: isFull
|
|
364
|
-
}
|
|
365
|
-
),
|
|
366
|
-
items: [
|
|
367
|
-
{
|
|
368
|
-
type: "group",
|
|
369
|
-
label: "Chat position",
|
|
370
|
-
items: CHAT_PLACEMENTS.map(({ id, label, icon }) => ({
|
|
371
|
-
label,
|
|
372
|
-
icon,
|
|
373
|
-
selected: placement === id,
|
|
374
|
-
onClick: () => setPlacement(id)
|
|
375
|
-
}))
|
|
376
|
-
}
|
|
377
|
-
]
|
|
445
|
+
type: "group",
|
|
446
|
+
label: placementLabel,
|
|
447
|
+
items: CHAT_PLACEMENTS.map(({ id, label, icon }) => ({
|
|
448
|
+
label: placementLabels?.[id] ?? label,
|
|
449
|
+
icon,
|
|
450
|
+
selected: placement === id,
|
|
451
|
+
onClick: () => setPlacement(id)
|
|
452
|
+
}))
|
|
378
453
|
}
|
|
379
|
-
|
|
454
|
+
]
|
|
380
455
|
}
|
|
381
|
-
),
|
|
456
|
+
) }),
|
|
382
457
|
fullscreenEnabled && /* @__PURE__ */ jsx(
|
|
383
458
|
CircularButton,
|
|
384
459
|
{
|
|
385
460
|
icon: isFull ? "close_fullscreen" : "open_in_full",
|
|
386
461
|
variant: "tertiary",
|
|
387
|
-
ariaLabel: isFull ?
|
|
462
|
+
ariaLabel: isFull ? exitFullscreenLabel : enterFullscreenLabel,
|
|
388
463
|
tooltipPosition: "bottom",
|
|
389
464
|
onClick: () => setView(isFull ? "panel" : "full")
|
|
390
465
|
}
|
|
@@ -394,14 +469,14 @@ function ChatWidget({
|
|
|
394
469
|
{
|
|
395
470
|
icon: "close",
|
|
396
471
|
variant: "tertiary",
|
|
397
|
-
ariaLabel:
|
|
472
|
+
ariaLabel: closeLabel,
|
|
398
473
|
tooltipPosition: "bottom",
|
|
399
474
|
onClick: () => setOpen(false)
|
|
400
475
|
}
|
|
401
476
|
)
|
|
402
477
|
] });
|
|
403
478
|
const ChatRoot = fileAttachments ? AttachmentDropZone : "div";
|
|
404
|
-
const dropProps = fileAttachments ? { onFilesSelected: queue.add, hint: attachHint } : {};
|
|
479
|
+
const dropProps = fileAttachments ? { ...attachmentDropZoneLabels, onFilesSelected: queue.add, hint: attachHint } : {};
|
|
405
480
|
const [rootScrolling, setRootScrolling] = useState(false);
|
|
406
481
|
const rootSettleTimer = useRef(void 0);
|
|
407
482
|
const handleRootScroll = () => {
|
|
@@ -424,6 +499,7 @@ function ChatWidget({
|
|
|
424
499
|
onScroll: handleRootScroll,
|
|
425
500
|
"data-lifted-actions": trailingInline || void 0,
|
|
426
501
|
onKeyDown: (e) => {
|
|
502
|
+
if (e.key === "Escape" && e.defaultPrevented) return;
|
|
427
503
|
if (e.key === "Escape" && (threadsOpen || asideShown && !asideWide || artifactShown && !asideWide)) {
|
|
428
504
|
e.stopPropagation();
|
|
429
505
|
if (threadsOpen) closeThreads();
|
|
@@ -454,7 +530,7 @@ function ChatWidget({
|
|
|
454
530
|
{
|
|
455
531
|
icon: "menu",
|
|
456
532
|
variant: "tertiary",
|
|
457
|
-
ariaLabel:
|
|
533
|
+
ariaLabel: openThreadsLabel,
|
|
458
534
|
tooltipPosition: "bottom",
|
|
459
535
|
onClick: () => setThreadsOpen(true)
|
|
460
536
|
}
|
|
@@ -478,7 +554,7 @@ function ChatWidget({
|
|
|
478
554
|
),
|
|
479
555
|
tabsNode && /* @__PURE__ */ jsx("div", { className: "ds-chat-widget__tabs-row", children: tabsNode }),
|
|
480
556
|
/* @__PURE__ */ jsxs("div", { className: "ds-chat-widget__body", children: [
|
|
481
|
-
/* @__PURE__ */ jsx(ArtifactSeatContext.Provider, { value: artifacts, children: /* @__PURE__ */ jsx(ChatThread, { className: "ds-chat-widget__thread", children: [
|
|
557
|
+
/* @__PURE__ */ jsx(ArtifactSeatContext.Provider, { value: artifacts, children: /* @__PURE__ */ jsx(ResponseActionsLabelsContext.Provider, { value: responseActionsLabels, children: /* @__PURE__ */ jsx(FollowupSuggestionsLabelContext.Provider, { value: followupsLabel, children: /* @__PURE__ */ jsx(ChatThread, { ...chatThreadLabels, className: "ds-chat-widget__thread", flow, children: [
|
|
482
558
|
...turns.map(
|
|
483
559
|
(turn) => turn.bare ? (
|
|
484
560
|
/* Conversation furniture (a day marker): the injected
|
|
@@ -491,18 +567,18 @@ function ChatWidget({
|
|
|
491
567
|
ChatMessage,
|
|
492
568
|
{
|
|
493
569
|
role: "user",
|
|
494
|
-
attachments: turn.attachments ? /* @__PURE__ */ jsx(AttachmentGroup, { align: "end", items: turn.attachments }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
570
|
+
attachments: turn.attachments ? /* @__PURE__ */ jsx(AttachmentGroup, { ...attachmentGroupLabels, align: "end", items: turn.attachments }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
495
571
|
turn.content,
|
|
496
572
|
turn.card && /* @__PURE__ */ jsx(TurnCard, { card: turn.card })
|
|
497
573
|
] }),
|
|
498
|
-
children: mentions && turn.text ? /* @__PURE__ */ jsx(MentionText, { text: turn.text, sources: mentions }) : turn.text
|
|
574
|
+
children: turn.reply ? /* @__PURE__ */ jsx(ReplyBody, { reply: turn.reply, text: turn.text, missingLabel: questionSummaryLabels?.missingLabel }) : mentions && turn.text ? /* @__PURE__ */ jsx(MentionText, { text: turn.text, sources: mentions }) : turn.text
|
|
499
575
|
},
|
|
500
576
|
turn.id
|
|
501
577
|
)
|
|
502
|
-
) : /* @__PURE__ */ jsx(AssistantTurn, { turn }, turn.id)
|
|
578
|
+
) : /* @__PURE__ */ jsx(AssistantTurn, { turn, labels: turnLabels }, turn.id)
|
|
503
579
|
),
|
|
504
|
-
...live ? [/* @__PURE__ */ jsx(AssistantTurn, { live }, live.id)] : []
|
|
505
|
-
] }) }),
|
|
580
|
+
...live ? [/* @__PURE__ */ jsx(AssistantTurn, { live, labels: turnLabels }, live.id)] : []
|
|
581
|
+
] }) }) }) }),
|
|
506
582
|
isEmpty && /* @__PURE__ */ jsx("div", { className: "ds-chat-widget__welcome", children: /* @__PURE__ */ jsxs("div", { className: "ds-chat-widget__greeting", children: [
|
|
507
583
|
/* @__PURE__ */ jsx("p", { className: "ds-chat-widget__hello", children: greeting }),
|
|
508
584
|
/* @__PURE__ */ jsx("p", { className: "ds-chat-widget__ask", children: tagline })
|
|
@@ -514,20 +590,18 @@ function ChatWidget({
|
|
|
514
590
|
/* @__PURE__ */ jsx("footer", { className: "ds-chat-widget__footer", children: /* @__PURE__ */ jsx("div", { className: "ds-chat-widget__composer", children: /* @__PURE__ */ jsx(
|
|
515
591
|
Composer,
|
|
516
592
|
{
|
|
593
|
+
...composerLabels,
|
|
517
594
|
ref: composerRef,
|
|
518
|
-
placeholder,
|
|
519
|
-
|
|
595
|
+
placeholder: questionsOpen ? questionsPlaceholder : placeholder,
|
|
596
|
+
disabled: questionsOpen,
|
|
597
|
+
sendLabel,
|
|
520
598
|
aiGlow: true,
|
|
521
599
|
value: draft,
|
|
522
600
|
onValueChange: setDraft,
|
|
523
601
|
onSubmit: handleSubmit,
|
|
524
602
|
streaming,
|
|
525
603
|
onStop: stop,
|
|
526
|
-
context: contextLabel ?
|
|
527
|
-
"Looking at “",
|
|
528
|
-
contextLabel,
|
|
529
|
-
"”"
|
|
530
|
-
] }) : void 0,
|
|
604
|
+
context: contextLabel ? contextNote(contextLabel) : void 0,
|
|
531
605
|
contextIcon: "description",
|
|
532
606
|
contextPlacement: "above",
|
|
533
607
|
mentions,
|
|
@@ -536,7 +610,7 @@ function ChatWidget({
|
|
|
536
610
|
onFilesSelected: queue.add,
|
|
537
611
|
onFileRemove: queue.remove,
|
|
538
612
|
pasteThreshold: LONG_PASTE_CHARS,
|
|
539
|
-
onPasteAsAttachment: (text) => queue.addText(text)
|
|
613
|
+
onPasteAsAttachment: (text) => queue.addText(text, pastedTextLabel)
|
|
540
614
|
} : {},
|
|
541
615
|
actions: (
|
|
542
616
|
/* A host can slot its own leading actions. The default is the
|
|
@@ -547,11 +621,12 @@ function ChatWidget({
|
|
|
547
621
|
composerActions ?? (pickerModels.length > 0 ? /* @__PURE__ */ jsx(
|
|
548
622
|
ModelPicker,
|
|
549
623
|
{
|
|
624
|
+
...modelPickerLabels,
|
|
550
625
|
models: pickerModels,
|
|
551
626
|
value: pickerValue,
|
|
552
627
|
onValueChange: setChosenModel,
|
|
553
628
|
placement: "top",
|
|
554
|
-
"aria-label":
|
|
629
|
+
"aria-label": modelPickerLabel
|
|
555
630
|
}
|
|
556
631
|
) : void 0)
|
|
557
632
|
)
|
|
@@ -582,7 +657,7 @@ function ChatWidget({
|
|
|
582
657
|
"data-artifact-resizing": artifactResizing || void 0,
|
|
583
658
|
style: artifactWidth !== null ? { "--ds-chat-artifact-width": `${artifactWidth}px` } : void 0,
|
|
584
659
|
onKeyDown: (event) => {
|
|
585
|
-
if (event.key === "Escape" && artifactExpanded) {
|
|
660
|
+
if (event.key === "Escape" && artifactExpanded && !event.defaultPrevented) {
|
|
586
661
|
event.stopPropagation();
|
|
587
662
|
setArtifactExpanded(false);
|
|
588
663
|
}
|
|
@@ -625,7 +700,11 @@ function ChatWidget({
|
|
|
625
700
|
artifact: heldArtifact,
|
|
626
701
|
expanded: artifactExpanded,
|
|
627
702
|
onExpandedChange: setArtifactExpanded,
|
|
628
|
-
onClose: closeArtifactPanel
|
|
703
|
+
onClose: closeArtifactPanel,
|
|
704
|
+
artifactPanelLabels,
|
|
705
|
+
emptyPanelTitle: artifactPanelTitle,
|
|
706
|
+
emptyTitle: artifactEmptyTitle,
|
|
707
|
+
emptyDescription: artifactEmptyDescription
|
|
629
708
|
}
|
|
630
709
|
) })
|
|
631
710
|
}
|
|
@@ -640,7 +719,7 @@ function ChatWidget({
|
|
|
640
719
|
{
|
|
641
720
|
type: "button",
|
|
642
721
|
className: "ds-chat-widget__rail-scrim",
|
|
643
|
-
"aria-label":
|
|
722
|
+
"aria-label": closeArtifactLabel,
|
|
644
723
|
tabIndex: artifactShown ? 0 : -1,
|
|
645
724
|
onClick: closeArtifactPanel
|
|
646
725
|
}
|
|
@@ -652,7 +731,17 @@ function ChatWidget({
|
|
|
652
731
|
id: artifactId,
|
|
653
732
|
children: [
|
|
654
733
|
/* @__PURE__ */ jsx("span", { className: "ds-chat-widget__aside-grabber", "aria-hidden": "true" }),
|
|
655
|
-
/* @__PURE__ */ jsx("div", { className: "ds-chat-widget__aside-sheet-body", children: /* @__PURE__ */ jsx(
|
|
734
|
+
/* @__PURE__ */ jsx("div", { className: "ds-chat-widget__aside-sheet-body", children: /* @__PURE__ */ jsx(
|
|
735
|
+
ChatArtifactPane,
|
|
736
|
+
{
|
|
737
|
+
artifact: heldArtifact,
|
|
738
|
+
onClose: closeArtifactPanel,
|
|
739
|
+
artifactPanelLabels,
|
|
740
|
+
emptyPanelTitle: artifactPanelTitle,
|
|
741
|
+
emptyTitle: artifactEmptyTitle,
|
|
742
|
+
emptyDescription: artifactEmptyDescription
|
|
743
|
+
}
|
|
744
|
+
) })
|
|
656
745
|
]
|
|
657
746
|
}
|
|
658
747
|
)
|
|
@@ -669,7 +758,7 @@ function ChatWidget({
|
|
|
669
758
|
{
|
|
670
759
|
type: "button",
|
|
671
760
|
className: "ds-chat-widget__rail-scrim",
|
|
672
|
-
"aria-label":
|
|
761
|
+
"aria-label": closeThreadsLabel,
|
|
673
762
|
tabIndex: threadsOpen ? 0 : -1,
|
|
674
763
|
onClick: closeThreads
|
|
675
764
|
}
|
|
@@ -688,7 +777,7 @@ function ChatWidget({
|
|
|
688
777
|
{
|
|
689
778
|
type: "button",
|
|
690
779
|
className: "ds-chat-widget__rail-scrim",
|
|
691
|
-
"aria-label":
|
|
780
|
+
"aria-label": closeAgentLabel,
|
|
692
781
|
tabIndex: asideShown ? 0 : -1,
|
|
693
782
|
onClick: closeAside
|
|
694
783
|
}
|
package/chat/DemoWelcome.js
CHANGED
|
@@ -61,7 +61,7 @@ function DemoBoard({ onAsk }) {
|
|
|
61
61
|
/* @__PURE__ */ jsx(WidgetRow, { title: "How is the trial going?", meta: "Ask", onClick: () => onAsk("How is the trial going?") })
|
|
62
62
|
] }),
|
|
63
63
|
/* @__PURE__ */ jsx(Widget, { title: "Projects", count: BOARD_PROJECTS.length, children: BOARD_PROJECTS.map(([name, state, when]) => /* @__PURE__ */ jsx(WidgetRow, { leading: /* @__PURE__ */ jsx(PixelAvatar, { name }), title: name, description: state, meta: when }, name)) }),
|
|
64
|
-
/* @__PURE__ */ jsxs(Widget, { title: "To do", count:
|
|
64
|
+
/* @__PURE__ */ jsxs(Widget, { title: "To do", count: 5, children: [
|
|
65
65
|
/* @__PURE__ */ jsxs(WidgetGroup, { label: "Waiting on you", children: [
|
|
66
66
|
/* @__PURE__ */ jsx(
|
|
67
67
|
WidgetRow,
|
|
@@ -70,7 +70,7 @@ function DemoBoard({ onAsk }) {
|
|
|
70
70
|
title: "Invite the other three",
|
|
71
71
|
description: "2 of 5 seats filled",
|
|
72
72
|
meta: "Today",
|
|
73
|
-
onClick: () => onAsk("
|
|
73
|
+
onClick: () => onAsk("Invite my team to a workspace")
|
|
74
74
|
}
|
|
75
75
|
),
|
|
76
76
|
/* @__PURE__ */ jsx(
|
|
@@ -80,7 +80,17 @@ function DemoBoard({ onAsk }) {
|
|
|
80
80
|
title: "Choose a plan",
|
|
81
81
|
description: "Trial ends in 9 days",
|
|
82
82
|
meta: "Oct 19",
|
|
83
|
-
onClick: () => onAsk("
|
|
83
|
+
onClick: () => onAsk("Help me pick a plan")
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
WidgetRow,
|
|
88
|
+
{
|
|
89
|
+
leading: /* @__PURE__ */ jsx(StatusDot, { variant: "info", size: "sm", "aria-hidden": "true" }),
|
|
90
|
+
title: "Plan the launch kickoff",
|
|
91
|
+
description: "A date, who comes, and how",
|
|
92
|
+
meta: "Oct 21",
|
|
93
|
+
onClick: () => onAsk("Plan our launch kickoff")
|
|
84
94
|
}
|
|
85
95
|
)
|
|
86
96
|
] }),
|
|
@@ -91,7 +101,8 @@ function DemoBoard({ onAsk }) {
|
|
|
91
101
|
leading: /* @__PURE__ */ jsx(StatusDot, { variant: "positive", size: "sm", "aria-hidden": "true" }),
|
|
92
102
|
title: "Shared calendar",
|
|
93
103
|
description: "Synced an hour ago",
|
|
94
|
-
meta: "On"
|
|
104
|
+
meta: "On",
|
|
105
|
+
onClick: () => onAsk("Find a time we can all meet")
|
|
95
106
|
}
|
|
96
107
|
),
|
|
97
108
|
/* @__PURE__ */ jsx(
|
|
@@ -100,7 +111,8 @@ function DemoBoard({ onAsk }) {
|
|
|
100
111
|
leading: /* @__PURE__ */ jsx(StatusDot, { variant: "neutral", size: "sm", "aria-hidden": "true" }),
|
|
101
112
|
title: "Mention notifications",
|
|
102
113
|
description: "Quiet hours, 6pm to 8am",
|
|
103
|
-
meta: "Paused"
|
|
114
|
+
meta: "Paused",
|
|
115
|
+
onClick: () => onAsk("Set up notifications for me")
|
|
104
116
|
}
|
|
105
117
|
)
|
|
106
118
|
] })
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
export declare const FollowupSuggestionsLabelContext: import('react').Context<string>;
|
|
1
2
|
/**
|
|
2
3
|
* The follow-up questions under a finished answer. Deliberately the same
|
|
3
4
|
* component, layout and scale as the welcome screen's conversation starters:
|
|
4
5
|
* one pattern for "here is something you could ask", whether the conversation
|
|
5
6
|
* has started or not. The only difference is where the questions come from.
|
|
6
7
|
*
|
|
7
|
-
* Tapping one sends it as the next message
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Tapping one sends it as the next message and keeps the row as the record
|
|
9
|
+
* of that choice: the chip checked, the rest dimmed and inert. A tap while a
|
|
10
|
+
* response is already streaming is ignored by `send`, the same as pressing
|
|
11
|
+
* enter in the composer would be, and leaves the row as it was.
|
|
10
12
|
*
|
|
11
13
|
* While the questions are still being generated, `pending` shows the row's
|
|
12
14
|
* shimmer placeholders in their place: a real loading state, unlike the
|
|
13
15
|
* welcome starters' staged one.
|
|
14
16
|
*/
|
|
15
|
-
export declare function FollowupSuggestions({ turnId, suggestions, pending, entrance, }: {
|
|
17
|
+
export declare function FollowupSuggestions({ turnId, suggestions, pending, entrance, chosen, chosenLabel, }: {
|
|
16
18
|
/** The turn these belong to; makes each suggestion's id unique in the thread. */
|
|
17
19
|
turnId: string;
|
|
18
20
|
suggestions: string[];
|
|
@@ -20,4 +22,8 @@ export declare function FollowupSuggestions({ turnId, suggestions, pending, entr
|
|
|
20
22
|
pending?: boolean;
|
|
21
23
|
/** Play the chips' staggered pop-in. Off for rows remounted by a reopen, whose suggestions already arrived once. */
|
|
22
24
|
entrance?: boolean;
|
|
25
|
+
/** The label already sent from this row, which keeps the row as a record. */
|
|
26
|
+
chosen?: string;
|
|
27
|
+
/** Visually hidden text read after the sent suggestion. Defaults to PromptSuggestions' "(chosen)". */
|
|
28
|
+
chosenLabel?: string;
|
|
23
29
|
}): import("react").JSX.Element;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
3
4
|
import { PromptSuggestions } from "../components/PromptSuggestions/PromptSuggestions.js";
|
|
4
5
|
import { useChatWidget } from "./context.js";
|
|
6
|
+
const FollowupSuggestionsLabelContext = createContext("Follow-up questions");
|
|
5
7
|
function FollowupSuggestions({
|
|
6
8
|
turnId,
|
|
7
9
|
suggestions,
|
|
8
10
|
pending = false,
|
|
9
|
-
entrance = true
|
|
11
|
+
entrance = true,
|
|
12
|
+
chosen,
|
|
13
|
+
chosenLabel
|
|
10
14
|
}) {
|
|
11
|
-
const {
|
|
15
|
+
const { chooseFollowup } = useChatWidget();
|
|
16
|
+
const rowLabel = useContext(FollowupSuggestionsLabelContext);
|
|
12
17
|
const items = suggestions.map((label, index) => ({
|
|
13
18
|
id: `${turnId}-followup-${index}`,
|
|
14
19
|
label
|
|
@@ -18,17 +23,20 @@ function FollowupSuggestions({
|
|
|
18
23
|
{
|
|
19
24
|
className: "ds-chat-widget__followups",
|
|
20
25
|
layout: "stack",
|
|
21
|
-
ariaLabel:
|
|
26
|
+
ariaLabel: rowLabel,
|
|
27
|
+
chosenLabel,
|
|
22
28
|
pending,
|
|
23
29
|
entrance,
|
|
24
30
|
suggestions: items,
|
|
31
|
+
value: chosen !== void 0 ? items.find((item) => item.label === chosen)?.id : void 0,
|
|
25
32
|
onValueChange: (id) => {
|
|
26
33
|
const item = items.find((candidate) => candidate.id === id);
|
|
27
|
-
if (item)
|
|
34
|
+
if (item) chooseFollowup(turnId, item.label);
|
|
28
35
|
}
|
|
29
36
|
}
|
|
30
37
|
);
|
|
31
38
|
}
|
|
32
39
|
export {
|
|
33
|
-
FollowupSuggestions
|
|
40
|
+
FollowupSuggestions,
|
|
41
|
+
FollowupSuggestionsLabelContext
|
|
34
42
|
};
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { ChatTurn } from './types';
|
|
2
|
+
/** The row's accessible names and its copy announcement, set from ChatWidget's label props. */
|
|
3
|
+
export interface ResponseActionsLabels {
|
|
4
|
+
/** The copy button's name. */
|
|
5
|
+
copy: string;
|
|
6
|
+
/** The copy button's name once the copy has landed. */
|
|
7
|
+
copied: string;
|
|
8
|
+
/** What the polite live region says once the copy has landed. */
|
|
9
|
+
copiedAnnouncement: string;
|
|
10
|
+
/** The thumbs-up button's name. */
|
|
11
|
+
good: string;
|
|
12
|
+
/** The thumbs-down button's name. */
|
|
13
|
+
bad: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const ResponseActionsLabelsContext: import('react').Context<ResponseActionsLabels>;
|
|
2
16
|
/**
|
|
3
17
|
* The row under a committed assistant turn: copy, and, when the server
|
|
4
18
|
* logged the exchange and the provider has somewhere to send a verdict,
|