@data-club/ai-hub 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/passwordPolicy.d.ts +55 -0
- package/dist/auth/passwordPolicy.d.ts.map +1 -0
- package/dist/auth/passwordPolicy.js +63 -0
- package/dist/auth/passwordPolicy.js.map +1 -0
- package/dist/auth/texts.d.ts +815 -0
- package/dist/auth/texts.d.ts.map +1 -0
- package/dist/auth/texts.js +429 -0
- package/dist/auth/texts.js.map +1 -0
- package/dist/client/AIHubClient.d.ts +1058 -0
- package/dist/client/AIHubClient.d.ts.map +1 -0
- package/dist/client/AIHubClient.js +950 -0
- package/dist/client/AIHubClient.js.map +1 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +9 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/sseParser.d.ts +41 -0
- package/dist/client/sseParser.d.ts.map +1 -0
- package/dist/client/sseParser.js +153 -0
- package/dist/client/sseParser.js.map +1 -0
- package/dist/client/tokenStorage.d.ts +56 -0
- package/dist/client/tokenStorage.d.ts.map +1 -0
- package/dist/client/tokenStorage.js +116 -0
- package/dist/client/tokenStorage.js.map +1 -0
- package/dist/components/AgentsPicker/index.d.ts +70 -0
- package/dist/components/AgentsPicker/index.d.ts.map +1 -0
- package/dist/components/AgentsPicker/index.js +63 -0
- package/dist/components/AgentsPicker/index.js.map +1 -0
- package/dist/components/AuthGate/index.d.ts +79 -0
- package/dist/components/AuthGate/index.d.ts.map +1 -0
- package/dist/components/AuthGate/index.js +61 -0
- package/dist/components/AuthGate/index.js.map +1 -0
- package/dist/components/CacheBadge/index.d.ts +88 -0
- package/dist/components/CacheBadge/index.d.ts.map +1 -0
- package/dist/components/CacheBadge/index.js +127 -0
- package/dist/components/CacheBadge/index.js.map +1 -0
- package/dist/components/ChangePassword/index.d.ts +109 -0
- package/dist/components/ChangePassword/index.d.ts.map +1 -0
- package/dist/components/ChangePassword/index.js +142 -0
- package/dist/components/ChangePassword/index.js.map +1 -0
- package/dist/components/ChatShell/ShellHeader.d.ts +44 -0
- package/dist/components/ChatShell/ShellHeader.d.ts.map +1 -0
- package/dist/components/ChatShell/ShellHeader.js +14 -0
- package/dist/components/ChatShell/ShellHeader.js.map +1 -0
- package/dist/components/ChatShell/UserMenu.d.ts +48 -0
- package/dist/components/ChatShell/UserMenu.d.ts.map +1 -0
- package/dist/components/ChatShell/UserMenu.js +86 -0
- package/dist/components/ChatShell/UserMenu.js.map +1 -0
- package/dist/components/ChatShell/index.d.ts +98 -0
- package/dist/components/ChatShell/index.d.ts.map +1 -0
- package/dist/components/ChatShell/index.js +124 -0
- package/dist/components/ChatShell/index.js.map +1 -0
- package/dist/components/DataClubAIHub/index.d.ts +132 -0
- package/dist/components/DataClubAIHub/index.d.ts.map +1 -0
- package/dist/components/DataClubAIHub/index.js +124 -0
- package/dist/components/DataClubAIHub/index.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.d.ts +89 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.js +199 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.d.ts +33 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.js +137 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.d.ts +50 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.js +93 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.d.ts +49 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.js +94 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.d.ts +37 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.js +44 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.d.ts +56 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.js +158 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.d.ts +29 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.js +183 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.d.ts +38 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.js +294 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.d.ts +36 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.js +373 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.d.ts +47 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.js +233 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/index.d.ts +87 -0
- package/dist/components/DataClubAIHubAdmin/index.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/index.js +137 -0
- package/dist/components/DataClubAIHubAdmin/index.js.map +1 -0
- package/dist/components/DataClubAIHubLogin/index.d.ts +113 -0
- package/dist/components/DataClubAIHubLogin/index.d.ts.map +1 -0
- package/dist/components/DataClubAIHubLogin/index.js +123 -0
- package/dist/components/DataClubAIHubLogin/index.js.map +1 -0
- package/dist/components/EffortControl/index.d.ts +57 -0
- package/dist/components/EffortControl/index.d.ts.map +1 -0
- package/dist/components/EffortControl/index.js +84 -0
- package/dist/components/EffortControl/index.js.map +1 -0
- package/dist/components/Layout/index.d.ts +63 -0
- package/dist/components/Layout/index.d.ts.map +1 -0
- package/dist/components/Layout/index.js +45 -0
- package/dist/components/Layout/index.js.map +1 -0
- package/dist/components/MainColumn/index.d.ts +69 -0
- package/dist/components/MainColumn/index.d.ts.map +1 -0
- package/dist/components/MainColumn/index.js +47 -0
- package/dist/components/MainColumn/index.js.map +1 -0
- package/dist/components/MarkdownRenderer/index.d.ts +66 -0
- package/dist/components/MarkdownRenderer/index.d.ts.map +1 -0
- package/dist/components/MarkdownRenderer/index.js +153 -0
- package/dist/components/MarkdownRenderer/index.js.map +1 -0
- package/dist/components/MessageInput/index.d.ts +85 -0
- package/dist/components/MessageInput/index.d.ts.map +1 -0
- package/dist/components/MessageInput/index.js +139 -0
- package/dist/components/MessageInput/index.js.map +1 -0
- package/dist/components/MessageList/index.d.ts +156 -0
- package/dist/components/MessageList/index.d.ts.map +1 -0
- package/dist/components/MessageList/index.js +352 -0
- package/dist/components/MessageList/index.js.map +1 -0
- package/dist/components/ReasoningSelector/index.d.ts +77 -0
- package/dist/components/ReasoningSelector/index.d.ts.map +1 -0
- package/dist/components/ReasoningSelector/index.js +156 -0
- package/dist/components/ReasoningSelector/index.js.map +1 -0
- package/dist/components/ReasoningView/index.d.ts +94 -0
- package/dist/components/ReasoningView/index.d.ts.map +1 -0
- package/dist/components/ReasoningView/index.js +83 -0
- package/dist/components/ReasoningView/index.js.map +1 -0
- package/dist/components/ScrollToPresentButton/index.d.ts +54 -0
- package/dist/components/ScrollToPresentButton/index.d.ts.map +1 -0
- package/dist/components/ScrollToPresentButton/index.js +44 -0
- package/dist/components/ScrollToPresentButton/index.js.map +1 -0
- package/dist/components/SessionsPanel/SessionTitleModal.d.ts +79 -0
- package/dist/components/SessionsPanel/SessionTitleModal.d.ts.map +1 -0
- package/dist/components/SessionsPanel/SessionTitleModal.js +102 -0
- package/dist/components/SessionsPanel/SessionTitleModal.js.map +1 -0
- package/dist/components/SessionsPanel/index.d.ts +100 -0
- package/dist/components/SessionsPanel/index.d.ts.map +1 -0
- package/dist/components/SessionsPanel/index.js +176 -0
- package/dist/components/SessionsPanel/index.js.map +1 -0
- package/dist/components/SystemNotice/index.d.ts +66 -0
- package/dist/components/SystemNotice/index.d.ts.map +1 -0
- package/dist/components/SystemNotice/index.js +81 -0
- package/dist/components/SystemNotice/index.js.map +1 -0
- package/dist/components/ThemeSwitcher/index.d.ts +66 -0
- package/dist/components/ThemeSwitcher/index.d.ts.map +1 -0
- package/dist/components/ThemeSwitcher/index.js +73 -0
- package/dist/components/ThemeSwitcher/index.js.map +1 -0
- package/dist/components/ToolCallView/formatContent.d.ts +36 -0
- package/dist/components/ToolCallView/formatContent.d.ts.map +1 -0
- package/dist/components/ToolCallView/formatContent.js +53 -0
- package/dist/components/ToolCallView/formatContent.js.map +1 -0
- package/dist/components/ToolCallView/index.d.ts +120 -0
- package/dist/components/ToolCallView/index.d.ts.map +1 -0
- package/dist/components/ToolCallView/index.js +104 -0
- package/dist/components/ToolCallView/index.js.map +1 -0
- package/dist/components/TpmBanner/index.d.ts +53 -0
- package/dist/components/TpmBanner/index.d.ts.map +1 -0
- package/dist/components/TpmBanner/index.js +116 -0
- package/dist/components/TpmBanner/index.js.map +1 -0
- package/dist/components/TurnStatusIndicator/index.d.ts +77 -0
- package/dist/components/TurnStatusIndicator/index.d.ts.map +1 -0
- package/dist/components/TurnStatusIndicator/index.js +122 -0
- package/dist/components/TurnStatusIndicator/index.js.map +1 -0
- package/dist/components/internal/PasswordInput.d.ts +62 -0
- package/dist/components/internal/PasswordInput.d.ts.map +1 -0
- package/dist/components/internal/PasswordInput.js +42 -0
- package/dist/components/internal/PasswordInput.js.map +1 -0
- package/dist/context/AIHubContext.d.ts +220 -0
- package/dist/context/AIHubContext.d.ts.map +1 -0
- package/dist/context/AIHubContext.js +19 -0
- package/dist/context/AIHubContext.js.map +1 -0
- package/dist/context/AIHubProvider.d.ts +75 -0
- package/dist/context/AIHubProvider.d.ts.map +1 -0
- package/dist/context/AIHubProvider.js +954 -0
- package/dist/context/AIHubProvider.js.map +1 -0
- package/dist/context/index.d.ts +9 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +9 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/theme.d.ts +43 -0
- package/dist/context/theme.d.ts.map +1 -0
- package/dist/context/theme.js +70 -0
- package/dist/context/theme.js.map +1 -0
- package/dist/context/useAIHub.d.ts +104 -0
- package/dist/context/useAIHub.d.ts.map +1 -0
- package/dist/context/useAIHub.js +63 -0
- package/dist/context/useAIHub.js.map +1 -0
- package/dist/context/useAIHubAuth.d.ts +44 -0
- package/dist/context/useAIHubAuth.d.ts.map +1 -0
- package/dist/context/useAIHubAuth.js +35 -0
- package/dist/context/useAIHubAuth.js.map +1 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/primitives/index.d.ts +99 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +97 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/state/affordances.d.ts +182 -0
- package/dist/state/affordances.d.ts.map +1 -0
- package/dist/state/affordances.js +189 -0
- package/dist/state/affordances.js.map +1 -0
- package/dist/state/stateReducer.d.ts +72 -0
- package/dist/state/stateReducer.d.ts.map +1 -0
- package/dist/state/stateReducer.js +122 -0
- package/dist/state/stateReducer.js.map +1 -0
- package/dist/stories/EffortControl.stories.d.ts +14 -0
- package/dist/stories/EffortControl.stories.d.ts.map +1 -0
- package/dist/stories/EffortControl.stories.js +43 -0
- package/dist/stories/EffortControl.stories.js.map +1 -0
- package/dist/stories/MarkdownRenderer.stories.d.ts +25 -0
- package/dist/stories/MarkdownRenderer.stories.d.ts.map +1 -0
- package/dist/stories/MarkdownRenderer.stories.js +178 -0
- package/dist/stories/MarkdownRenderer.stories.js.map +1 -0
- package/dist/stories/MessageBubble.stories.d.ts +21 -0
- package/dist/stories/MessageBubble.stories.d.ts.map +1 -0
- package/dist/stories/MessageBubble.stories.js +59 -0
- package/dist/stories/MessageBubble.stories.js.map +1 -0
- package/dist/stories/ReasoningView.stories.d.ts +18 -0
- package/dist/stories/ReasoningView.stories.d.ts.map +1 -0
- package/dist/stories/ReasoningView.stories.js +62 -0
- package/dist/stories/ReasoningView.stories.js.map +1 -0
- package/dist/stories/ScrollToPresentButton.stories.d.ts +18 -0
- package/dist/stories/ScrollToPresentButton.stories.d.ts.map +1 -0
- package/dist/stories/ScrollToPresentButton.stories.js +34 -0
- package/dist/stories/ScrollToPresentButton.stories.js.map +1 -0
- package/dist/stories/SystemNotice.stories.d.ts +17 -0
- package/dist/stories/SystemNotice.stories.d.ts.map +1 -0
- package/dist/stories/SystemNotice.stories.js +42 -0
- package/dist/stories/SystemNotice.stories.js.map +1 -0
- package/dist/stories/ThemeSwitcher.stories.d.ts +15 -0
- package/dist/stories/ThemeSwitcher.stories.d.ts.map +1 -0
- package/dist/stories/ThemeSwitcher.stories.js +35 -0
- package/dist/stories/ThemeSwitcher.stories.js.map +1 -0
- package/dist/stories/ToolCallView.stories.d.ts +20 -0
- package/dist/stories/ToolCallView.stories.d.ts.map +1 -0
- package/dist/stories/ToolCallView.stories.js +65 -0
- package/dist/stories/ToolCallView.stories.js.map +1 -0
- package/dist/stories/TpmBanner.stories.d.ts +24 -0
- package/dist/stories/TpmBanner.stories.d.ts.map +1 -0
- package/dist/stories/TpmBanner.stories.js +63 -0
- package/dist/stories/TpmBanner.stories.js.map +1 -0
- package/dist/stories/TurnStatusIndicator.stories.d.ts +25 -0
- package/dist/stories/TurnStatusIndicator.stories.d.ts.map +1 -0
- package/dist/stories/TurnStatusIndicator.stories.js +56 -0
- package/dist/stories/TurnStatusIndicator.stories.js.map +1 -0
- package/dist/stories/_mockProvider.d.ts +44 -0
- package/dist/stories/_mockProvider.d.ts.map +1 -0
- package/dist/stories/_mockProvider.js +84 -0
- package/dist/stories/_mockProvider.js.map +1 -0
- package/dist/types.d.ts +787 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/dist/webcomponent/defineWebComponent.d.ts +106 -0
- package/dist/webcomponent/defineWebComponent.d.ts.map +1 -0
- package/dist/webcomponent/defineWebComponent.js +126 -0
- package/dist/webcomponent/defineWebComponent.js.map +1 -0
- package/dist/webcomponent/index.d.ts +7 -0
- package/dist/webcomponent/index.d.ts.map +1 -0
- package/dist/webcomponent/index.js +7 -0
- package/dist/webcomponent/index.js.map +1 -0
- package/package.json +63 -0
- package/src/__lint-canary__/step1-lint-canary.ts.disabled +28 -0
- package/src/auth/passwordPolicy.ts +75 -0
- package/src/auth/texts.ts +1294 -0
- package/src/client/AIHubClient.ts +1718 -0
- package/src/client/index.ts +30 -0
- package/src/client/sseParser.ts +168 -0
- package/src/client/tokenStorage.ts +131 -0
- package/src/components/AgentsPicker/index.tsx +147 -0
- package/src/components/AuthGate/index.tsx +132 -0
- package/src/components/CacheBadge/index.tsx +245 -0
- package/src/components/ChangePassword/index.tsx +375 -0
- package/src/components/ChatShell/ShellHeader.tsx +80 -0
- package/src/components/ChatShell/UserMenu.tsx +196 -0
- package/src/components/ChatShell/index.tsx +307 -0
- package/src/components/DataClubAIHub/index.tsx +300 -0
- package/src/components/DataClubAIHubAdmin/AgentEditorModal.tsx +505 -0
- package/src/components/DataClubAIHubAdmin/AgentsPage.tsx +342 -0
- package/src/components/DataClubAIHubAdmin/CreateUserModal.tsx +214 -0
- package/src/components/DataClubAIHubAdmin/PasswordRevealModal.tsx +204 -0
- package/src/components/DataClubAIHubAdmin/ResetPasswordModal.tsx +122 -0
- package/src/components/DataClubAIHubAdmin/RotatingMessageEditorModal.tsx +408 -0
- package/src/components/DataClubAIHubAdmin/RotatingMessagesPage.tsx +373 -0
- package/src/components/DataClubAIHubAdmin/SessionsOverviewPage.tsx +639 -0
- package/src/components/DataClubAIHubAdmin/SettingsPage.tsx +979 -0
- package/src/components/DataClubAIHubAdmin/UsersPage.tsx +495 -0
- package/src/components/DataClubAIHubAdmin/index.tsx +277 -0
- package/src/components/DataClubAIHubLogin/index.tsx +282 -0
- package/src/components/EffortControl/index.tsx +138 -0
- package/src/components/Layout/index.tsx +92 -0
- package/src/components/MainColumn/index.tsx +131 -0
- package/src/components/MarkdownRenderer/index.tsx +256 -0
- package/src/components/MessageInput/index.tsx +283 -0
- package/src/components/MessageList/index.tsx +753 -0
- package/src/components/ReasoningSelector/index.tsx +268 -0
- package/src/components/ReasoningView/index.tsx +183 -0
- package/src/components/ScrollToPresentButton/index.tsx +85 -0
- package/src/components/SessionsPanel/SessionTitleModal.tsx +256 -0
- package/src/components/SessionsPanel/index.tsx +406 -0
- package/src/components/SystemNotice/index.tsx +151 -0
- package/src/components/ThemeSwitcher/index.tsx +136 -0
- package/src/components/ToolCallView/formatContent.ts +50 -0
- package/src/components/ToolCallView/index.tsx +274 -0
- package/src/components/TpmBanner/index.tsx +172 -0
- package/src/components/TurnStatusIndicator/index.tsx +203 -0
- package/src/components/internal/PasswordInput.tsx +145 -0
- package/src/context/AIHubContext.ts +249 -0
- package/src/context/AIHubProvider.tsx +1084 -0
- package/src/context/index.ts +9 -0
- package/src/context/theme.ts +76 -0
- package/src/context/useAIHub.ts +151 -0
- package/src/context/useAIHubAuth.ts +65 -0
- package/src/index.ts +275 -0
- package/src/primitives/index.ts +101 -0
- package/src/state/affordances.ts +321 -0
- package/src/state/stateReducer.ts +131 -0
- package/src/stories/EffortControl.stories.tsx +63 -0
- package/src/stories/MarkdownRenderer.stories.tsx +201 -0
- package/src/stories/MessageBubble.stories.tsx +101 -0
- package/src/stories/ReasoningView.stories.tsx +81 -0
- package/src/stories/ScrollToPresentButton.stories.tsx +52 -0
- package/src/stories/SystemNotice.stories.tsx +59 -0
- package/src/stories/ThemeSwitcher.stories.tsx +55 -0
- package/src/stories/ToolCallView.stories.tsx +95 -0
- package/src/stories/TpmBanner.stories.tsx +93 -0
- package/src/stories/TurnStatusIndicator.stories.tsx +86 -0
- package/src/stories/_mockProvider.tsx +116 -0
- package/src/styles/CLASSES.md +356 -0
- package/src/styles/default.css +2937 -0
- package/src/types.ts +867 -0
- package/src/webcomponent/defineWebComponent.tsx +193 -0
- package/src/webcomponent/index.ts +11 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* `<MarkdownRenderer />` — renders the textual body of an assistant
|
|
4
|
+
* message as GitHub-flavored Markdown with LaTeX-style math.
|
|
5
|
+
*
|
|
6
|
+
* The plumbing is the de-facto standard for AI chat output:
|
|
7
|
+
*
|
|
8
|
+
* - `react-markdown` parses the source into a hast (HTML AST) tree.
|
|
9
|
+
* - `remark-gfm` adds GitHub-flavored extensions on the mdast (markdown
|
|
10
|
+
* AST) side: pipe tables, task lists, strikethrough, autolinked URLs.
|
|
11
|
+
* - `remark-math` recognises `$inline$` and `$$block$$` LaTeX-style
|
|
12
|
+
* math, leaving it as an inline / block math node in mdast.
|
|
13
|
+
* - `rehype-katex` walks the hast tree and replaces those math nodes
|
|
14
|
+
* with rendered KaTeX HTML; consumers MUST also import
|
|
15
|
+
* `katex/dist/katex.min.css` (the chat shell's stylesheet bundles
|
|
16
|
+
* it — see `src/styles/default.css`) for the equations to look right.
|
|
17
|
+
*
|
|
18
|
+
* Every node we override emits a BEM-style class under
|
|
19
|
+
* `data-club-ai-hub__markdown__*`. The default stylesheet themes those
|
|
20
|
+
* via `--dc-aih-*` custom properties so per-customer wrappers keep
|
|
21
|
+
* working without touching this component.
|
|
22
|
+
*
|
|
23
|
+
* @see SPECIFICATIONS.md §7.3 — message bubble variants
|
|
24
|
+
* @see docs/react/markdown-rendering.md
|
|
25
|
+
*/
|
|
26
|
+
import ReactMarkdown from "react-markdown";
|
|
27
|
+
import remarkGfm from "remark-gfm";
|
|
28
|
+
import remarkMath from "remark-math";
|
|
29
|
+
import rehypeKatex from "rehype-katex";
|
|
30
|
+
const DEFAULT_CLASS_NAMES = Object.freeze({
|
|
31
|
+
root: "data-club-ai-hub__markdown",
|
|
32
|
+
paragraph: "data-club-ai-hub__markdown__p",
|
|
33
|
+
heading: "data-club-ai-hub__markdown__heading",
|
|
34
|
+
ul: "data-club-ai-hub__markdown__ul",
|
|
35
|
+
ol: "data-club-ai-hub__markdown__ol",
|
|
36
|
+
li: "data-club-ai-hub__markdown__li",
|
|
37
|
+
link: "data-club-ai-hub__markdown__a",
|
|
38
|
+
blockquote: "data-club-ai-hub__markdown__blockquote",
|
|
39
|
+
hr: "data-club-ai-hub__markdown__hr",
|
|
40
|
+
inlineCode: "data-club-ai-hub__markdown__code--inline",
|
|
41
|
+
codeBlock: "data-club-ai-hub__markdown__pre",
|
|
42
|
+
tableWrapper: "data-club-ai-hub__markdown__table-wrapper",
|
|
43
|
+
table: "data-club-ai-hub__markdown__table",
|
|
44
|
+
thead: "data-club-ai-hub__markdown__thead",
|
|
45
|
+
tbody: "data-club-ai-hub__markdown__tbody",
|
|
46
|
+
tr: "data-club-ai-hub__markdown__tr",
|
|
47
|
+
th: "data-club-ai-hub__markdown__th",
|
|
48
|
+
td: "data-club-ai-hub__markdown__td",
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Build the `react-markdown` component overrides table. Pulled out of
|
|
52
|
+
* the render body so the closure captures only `cls` (cheap to recreate)
|
|
53
|
+
* and the JSX inside is uncluttered.
|
|
54
|
+
*/
|
|
55
|
+
function buildComponents(cls) {
|
|
56
|
+
return {
|
|
57
|
+
p({ children }) {
|
|
58
|
+
return _jsx("p", { className: cls.paragraph, children: children });
|
|
59
|
+
},
|
|
60
|
+
h1({ children }) {
|
|
61
|
+
return (_jsx("h1", { className: `${cls.heading} ${cls.heading}--1`, children: children }));
|
|
62
|
+
},
|
|
63
|
+
h2({ children }) {
|
|
64
|
+
return (_jsx("h2", { className: `${cls.heading} ${cls.heading}--2`, children: children }));
|
|
65
|
+
},
|
|
66
|
+
h3({ children }) {
|
|
67
|
+
return (_jsx("h3", { className: `${cls.heading} ${cls.heading}--3`, children: children }));
|
|
68
|
+
},
|
|
69
|
+
h4({ children }) {
|
|
70
|
+
return (_jsx("h4", { className: `${cls.heading} ${cls.heading}--4`, children: children }));
|
|
71
|
+
},
|
|
72
|
+
h5({ children }) {
|
|
73
|
+
return (_jsx("h5", { className: `${cls.heading} ${cls.heading}--5`, children: children }));
|
|
74
|
+
},
|
|
75
|
+
h6({ children }) {
|
|
76
|
+
return (_jsx("h6", { className: `${cls.heading} ${cls.heading}--6`, children: children }));
|
|
77
|
+
},
|
|
78
|
+
ul({ children }) {
|
|
79
|
+
return _jsx("ul", { className: cls.ul, children: children });
|
|
80
|
+
},
|
|
81
|
+
ol({ children }) {
|
|
82
|
+
return _jsx("ol", { className: cls.ol, children: children });
|
|
83
|
+
},
|
|
84
|
+
li({ children }) {
|
|
85
|
+
return _jsx("li", { className: cls.li, children: children });
|
|
86
|
+
},
|
|
87
|
+
a({ href, children }) {
|
|
88
|
+
return (_jsx("a", { className: cls.link, href: href, target: "_blank", rel: "noopener noreferrer", children: children }));
|
|
89
|
+
},
|
|
90
|
+
blockquote({ children }) {
|
|
91
|
+
return _jsx("blockquote", { className: cls.blockquote, children: children });
|
|
92
|
+
},
|
|
93
|
+
hr() {
|
|
94
|
+
return _jsx("hr", { className: cls.hr });
|
|
95
|
+
},
|
|
96
|
+
code({ className, children, ...rest }) {
|
|
97
|
+
// `react-markdown` calls this renderer for BOTH inline (`` `foo` ``)
|
|
98
|
+
// and fenced (```` ```lang … ``` ````) code. The fenced form gets a
|
|
99
|
+
// `language-<lang>` class from remark; inline code has no className.
|
|
100
|
+
const langMatch = /language-(\w+)/.exec(className ?? "");
|
|
101
|
+
const isFenced = langMatch !== null;
|
|
102
|
+
if (!isFenced) {
|
|
103
|
+
return (_jsx("code", { className: cls.inlineCode, ...rest, children: children }));
|
|
104
|
+
}
|
|
105
|
+
// Fenced: keep `react-markdown`'s default `<pre><code class="language-…">`
|
|
106
|
+
// structure so future syntax-highlighter integrations (or wrapper
|
|
107
|
+
// overrides via `renderMessageBubble`) can target the language class.
|
|
108
|
+
return (_jsx("code", { className: className, ...rest, children: children }));
|
|
109
|
+
},
|
|
110
|
+
pre({ children }) {
|
|
111
|
+
return _jsx("pre", { className: cls.codeBlock, children: children });
|
|
112
|
+
},
|
|
113
|
+
// GFM tables. We wrap the table in a horizontally-scrollable div so
|
|
114
|
+
// wide tables (which Letta loves to produce when summarising data)
|
|
115
|
+
// don't push the chat bubble past its `max-width: 80%`.
|
|
116
|
+
table({ children }) {
|
|
117
|
+
return (_jsx("div", { className: cls.tableWrapper, children: _jsx("table", { className: cls.table, children: children }) }));
|
|
118
|
+
},
|
|
119
|
+
thead({ children }) {
|
|
120
|
+
return _jsx("thead", { className: cls.thead, children: children });
|
|
121
|
+
},
|
|
122
|
+
tbody({ children }) {
|
|
123
|
+
return _jsx("tbody", { className: cls.tbody, children: children });
|
|
124
|
+
},
|
|
125
|
+
tr({ children }) {
|
|
126
|
+
return _jsx("tr", { className: cls.tr, children: children });
|
|
127
|
+
},
|
|
128
|
+
th({ children }) {
|
|
129
|
+
return _jsx("th", { className: cls.th, children: children });
|
|
130
|
+
},
|
|
131
|
+
td({ children }) {
|
|
132
|
+
return _jsx("td", { className: cls.td, children: children });
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Render markdown source as the body of an assistant message.
|
|
138
|
+
*
|
|
139
|
+
* @param props - see `MarkdownRendererProps`.
|
|
140
|
+
* @returns the rendered markdown tree, or `null` if `content` is
|
|
141
|
+
* whitespace-only.
|
|
142
|
+
*/
|
|
143
|
+
export function MarkdownRenderer(props) {
|
|
144
|
+
const trimmed = props.content.trim();
|
|
145
|
+
if (trimmed === "")
|
|
146
|
+
return null;
|
|
147
|
+
const cls = { ...DEFAULT_CLASS_NAMES, ...(props.classNames ?? {}) };
|
|
148
|
+
const rootClass = props.className
|
|
149
|
+
? `${cls.root} ${props.className}`
|
|
150
|
+
: cls.root;
|
|
151
|
+
return (_jsx("div", { className: rootClass, "data-testid": "markdown", children: _jsx(ReactMarkdown, { remarkPlugins: [remarkGfm, remarkMath], rehypePlugins: [rehypeKatex], components: buildComponents(cls), children: trimmed }) }));
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/MarkdownRenderer/index.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,WAAW,MAAM,cAAc,CAAC;AAkDvC,MAAM,mBAAmB,GAA+B,MAAM,CAAC,MAAM,CAAC;IACpE,IAAI,EAAE,4BAA4B;IAClC,SAAS,EAAE,+BAA+B;IAC1C,OAAO,EAAE,qCAAqC;IAC9C,EAAE,EAAE,gCAAgC;IACpC,EAAE,EAAE,gCAAgC;IACpC,EAAE,EAAE,gCAAgC;IACpC,IAAI,EAAE,+BAA+B;IACrC,UAAU,EAAE,wCA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AAG,QAAQ,GAAM,CAAC;QAChD,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACrC,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,GAAG,GAAG,EAAE,GAAG,mBAAmB,EAAE,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,CAAC;IACpE,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS;QAC/B,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC,SAAS,EAAE;QAClC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IACb,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,iBAAc,UAAU,YAC/C,KAAC,aAAa,IACZ,aAAa,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EACtC,aAAa,EAAE,CAAC,WAAW,CAAC,EAC5B,UAAU,EAAE,eAAe,CAAC,GAAG,CAAC,YAE/B,OAAO,GACM,GACZ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<MessageInput />` — auto-growing textarea + send/stop buttons + toolbar
|
|
3
|
+
* (effort dropdown + slot for custom toolbar items).
|
|
4
|
+
*
|
|
5
|
+
* Step 9 shipped the structural input (Enter to send, Shift+Enter for
|
|
6
|
+
* newline, auto-grow, send ↔ stop toggle). Step 10 layers in:
|
|
7
|
+
*
|
|
8
|
+
* - **Phase-aware stop label** — "Stop generation" during model phases,
|
|
9
|
+
* "Cancel tool" during `tool_executing` (§10.4 stop-button row notes
|
|
10
|
+
* the label change; the i18n keys are `stopGenerationButton` /
|
|
11
|
+
* `cancelToolButton`).
|
|
12
|
+
* - **Effort dropdown** — `<EffortControl />` in the toolbar, gated by
|
|
13
|
+
* the resolved `effortControlVisible` flag.
|
|
14
|
+
* - **Custom toolbar items slot** — `customInputToolbarItems` from the
|
|
15
|
+
* monolith (Tier 2) and `toolbar` from primitive composition (Tier 3).
|
|
16
|
+
* Rendered after the effort dropdown.
|
|
17
|
+
*
|
|
18
|
+
* Exported under `AIHub.Input`.
|
|
19
|
+
*
|
|
20
|
+
* @see SPECIFICATIONS.md §7.1 — exports
|
|
21
|
+
* @see SPECIFICATIONS.md §7.4 — reasoning effort
|
|
22
|
+
* @see SPECIFICATIONS.md §10.4 — predicate table
|
|
23
|
+
* @see ui-sketches/03-chat.md — input_area
|
|
24
|
+
*/
|
|
25
|
+
import { type ReactNode } from "react";
|
|
26
|
+
import { type AIHubTexts, type DeepPartial } from "../../auth/texts.js";
|
|
27
|
+
/**
|
|
28
|
+
* BEM class names emitted by `<MessageInput />`.
|
|
29
|
+
*/
|
|
30
|
+
export interface MessageInputClassNames {
|
|
31
|
+
/** Outer wrapper. */
|
|
32
|
+
root: string;
|
|
33
|
+
/** Form element. */
|
|
34
|
+
form: string;
|
|
35
|
+
/** Wrapper around the textarea + buttons. */
|
|
36
|
+
inputRow: string;
|
|
37
|
+
/** The textarea itself. */
|
|
38
|
+
textarea: string;
|
|
39
|
+
/** Toolbar row beneath the textarea (effort + custom items). */
|
|
40
|
+
toolbar: string;
|
|
41
|
+
/** Send button. */
|
|
42
|
+
sendButton: string;
|
|
43
|
+
/** Stop button (replaces send while streaming). */
|
|
44
|
+
stopButton: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Props for `<MessageInput />`.
|
|
48
|
+
*/
|
|
49
|
+
export interface MessageInputProps {
|
|
50
|
+
/** Show the toolbar row. Defaults to true. */
|
|
51
|
+
showToolbar?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the effort dropdown renders inside the toolbar. Defaults to
|
|
54
|
+
* true. Set false to suppress (overridden upstream by the §8.4
|
|
55
|
+
* `effort_control_visible` toggle).
|
|
56
|
+
*/
|
|
57
|
+
showEffortControl?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Stop-button visibility flag from the §8.4 resolved stack. When
|
|
60
|
+
* false, the stop button is hidden during streaming and the input
|
|
61
|
+
* stays disabled until the server emits the terminal event. Default
|
|
62
|
+
* true.
|
|
63
|
+
*/
|
|
64
|
+
stopButtonEnabled?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Slot rendered after the effort dropdown — used by the monolith's
|
|
67
|
+
* `customInputToolbarItems` slot prop and by Tier-3 wrappers that
|
|
68
|
+
* pass a `toolbar` to `<AIHub.Input />` directly.
|
|
69
|
+
*/
|
|
70
|
+
toolbar?: ReactNode;
|
|
71
|
+
/** Extra class merged onto the root. */
|
|
72
|
+
className?: string;
|
|
73
|
+
/** Per-element class overrides. */
|
|
74
|
+
classNames?: Partial<MessageInputClassNames>;
|
|
75
|
+
/** Wrapper-supplied i18n. */
|
|
76
|
+
texts?: DeepPartial<AIHubTexts>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Renders the input area.
|
|
80
|
+
*
|
|
81
|
+
* @param props - see `MessageInputProps`.
|
|
82
|
+
* @returns the rendered input.
|
|
83
|
+
*/
|
|
84
|
+
export declare function MessageInput(props: MessageInputProps): ReactNode;
|
|
85
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MessageInput/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAM7B;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;CACpB;AAeD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC7C,6BAA6B;IAC7B,KAAK,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAuKhE"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* `<MessageInput />` — auto-growing textarea + send/stop buttons + toolbar
|
|
4
|
+
* (effort dropdown + slot for custom toolbar items).
|
|
5
|
+
*
|
|
6
|
+
* Step 9 shipped the structural input (Enter to send, Shift+Enter for
|
|
7
|
+
* newline, auto-grow, send ↔ stop toggle). Step 10 layers in:
|
|
8
|
+
*
|
|
9
|
+
* - **Phase-aware stop label** — "Stop generation" during model phases,
|
|
10
|
+
* "Cancel tool" during `tool_executing` (§10.4 stop-button row notes
|
|
11
|
+
* the label change; the i18n keys are `stopGenerationButton` /
|
|
12
|
+
* `cancelToolButton`).
|
|
13
|
+
* - **Effort dropdown** — `<EffortControl />` in the toolbar, gated by
|
|
14
|
+
* the resolved `effortControlVisible` flag.
|
|
15
|
+
* - **Custom toolbar items slot** — `customInputToolbarItems` from the
|
|
16
|
+
* monolith (Tier 2) and `toolbar` from primitive composition (Tier 3).
|
|
17
|
+
* Rendered after the effort dropdown.
|
|
18
|
+
*
|
|
19
|
+
* Exported under `AIHub.Input`.
|
|
20
|
+
*
|
|
21
|
+
* @see SPECIFICATIONS.md §7.1 — exports
|
|
22
|
+
* @see SPECIFICATIONS.md §7.4 — reasoning effort
|
|
23
|
+
* @see SPECIFICATIONS.md §10.4 — predicate table
|
|
24
|
+
* @see ui-sketches/03-chat.md — input_area
|
|
25
|
+
*/
|
|
26
|
+
import { useEffect, useRef, useState, } from "react";
|
|
27
|
+
import { resolveAIHubTexts, } from "../../auth/texts.js";
|
|
28
|
+
import { useAIHub } from "../../context/useAIHub.js";
|
|
29
|
+
import { chatAffordances } from "../../state/affordances.js";
|
|
30
|
+
import { EffortControl } from "../EffortControl/index.js";
|
|
31
|
+
const DEFAULT_CLASS_NAMES = Object.freeze({
|
|
32
|
+
root: "data-club-ai-hub__input-area",
|
|
33
|
+
form: "data-club-ai-hub__input-area__form",
|
|
34
|
+
inputRow: "data-club-ai-hub__input-area__row",
|
|
35
|
+
textarea: "data-club-ai-hub__input-area__textarea",
|
|
36
|
+
toolbar: "data-club-ai-hub__input-area__toolbar",
|
|
37
|
+
sendButton: "data-club-ai-hub__input-area__send",
|
|
38
|
+
stopButton: "data-club-ai-hub__input-area__stop",
|
|
39
|
+
});
|
|
40
|
+
/** Cap the textarea growth — past this many pixels it scrolls internally. */
|
|
41
|
+
const MAX_TEXTAREA_HEIGHT = 240;
|
|
42
|
+
/**
|
|
43
|
+
* Renders the input area.
|
|
44
|
+
*
|
|
45
|
+
* @param props - see `MessageInputProps`.
|
|
46
|
+
* @returns the rendered input.
|
|
47
|
+
*/
|
|
48
|
+
export function MessageInput(props) {
|
|
49
|
+
const { sendMessage, stop, state, activeSessionId, messagesLoading, isStoppingTurn, pendingDraft, consumePendingDraft, } = useAIHub();
|
|
50
|
+
const texts = resolveAIHubTexts(props.texts);
|
|
51
|
+
const cls = { ...DEFAULT_CLASS_NAMES, ...(props.classNames ?? {}) };
|
|
52
|
+
const showToolbar = props.showToolbar ?? true;
|
|
53
|
+
const showEffortControl = props.showEffortControl ?? true;
|
|
54
|
+
const stopButtonEnabled = props.stopButtonEnabled ?? true;
|
|
55
|
+
const [text, setText] = useState("");
|
|
56
|
+
const textareaRef = useRef(null);
|
|
57
|
+
// Consume `pendingDraft` when it appears, and never twice for the
|
|
58
|
+
// same value. The functional `setText` callback reads React's truly
|
|
59
|
+
// current state at flush time, so this is robust against:
|
|
60
|
+
//
|
|
61
|
+
// 1. Provider re-rendering between the moment pendingDraft is set
|
|
62
|
+
// and the moment this effect runs (`consumePendingDraft` changes
|
|
63
|
+
// identity on every provider render, which forces the effect to
|
|
64
|
+
// re-fire — the functional update tolerates that).
|
|
65
|
+
// 2. A stale `textRef` (the previous implementation relied on a
|
|
66
|
+
// render-time `textRef.current = text` assignment, which was
|
|
67
|
+
// correct in theory but proved fragile in practice — the
|
|
68
|
+
// functional form removes the read-side step entirely).
|
|
69
|
+
//
|
|
70
|
+
// We also always call `consumePendingDraft()` once we've seen a
|
|
71
|
+
// non-null draft, even if the user has typed something — that way
|
|
72
|
+
// the draft doesn't loop back the next time the user clears the
|
|
73
|
+
// input (the contract is "one-shot push from the provider; consume
|
|
74
|
+
// exactly once").
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (pendingDraft === null)
|
|
77
|
+
return;
|
|
78
|
+
setText((current) => (current.length === 0 ? pendingDraft : current));
|
|
79
|
+
consumePendingDraft();
|
|
80
|
+
}, [pendingDraft, consumePendingDraft]);
|
|
81
|
+
const affordances = chatAffordances(state);
|
|
82
|
+
const isStreaming = state.status === "running";
|
|
83
|
+
const disabled = !activeSessionId ||
|
|
84
|
+
affordances.inputDisabled ||
|
|
85
|
+
messagesLoading ||
|
|
86
|
+
isStoppingTurn;
|
|
87
|
+
const canSend = !isStreaming &&
|
|
88
|
+
text.trim().length > 0 &&
|
|
89
|
+
!!activeSessionId &&
|
|
90
|
+
!messagesLoading &&
|
|
91
|
+
!isStoppingTurn;
|
|
92
|
+
// Auto-grow the textarea up to MAX_TEXTAREA_HEIGHT.
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const el = textareaRef.current;
|
|
95
|
+
if (!el)
|
|
96
|
+
return;
|
|
97
|
+
el.style.height = "auto";
|
|
98
|
+
el.style.height = `${Math.min(el.scrollHeight, MAX_TEXTAREA_HEIGHT)}px`;
|
|
99
|
+
}, [text]);
|
|
100
|
+
// Focus the stop button when a turn starts so keyboard users can cancel
|
|
101
|
+
// without finding it. (§7.7.)
|
|
102
|
+
const stopButtonRef = useRef(null);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (isStreaming && stopButtonEnabled) {
|
|
105
|
+
stopButtonRef.current?.focus();
|
|
106
|
+
}
|
|
107
|
+
}, [isStreaming, stopButtonEnabled]);
|
|
108
|
+
function handleSubmit() {
|
|
109
|
+
const trimmed = text.trim();
|
|
110
|
+
if (!canSend || trimmed.length === 0)
|
|
111
|
+
return;
|
|
112
|
+
setText("");
|
|
113
|
+
void sendMessage(trimmed);
|
|
114
|
+
}
|
|
115
|
+
function handleKeyDown(e) {
|
|
116
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
handleSubmit();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const rootClass = props.className
|
|
122
|
+
? `${cls.root} ${props.className}`
|
|
123
|
+
: cls.root;
|
|
124
|
+
// Phase-aware stop label per §10.4: "Stop generation" during the
|
|
125
|
+
// model_* phases; "Cancel tool" during `tool_executing`. The label
|
|
126
|
+
// is the visible text AND the `aria-label`.
|
|
127
|
+
const stopLabel = state.phase === "tool_executing"
|
|
128
|
+
? texts.chat.cancelToolButton
|
|
129
|
+
: texts.chat.stopGenerationButton;
|
|
130
|
+
return (_jsx("div", { className: rootClass, "data-testid": "message-input", children: _jsxs("form", { className: cls.form, onSubmit: (e) => {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
handleSubmit();
|
|
133
|
+
}, children: [_jsxs("div", { className: cls.inputRow, children: [_jsx("textarea", { ref: textareaRef, className: cls.textarea, value: text, onChange: (e) => setText(e.target.value), onKeyDown: handleKeyDown, placeholder: texts.chat.inputPlaceholder, disabled: disabled, rows: 1, "data-testid": "message-input-textarea", "aria-label": texts.chat.inputPlaceholder }), isStreaming && stopButtonEnabled ? (_jsx("button", { ref: stopButtonRef, type: "button", className: cls.stopButton, onClick: () => {
|
|
134
|
+
if (isStoppingTurn)
|
|
135
|
+
return;
|
|
136
|
+
void stop();
|
|
137
|
+
}, disabled: isStoppingTurn, "aria-label": isStoppingTurn ? texts.chat.stoppingButton : stopLabel, "aria-busy": isStoppingTurn, "data-testid": "message-input-stop", "data-stopping": isStoppingTurn ? "true" : "false", "data-phase": state.phase ?? "none", children: isStoppingTurn ? texts.chat.stoppingButton : stopLabel })) : !isStreaming ? (_jsx("button", { type: "submit", className: cls.sendButton, disabled: !canSend, "aria-label": texts.chat.sendButtonAriaLabel, "data-testid": "message-input-send", children: texts.chat.sendButton })) : null] }), showToolbar && (showEffortControl || props.toolbar) ? (_jsxs("div", { className: cls.toolbar, "data-testid": "message-input-toolbar", children: [showEffortControl ? (_jsx(EffortControl, { disabled: disabled, ...(props.texts !== undefined ? { texts: props.texts } : {}) })) : null, props.toolbar] })) : null] }) }));
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/MessageInput/index.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,SAAS,EACT,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO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Q,EAAE,CAAC,OAAO,gBACN,KAAK,CAAC,IAAI,CAAC,mBAAmB,iBAC9B,oBAAoB,YAE/B,KAAK,CAAC,IAAI,CAAC,UAAU,GACf,CACV,CAAC,CAAC,CAAC,IAAI,IACJ,EACL,WAAW,IAAI,CAAC,iBAAiB,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CACrD,eAAK,SAAS,EAAE,GAAG,CAAC,OAAO,iBAAc,uBAAuB,aAC7D,iBAAiB,CAAC,CAAC,CAAC,CACnB,KAAC,aAAa,IACZ,QAAQ,EAAE,QAAQ,KACd,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAC7D,CACH,CAAC,CAAC,CAAC,IAAI,EACP,KAAK,CAAC,OAAO,IACV,CACP,CAAC,CAAC,CAAC,IAAI,IACH,GACH,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<MessageList />` — the scrollable list of message bubbles in the
|
|
3
|
+
* active session.
|
|
4
|
+
*
|
|
5
|
+
* Step 10 layers in:
|
|
6
|
+
*
|
|
7
|
+
* - `--system` / `--tool` / `--failed` bubble modifiers (Step 9 shipped
|
|
8
|
+
* `--user` / `--assistant`).
|
|
9
|
+
* - The `customMessageActions` slot — Tier-2 / Tier-3 wrappers render
|
|
10
|
+
* their own action bar inside every assistant bubble (e.g. 👍 / 👎).
|
|
11
|
+
* - The `customMessageBubble` slot — Tier-3 escape hatch that replaces
|
|
12
|
+
* the entire bubble for a message.
|
|
13
|
+
* - The `<TpmBanner />` — sits above the streaming bubble during a
|
|
14
|
+
* `waiting_provider` phase + the brief resumed-flash.
|
|
15
|
+
* - The `<ScrollToPresentButton />` — appears when the user has scrolled
|
|
16
|
+
* away from the bottom during a running turn (auto-scroll is
|
|
17
|
+
* inhibited while they're scrolled up).
|
|
18
|
+
* - Per-row Retry button on the failed-turn `--failed` assistant bubble.
|
|
19
|
+
*
|
|
20
|
+
* Server toggles (§8.4) gate via the resolved prop stack the monolith
|
|
21
|
+
* passes in:
|
|
22
|
+
*
|
|
23
|
+
* - `systemMessagesVisible` — when false, `system` and `tool`-role
|
|
24
|
+
* messages are filtered out of the list.
|
|
25
|
+
* - `tpmNoticeVisible` — when false, `<TpmBanner />` is suppressed.
|
|
26
|
+
* - `scrollToPresentVisible` — when false, the scroll-to-present
|
|
27
|
+
* button is suppressed.
|
|
28
|
+
*
|
|
29
|
+
* Exported under `AIHub.MessageList`.
|
|
30
|
+
*
|
|
31
|
+
* @see SPECIFICATIONS.md §7.1, §8.4, §10.4
|
|
32
|
+
* @see ui-sketches/03-chat.md — message_bubble + system_notice
|
|
33
|
+
*/
|
|
34
|
+
import { type ReactNode } from "react";
|
|
35
|
+
import { type AIHubTexts, type DeepPartial } from "../../auth/texts.js";
|
|
36
|
+
import type { AIHubMessageActionRenderer, AIHubMessageBubbleRenderer } from "../../types.js";
|
|
37
|
+
/**
|
|
38
|
+
* BEM class names emitted by `<MessageList />`.
|
|
39
|
+
*/
|
|
40
|
+
export interface MessageListClassNames {
|
|
41
|
+
/**
|
|
42
|
+
* Outer wrapper. NOT the scroll container — that's `root` (a child of
|
|
43
|
+
* this element). The wrapper exists so `<ScrollToPresentButton />`
|
|
44
|
+
* can sit as a sibling of the scroll container and stay anchored to
|
|
45
|
+
* the visible chat area as the user scrolls.
|
|
46
|
+
*/
|
|
47
|
+
wrapper: string;
|
|
48
|
+
/** Scroll container — the actual element that overflows + scrolls. */
|
|
49
|
+
root: string;
|
|
50
|
+
/** Inner block; targets `max-width` for readable line lengths. */
|
|
51
|
+
inner: string;
|
|
52
|
+
/** Empty-state placeholder (zero messages in the active session). */
|
|
53
|
+
empty: string;
|
|
54
|
+
/** Loading state. */
|
|
55
|
+
loading: string;
|
|
56
|
+
/** Placeholder when no session is selected. */
|
|
57
|
+
noSession: string;
|
|
58
|
+
/**
|
|
59
|
+
* Error banner shown above the streaming-assistant placeholder when
|
|
60
|
+
* the active turn failed without producing any assistant output.
|
|
61
|
+
*/
|
|
62
|
+
errorBanner: string;
|
|
63
|
+
/** Per-bubble base class. */
|
|
64
|
+
bubble: string;
|
|
65
|
+
/** Bubble modifier — `--user`. */
|
|
66
|
+
bubbleUser: string;
|
|
67
|
+
/** Bubble modifier — `--assistant`. */
|
|
68
|
+
bubbleAssistant: string;
|
|
69
|
+
/** Bubble modifier — `--system`. */
|
|
70
|
+
bubbleSystem: string;
|
|
71
|
+
/** Bubble modifier — `--tool`. */
|
|
72
|
+
bubbleTool: string;
|
|
73
|
+
/** Bubble modifier — `--failed` (applied to the assistant bubble of a failed turn). */
|
|
74
|
+
bubbleFailed: string;
|
|
75
|
+
/** Bubble modifier — `--cancelled` (for the "Stopped" stamp). */
|
|
76
|
+
bubbleCancelled: string;
|
|
77
|
+
/** Wrapper for the role label inside the bubble. */
|
|
78
|
+
bubbleRole: string;
|
|
79
|
+
/** The text body inside the bubble. */
|
|
80
|
+
bubbleBody: string;
|
|
81
|
+
/** The action bar inside the bubble (slot for custom actions). */
|
|
82
|
+
bubbleActions: string;
|
|
83
|
+
/** The retry-button on `--failed` bubbles. */
|
|
84
|
+
bubbleRetryButton: string;
|
|
85
|
+
/** The "Stopped" stamp on `--cancelled` bubbles. */
|
|
86
|
+
bubbleCancelledStamp: string;
|
|
87
|
+
/** Streaming caret while a turn is in flight. */
|
|
88
|
+
bubbleCaret: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Props for `<MessageList />`.
|
|
92
|
+
*/
|
|
93
|
+
export interface MessageListProps {
|
|
94
|
+
/**
|
|
95
|
+
* Show system / tool-role bubbles. Default true. When false, those
|
|
96
|
+
* messages are filtered out (the user-facing list shows user +
|
|
97
|
+
* assistant only).
|
|
98
|
+
*/
|
|
99
|
+
showSystemMessages?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Render `<TpmBanner />` during `waiting_provider` and on
|
|
102
|
+
* tpm_exhausted. Default true. The monolith passes the resolved
|
|
103
|
+
* §8.4 flag here.
|
|
104
|
+
*/
|
|
105
|
+
showTpmNotice?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Render `<ReasoningView />` inside assistant bubbles when the
|
|
108
|
+
* message carries `reasoning`. Default true. Monolith forwards the
|
|
109
|
+
* resolved `reasoning_visible` flag.
|
|
110
|
+
*/
|
|
111
|
+
showReasoning?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Render `<ToolCallView />` cards inside assistant bubbles when the
|
|
114
|
+
* message carries `tool_calls`. Default true. Monolith forwards the
|
|
115
|
+
* resolved `tool_calls_visible` flag.
|
|
116
|
+
*/
|
|
117
|
+
showToolCalls?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Render `<ScrollToPresentButton />` when the user has scrolled away
|
|
120
|
+
* from the bottom of the list during a running turn. Default true.
|
|
121
|
+
*/
|
|
122
|
+
showScrollToPresentButton?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Render a "Retry" button on `--failed` assistant bubbles. Default
|
|
125
|
+
* true. When false the bubble still renders with the failed modifier
|
|
126
|
+
* but no action is offered.
|
|
127
|
+
*/
|
|
128
|
+
showRetryButton?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Tier 2 / Tier 3 slot — render the action bar of every assistant
|
|
131
|
+
* message bubble. The renderer receives the full `AIHubMessage` and
|
|
132
|
+
* returns React-renderable content (or null to suppress the bar
|
|
133
|
+
* for that message).
|
|
134
|
+
*/
|
|
135
|
+
renderMessageActions?: AIHubMessageActionRenderer;
|
|
136
|
+
/**
|
|
137
|
+
* Tier 3 escape hatch — fully replace the message bubble for any
|
|
138
|
+
* message. The renderer is wrapped in the list's flex container; the
|
|
139
|
+
* caller is responsible for choosing variant modifiers.
|
|
140
|
+
*/
|
|
141
|
+
renderMessageBubble?: AIHubMessageBubbleRenderer;
|
|
142
|
+
/** Extra class merged onto the root. */
|
|
143
|
+
className?: string;
|
|
144
|
+
/** Per-element class overrides. */
|
|
145
|
+
classNames?: Partial<MessageListClassNames>;
|
|
146
|
+
/** Wrapper-supplied i18n. */
|
|
147
|
+
texts?: DeepPartial<AIHubTexts>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Renders the message list.
|
|
151
|
+
*
|
|
152
|
+
* @param props - see `MessageListProps`.
|
|
153
|
+
* @returns the rendered list.
|
|
154
|
+
*/
|
|
155
|
+
export declare function MessageList(props: MessageListProps): ReactNode;
|
|
156
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MessageList/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAEV,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AA8CxB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,eAAe,EAAE,MAAM,CAAC;IACxB,oCAA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