@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,639 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<AdminSessionsOverviewPage />` — the read-only Sessions overview sub-page
|
|
3
|
+
* mounted inside `<DataClubAIHubAdmin />` ([07-admin-sessions-overview.md]).
|
|
4
|
+
*
|
|
5
|
+
* Two views:
|
|
6
|
+
*
|
|
7
|
+
* - **List view** — `[🔍 search]` + `Owner / Agent / Status` filters above a
|
|
8
|
+
* paginated table of every session in the deployment. Each row has a
|
|
9
|
+
* `[View]` button.
|
|
10
|
+
* - **Detail view** — read-only render of the session's messages using the
|
|
11
|
+
* `<AdminMessagesReadOnly />` helper. No input area, no effort dropdown, no
|
|
12
|
+
* send / stop. Reasoning + tool-call cards remain expandable.
|
|
13
|
+
*
|
|
14
|
+
* Pagination is cursor-based — the server returns `next_cursor` (or `null`
|
|
15
|
+
* on the last page). We keep the chain in `cursorStack` so the user can
|
|
16
|
+
* navigate forward (push) and backward (pop) without re-fetching from the
|
|
17
|
+
* top.
|
|
18
|
+
*
|
|
19
|
+
* Visible to `power_user`+ per §8.2; the parent shell gates on role.
|
|
20
|
+
*
|
|
21
|
+
* @see SPECIFICATIONS.md §6.3.4 / §8.3
|
|
22
|
+
* @see ui-sketches/07-admin-sessions-overview.md
|
|
23
|
+
*/
|
|
24
|
+
import { useEffect, useMemo, useState, type ReactNode } from "react";
|
|
25
|
+
|
|
26
|
+
import type { AIHubAdminTexts } from "../../auth/texts.js";
|
|
27
|
+
import { AIHubRequestError } from "../../client/AIHubClient.js";
|
|
28
|
+
import type {
|
|
29
|
+
AdminAgentView,
|
|
30
|
+
AdminSessionView,
|
|
31
|
+
AdminUserView,
|
|
32
|
+
ListAdminSessionsResponse,
|
|
33
|
+
} from "../../client/AIHubClient.js";
|
|
34
|
+
import { useAIHub } from "../../context/useAIHub.js";
|
|
35
|
+
import { useAIHubAuth } from "../../context/useAIHubAuth.js";
|
|
36
|
+
import type { AIHubMessage } from "../../types.js";
|
|
37
|
+
import { ReasoningView } from "../ReasoningView/index.js";
|
|
38
|
+
import { ToolCallView, type ToolCallStatus } from "../ToolCallView/index.js";
|
|
39
|
+
|
|
40
|
+
/** What the user is looking at — list or one session's messages. */
|
|
41
|
+
type View =
|
|
42
|
+
| { kind: "list" }
|
|
43
|
+
| { kind: "detail"; session: AdminSessionView };
|
|
44
|
+
|
|
45
|
+
/** Server-accepted status filter values. */
|
|
46
|
+
type StatusFilter = "active" | "archived" | "all";
|
|
47
|
+
|
|
48
|
+
/** Page size — matches the spec's default of 50. */
|
|
49
|
+
const PAGE_SIZE = 50;
|
|
50
|
+
|
|
51
|
+
/** Format an ISO date as a short relative "x ago" string. */
|
|
52
|
+
function formatLastMessage(iso: string): string {
|
|
53
|
+
const date = Date.parse(iso);
|
|
54
|
+
if (Number.isNaN(date)) return iso;
|
|
55
|
+
const diffMs = Date.now() - date;
|
|
56
|
+
if (diffMs < 60_000) return "just now";
|
|
57
|
+
const minutes = Math.floor(diffMs / 60_000);
|
|
58
|
+
if (minutes < 60) return `${minutes} min ago`;
|
|
59
|
+
const hours = Math.floor(minutes / 60);
|
|
60
|
+
if (hours < 24) return `${hours}h ago`;
|
|
61
|
+
const days = Math.floor(hours / 24);
|
|
62
|
+
if (days < 7) return `${days}d ago`;
|
|
63
|
+
return new Date(date).toISOString().slice(0, 10);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Props for `<AdminSessionsOverviewPage />`. */
|
|
67
|
+
export interface AdminSessionsOverviewPageProps {
|
|
68
|
+
/** Resolved admin texts. */
|
|
69
|
+
texts: AIHubAdminTexts;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Renders the sessions-overview sub-page.
|
|
74
|
+
*
|
|
75
|
+
* @param props - see {@link AdminSessionsOverviewPageProps}.
|
|
76
|
+
* @returns the rendered page.
|
|
77
|
+
*/
|
|
78
|
+
export function AdminSessionsOverviewPage(
|
|
79
|
+
props: AdminSessionsOverviewPageProps,
|
|
80
|
+
): ReactNode {
|
|
81
|
+
const { client } = useAIHub();
|
|
82
|
+
|
|
83
|
+
const [view, setView] = useState<View>({ kind: "list" });
|
|
84
|
+
|
|
85
|
+
// List-view state.
|
|
86
|
+
const [page, setPage] = useState<ListAdminSessionsResponse | null>(null);
|
|
87
|
+
const [pageError, setPageError] = useState<string | null>(null);
|
|
88
|
+
const [loading, setLoading] = useState(true);
|
|
89
|
+
// Cursor for the page currently being viewed; null = page 1.
|
|
90
|
+
const [activeCursor, setActiveCursor] = useState<string | null>(null);
|
|
91
|
+
// Stack of previous cursors for back navigation. Entry at index i is the
|
|
92
|
+
// cursor that loaded page i+2 (we never push the page-1 cursor since
|
|
93
|
+
// that's just null).
|
|
94
|
+
const [cursorStack, setCursorStack] = useState<string[]>([]);
|
|
95
|
+
|
|
96
|
+
// Filters — server params.
|
|
97
|
+
const [search, setSearch] = useState("");
|
|
98
|
+
const [ownerId, setOwnerId] = useState<string>("");
|
|
99
|
+
const [agentId, setAgentId] = useState<string>("");
|
|
100
|
+
const [status, setStatus] = useState<StatusFilter>("active");
|
|
101
|
+
|
|
102
|
+
// Dropdown data for the filters.
|
|
103
|
+
const [owners, setOwners] = useState<AdminUserView[]>([]);
|
|
104
|
+
const [agents, setAgents] = useState<AdminAgentView[]>([]);
|
|
105
|
+
|
|
106
|
+
// Fetch the dropdown data once on mount. Owners can come back as 403 for
|
|
107
|
+
// power_user (they can't list users), in which case we render the dropdown
|
|
108
|
+
// disabled with "all users" only.
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
let cancelled = false;
|
|
111
|
+
void (async () => {
|
|
112
|
+
try {
|
|
113
|
+
const [u, a] = await Promise.allSettled([
|
|
114
|
+
client.listAdminUsers(),
|
|
115
|
+
client.listAdminAgents(),
|
|
116
|
+
]);
|
|
117
|
+
if (cancelled) return;
|
|
118
|
+
if (u.status === "fulfilled") setOwners(u.value);
|
|
119
|
+
if (a.status === "fulfilled") setAgents(a.value);
|
|
120
|
+
} catch {
|
|
121
|
+
/* swallowed — the dropdowns just stay limited */
|
|
122
|
+
}
|
|
123
|
+
})();
|
|
124
|
+
return () => {
|
|
125
|
+
cancelled = true;
|
|
126
|
+
};
|
|
127
|
+
}, [client]);
|
|
128
|
+
|
|
129
|
+
// Fetch the current page whenever the cursor or filters change. We debounce
|
|
130
|
+
// the search input via a separate effect that bumps a re-load token.
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
let cancelled = false;
|
|
133
|
+
setLoading(true);
|
|
134
|
+
setPageError(null);
|
|
135
|
+
void (async () => {
|
|
136
|
+
try {
|
|
137
|
+
const options: Parameters<typeof client.listAdminSessions>[0] = {
|
|
138
|
+
limit: PAGE_SIZE,
|
|
139
|
+
status,
|
|
140
|
+
};
|
|
141
|
+
if (activeCursor !== null) options.cursor = activeCursor;
|
|
142
|
+
if (ownerId !== "") options.ownerId = ownerId;
|
|
143
|
+
if (agentId !== "") options.agentId = agentId;
|
|
144
|
+
if (search.trim().length > 0) options.search = search.trim();
|
|
145
|
+
const result = await client.listAdminSessions(options);
|
|
146
|
+
if (!cancelled) {
|
|
147
|
+
setPage(result);
|
|
148
|
+
setLoading(false);
|
|
149
|
+
}
|
|
150
|
+
} catch (err) {
|
|
151
|
+
if (!cancelled) {
|
|
152
|
+
setPageError(
|
|
153
|
+
err instanceof Error && err.message.length > 0
|
|
154
|
+
? err.message
|
|
155
|
+
: props.texts.sessionsOverviewGenericError,
|
|
156
|
+
);
|
|
157
|
+
setLoading(false);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
})();
|
|
161
|
+
return () => {
|
|
162
|
+
cancelled = true;
|
|
163
|
+
};
|
|
164
|
+
}, [client, activeCursor, ownerId, agentId, status, search]);
|
|
165
|
+
|
|
166
|
+
const pageNumber = cursorStack.length + 1;
|
|
167
|
+
const hasNext = page?.nextCursor !== null && page?.nextCursor !== undefined;
|
|
168
|
+
const hasPrev = cursorStack.length > 0;
|
|
169
|
+
|
|
170
|
+
function applyFilterAndReset(): void {
|
|
171
|
+
setActiveCursor(null);
|
|
172
|
+
setCursorStack([]);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function goNext(): void {
|
|
176
|
+
if (page?.nextCursor === null || page?.nextCursor === undefined) return;
|
|
177
|
+
setCursorStack((prev) =>
|
|
178
|
+
activeCursor === null ? prev : [...prev, activeCursor],
|
|
179
|
+
);
|
|
180
|
+
setActiveCursor(page.nextCursor);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function goPrev(): void {
|
|
184
|
+
setCursorStack((prev) => {
|
|
185
|
+
if (prev.length === 0) {
|
|
186
|
+
setActiveCursor(null);
|
|
187
|
+
return prev;
|
|
188
|
+
}
|
|
189
|
+
const next = [...prev];
|
|
190
|
+
next.pop();
|
|
191
|
+
setActiveCursor(next.length === 0 ? null : (next[next.length - 1] ?? null));
|
|
192
|
+
return next;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (view.kind === "detail") {
|
|
197
|
+
return (
|
|
198
|
+
<AdminSessionDetail
|
|
199
|
+
session={view.session}
|
|
200
|
+
texts={props.texts}
|
|
201
|
+
onBack={() => setView({ kind: "list" })}
|
|
202
|
+
/>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<div
|
|
208
|
+
className="data-club-ai-hub-admin__sessions-page"
|
|
209
|
+
data-testid="admin-sessions-page"
|
|
210
|
+
>
|
|
211
|
+
<header className="data-club-ai-hub-admin__page-header">
|
|
212
|
+
<h1
|
|
213
|
+
className="data-club-ai-hub-admin__page-heading"
|
|
214
|
+
data-testid="admin-sessions-heading"
|
|
215
|
+
>
|
|
216
|
+
{props.texts.sessionsOverviewHeading}
|
|
217
|
+
</h1>
|
|
218
|
+
<input
|
|
219
|
+
type="search"
|
|
220
|
+
className="data-club-ai-hub-admin__search"
|
|
221
|
+
data-testid="admin-sessions-search"
|
|
222
|
+
placeholder={props.texts.sessionsOverviewSearchPlaceholder}
|
|
223
|
+
value={search}
|
|
224
|
+
onChange={(event) => {
|
|
225
|
+
setSearch(event.target.value);
|
|
226
|
+
applyFilterAndReset();
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
</header>
|
|
230
|
+
<div
|
|
231
|
+
className="data-club-ai-hub-admin__filters"
|
|
232
|
+
data-testid="admin-sessions-filters"
|
|
233
|
+
>
|
|
234
|
+
<label className="data-club-ai-hub-admin__filter">
|
|
235
|
+
<span>{props.texts.sessionsOverviewOwnerFilterLabel}</span>
|
|
236
|
+
<select
|
|
237
|
+
data-testid="admin-sessions-filter-owner"
|
|
238
|
+
value={ownerId}
|
|
239
|
+
disabled={owners.length === 0}
|
|
240
|
+
onChange={(event) => {
|
|
241
|
+
setOwnerId(event.target.value);
|
|
242
|
+
applyFilterAndReset();
|
|
243
|
+
}}
|
|
244
|
+
>
|
|
245
|
+
<option value="">{props.texts.sessionsOverviewOwnerFilterAll}</option>
|
|
246
|
+
{owners.map((u) => (
|
|
247
|
+
<option key={u.id} value={u.id}>
|
|
248
|
+
{u.username}
|
|
249
|
+
</option>
|
|
250
|
+
))}
|
|
251
|
+
</select>
|
|
252
|
+
</label>
|
|
253
|
+
<label className="data-club-ai-hub-admin__filter">
|
|
254
|
+
<span>{props.texts.sessionsOverviewAgentFilterLabel}</span>
|
|
255
|
+
<select
|
|
256
|
+
data-testid="admin-sessions-filter-agent"
|
|
257
|
+
value={agentId}
|
|
258
|
+
disabled={agents.length === 0}
|
|
259
|
+
onChange={(event) => {
|
|
260
|
+
setAgentId(event.target.value);
|
|
261
|
+
applyFilterAndReset();
|
|
262
|
+
}}
|
|
263
|
+
>
|
|
264
|
+
<option value="">{props.texts.sessionsOverviewAgentFilterAll}</option>
|
|
265
|
+
{agents.map((a) => (
|
|
266
|
+
<option key={a.id} value={a.id}>
|
|
267
|
+
{a.display_name}
|
|
268
|
+
</option>
|
|
269
|
+
))}
|
|
270
|
+
</select>
|
|
271
|
+
</label>
|
|
272
|
+
<label className="data-club-ai-hub-admin__filter">
|
|
273
|
+
<span>{props.texts.sessionsOverviewStatusFilterLabel}</span>
|
|
274
|
+
<select
|
|
275
|
+
data-testid="admin-sessions-filter-status"
|
|
276
|
+
value={status}
|
|
277
|
+
onChange={(event) => {
|
|
278
|
+
setStatus(event.target.value as StatusFilter);
|
|
279
|
+
applyFilterAndReset();
|
|
280
|
+
}}
|
|
281
|
+
>
|
|
282
|
+
<option value="active">{props.texts.sessionsOverviewStatusActive}</option>
|
|
283
|
+
<option value="archived">
|
|
284
|
+
{props.texts.sessionsOverviewStatusArchived}
|
|
285
|
+
</option>
|
|
286
|
+
<option value="all">{props.texts.sessionsOverviewStatusAll}</option>
|
|
287
|
+
</select>
|
|
288
|
+
</label>
|
|
289
|
+
</div>
|
|
290
|
+
{pageError !== null ? (
|
|
291
|
+
<div
|
|
292
|
+
className="data-club-ai-hub-admin__error"
|
|
293
|
+
role="alert"
|
|
294
|
+
data-testid="admin-sessions-error"
|
|
295
|
+
>
|
|
296
|
+
{pageError}
|
|
297
|
+
</div>
|
|
298
|
+
) : null}
|
|
299
|
+
{loading ? (
|
|
300
|
+
<p
|
|
301
|
+
className="data-club-ai-hub-admin__loading"
|
|
302
|
+
data-testid="admin-sessions-loading"
|
|
303
|
+
>
|
|
304
|
+
{props.texts.sessionsOverviewLoading}
|
|
305
|
+
</p>
|
|
306
|
+
) : null}
|
|
307
|
+
{!loading && pageError === null && (page?.sessions.length ?? 0) === 0 ? (
|
|
308
|
+
<p
|
|
309
|
+
className="data-club-ai-hub-admin__empty"
|
|
310
|
+
data-testid="admin-sessions-empty"
|
|
311
|
+
>
|
|
312
|
+
{props.texts.sessionsOverviewEmpty}
|
|
313
|
+
</p>
|
|
314
|
+
) : null}
|
|
315
|
+
{!loading && page !== null && page.sessions.length > 0 ? (
|
|
316
|
+
<>
|
|
317
|
+
<table
|
|
318
|
+
className="data-club-ai-hub-admin__sessions-table"
|
|
319
|
+
data-testid="admin-sessions-table"
|
|
320
|
+
>
|
|
321
|
+
<thead>
|
|
322
|
+
<tr>
|
|
323
|
+
<th>{props.texts.sessionsOverviewColumnTitle}</th>
|
|
324
|
+
<th>{props.texts.sessionsOverviewColumnOwner}</th>
|
|
325
|
+
<th>{props.texts.sessionsOverviewColumnAgent}</th>
|
|
326
|
+
<th>{props.texts.sessionsOverviewColumnLastMessage}</th>
|
|
327
|
+
<th>{props.texts.sessionsOverviewColumnActions}</th>
|
|
328
|
+
</tr>
|
|
329
|
+
</thead>
|
|
330
|
+
<tbody>
|
|
331
|
+
{page.sessions.map((s) => (
|
|
332
|
+
<tr
|
|
333
|
+
key={s.id}
|
|
334
|
+
data-testid={`admin-session-row-${s.id}`}
|
|
335
|
+
data-archived={s.is_archived ? "true" : "false"}
|
|
336
|
+
>
|
|
337
|
+
<td>{s.title}</td>
|
|
338
|
+
<td>{s.owner_username}</td>
|
|
339
|
+
<td>{s.agent_display_name}</td>
|
|
340
|
+
<td>{formatLastMessage(s.updated_at)}</td>
|
|
341
|
+
<td>
|
|
342
|
+
<button
|
|
343
|
+
type="button"
|
|
344
|
+
className="data-club-ai-hub-admin__row-action"
|
|
345
|
+
data-testid={`admin-session-row-${s.id}-view`}
|
|
346
|
+
onClick={() => setView({ kind: "detail", session: s })}
|
|
347
|
+
>
|
|
348
|
+
{props.texts.sessionsOverviewViewButton}
|
|
349
|
+
</button>
|
|
350
|
+
</td>
|
|
351
|
+
</tr>
|
|
352
|
+
))}
|
|
353
|
+
</tbody>
|
|
354
|
+
</table>
|
|
355
|
+
<div
|
|
356
|
+
className="data-club-ai-hub-admin__pagination"
|
|
357
|
+
data-testid="admin-sessions-pagination"
|
|
358
|
+
>
|
|
359
|
+
<button
|
|
360
|
+
type="button"
|
|
361
|
+
className="data-club-ai-hub-admin__button"
|
|
362
|
+
data-testid="admin-sessions-prev"
|
|
363
|
+
onClick={goPrev}
|
|
364
|
+
disabled={!hasPrev}
|
|
365
|
+
>
|
|
366
|
+
{props.texts.sessionsOverviewPrevPage}
|
|
367
|
+
</button>
|
|
368
|
+
<span
|
|
369
|
+
className="data-club-ai-hub-admin__page-number"
|
|
370
|
+
data-testid="admin-sessions-page-number"
|
|
371
|
+
>
|
|
372
|
+
{props.texts.sessionsOverviewPageNumber.replace(
|
|
373
|
+
"{n}",
|
|
374
|
+
String(pageNumber),
|
|
375
|
+
)}
|
|
376
|
+
</span>
|
|
377
|
+
<button
|
|
378
|
+
type="button"
|
|
379
|
+
className="data-club-ai-hub-admin__button"
|
|
380
|
+
data-testid="admin-sessions-next"
|
|
381
|
+
onClick={goNext}
|
|
382
|
+
disabled={!hasNext}
|
|
383
|
+
>
|
|
384
|
+
{props.texts.sessionsOverviewNextPage}
|
|
385
|
+
</button>
|
|
386
|
+
</div>
|
|
387
|
+
</>
|
|
388
|
+
) : null}
|
|
389
|
+
</div>
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** Props for the detail sub-view. */
|
|
394
|
+
interface AdminSessionDetailProps {
|
|
395
|
+
session: AdminSessionView;
|
|
396
|
+
texts: AIHubAdminTexts;
|
|
397
|
+
onBack: () => void;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Renders the read-only session detail view. Fetches messages on mount,
|
|
402
|
+
* mounts `<MessageBubble />`-equivalent rendering without an input area.
|
|
403
|
+
*
|
|
404
|
+
* The bubble rendering is intentionally minimal in this admin context —
|
|
405
|
+
* no streaming dots, no send/stop, no retry. We don't reuse `<MessageList />`
|
|
406
|
+
* because it pulls data from `useAIHub()` (the active session); admin-side
|
|
407
|
+
* detail browses arbitrary sessions outside the chat context.
|
|
408
|
+
*/
|
|
409
|
+
function AdminSessionDetail(props: AdminSessionDetailProps): ReactNode {
|
|
410
|
+
const { client } = useAIHub();
|
|
411
|
+
const auth = useAIHubAuth();
|
|
412
|
+
const isSuperAdmin = auth.user?.role === "super_admin";
|
|
413
|
+
const { session, texts } = props;
|
|
414
|
+
const [messages, setMessages] = useState<AIHubMessage[] | null>(null);
|
|
415
|
+
const [error, setError] = useState<string | null>(null);
|
|
416
|
+
// Step-12.5 — local mirror of the sandbox state so the footer + button
|
|
417
|
+
// can update without a refetch after a successful purge.
|
|
418
|
+
const [hasSandbox, setHasSandbox] = useState(session.has_sandbox);
|
|
419
|
+
const [purging, setPurging] = useState(false);
|
|
420
|
+
const [purgeError, setPurgeError] = useState<string | null>(null);
|
|
421
|
+
const [purgeFlash, setPurgeFlash] = useState<string | null>(null);
|
|
422
|
+
|
|
423
|
+
useEffect(() => {
|
|
424
|
+
let cancelled = false;
|
|
425
|
+
void (async () => {
|
|
426
|
+
try {
|
|
427
|
+
const rows = await client.getAdminSessionMessages(session.id);
|
|
428
|
+
if (!cancelled) {
|
|
429
|
+
setMessages(rows);
|
|
430
|
+
setError(null);
|
|
431
|
+
}
|
|
432
|
+
} catch (err) {
|
|
433
|
+
if (!cancelled) {
|
|
434
|
+
setError(
|
|
435
|
+
err instanceof Error && err.message.length > 0
|
|
436
|
+
? err.message
|
|
437
|
+
: texts.sessionsOverviewDetailGenericError,
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
})();
|
|
442
|
+
return () => {
|
|
443
|
+
cancelled = true;
|
|
444
|
+
};
|
|
445
|
+
}, [client, session.id, texts.sessionsOverviewDetailGenericError]);
|
|
446
|
+
|
|
447
|
+
async function handlePurgeSandbox(): Promise<void> {
|
|
448
|
+
// Native window.confirm — consistent with the archive-confirm pattern
|
|
449
|
+
// used elsewhere in the admin UI ([06-admin-agents.md]).
|
|
450
|
+
// eslint-disable-next-line no-alert
|
|
451
|
+
const ok =
|
|
452
|
+
typeof window !== "undefined" && typeof window.confirm === "function"
|
|
453
|
+
? window.confirm(texts.sessionsOverviewPurgeSandboxConfirmPrompt)
|
|
454
|
+
: true;
|
|
455
|
+
if (!ok) return;
|
|
456
|
+
setPurging(true);
|
|
457
|
+
setPurgeError(null);
|
|
458
|
+
setPurgeFlash(null);
|
|
459
|
+
try {
|
|
460
|
+
await client.purgeAdminSessionSandbox(session.id);
|
|
461
|
+
setHasSandbox(false);
|
|
462
|
+
setPurgeFlash(texts.sessionsOverviewPurgeSandboxSuccessFlash);
|
|
463
|
+
} catch (err) {
|
|
464
|
+
if (err instanceof AIHubRequestError && err.code === "turn_running") {
|
|
465
|
+
setPurgeError(texts.sessionsOverviewPurgeSandboxTurnRunningError);
|
|
466
|
+
} else {
|
|
467
|
+
setPurgeError(
|
|
468
|
+
err instanceof Error && err.message.length > 0
|
|
469
|
+
? err.message
|
|
470
|
+
: texts.sessionsOverviewPurgeSandboxGenericError,
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
} finally {
|
|
474
|
+
setPurging(false);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const heading = useMemo(
|
|
479
|
+
() =>
|
|
480
|
+
texts.sessionsOverviewDetailHeading
|
|
481
|
+
.replace("{title}", session.title)
|
|
482
|
+
.replace("{owner}", session.owner_username)
|
|
483
|
+
.replace("{agent}", session.agent_display_name),
|
|
484
|
+
[
|
|
485
|
+
texts.sessionsOverviewDetailHeading,
|
|
486
|
+
session.title,
|
|
487
|
+
session.owner_username,
|
|
488
|
+
session.agent_display_name,
|
|
489
|
+
],
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
return (
|
|
493
|
+
<div
|
|
494
|
+
className="data-club-ai-hub-admin__session-detail"
|
|
495
|
+
data-testid="admin-session-detail"
|
|
496
|
+
>
|
|
497
|
+
<header
|
|
498
|
+
className="data-club-ai-hub-admin__detail-header"
|
|
499
|
+
data-testid="admin-session-detail-header"
|
|
500
|
+
>
|
|
501
|
+
<button
|
|
502
|
+
type="button"
|
|
503
|
+
className="data-club-ai-hub-admin__back-link"
|
|
504
|
+
data-testid="admin-session-detail-back"
|
|
505
|
+
onClick={props.onBack}
|
|
506
|
+
>
|
|
507
|
+
{texts.sessionsOverviewBackLink}
|
|
508
|
+
</button>
|
|
509
|
+
<h1
|
|
510
|
+
className="data-club-ai-hub-admin__detail-heading"
|
|
511
|
+
data-testid="admin-session-detail-heading"
|
|
512
|
+
>
|
|
513
|
+
{heading}
|
|
514
|
+
</h1>
|
|
515
|
+
</header>
|
|
516
|
+
{error !== null ? (
|
|
517
|
+
<div
|
|
518
|
+
className="data-club-ai-hub-admin__error"
|
|
519
|
+
role="alert"
|
|
520
|
+
data-testid="admin-session-detail-error"
|
|
521
|
+
>
|
|
522
|
+
{error}
|
|
523
|
+
</div>
|
|
524
|
+
) : null}
|
|
525
|
+
{messages === null && error === null ? (
|
|
526
|
+
<p
|
|
527
|
+
className="data-club-ai-hub-admin__loading"
|
|
528
|
+
data-testid="admin-session-detail-loading"
|
|
529
|
+
>
|
|
530
|
+
{texts.sessionsOverviewDetailLoading}
|
|
531
|
+
</p>
|
|
532
|
+
) : null}
|
|
533
|
+
{messages !== null && messages.length === 0 ? (
|
|
534
|
+
<p
|
|
535
|
+
className="data-club-ai-hub-admin__empty"
|
|
536
|
+
data-testid="admin-session-detail-empty"
|
|
537
|
+
>
|
|
538
|
+
{texts.sessionsOverviewDetailEmpty}
|
|
539
|
+
</p>
|
|
540
|
+
) : null}
|
|
541
|
+
{messages !== null && messages.length > 0 ? (
|
|
542
|
+
<ol
|
|
543
|
+
className="data-club-ai-hub-admin__readonly-messages"
|
|
544
|
+
data-testid="admin-session-detail-messages"
|
|
545
|
+
>
|
|
546
|
+
{messages.map((m) => (
|
|
547
|
+
<li
|
|
548
|
+
key={m.id}
|
|
549
|
+
className={`data-club-ai-hub-admin__readonly-bubble data-club-ai-hub-admin__readonly-bubble--${m.role}`}
|
|
550
|
+
data-testid={`admin-session-detail-message-${m.id}`}
|
|
551
|
+
data-role={m.role}
|
|
552
|
+
>
|
|
553
|
+
<div className="data-club-ai-hub-admin__readonly-meta">
|
|
554
|
+
<strong>{m.role}</strong>
|
|
555
|
+
<span>{formatLastMessage(m.created_at)}</span>
|
|
556
|
+
</div>
|
|
557
|
+
<div className="data-club-ai-hub-admin__readonly-content">
|
|
558
|
+
{m.content}
|
|
559
|
+
</div>
|
|
560
|
+
{m.reasoning !== null && m.reasoning !== undefined && m.reasoning.length > 0 ? (
|
|
561
|
+
<ReasoningView content={m.reasoning} />
|
|
562
|
+
) : null}
|
|
563
|
+
{m.tool_calls && m.tool_calls.length > 0
|
|
564
|
+
? m.tool_calls.map((tc) => {
|
|
565
|
+
const statusValue: ToolCallStatus =
|
|
566
|
+
tc.status === "error" ? "error" : "done";
|
|
567
|
+
const props2: import("../ToolCallView/index.js").ToolCallViewProps =
|
|
568
|
+
{
|
|
569
|
+
toolName: tc.tool_name,
|
|
570
|
+
status: statusValue,
|
|
571
|
+
input: tc.input,
|
|
572
|
+
};
|
|
573
|
+
if (tc.output !== undefined && tc.output !== null) {
|
|
574
|
+
props2.output = tc.output;
|
|
575
|
+
}
|
|
576
|
+
if (tc.error !== undefined && tc.error !== null) {
|
|
577
|
+
props2.error = tc.error;
|
|
578
|
+
}
|
|
579
|
+
return <ToolCallView key={tc.tool_call_id} {...props2} />;
|
|
580
|
+
})
|
|
581
|
+
: null}
|
|
582
|
+
</li>
|
|
583
|
+
))}
|
|
584
|
+
</ol>
|
|
585
|
+
) : null}
|
|
586
|
+
|
|
587
|
+
{isSuperAdmin ? (
|
|
588
|
+
<footer
|
|
589
|
+
className="data-club-ai-hub-admin__detail-footer"
|
|
590
|
+
data-testid="admin-session-detail-footer"
|
|
591
|
+
>
|
|
592
|
+
<div
|
|
593
|
+
className="data-club-ai-hub-admin__detail-sandbox"
|
|
594
|
+
data-testid="admin-session-detail-sandbox"
|
|
595
|
+
>
|
|
596
|
+
<strong>{texts.sessionsOverviewDetailSandboxLabel}</strong>{" "}
|
|
597
|
+
<span data-testid="admin-session-detail-sandbox-state">
|
|
598
|
+
{hasSandbox
|
|
599
|
+
? texts.sessionsOverviewDetailSandboxPresent
|
|
600
|
+
: texts.sessionsOverviewDetailSandboxAbsent}
|
|
601
|
+
</span>
|
|
602
|
+
{hasSandbox ? (
|
|
603
|
+
<button
|
|
604
|
+
type="button"
|
|
605
|
+
className="data-club-ai-hub-admin__button"
|
|
606
|
+
data-testid="admin-session-detail-purge-sandbox"
|
|
607
|
+
onClick={() => {
|
|
608
|
+
void handlePurgeSandbox();
|
|
609
|
+
}}
|
|
610
|
+
disabled={purging}
|
|
611
|
+
>
|
|
612
|
+
{purging
|
|
613
|
+
? texts.sessionsOverviewPurgeSandboxConfirming
|
|
614
|
+
: texts.sessionsOverviewPurgeSandboxButton}
|
|
615
|
+
</button>
|
|
616
|
+
) : null}
|
|
617
|
+
</div>
|
|
618
|
+
{purgeError !== null ? (
|
|
619
|
+
<div
|
|
620
|
+
className="data-club-ai-hub-admin__error"
|
|
621
|
+
role="alert"
|
|
622
|
+
data-testid="admin-session-detail-purge-error"
|
|
623
|
+
>
|
|
624
|
+
{purgeError}
|
|
625
|
+
</div>
|
|
626
|
+
) : null}
|
|
627
|
+
{purgeFlash !== null ? (
|
|
628
|
+
<div
|
|
629
|
+
className="data-club-ai-hub-admin__flash"
|
|
630
|
+
data-testid="admin-session-detail-purge-flash"
|
|
631
|
+
>
|
|
632
|
+
{purgeFlash}
|
|
633
|
+
</div>
|
|
634
|
+
) : null}
|
|
635
|
+
</footer>
|
|
636
|
+
) : null}
|
|
637
|
+
</div>
|
|
638
|
+
);
|
|
639
|
+
}
|