@cognizant-ai-lab/ui-common 1.14.0 → 1.15.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.
Files changed (101) hide show
  1. package/dist/Theme/Palettes.d.ts +1 -0
  2. package/dist/Theme/Palettes.js +13 -0
  3. package/dist/Theme/sheen.d.ts +172 -0
  4. package/dist/Theme/sheen.js +219 -0
  5. package/dist/components/AgentChat/ChatCommon/ChatCommon.js +111 -32
  6. package/dist/components/AgentChat/ChatCommon/ChatHistory.js +4 -3
  7. package/dist/components/AgentChat/ChatCommon/ControlButtons.js +27 -1
  8. package/dist/components/AgentChat/ChatCommon/Conversation.d.ts +2 -0
  9. package/dist/components/AgentChat/ChatCommon/Conversation.js +174 -18
  10. package/dist/components/AgentChat/ChatCommon/FormattedMarkdown.d.ts +12 -1
  11. package/dist/components/AgentChat/ChatCommon/FormattedMarkdown.js +20 -9
  12. package/dist/components/AgentChat/ChatCommon/SampleQueries.d.ts +1 -1
  13. package/dist/components/AgentChat/ChatCommon/SampleQueries.js +74 -17
  14. package/dist/components/AgentChat/ChatCommon/SendButton.js +32 -1
  15. package/dist/components/AgentChat/ChatCommon/SyntaxHighlighterThemes.d.ts +6 -0
  16. package/dist/components/AgentChat/ChatCommon/SyntaxHighlighterThemes.js +4 -1
  17. package/dist/components/AgentChat/Common/LlmChatButton.js +4 -2
  18. package/dist/components/AgentChat/VoiceChat/MicrophoneButton.js +5 -0
  19. package/dist/components/ChatBot/ChatBot.js +79 -25
  20. package/dist/components/CommandPalette/CommandPalette.d.ts +21 -0
  21. package/dist/components/CommandPalette/CommandPalette.js +411 -0
  22. package/dist/components/Common/ConfirmationModal.d.ts +2 -0
  23. package/dist/components/Common/ConfirmationModal.js +2 -2
  24. package/dist/components/Common/Footer.d.ts +2 -2
  25. package/dist/components/Common/Footer.js +86 -32
  26. package/dist/components/Common/LoadingSpinner.d.ts +2 -1
  27. package/dist/components/Common/LoadingSpinner.js +24 -3
  28. package/dist/components/Common/MUIDialog.js +1 -1
  29. package/dist/components/Common/Navbar.d.ts +4 -1
  30. package/dist/components/Common/Navbar.js +235 -43
  31. package/dist/components/Common/Snackbar.d.ts +1 -1
  32. package/dist/components/Common/Snackbar.js +81 -48
  33. package/dist/components/Common/Spotlight.d.ts +31 -0
  34. package/dist/components/Common/Spotlight.js +76 -0
  35. package/dist/components/ErrorPage/ErrorPage.js +1 -1
  36. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.d.ts +14 -0
  37. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.js +169 -96
  38. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentNode.js +100 -23
  39. package/dist/components/MultiAgentAccelerator/AgentFlow/NetworkHud.d.ts +19 -0
  40. package/dist/components/MultiAgentAccelerator/AgentFlow/NetworkHud.js +128 -0
  41. package/dist/components/MultiAgentAccelerator/Editor/Const.d.ts +2 -1
  42. package/dist/components/MultiAgentAccelerator/Editor/Const.js +4 -2
  43. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.js +62 -33
  44. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +2 -0
  45. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +279 -72
  46. package/dist/components/MultiAgentAccelerator/NeuroSanStudioCallout.js +38 -22
  47. package/dist/components/MultiAgentAccelerator/PanelSeparator.d.ts +7 -1
  48. package/dist/components/MultiAgentAccelerator/PanelSeparator.js +44 -36
  49. package/dist/components/MultiAgentAccelerator/Publish/Publish.d.ts +30 -10
  50. package/dist/components/MultiAgentAccelerator/Publish/Publish.js +137 -42
  51. package/dist/components/MultiAgentAccelerator/Publish/PublishButton.d.ts +5 -2
  52. package/dist/components/MultiAgentAccelerator/Publish/PublishButton.js +45 -19
  53. package/dist/components/MultiAgentAccelerator/Publish/PublishConfirmation.d.ts +8 -2
  54. package/dist/components/MultiAgentAccelerator/Publish/PublishConfirmation.js +31 -4
  55. package/dist/components/MultiAgentAccelerator/Publish/PublishIconButton.d.ts +4 -2
  56. package/dist/components/MultiAgentAccelerator/Publish/PublishIconButton.js +17 -16
  57. package/dist/components/MultiAgentAccelerator/Publish/PublishPanel.d.ts +4 -2
  58. package/dist/components/MultiAgentAccelerator/Publish/PublishPanel.js +32 -2
  59. package/dist/components/MultiAgentAccelerator/Publish/PublishedNetworkUrl.js +3 -2
  60. package/dist/components/MultiAgentAccelerator/Publish/usePublishTarget.d.ts +2 -2
  61. package/dist/components/MultiAgentAccelerator/Publish/usePublishTarget.js +14 -7
  62. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +81 -53
  63. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +40 -20
  64. package/dist/components/MultiAgentAccelerator/ThoughtBubbles/ThoughtBubbleOverlay.d.ts +4 -0
  65. package/dist/components/MultiAgentAccelerator/ThoughtBubbles/ThoughtBubbleOverlay.js +49 -28
  66. package/dist/components/MultiAgentAccelerator/Workspace/FloatingPanel.d.ts +21 -0
  67. package/dist/components/MultiAgentAccelerator/Workspace/FloatingPanel.js +57 -0
  68. package/dist/components/Settings/ApiKeyErrorBanner.d.ts +1 -0
  69. package/dist/components/Settings/ApiKeyErrorBanner.js +1 -1
  70. package/dist/components/Settings/ApiKeyInput.d.ts +2 -1
  71. package/dist/components/Settings/ApiKeyInput.js +31 -4
  72. package/dist/components/Settings/Byok/ByokInputs.d.ts +1 -1
  73. package/dist/components/Settings/Byok/ByokInputs.js +3 -1
  74. package/dist/components/Settings/Byok/ByokStorageTooltip.js +3 -2
  75. package/dist/components/Settings/Byok/ByokUnsavedChangesModal.d.ts +4 -0
  76. package/dist/components/Settings/Byok/ByokUnsavedChangesModal.js +3 -2
  77. package/dist/components/Settings/Byok/useByokKeyManager.d.ts +3 -2
  78. package/dist/components/Settings/Byok/useByokKeyManager.js +97 -27
  79. package/dist/components/Settings/FadingCheckmark.js +1 -1
  80. package/dist/components/Settings/PublishSettings.d.ts +4 -4
  81. package/dist/components/Settings/PublishSettings.js +33 -44
  82. package/dist/components/Settings/SettingsDialog.js +95 -41
  83. package/dist/components/Settings/SettingsLayout.d.ts +1 -3
  84. package/dist/components/Settings/SettingsLayout.js +41 -12
  85. package/dist/components/Settings/SettingsNav.d.ts +14 -0
  86. package/dist/components/Settings/SettingsNav.js +229 -0
  87. package/dist/components/Settings/SettingsRow.js +4 -1
  88. package/dist/controller/llm/Providers.d.ts +1 -0
  89. package/dist/controller/llm/Providers.js +4 -0
  90. package/dist/controller/publish/Publish.d.ts +34 -9
  91. package/dist/controller/publish/Publish.js +83 -23
  92. package/dist/index.d.ts +2 -0
  93. package/dist/index.js +2 -0
  94. package/dist/state/Publish.d.ts +25 -11
  95. package/dist/state/Publish.js +38 -3
  96. package/dist/state/Settings.d.ts +5 -79
  97. package/dist/state/Settings.js +36 -6
  98. package/dist/state/TemporaryNetworks.d.ts +12 -1
  99. package/dist/state/TemporaryNetworks.js +15 -8
  100. package/dist/tsconfig.build.tsbuildinfo +1 -1
  101. package/package.json +6 -4
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useTheme } from "@mui/material/styles";
3
3
  import { Conversation } from "./Conversation.js";
4
4
  import { MessageRole } from "./ConversationTurn.js";
5
- import { adjustBrightness } from "../../../Theme/Theme.js";
5
+ import { glassSurface, SHEEN_RADIUS } from "../../../Theme/sheen.js";
6
6
  import { AccordionLite } from "../../Common/AccordionLite.js";
7
7
  // #endregion: Types
8
8
  /**
@@ -31,8 +31,9 @@ export const ChatHistory = ({ id, messages }) => {
31
31
  // messages in chat history.
32
32
  includeAgentMessages: true, shouldWrapOutput: true, turns: turns }, `${id}-conversation`));
33
33
  return (_jsx(AccordionLite, { id: `${id}-history-items`, items: conversation, contentSx: {
34
- // Slightly darker background to differentiate from main chat
35
- backgroundColor: adjustBrightness(theme.palette.background.paper, -5),
34
+ // Frosted-glass panel to set past conversations apart from the live chat
35
+ ...glassSurface(theme, SHEEN_RADIUS),
36
36
  opacity: 0.5,
37
+ px: 2,
37
38
  }, title: "Chat History" }));
38
39
  };
@@ -20,7 +20,33 @@ import SaveIcon from "@mui/icons-material/Save";
20
20
  import StopCircle from "@mui/icons-material/StopCircle";
21
21
  import Box from "@mui/material/Box";
22
22
  import Tooltip from "@mui/material/Tooltip";
23
+ import { getSheen, glassSurface, SHEEN_EASE, spinningBorder } from "../../../Theme/sheen.js";
23
24
  import { SmallLlmChatButton } from "../Common/LlmChatButton.js";
25
+ // Diameter of the stop button
26
+ const STOP_BUTTON_SIZE = 34;
27
+ /**
28
+ * Stop button: glass disc ringed by the rotating iridescent border (the request is "live"), with an error-colored
29
+ * icon and halo on hover so it reads clearly as "cancel".
30
+ */
31
+ const stopButtonSx = (theme) => {
32
+ const errorMain = (theme.vars ?? theme).palette.error.main;
33
+ return {
34
+ ...glassSurface(theme, STOP_BUTTON_SIZE / 2),
35
+ ...spinningBorder(theme, STOP_BUTTON_SIZE / 2, 1.5),
36
+ border: "none",
37
+ borderRadius: "50%",
38
+ boxShadow: `inset 0 1px 0 ${getSheen(theme).highlight}, 0 0 24px -6px ${getSheen(theme).glow}`,
39
+ color: "error.main",
40
+ height: STOP_BUTTON_SIZE,
41
+ transition: `box-shadow 0.3s ${SHEEN_EASE}, transform 0.3s ${SHEEN_EASE}`,
42
+ width: STOP_BUTTON_SIZE,
43
+ "&:hover": {
44
+ backgroundColor: getSheen(theme).glassBg,
45
+ boxShadow: `0 0 0 4px color-mix(in srgb, ${errorMain} 18%, transparent), 0 0 28px -4px ${errorMain}`,
46
+ transform: "scale(1.06)",
47
+ },
48
+ };
49
+ };
24
50
  //#endregion: Types
25
51
  /**
26
52
  * Generate the Control Buttons for a chat window (resend, clear chat, stop)
@@ -28,7 +54,7 @@ import { SmallLlmChatButton } from "../Common/LlmChatButton.js";
28
54
  */
29
55
  export const ControlButtons = ({ enableClearChatButton, enableSaveChatButton, handleClearChat, handleSave, handleSend, handleStop, isAwaitingLlm, previousUserQuery, shouldEnableRegenerateButton, }) => (_jsx(_Fragment, { children: isAwaitingLlm ? (
30
56
  // Stop Button
31
- _jsx(Tooltip, { title: "Terminate request", children: _jsx(SmallLlmChatButton, { "aria-label": "Stop", disabled: !isAwaitingLlm, id: "stop-output-button", onClick: () => handleStop(), children: _jsx(StopCircle, { fontSize: "small", id: "stop-button-icon" }) }) })) : (_jsxs(Box, { sx: { display: "flex", gap: 1 }, children: [_jsx(Tooltip, { title: "Save Chat", children: _jsx("span", { children: _jsx(SmallLlmChatButton, { "aria-label": "Save Chat", disabled: !enableSaveChatButton, id: "save-chat-button", onClick: handleSave, children: _jsx(SaveIcon, { fontSize: "small", id: "save-button-icon" }) }) }) }), _jsx(Tooltip, { title: "Clear Chat", children: _jsx("span", { children: _jsx(SmallLlmChatButton, { "aria-label": "Clear Chat", disabled: !enableClearChatButton, id: "clear-chat-button", onClick: handleClearChat, children: _jsx(DeleteOutlined, { fontSize: "small", id: "stop-button-icon", sx: {
57
+ _jsx(Tooltip, { title: "Terminate request", children: _jsx(SmallLlmChatButton, { "aria-label": "Stop", disabled: !isAwaitingLlm, id: "stop-output-button", onClick: () => handleStop(), sx: stopButtonSx, children: _jsx(StopCircle, { fontSize: "small", id: "stop-button-icon" }) }) })) : (_jsxs(Box, { sx: { display: "flex", gap: 1 }, children: [_jsx(Tooltip, { title: "Save Chat", children: _jsx("span", { children: _jsx(SmallLlmChatButton, { "aria-label": "Save Chat", disabled: !enableSaveChatButton, id: "save-chat-button", onClick: handleSave, children: _jsx(SaveIcon, { fontSize: "small", id: "save-button-icon" }) }) }) }), _jsx(Tooltip, { title: "Clear Chat", children: _jsx("span", { children: _jsx(SmallLlmChatButton, { "aria-label": "Clear Chat", disabled: !enableClearChatButton, id: "clear-chat-button", onClick: handleClearChat, children: _jsx(DeleteOutlined, { fontSize: "small", id: "stop-button-icon", sx: {
32
58
  "&:hover": {
33
59
  color: "error.main",
34
60
  },
@@ -3,9 +3,11 @@ import { ConversationTurn } from "./ConversationTurn.js";
3
3
  interface ConversationProps {
4
4
  readonly id: string;
5
5
  readonly includeAgentMessages?: boolean;
6
+ readonly isStreaming?: boolean;
6
7
  readonly shouldWrapOutput: boolean;
7
8
  readonly turns: ConversationTurn[];
8
9
  }
10
+ export declare const USER_BUBBLE_RADIUS: string;
9
11
  /**
10
12
  * Component to render a conversation between the user and the agent.
11
13
  */
@@ -1,28 +1,161 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Box from "@mui/material/Box";
3
- import { styled, useTheme } from "@mui/material/styles";
3
+ import { keyframes, styled, useTheme } from "@mui/material/styles";
4
4
  import { useMemo } from "react";
5
5
  import { MessageRole } from "./ConversationTurn.js";
6
6
  import { FormattedMarkdown } from "./FormattedMarkdown.js";
7
7
  import { HLJS_THEMES } from "./SyntaxHighlighterThemes.js";
8
+ import { getSheen, gradientBorder, SHEEN_FONT_MONO, SHEEN_RADIUS, SHEEN_RADIUS_SURFACE, sheenConic, sheenGradient, } from "../../../Theme/sheen.js";
8
9
  import { MUIAlert } from "../../Common/MUIAlert.js";
9
- const { atelierDuneDark, a11yLight } = HLJS_THEMES;
10
+ // Atom One is a cool blue/purple palette in both variants, so it sits well on the blue-black / lavender surfaces
11
+ const { atomOneDark, atomOneLight } = HLJS_THEMES;
12
+ // Height of the slim header bar painted across the top of code blocks
13
+ const CODE_HEADER_HEIGHT = 28;
14
+ // User bubbles are fully rounded except for a tighter "tail" corner pointing back at the sender
15
+ const USER_BUBBLE_TAIL_RADIUS = 6;
16
+ export const USER_BUBBLE_RADIUS = [
17
+ SHEEN_RADIUS_SURFACE,
18
+ SHEEN_RADIUS_SURFACE,
19
+ USER_BUBBLE_TAIL_RADIUS,
20
+ SHEEN_RADIUS_SURFACE,
21
+ ]
22
+ .map((r) => `${r}px`)
23
+ .join(" ");
24
+ // Blinking for the streaming caret
25
+ const CARET_BLINK = keyframes `
26
+ 0%, 45% { opacity: 1; }
27
+ 55%, 100% { opacity: 0.15; }
28
+ `;
10
29
  /**
11
- * Styled component for a user turn bubble.
30
+ * Styled component for a user turn bubble: primary tint washed with the iridescent gradient, a gradient hairline and a
31
+ * tighter tail corner.
12
32
  */
13
- const UserTurnBubble = styled(Box)(({ theme }) => ({
14
- backgroundColor: theme.palette.background.paper,
15
- borderRadius: "1rem",
16
- marginBottom: "1rem",
17
- marginLeft: "auto",
18
- overflowWrap: "anywhere",
19
- paddingLeft: "1rem",
20
- paddingRight: "1rem",
21
- paddingTop: "0.5rem",
22
- paddingBottom: "0.5rem",
23
- whiteSpace: "pre-wrap",
24
- width: "60%",
25
- }));
33
+ const UserTurnBubble = styled(Box)(({ theme }) => {
34
+ const sheen = getSheen(theme);
35
+ const border = gradientBorder(theme, SHEEN_RADIUS_SURFACE, 1, 0.55);
36
+ return {
37
+ ...border,
38
+ backgroundColor: sheen.tint,
39
+ backgroundImage: `linear-gradient(180deg, ${sheen.highlight}, transparent 60%)`,
40
+ border: "1px solid transparent",
41
+ borderRadius: USER_BUBBLE_RADIUS,
42
+ boxShadow: `0 10px 30px -18px ${sheen.glow}`,
43
+ color: (theme.vars ?? theme).palette.text.primary,
44
+ isolation: "isolate",
45
+ marginBottom: "1rem",
46
+ marginLeft: "auto",
47
+ maxWidth: "75%",
48
+ overflowWrap: "anywhere",
49
+ paddingLeft: "1rem",
50
+ paddingRight: "1rem",
51
+ paddingTop: "0.6rem",
52
+ paddingBottom: "0.6rem",
53
+ whiteSpace: "pre-wrap",
54
+ width: "fit-content",
55
+ minWidth: "30%",
56
+ "&::before": { ...border["&::before"], borderRadius: USER_BUBBLE_RADIUS },
57
+ // Low-alpha wash of the signature gradient under the text
58
+ "&::after": {
59
+ content: '""',
60
+ position: "absolute",
61
+ inset: 0,
62
+ zIndex: -1,
63
+ borderRadius: USER_BUBBLE_RADIUS,
64
+ background: sheenGradient(theme),
65
+ opacity: 0.14,
66
+ pointerEvents: "none",
67
+ },
68
+ };
69
+ });
70
+ /**
71
+ * Styles for the conversation container: assistant Markdown blocks become glass cards marked with a small spinning
72
+ * iridescent orb, and code blocks get a slim header bar with their language.
73
+ */
74
+ const getConversationSx = (theme) => {
75
+ const sheen = getSheen(theme);
76
+ return {
77
+ // Entrance and layout animations are driven by motion (see FormattedMarkdown)
78
+ "& > .formatted-markdown-block": {
79
+ backgroundColor: sheen.glassBg,
80
+ backgroundImage: `linear-gradient(180deg, ${sheen.highlight}, transparent 38%)`,
81
+ border: `1px solid ${sheen.glassBorder}`,
82
+ borderRadius: `${SHEEN_RADIUS_SURFACE}px`,
83
+ boxShadow: `inset 0 1px 0 ${sheen.highlight}, 0 8px 28px -18px rgba(0, 0, 0, 0.45)`,
84
+ marginBottom: "1rem",
85
+ overflowWrap: "anywhere",
86
+ padding: "0.75rem 1.1rem 0.75rem 2.6rem",
87
+ position: "relative",
88
+ // Assistant "orb": conic gradient with a specular highlight and a soft glow. Deliberately static: one orb
89
+ // per message stays on screen indefinitely, and any never-ending animation makes Firefox recomposite the
90
+ // whole (glass and blur heavy) window every frame, i.e. 100%+ CPU while idle.
91
+ "&::before": {
92
+ content: '""',
93
+ position: "absolute",
94
+ left: 14,
95
+ top: 18,
96
+ width: 12,
97
+ height: 12,
98
+ borderRadius: "50%",
99
+ background: [
100
+ "radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.85), transparent 45%)",
101
+ sheenConic(theme),
102
+ ].join(", "),
103
+ boxShadow: `0 0 12px 1px ${sheen.glow}`,
104
+ pointerEvents: "none",
105
+ },
106
+ "& > :first-of-type": { marginTop: 0 },
107
+ "& > :last-child": { marginBottom: 0 },
108
+ },
109
+ // While a response streams in, a soft gradient caret glows at the end of the text. Inline at the end of the
110
+ // last paragraph/list item, or on its own line after a code block.
111
+ "& > .formatted-markdown-block.is-streaming": {
112
+ "& > :last-child:not(pre, div, ul, ol, table)::after, & > :is(ul, ol):last-child > li:last-child::after": {
113
+ animation: `${CARET_BLINK} 1s ease-in-out infinite`,
114
+ backgroundImage: sheenGradient(theme, 180),
115
+ borderRadius: "2px",
116
+ boxShadow: `0 0 10px ${sheen.glow}`,
117
+ content: '""',
118
+ display: "inline-block",
119
+ height: "1.05em",
120
+ marginLeft: "3px",
121
+ transform: "translateY(0.18em)",
122
+ width: "0.5em",
123
+ },
124
+ "& > :is(pre, div, table):last-child::after": {
125
+ animation: `${CARET_BLINK} 1s ease-in-out infinite`,
126
+ backgroundImage: sheenGradient(theme, 180),
127
+ borderRadius: "2px",
128
+ boxShadow: `0 0 10px ${sheen.glow}`,
129
+ content: '""',
130
+ display: "block",
131
+ height: "1.05em",
132
+ marginTop: "0.4em",
133
+ width: "0.5em",
134
+ },
135
+ },
136
+ "& code": { fontFamily: SHEEN_FONT_MONO, fontSize: "0.9em" },
137
+ "& :not(pre) > code:not([class])": {
138
+ backgroundColor: sheen.tint,
139
+ borderRadius: "6px",
140
+ padding: "0.1em 0.35em",
141
+ },
142
+ // Language label in the code block header bar
143
+ "& [data-language]::before": {
144
+ content: "attr(data-language)",
145
+ position: "absolute",
146
+ top: 0,
147
+ left: "1em",
148
+ height: CODE_HEADER_HEIGHT,
149
+ display: "flex",
150
+ alignItems: "center",
151
+ color: (theme.vars ?? theme).palette.text.secondary,
152
+ fontFamily: SHEEN_FONT_MONO,
153
+ fontSize: "0.7rem",
154
+ letterSpacing: "0.08em",
155
+ textTransform: "uppercase",
156
+ },
157
+ };
158
+ };
26
159
  /**
27
160
  * Format the content of a conversation turn for display. Pretty-print JSON.
28
161
  * @param turn The conversation turn to format.
@@ -42,10 +175,33 @@ const formatTurnContent = (turn) => {
42
175
  /**
43
176
  * Component to render a conversation between the user and the agent.
44
177
  */
45
- export const Conversation = ({ id, includeAgentMessages = false, shouldWrapOutput, turns }) => {
178
+ export const Conversation = ({ id, includeAgentMessages = false, isStreaming = false, shouldWrapOutput, turns, }) => {
46
179
  // MUI theme
47
180
  const theme = useTheme();
48
181
  const darkMode = theme.palette.mode === "dark";
182
+ // Syntax highlighter theme for the current mode, with code blocks rounded and outlined to match glass surfaces
183
+ const syntaxStyle = useMemo(() => {
184
+ const base = darkMode ? atomOneDark : atomOneLight;
185
+ const sheen = getSheen(theme);
186
+ // Slim header bar (tint band + hairline) layered over the highlighter's own background color
187
+ const headerBar = `linear-gradient(180deg, ${sheen.tint} 0 ${CODE_HEADER_HEIGHT}px, ${sheen.glassBorder} ` +
188
+ `${CODE_HEADER_HEIGHT}px ${CODE_HEADER_HEIGHT + 1}px, transparent ${CODE_HEADER_HEIGHT + 1}px)`;
189
+ // Split the theme's background shorthand into longhands so the header bar can be layered over its color
190
+ const { background: themeBackground, ...hljsBase } = base["hljs"];
191
+ const hljsBlock = {
192
+ ...hljsBase,
193
+ backgroundColor: String(themeBackground),
194
+ backgroundImage: headerBar,
195
+ border: `1px solid ${sheen.glassBorder}`,
196
+ borderRadius: SHEEN_RADIUS,
197
+ boxShadow: `inset 0 1px 0 ${sheen.highlight}, 0 10px 30px -18px rgba(0, 0, 0, 0.5)`,
198
+ fontFamily: SHEEN_FONT_MONO,
199
+ padding: `${CODE_HEADER_HEIGHT + 10}px 1em 0.75em`,
200
+ position: "relative",
201
+ };
202
+ return { ...base, hljs: hljsBlock };
203
+ }, [darkMode, theme]);
204
+ const conversationSx = useMemo(() => getConversationSx(theme), [theme]);
49
205
  /**
50
206
  * Render the list of conversation turns.
51
207
  */
@@ -76,5 +232,5 @@ export const Conversation = ({ id, includeAgentMessages = false, shouldWrapOutpu
76
232
  }
77
233
  }
78
234
  }), [includeAgentMessages, turns]);
79
- return (_jsx(FormattedMarkdown, { id: `${id}-conversation`, nodesList: nodesList, style: darkMode ? atelierDuneDark : a11yLight, wrapLongLines: shouldWrapOutput }));
235
+ return (_jsx(FormattedMarkdown, { id: `${id}-conversation`, isStreaming: isStreaming, nodesList: nodesList, style: syntaxStyle, sx: conversationSx, wrapLongLines: shouldWrapOutput }));
80
236
  };
@@ -1,3 +1,4 @@
1
+ import { SxProps, Theme } from "@mui/material/styles";
1
2
  import { JSX as ReactJSX, ReactNode } from "react";
2
3
  import { SyntaxHighlighterProps } from "react-syntax-highlighter";
3
4
  /**
@@ -16,10 +17,20 @@ interface FormattedMarkdownProps {
16
17
  * The style to use for the syntax highlighter. @see SyntaxHighlighterThemes
17
18
  */
18
19
  readonly style: SyntaxHighlighterProps["style"];
20
+ /**
21
+ * Optional styles for the container. Aggregated Markdown blocks are wrapped in elements with the
22
+ * `formatted-markdown-block` class, and code blocks carry a `data-language` attribute, so they can be targeted.
23
+ */
24
+ readonly sx?: SxProps<Theme>;
19
25
  /**
20
26
  * Whether to wrap long lines in the Markdown.
21
27
  */
22
28
  readonly wrapLongLines: boolean;
29
+ /**
30
+ * Whether the last Markdown block is still being streamed into. That block gets the `is-streaming` class, so a
31
+ * caret can be painted at the end of its text.
32
+ */
33
+ readonly isStreaming?: boolean;
23
34
  }
24
35
  /**
25
36
  * Format the output to ensure that text nodes are formatted as Markdown but other nodes are passed along as-is.
@@ -28,5 +39,5 @@ interface FormattedMarkdownProps {
28
39
  * @returns The formatted output. Consecutive string nodes will be aggregated and wrapped in a Markdown component,
29
40
  * while other nodes will be passed along as-is.
30
41
  */
31
- export declare const FormattedMarkdown: ({ id, nodesList, style, wrapLongLines, }: FormattedMarkdownProps) => ReactJSX.Element;
42
+ export declare const FormattedMarkdown: ({ id, nodesList, style, sx, wrapLongLines, isStreaming, }: FormattedMarkdownProps) => ReactJSX.Element;
32
43
  export {};
@@ -15,13 +15,15 @@ See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
  */
17
17
  import Box from "@mui/material/Box";
18
- import { Fragment } from "react";
18
+ import { motion, useReducedMotion } from "motion/react";
19
19
  import ReactMarkdown from "react-markdown";
20
20
  import SyntaxHighlighter from "react-syntax-highlighter";
21
21
  import rehypeRaw from "rehype-raw";
22
22
  import rehypeSlug from "rehype-slug";
23
23
  import remarkGfm from "remark-gfm";
24
24
  import { hashString } from "../../../utils/text.js";
25
+ // Spring for message entrances; layout animations use it too, so earlier messages glide as the list grows
26
+ const MESSAGE_SPRING = { type: "spring", stiffness: 380, damping: 30, mass: 0.8 };
25
27
  /**
26
28
  * Format the output to ensure that text nodes are formatted as Markdown but other nodes are passed along as-is.
27
29
  *
@@ -29,7 +31,9 @@ import { hashString } from "../../../utils/text.js";
29
31
  * @returns The formatted output. Consecutive string nodes will be aggregated and wrapped in a Markdown component,
30
32
  * while other nodes will be passed along as-is.
31
33
  */
32
- export const FormattedMarkdown = ({ id, nodesList, style, wrapLongLines = false, }) => {
34
+ export const FormattedMarkdown = ({ id, nodesList, style, sx, wrapLongLines = false, isStreaming = false, }) => {
35
+ const reduceMotion = useReducedMotion();
36
+ const entrance = reduceMotion ? { opacity: 0 } : { opacity: 0, y: 14, scale: 0.98 };
33
37
  /**
34
38
  * Get the formatted output for a given string. The string is assumed to be in Markdown format.
35
39
  * @param stringToFormat The string to format.
@@ -40,7 +44,7 @@ export const FormattedMarkdown = ({ id, nodesList, style, wrapLongLines = false,
40
44
  code: (codeProps) => {
41
45
  const { children, className, ...rest } = codeProps;
42
46
  const match = /language-(?<language>\w+)/u.exec(className || "");
43
- return match ? (_jsx(SyntaxHighlighter, { PreTag: "div", id: `syntax-highlighter-${match.groups["language"]}`, language: match.groups["language"], style: style, wrapLongLines: wrapLongLines, children: String(children).replace(/\n$/u, "") })) : (_jsx("code", { id: `code-${className}`, ...rest, className: className, style: wrapLongLines ? { whiteSpace: "pre-wrap", wordBreak: "break-word" } : {}, children: children }));
47
+ return match ? (_jsx(SyntaxHighlighter, { PreTag: "div", "data-language": match.groups["language"], id: `syntax-highlighter-${match.groups["language"]}`, language: match.groups["language"], style: style, wrapLongLines: wrapLongLines, children: String(children).replace(/\n$/u, "") })) : (_jsx("code", { id: `code-${className}`, ...rest, className: className, style: wrapLongLines ? { whiteSpace: "pre-wrap", wordBreak: "break-word" } : {}, children: children }));
44
48
  },
45
49
  // Handle links specially since we want them to open in a new tab
46
50
  a: ({ ...codeProps }) => (_jsx("a", { ...codeProps, id: "reference-link", target: "_blank", rel: "noopener noreferrer", children: codeProps.children })),
@@ -59,6 +63,15 @@ export const FormattedMarkdown = ({ id, nodesList, style, wrapLongLines = false,
59
63
  // Walk through the nodes list. If we encounter a string node, we'll aggregate it with other string nodes.
60
64
  const formattedOutput = [];
61
65
  let currentTextNodes = [];
66
+ // Wrap each aggregated Markdown block in an element with a stable key (its ordinal), so that a block being
67
+ // streamed into doesn't remount (and re-run its entrance animation) every time its text changes.
68
+ let blockCount = 0;
69
+ let lastIsMarkdown = false;
70
+ const pushMarkdownBlock = (text, index, isLast) => {
71
+ formattedOutput.push(_jsx(motion.div, { animate: { opacity: 1, y: 0, scale: 1 }, className: `formatted-markdown-block${isLast && isStreaming ? " is-streaming" : ""}`, initial: entrance, layout: reduceMotion ? false : "position", transition: MESSAGE_SPRING, children: getFormattedMarkdown(text, index) }, `formatted-markdown-block-${blockCount}`));
72
+ blockCount += 1;
73
+ lastIsMarkdown = isLast;
74
+ };
62
75
  for (const [i, node] of nodesList.entries()) {
63
76
  // If it's a string node, aggregate it with other string nodes
64
77
  if (typeof node === "string") {
@@ -67,19 +80,17 @@ export const FormattedMarkdown = ({ id, nodesList, style, wrapLongLines = false,
67
80
  else {
68
81
  // Not a string node. Process any aggregated text nodes
69
82
  if (currentTextNodes.length > 0) {
70
- const concatenatedText = getFormattedMarkdown(currentTextNodes.join(""), i);
71
- formattedOutput.push(concatenatedText);
83
+ pushMarkdownBlock(currentTextNodes.join(""), i, false);
72
84
  currentTextNodes = [];
73
85
  }
74
86
  // Not a string node. Add the node as-is
75
87
  const key = getNodeKey(node, i);
76
- formattedOutput.push(_jsx(Fragment, { children: node }, key));
88
+ formattedOutput.push(_jsx(motion.div, { animate: { opacity: 1, y: 0, scale: 1 }, className: "formatted-node", initial: entrance, layout: reduceMotion ? false : "position", transition: MESSAGE_SPRING, children: node }, key));
77
89
  }
78
90
  }
79
91
  // Process any remaining text nodes
80
92
  if (currentTextNodes.length > 0) {
81
- const concatenatedText = getFormattedMarkdown(currentTextNodes.join(""), nodesList.length);
82
- formattedOutput.push(concatenatedText);
93
+ pushMarkdownBlock(currentTextNodes.join(""), nodesList.length, true);
83
94
  }
84
- return _jsx(Box, { id: id, children: formattedOutput });
95
+ return (_jsx(Box, { "data-streaming": isStreaming && lastIsMarkdown ? "true" : undefined, id: id, sx: sx, children: formattedOutput }));
85
96
  };
@@ -1,6 +1,6 @@
1
1
  import { FC } from "react";
2
2
  export declare const MAX_SAMPLE_QUERIES = 5;
3
- export declare const QUERY_TRUNCATE_LENGTH = 80;
3
+ export declare const QUERY_TRUNCATE_LENGTH = 250;
4
4
  interface SampleQueriesProps {
5
5
  readonly disabled: boolean;
6
6
  readonly handleSend: (query: string) => void;
@@ -1,12 +1,34 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Box from "@mui/material/Box";
3
- import Chip from "@mui/material/Chip";
3
+ import Chip, { chipClasses } from "@mui/material/Chip";
4
4
  import Tooltip from "@mui/material/Tooltip";
5
+ import { motion, useReducedMotion } from "motion/react";
6
+ import { getSheen, glassSurface, glowShadow, gradientBorder, SHEEN_EASE } from "../../../Theme/sheen.js";
5
7
  import { hashString } from "../../../utils/text.js";
6
8
  // Maximum number of sample queries to show
7
9
  export const MAX_SAMPLE_QUERIES = 5;
8
- // Maximum length of query to show in sample query chips
9
- export const QUERY_TRUNCATE_LENGTH = 80;
10
+ // Chip radius: large enough to keep chips fully pill-shaped
11
+ const CHIP_RADIUS = 999;
12
+ // Chips cascade in one after another
13
+ const CONTAINER_VARIANTS = {
14
+ hidden: {},
15
+ shown: { transition: { staggerChildren: 0.07, delayChildren: 0.1 } },
16
+ };
17
+ const CHIP_VARIANTS = {
18
+ hidden: { opacity: 0, y: 10, scale: 0.92, filter: "blur(4px)" },
19
+ shown: {
20
+ opacity: 1,
21
+ y: 0,
22
+ scale: 1,
23
+ filter: "blur(0px)",
24
+ transition: { type: "spring", stiffness: 420, damping: 26 },
25
+ transitionEnd: { filter: "none" },
26
+ },
27
+ };
28
+ const CHIP_VARIANTS_REDUCED = { hidden: { opacity: 0 }, shown: { opacity: 1 } };
29
+ // Maximum length of query to show in sample query chips. Chips wrap, so this only reins in pathologically long
30
+ // queries; the full text is always in the tooltip and is what gets sent.
31
+ export const QUERY_TRUNCATE_LENGTH = 250;
10
32
  /**
11
33
  * Render sample queries as clickable chips. Agents may or may not have sample queries defined.
12
34
  * @param disabled Whether the chips should be disabled or not. Chips should be disabled when the agent is
@@ -16,17 +38,52 @@ export const QUERY_TRUNCATE_LENGTH = 80;
16
38
  * @returns A ReactNode representing the sample queries as clickable chips. If a user clicks a chip, it will
17
39
  * send the query to the agent.
18
40
  */
19
- export const SampleQueries = ({ disabled, handleSend, sampleQueries }) => sampleQueries?.length > 0 ? (_jsx(Box, { id: "sample-queries-box", sx: { marginTop: "1rem" }, children: sampleQueries.slice(0, MAX_SAMPLE_QUERIES).map((query) => {
20
- const hashedQuery = hashString(query);
21
- return (_jsx(Tooltip, { title: `Click to send query: "${query}"`, children: _jsx(Chip, { disabled: disabled, label: query.length > QUERY_TRUNCATE_LENGTH
22
- ? `${query.slice(0, QUERY_TRUNCATE_LENGTH)}...`
23
- : query, onClick: async () => {
24
- handleSend(query);
25
- }, sx: {
26
- color: "var(--bs-white)",
27
- marginRight: "1rem",
28
- marginBottom: "1rem",
29
- backgroundColor: "var(--bs-accent2-medium)",
30
- "&:hover": { backgroundColor: "var(--bs-accent2-dark)" },
31
- } }) }, `tooltip-${hashedQuery}`));
32
- }) })) : null;
41
+ export const SampleQueries = ({ disabled, handleSend, sampleQueries }) => {
42
+ const reduceMotion = useReducedMotion();
43
+ return sampleQueries?.length > 0 ? (_jsx(Box, { animate: "shown", component: motion.div, id: "sample-queries-box", initial: "hidden", sx: { marginTop: "1rem" }, variants: CONTAINER_VARIANTS, children: sampleQueries.slice(0, MAX_SAMPLE_QUERIES).map((query) => {
44
+ const hashedQuery = hashString(query);
45
+ return (_jsx(motion.span, { style: { display: "inline-block", maxWidth: "100%" }, variants: reduceMotion ? CHIP_VARIANTS_REDUCED : CHIP_VARIANTS, children: _jsx(Tooltip, { title: `Click to send query: "${query}"`, children: _jsx(Chip, { disabled: disabled, label: query.length > QUERY_TRUNCATE_LENGTH
46
+ ? `${query.slice(0, QUERY_TRUNCATE_LENGTH)}...`
47
+ : query, onClick: async () => {
48
+ handleSend(query);
49
+ }, variant: "outlined", sx: (theme) => {
50
+ // Glass pill whose gradient hairline fades in (and which lifts) on hover
51
+ const border = gradientBorder(theme, CHIP_RADIUS, 1, 0);
52
+ return {
53
+ ...glassSurface(theme, CHIP_RADIUS),
54
+ ...border,
55
+ color: "text.primary",
56
+ // Long queries wrap onto multiple lines rather than being cut off at the
57
+ // edge of the chat window
58
+ height: "auto",
59
+ maxWidth: "100%",
60
+ minHeight: "36px",
61
+ [`& .${chipClasses.label}`]: {
62
+ lineHeight: 1.45,
63
+ overflowWrap: "anywhere",
64
+ paddingBottom: "8px",
65
+ paddingLeft: "14px",
66
+ paddingRight: "14px",
67
+ paddingTop: "8px",
68
+ whiteSpace: "normal",
69
+ },
70
+ marginRight: "0.75rem",
71
+ marginBottom: "0.75rem",
72
+ transition: [
73
+ `transform 0.3s ${SHEEN_EASE}`,
74
+ `box-shadow 0.3s ${SHEEN_EASE}`,
75
+ "border-color 0.2s ease",
76
+ ].join(", "),
77
+ "&::before": { ...border["&::before"], transition: "opacity 0.3s ease" },
78
+ // Chip's own clickable hover style is more specific than "&:hover", so match it
79
+ "&&:hover": {
80
+ backgroundColor: getSheen(theme).tint,
81
+ borderColor: "transparent",
82
+ boxShadow: glowShadow(theme, 20),
83
+ transform: "translateY(-2px)",
84
+ },
85
+ "&:hover::before": { opacity: 0.9 },
86
+ };
87
+ } }) }, `tooltip-${hashedQuery}`) }, `chip-${hashedQuery}`));
88
+ }) })) : null;
89
+ };
@@ -16,6 +16,7 @@ limitations under the License.
16
16
  */
17
17
  import SendIcon from "@mui/icons-material/Send";
18
18
  import Tooltip from "@mui/material/Tooltip";
19
+ import { getSheen, glowShadow, SHEEN_EASE, sheenGradient, shimmerOnHover } from "../../../Theme/sheen.js";
19
20
  import { LlmChatButton } from "../Common/LlmChatButton.js";
20
21
  //#endregion: Types
21
22
  /**
@@ -25,5 +26,35 @@ import { LlmChatButton } from "../Common/LlmChatButton.js";
25
26
  export const SendButton = ({ enableSendButton, id, onClickCallback }) => (_jsx(Tooltip, { placement: "top", title: enableSendButton ? "Send" : "Enter a message to enable the send button", children: _jsx("span", { style: {
26
27
  display: "inline-block",
27
28
  cursor: enableSendButton ? "inherit" : "not-allowed",
28
- }, children: _jsx(LlmChatButton, { "aria-label": "Send", disabled: !enableSendButton, id: id, onClick: onClickCallback, tabIndex: 0, children: _jsx(SendIcon, { fontSize: "small", id: "stop-button-icon" // Could update this but it would impact QA
29
+ }, children: _jsx(LlmChatButton, { "aria-label": "Send", disabled: !enableSendButton, id: id, onClick: onClickCallback, sx: (theme) => ({
30
+ // Glossy gradient orb: light sweep on hover, accent glow, specular top edge
31
+ ...shimmerOnHover(),
32
+ backgroundImage: sheenGradient(theme),
33
+ backgroundPosition: "0% 50%",
34
+ backgroundSize: "180% 100%",
35
+ border: "none",
36
+ borderRadius: "50%",
37
+ boxShadow: `inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 6px 18px -6px ${getSheen(theme).glow}`,
38
+ color: "primary.contrastText",
39
+ height: 40,
40
+ minWidth: 0,
41
+ transition: [
42
+ `box-shadow 0.3s ${SHEEN_EASE}`,
43
+ `transform 0.3s ${SHEEN_EASE}`,
44
+ `background-position 0.6s ${SHEEN_EASE}`,
45
+ "filter 0.3s ease",
46
+ ].join(", "),
47
+ width: 40,
48
+ "&:hover": {
49
+ backgroundPosition: "100% 50%",
50
+ boxShadow: glowShadow(theme),
51
+ transform: "translateY(-1px) scale(1.05)",
52
+ },
53
+ "&:active": { transform: "scale(0.95)" },
54
+ "&.Mui-disabled": {
55
+ boxShadow: "none",
56
+ color: "primary.contrastText",
57
+ filter: "saturate(0.35)",
58
+ },
59
+ }), tabIndex: 0, children: _jsx(SendIcon, { fontSize: "small", id: "stop-button-icon" // Could update this but it would impact QA
29
60
  }) }) }) }));
@@ -8,6 +8,12 @@ export declare const HLJS_THEMES: {
8
8
  atelierDuneDark: {
9
9
  [key: string]: import("react").CSSProperties;
10
10
  };
11
+ atomOneDark: {
12
+ [key: string]: import("react").CSSProperties;
13
+ };
14
+ atomOneLight: {
15
+ [key: string]: import("react").CSSProperties;
16
+ };
11
17
  docco: {
12
18
  [key: string]: import("react").CSSProperties;
13
19
  };
@@ -17,11 +17,14 @@ limitations under the License.
17
17
  * List of available hljs themes for the syntax highlighter.
18
18
  * See: https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/src/styles/hljs/index.js
19
19
  */
20
- import { a11yDark, a11yLight, atelierDuneDark, docco } from "react-syntax-highlighter/dist/esm/styles/hljs";
20
+ import { a11yDark, a11yLight, atelierDuneDark, atomOneDark, atomOneLight, docco, } from "react-syntax-highlighter/dist/esm/styles/hljs";
21
21
  // hljs themes
22
22
  export const HLJS_THEMES = {
23
23
  a11yDark,
24
24
  a11yLight,
25
25
  atelierDuneDark,
26
+ // Cool indigo/blue palettes that pair with the "sheen" dark and light color schemes
27
+ atomOneDark,
28
+ atomOneLight,
26
29
  docco,
27
30
  };
@@ -15,9 +15,11 @@ limitations under the License.
15
15
  */
16
16
  import Button from "@mui/material/Button";
17
17
  import { styled } from "@mui/material/styles";
18
+ import { getSheen, SHEEN_RADIUS } from "../../../Theme/sheen.js";
18
19
  export const LlmChatButton = styled(Button)(({ disabled, theme }) => ({
19
- backgroundColor: theme.palette.background.paper,
20
- borderRadius: "var(--bs-border-radius)",
20
+ backgroundColor: (theme.vars ?? theme).palette.background.paper,
21
+ border: `1px solid ${getSheen(theme).glassBorder}`,
22
+ borderRadius: SHEEN_RADIUS,
21
23
  cursor: disabled ? "not-allowed" : "pointer",
22
24
  opacity: disabled ? "50%" : "100%",
23
25
  padding: "0.5rem",
@@ -53,5 +53,10 @@ export const MicrophoneButton = ({ isMicOn, onMicToggle, speechRecognitionRef, v
53
53
  cursor: isDisabled ? "not-allowed" : "inherit",
54
54
  }, children: _jsx(LlmChatButton, { "data-testid": "microphone-button", disabled: isDisabled, id: "microphone-button", onClick: handleClick, sx: {
55
55
  backgroundColor: isListeningActive ? "success.main" : "background.paper",
56
+ // Circular, to sit alongside the circular send button
57
+ borderRadius: "50%",
58
+ height: 40,
59
+ minWidth: 0,
60
+ width: 40,
56
61
  }, tabIndex: 0, children: voiceInputState.isListening ? (_jsx(MicNoneIcon, { "data-testid": "MicNoneIcon", fontSize: "small" })) : (_jsx(MicOffIcon, { "data-testid": "MicOffIcon", fontSize: "small" })) }) }) }));
57
62
  };