@bevel-software/platform-core-frontend 0.15.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/package.json +3 -3
- package/src/core/CoreAppShell.tsx +20 -9
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +11 -3
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/email.ts +37 -1
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +140 -6
- package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
- package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
- package/src/modules/admin/components/AddMemberInput.tsx +268 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/audit/__tests__/AuditLogPage.test.tsx +312 -0
- package/src/modules/audit/components/AuditEventsPanel.tsx +319 -0
- package/src/modules/audit/components/AuditLogPage.tsx +373 -0
- package/src/modules/audit/components/principal-grouping.ts +49 -0
- package/src/modules/audit/services/audit.api.ts +98 -0
- package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
- package/src/modules/auth/components/AccountPage.tsx +73 -54
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/auth/services/account.api.ts +78 -4
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
- package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
- package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
- package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
- package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
- package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
- package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
- package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
- package/src/modules/change-requests/services/change-requests.api.ts +57 -1
- package/src/modules/change-requests/services/denied-file.api.ts +53 -0
- package/src/modules/change-requests/services/propose.api.ts +97 -8
- package/src/modules/change-requests/utils/approval.ts +15 -0
- package/src/modules/change-requests/utils/author.ts +32 -0
- package/src/modules/change-requests/utils/readFailure.ts +110 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +108 -3
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
- package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +47 -4
- package/src/modules/library/__tests__/link-membership.test.ts +13 -4
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +146 -45
- package/src/modules/library/components/LibraryLayout.tsx +119 -256
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
- package/src/modules/library/components/LockedPluginView.tsx +62 -34
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +16 -2
- package/src/modules/library/components/PageActions.tsx +11 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
- package/src/modules/library/components/PluginExtras.tsx +140 -17
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +157 -41
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +239 -263
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +141 -28
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +103 -17
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
- package/src/modules/library/routes/library-paths.ts +26 -28
- package/src/modules/library/services/library.api.ts +38 -20
- package/src/modules/library/services/plugins.api.ts +69 -8
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +170 -32
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +75 -9
- package/src/modules/library/utils/status.ts +135 -33
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +10 -30
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +7 -6
- package/src/modules/settings/services/github-facade.api.ts +23 -0
- package/src/modules/settings/settings-nav-items.tsx +13 -3
- package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
- package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
- package/src/modules/setup/__tests__/setup.test.tsx +497 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +532 -43
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +141 -4
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
- package/src/modules/setup/utils/root-folders.ts +46 -0
- package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
- package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
- package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
- package/src/modules/workspace/components/FileRoute.tsx +353 -36
- package/src/modules/workspace/components/FileViewer.tsx +172 -46
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
- package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
- package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2533 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +381 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +206 -29
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +134 -1
- package/src/modules/workspace/services/workspace.api.ts +57 -4
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
- package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
- package/src/modules/workspace/state/open-change-requests.tsx +100 -12
- package/src/modules/workspace/state/workspace.context.ts +125 -19
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +112 -36
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +6 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +33 -5
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +25 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
5
|
+
import { AuditLogPage } from '../components/AuditLogPage';
|
|
6
|
+
import { groupByAccount } from '../components/principal-grouping';
|
|
7
|
+
import { AdminContext } from '../../admin/state/admin.context';
|
|
8
|
+
import { AuthContext } from '../../auth/state/auth.context';
|
|
9
|
+
import {
|
|
10
|
+
listPrincipals,
|
|
11
|
+
listEvents,
|
|
12
|
+
revokeAgent,
|
|
13
|
+
revokeKey,
|
|
14
|
+
type AgentEvent,
|
|
15
|
+
type AuditPrincipal,
|
|
16
|
+
} from '../services/audit.api';
|
|
17
|
+
|
|
18
|
+
vi.mock('../services/audit.api', () => ({
|
|
19
|
+
listPrincipals: vi.fn(),
|
|
20
|
+
listEvents: vi.fn(),
|
|
21
|
+
revokeAgent: vi.fn(),
|
|
22
|
+
revokeKey: vi.fn(),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const ALICE = { id: 'u-alice', email: 'alice@example.com', name: 'Alice' };
|
|
26
|
+
const BOB = { id: 'u-bob', email: 'bob@example.com', name: 'Bob' };
|
|
27
|
+
|
|
28
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
29
|
+
const NOW = Date.now();
|
|
30
|
+
|
|
31
|
+
const ALICE_CLAUDE: AuditPrincipal = {
|
|
32
|
+
kind: 'agent',
|
|
33
|
+
id: 'c-claude',
|
|
34
|
+
label: 'Claude',
|
|
35
|
+
createdAt: NOW - 12 * DAY,
|
|
36
|
+
lastUsedAt: NOW - 4 * 60 * 1000,
|
|
37
|
+
revokedAt: null,
|
|
38
|
+
revokedBy: null,
|
|
39
|
+
eventCount: 3,
|
|
40
|
+
user: ALICE,
|
|
41
|
+
};
|
|
42
|
+
const ALICE_CI: AuditPrincipal = {
|
|
43
|
+
kind: 'key',
|
|
44
|
+
id: 'k-ci',
|
|
45
|
+
label: 'CI pipeline',
|
|
46
|
+
keyKind: 'key',
|
|
47
|
+
createdAt: NOW - 10 * DAY,
|
|
48
|
+
lastUsedAt: NOW - 2 * 60 * 60 * 1000,
|
|
49
|
+
revokedAt: null,
|
|
50
|
+
revokedBy: null,
|
|
51
|
+
eventCount: 0,
|
|
52
|
+
user: ALICE,
|
|
53
|
+
};
|
|
54
|
+
const BOB_OLD: AuditPrincipal = {
|
|
55
|
+
kind: 'key',
|
|
56
|
+
id: 'k-old',
|
|
57
|
+
label: 'Old script',
|
|
58
|
+
keyKind: 'key',
|
|
59
|
+
createdAt: NOW - 40 * DAY,
|
|
60
|
+
lastUsedAt: NOW - 30 * DAY,
|
|
61
|
+
revokedAt: NOW - 20 * DAY,
|
|
62
|
+
revokedBy: 'admin',
|
|
63
|
+
eventCount: 18,
|
|
64
|
+
user: BOB,
|
|
65
|
+
};
|
|
66
|
+
const BOB_LINK: AuditPrincipal = {
|
|
67
|
+
kind: 'key',
|
|
68
|
+
id: 'k-link',
|
|
69
|
+
label: 'Claude',
|
|
70
|
+
keyKind: 'github-link',
|
|
71
|
+
createdAt: NOW - DAY,
|
|
72
|
+
lastUsedAt: NOW - 60 * 1000,
|
|
73
|
+
revokedAt: null,
|
|
74
|
+
revokedBy: null,
|
|
75
|
+
eventCount: 63,
|
|
76
|
+
user: BOB,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const EVENTS: AgentEvent[] = [
|
|
80
|
+
{ id: 'e1', kind: 'capability', manual: null, name: 'grep', outcome: 'ok', at: NOW - 1000 },
|
|
81
|
+
{ id: 'e2', kind: 'tool', manual: 'notion', name: 'notion-search', outcome: 'error', at: NOW - 2000 },
|
|
82
|
+
{ id: 'e3', kind: 'skill', manual: 'Plugins/Sales/rfi', name: 'rfi', outcome: 'ok', at: NOW - 3000 },
|
|
83
|
+
{ id: 'e4', kind: 'tool', manual: 'slack', name: 'post_message', outcome: 'denied', at: NOW - 4000 },
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
function renderPage(opts: { isAdmin?: boolean; me?: typeof ALICE } = {}) {
|
|
87
|
+
const me = opts.me ?? ALICE;
|
|
88
|
+
return render(
|
|
89
|
+
<MemoryRouter>
|
|
90
|
+
<AuthContext.Provider
|
|
91
|
+
value={{
|
|
92
|
+
user: { id: me.id, email: me.email, name: me.name },
|
|
93
|
+
token: 'jwt',
|
|
94
|
+
isLoading: false,
|
|
95
|
+
login: async () => {},
|
|
96
|
+
logout: () => {},
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<AdminContext.Provider
|
|
100
|
+
value={{
|
|
101
|
+
isAdmin: opts.isAdmin ?? false,
|
|
102
|
+
isAdminLoading: false,
|
|
103
|
+
unreadCount: 0,
|
|
104
|
+
lastSeen: null,
|
|
105
|
+
markSeen: () => {},
|
|
106
|
+
refresh: () => {},
|
|
107
|
+
rolesConfigCorrupted: false,
|
|
108
|
+
rolesConfigErrors: [],
|
|
109
|
+
runRolesRecovery: async () => {},
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
<AuditLogPage />
|
|
113
|
+
</AdminContext.Provider>
|
|
114
|
+
</AuthContext.Provider>
|
|
115
|
+
</MemoryRouter>,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
beforeEach(() => {
|
|
120
|
+
vi.mocked(listPrincipals).mockReset().mockResolvedValue([ALICE_CLAUDE, ALICE_CI, BOB_LINK, BOB_OLD]);
|
|
121
|
+
vi.mocked(listEvents).mockReset().mockResolvedValue({ events: EVENTS, total: 4, nextCursor: null });
|
|
122
|
+
vi.mocked(revokeAgent).mockReset().mockResolvedValue(undefined);
|
|
123
|
+
vi.mocked(revokeKey).mockReset().mockResolvedValue(undefined);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('groupByAccount', () => {
|
|
127
|
+
it('groups in server order and drops revoked rows (and accounts left empty) when they are hidden', () => {
|
|
128
|
+
const groups = groupByAccount([ALICE_CLAUDE, ALICE_CI, BOB_OLD], { includeRevoked: false });
|
|
129
|
+
expect(groups.map((g) => g.user.id)).toEqual(['u-alice']);
|
|
130
|
+
expect(groups[0].principals.map((p) => p.id)).toEqual(['c-claude', 'k-ci']);
|
|
131
|
+
expect(groupByAccount([ALICE_CLAUDE, BOB_OLD], { includeRevoked: true }).map((g) => g.user.id)).toEqual(['u-alice', 'u-bob']);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('narrows by person or by row label', () => {
|
|
135
|
+
const all = [ALICE_CLAUDE, ALICE_CI, BOB_LINK];
|
|
136
|
+
expect(groupByAccount(all, { includeRevoked: true, query: 'bob' }).map((g) => g.user.id)).toEqual(['u-bob']);
|
|
137
|
+
const byLabel = groupByAccount(all, { includeRevoked: true, query: 'CI' });
|
|
138
|
+
expect(byLabel).toHaveLength(1);
|
|
139
|
+
expect(byLabel[0].principals.map((p) => p.id)).toEqual(['k-ci']);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('AuditLogPage', () => {
|
|
144
|
+
it("asks for the member's own rows and lists them without account headers", async () => {
|
|
145
|
+
vi.mocked(listPrincipals).mockResolvedValue([ALICE_CLAUDE, ALICE_CI]);
|
|
146
|
+
renderPage({ isAdmin: false });
|
|
147
|
+
await waitFor(() => expect(screen.getByText('CI pipeline')).toBeInTheDocument());
|
|
148
|
+
|
|
149
|
+
expect(listPrincipals).toHaveBeenCalledWith('me');
|
|
150
|
+
expect(screen.getByText('Claude')).toBeInTheDocument();
|
|
151
|
+
expect(screen.getByText('Agent · OAuth')).toBeInTheDocument();
|
|
152
|
+
expect(screen.getByText('Connection key')).toBeInTheDocument();
|
|
153
|
+
expect(screen.getByText(/Connected 1w ago/)).toBeInTheDocument();
|
|
154
|
+
expect(screen.getByText(/3 events/)).toBeInTheDocument();
|
|
155
|
+
expect(screen.getByText(/No events yet/)).toBeInTheDocument();
|
|
156
|
+
// A member sees no per-account header: the page is theirs alone.
|
|
157
|
+
expect(screen.queryByText('alice@example.com')).not.toBeInTheDocument();
|
|
158
|
+
expect(screen.getByText(/2 live/)).toBeInTheDocument();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('asks for every account for an admin, grouped per person, hiding revoked rows by default', async () => {
|
|
162
|
+
renderPage({ isAdmin: true });
|
|
163
|
+
await waitFor(() => expect(screen.getByText('CI pipeline')).toBeInTheDocument());
|
|
164
|
+
|
|
165
|
+
expect(listPrincipals).toHaveBeenCalledWith('all');
|
|
166
|
+
const alice = screen.getByRole('region', { name: 'Agents and keys for alice@example.com' });
|
|
167
|
+
expect(within(alice).getByText('Alice')).toBeInTheDocument();
|
|
168
|
+
expect(within(alice).getByText('CI pipeline')).toBeInTheDocument();
|
|
169
|
+
const bob = screen.getByRole('region', { name: 'Agents and keys for bob@example.com' });
|
|
170
|
+
expect(within(bob).getByText('Claude link')).toBeInTheDocument();
|
|
171
|
+
expect(within(bob).queryByText('Old script')).not.toBeInTheDocument();
|
|
172
|
+
expect(screen.getByText(/2 accounts · 3 live · 1 revoked/)).toBeInTheDocument();
|
|
173
|
+
|
|
174
|
+
await userEvent.click(screen.getByRole('checkbox', { name: 'Show revoked' }));
|
|
175
|
+
expect(within(bob).getByText('Old script')).toBeInTheDocument();
|
|
176
|
+
expect(within(bob).getByText('Revoked by an admin')).toBeInTheDocument();
|
|
177
|
+
expect(screen.queryByRole('button', { name: /Revoke key for Old script/ })).not.toBeInTheDocument();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('shows an admin a key its owner deleted for good, marked as such, with its history intact', async () => {
|
|
181
|
+
vi.mocked(listPrincipals).mockResolvedValue([{ ...BOB_OLD, deletedAt: NOW - 10 * DAY, eventCount: 18 }]);
|
|
182
|
+
renderPage({ isAdmin: true });
|
|
183
|
+
await waitFor(() => expect(screen.getByText(/1 revoked/)).toBeInTheDocument());
|
|
184
|
+
await userEvent.click(screen.getByRole('checkbox', { name: 'Show revoked' }));
|
|
185
|
+
expect(screen.getByText('Old script')).toBeInTheDocument();
|
|
186
|
+
expect(screen.getByText('Deleted by owner')).toBeInTheDocument();
|
|
187
|
+
expect(screen.getByText(/18 events/)).toBeInTheDocument();
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('expands a row to its events once, keeps them across a collapse, and filters them', async () => {
|
|
191
|
+
vi.mocked(listPrincipals).mockResolvedValue([ALICE_CLAUDE]);
|
|
192
|
+
renderPage();
|
|
193
|
+
const row = await screen.findByRole('button', { name: /Claude/, expanded: false });
|
|
194
|
+
|
|
195
|
+
await userEvent.click(row);
|
|
196
|
+
await waitFor(() => expect(screen.getByText('grep')).toBeInTheDocument());
|
|
197
|
+
expect(listEvents).toHaveBeenCalledWith('agent', 'c-claude', { limit: 50 });
|
|
198
|
+
expect(row).toHaveAttribute('aria-expanded', 'true');
|
|
199
|
+
|
|
200
|
+
// Skills and tools link to their pages; a capability is plain text.
|
|
201
|
+
expect(screen.getByRole('link', { name: 'rfi' })).toHaveAttribute('href', '/skills-and-tools/skills/rfi');
|
|
202
|
+
expect(screen.getByRole('link', { name: /notion-search/ })).toHaveAttribute('href', '/skills-and-tools/tools/notion');
|
|
203
|
+
expect(screen.queryByRole('link', { name: 'grep' })).not.toBeInTheDocument();
|
|
204
|
+
expect(screen.getByText('needs sign-in')).toBeInTheDocument();
|
|
205
|
+
expect(screen.getByText(/Showing 4 of 4 events/)).toBeInTheDocument();
|
|
206
|
+
|
|
207
|
+
// Errors only: the ok rows go, the error and the denied one stay.
|
|
208
|
+
await userEvent.click(screen.getByRole('checkbox', { name: 'Errors only' }));
|
|
209
|
+
expect(screen.queryByText('grep')).not.toBeInTheDocument();
|
|
210
|
+
expect(screen.getByRole('link', { name: /notion-search/ })).toBeInTheDocument();
|
|
211
|
+
expect(screen.getByRole('link', { name: /post_message/ })).toBeInTheDocument();
|
|
212
|
+
await userEvent.click(screen.getByRole('checkbox', { name: 'Errors only' }));
|
|
213
|
+
|
|
214
|
+
// Type chips narrow to one kind.
|
|
215
|
+
await userEvent.click(screen.getByRole('button', { name: 'Skill', pressed: false }));
|
|
216
|
+
expect(screen.getByRole('link', { name: 'rfi' })).toBeInTheDocument();
|
|
217
|
+
expect(screen.queryByText('grep')).not.toBeInTheDocument();
|
|
218
|
+
|
|
219
|
+
// Collapse and re-expand: no second request.
|
|
220
|
+
await userEvent.click(row);
|
|
221
|
+
expect(row).toHaveAttribute('aria-expanded', 'false');
|
|
222
|
+
await userEvent.click(row);
|
|
223
|
+
expect(row).toHaveAttribute('aria-expanded', 'true');
|
|
224
|
+
expect(listEvents).toHaveBeenCalledTimes(1);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('offers to try again when the first load fails, and names its panel only once it exists', async () => {
|
|
228
|
+
vi.mocked(listPrincipals).mockResolvedValue([ALICE_CLAUDE]);
|
|
229
|
+
vi.mocked(listEvents)
|
|
230
|
+
.mockRejectedValueOnce(new Error('Could not load events'))
|
|
231
|
+
.mockResolvedValueOnce({ events: EVENTS, total: 4, nextCursor: null });
|
|
232
|
+
renderPage();
|
|
233
|
+
const row = await screen.findByRole('button', { name: /Claude/, expanded: false });
|
|
234
|
+
// Nothing to control yet: the panel is mounted on the first open.
|
|
235
|
+
expect(row).not.toHaveAttribute('aria-controls');
|
|
236
|
+
|
|
237
|
+
await userEvent.click(row);
|
|
238
|
+
expect(row).toHaveAttribute('aria-controls', expect.stringContaining('c-claude'));
|
|
239
|
+
await waitFor(() => expect(screen.getByRole('alert')).toHaveTextContent('Could not load events'));
|
|
240
|
+
|
|
241
|
+
// A collapse keeps the panel, so the failure would otherwise be permanent.
|
|
242
|
+
await userEvent.click(row);
|
|
243
|
+
await userEvent.click(row);
|
|
244
|
+
await userEvent.click(screen.getByRole('button', { name: 'Try again' }));
|
|
245
|
+
await waitFor(() => expect(screen.getByText('grep')).toBeInTheDocument());
|
|
246
|
+
expect(listEvents).toHaveBeenCalledTimes(2);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('loads older events through the cursor', async () => {
|
|
250
|
+
vi.mocked(listPrincipals).mockResolvedValue([ALICE_CLAUDE]);
|
|
251
|
+
vi.mocked(listEvents)
|
|
252
|
+
.mockResolvedValueOnce({ events: EVENTS.slice(0, 2), total: 4, nextCursor: 'cur-2' })
|
|
253
|
+
.mockResolvedValueOnce({ events: EVENTS.slice(2), total: 4, nextCursor: null });
|
|
254
|
+
renderPage();
|
|
255
|
+
await userEvent.click(await screen.findByRole('button', { name: /Claude/, expanded: false }));
|
|
256
|
+
await waitFor(() => expect(screen.getByText(/Showing 2 of 4 events/)).toBeInTheDocument());
|
|
257
|
+
|
|
258
|
+
await userEvent.click(screen.getByRole('button', { name: 'Load older events' }));
|
|
259
|
+
await waitFor(() => expect(screen.getByText(/Showing 4 of 4 events/)).toBeInTheDocument());
|
|
260
|
+
expect(listEvents).toHaveBeenLastCalledWith('agent', 'c-claude', { before: 'cur-2', limit: 50 });
|
|
261
|
+
expect(screen.queryByRole('button', { name: 'Load older events' })).not.toBeInTheDocument();
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('revokes an agent after confirmation and marks the row at once', async () => {
|
|
265
|
+
vi.mocked(listPrincipals).mockResolvedValue([ALICE_CLAUDE]);
|
|
266
|
+
renderPage();
|
|
267
|
+
await userEvent.click(await screen.findByRole('button', { name: 'Revoke access for Claude (alice@example.com)' }));
|
|
268
|
+
|
|
269
|
+
const dialog = screen.getByRole('dialog');
|
|
270
|
+
expect(within(dialog).getByText(/Every token it holds stops working now/)).toBeInTheDocument();
|
|
271
|
+
// The reload after the revoke sees the server's view of it.
|
|
272
|
+
vi.mocked(listPrincipals).mockResolvedValue([{ ...ALICE_CLAUDE, revokedAt: NOW, revokedBy: 'owner' }]);
|
|
273
|
+
await userEvent.click(within(dialog).getByRole('button', { name: 'Revoke access' }));
|
|
274
|
+
|
|
275
|
+
await waitFor(() => expect(revokeAgent).toHaveBeenCalledWith('c-claude'));
|
|
276
|
+
expect(revokeKey).not.toHaveBeenCalled();
|
|
277
|
+
// Revoked rows hide by default; the toggle now offers them.
|
|
278
|
+
await userEvent.click(await screen.findByRole('checkbox', { name: 'Show revoked' }));
|
|
279
|
+
expect(screen.getByText('Disconnected by owner')).toBeInTheDocument();
|
|
280
|
+
expect(screen.queryByRole('button', { name: /Revoke access for Claude/ })).not.toBeInTheDocument();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it("revokes someone else's key as an admin, marked as an admin's doing", async () => {
|
|
284
|
+
vi.mocked(listPrincipals).mockResolvedValue([BOB_LINK]);
|
|
285
|
+
renderPage({ isAdmin: true });
|
|
286
|
+
await userEvent.click(await screen.findByRole('button', { name: 'Revoke key for Claude (bob@example.com)' }));
|
|
287
|
+
vi.mocked(listPrincipals).mockResolvedValue([{ ...BOB_LINK, revokedAt: NOW, revokedBy: 'admin' }]);
|
|
288
|
+
await userEvent.click(within(screen.getByRole('dialog')).getByRole('button', { name: 'Revoke key' }));
|
|
289
|
+
|
|
290
|
+
await waitFor(() => expect(revokeKey).toHaveBeenCalledWith('k-link'));
|
|
291
|
+
await userEvent.click(await screen.findByRole('checkbox', { name: 'Show revoked' }));
|
|
292
|
+
expect(screen.getByText('Revoked by an admin')).toBeInTheDocument();
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('keeps the rows and shows the error when a revoke fails', async () => {
|
|
296
|
+
vi.mocked(listPrincipals).mockResolvedValue([ALICE_CI]);
|
|
297
|
+
vi.mocked(revokeKey).mockRejectedValue(new Error('Could not revoke this key'));
|
|
298
|
+
renderPage();
|
|
299
|
+
await userEvent.click(await screen.findByRole('button', { name: 'Revoke key for CI pipeline (alice@example.com)' }));
|
|
300
|
+
await userEvent.click(within(screen.getByRole('dialog')).getByRole('button', { name: 'Revoke key' }));
|
|
301
|
+
|
|
302
|
+
await waitFor(() => expect(screen.getByRole('alert')).toHaveTextContent('Could not revoke this key'));
|
|
303
|
+
expect(screen.getByRole('button', { name: 'Revoke key for CI pipeline (alice@example.com)' })).toBeInTheDocument();
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('shows the load error instead of an empty log when the list cannot be fetched', async () => {
|
|
307
|
+
vi.mocked(listPrincipals).mockRejectedValue(new Error('Could not load the audit log'));
|
|
308
|
+
renderPage();
|
|
309
|
+
await waitFor(() => expect(screen.getByRole('alert')).toHaveTextContent('Could not load the audit log'));
|
|
310
|
+
expect(screen.queryByText(/Nothing connected/)).not.toBeInTheDocument();
|
|
311
|
+
});
|
|
312
|
+
});
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { Fragment, useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
import { Badge, Banner, Button } from '../../../shared/components';
|
|
4
|
+
import { cn } from '../../../lib/utils';
|
|
5
|
+
import { pathForSkill, pathForTool } from '../../library/routes/library-paths';
|
|
6
|
+
import {
|
|
7
|
+
listEvents,
|
|
8
|
+
type AgentEvent,
|
|
9
|
+
type AgentEventKind,
|
|
10
|
+
type AgentEventOutcome,
|
|
11
|
+
type AuditPrincipalKind,
|
|
12
|
+
} from '../services/audit.api';
|
|
13
|
+
|
|
14
|
+
/** How many events one load brings; "Load older events" fetches the next batch. */
|
|
15
|
+
const PAGE_SIZE = 50;
|
|
16
|
+
|
|
17
|
+
const KIND_LABEL: Record<AgentEventKind, string> = {
|
|
18
|
+
capability: 'Hexis capability',
|
|
19
|
+
tool: 'Tool',
|
|
20
|
+
skill: 'Skill',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** A small square per kind — a category mark, not a status (statuses are the outcome badge). */
|
|
24
|
+
const KIND_MARK: Record<AgentEventKind, string> = {
|
|
25
|
+
capability: 'bg-accent',
|
|
26
|
+
tool: 'bg-ink-faint',
|
|
27
|
+
skill: 'bg-ok',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const OUTCOME: Record<AgentEventOutcome, { tone: 'ok' | 'danger' | 'wait'; label: string }> = {
|
|
31
|
+
ok: { tone: 'ok', label: 'ok' },
|
|
32
|
+
error: { tone: 'danger', label: 'error' },
|
|
33
|
+
denied: { tone: 'wait', label: 'needs sign-in' },
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type TypeFilter = 'all' | AgentEventKind;
|
|
37
|
+
|
|
38
|
+
const TYPE_FILTERS: { id: TypeFilter; label: string }[] = [
|
|
39
|
+
{ id: 'all', label: 'All' },
|
|
40
|
+
{ id: 'capability', label: KIND_LABEL.capability },
|
|
41
|
+
{ id: 'tool', label: KIND_LABEL.tool },
|
|
42
|
+
{ id: 'skill', label: KIND_LABEL.skill },
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
function timeOf(at: number): string {
|
|
46
|
+
return new Date(at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** "Today", "Yesterday", or the date — the day separator's label. */
|
|
50
|
+
function dayLabel(at: number, now: number): string {
|
|
51
|
+
const day = new Date(at);
|
|
52
|
+
const today = new Date(now);
|
|
53
|
+
const yesterday = new Date(now - 24 * 60 * 60 * 1000);
|
|
54
|
+
const date = day.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
|
|
55
|
+
if (day.toDateString() === today.toDateString()) return `Today · ${date}`;
|
|
56
|
+
if (day.toDateString() === yesterday.toDateString()) return `Yesterday · ${date}`;
|
|
57
|
+
return date;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The "What was called" cell. A skill shows just its name and opens the
|
|
62
|
+
* skill's page; a tool shows `server · tool` and opens that manual's page —
|
|
63
|
+
* both through the name-based library routes, so no catalog is needed here.
|
|
64
|
+
* A hexis capability is plain text: it has no page of its own.
|
|
65
|
+
*/
|
|
66
|
+
function WhatWasCalled({ event }: { event: AgentEvent }) {
|
|
67
|
+
const link = 'border-b border-line-strong hover:border-accent hover:text-accent';
|
|
68
|
+
if (event.kind === 'skill') {
|
|
69
|
+
return (
|
|
70
|
+
<Link to={pathForSkill(event.name)} className={link} title={`Open the ${event.name} skill`}>
|
|
71
|
+
{event.name}
|
|
72
|
+
</Link>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
if (event.kind === 'tool' && event.manual) {
|
|
76
|
+
return (
|
|
77
|
+
<Link to={pathForTool(event.manual)} className={link} title={`Open the ${event.manual} tool page`}>
|
|
78
|
+
<span className="text-ink-muted">{event.manual}</span>
|
|
79
|
+
<span className="text-ink-faint"> · </span>
|
|
80
|
+
{event.name}
|
|
81
|
+
</Link>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return <>{event.name}</>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* One principal's events, rendered under its row in the Audit log: filters
|
|
89
|
+
* over what has been loaded, the day-grouped table, and the way to older
|
|
90
|
+
* pages. Loads on mount — the page mounts it on the row's first expand and
|
|
91
|
+
* keeps it, so collapsing and re-expanding costs no request.
|
|
92
|
+
*/
|
|
93
|
+
export function AuditEventsPanel({
|
|
94
|
+
kind,
|
|
95
|
+
id,
|
|
96
|
+
label,
|
|
97
|
+
}: {
|
|
98
|
+
kind: AuditPrincipalKind;
|
|
99
|
+
id: string;
|
|
100
|
+
/** The row's label, for the accessible names of the controls in here. */
|
|
101
|
+
label: string;
|
|
102
|
+
}) {
|
|
103
|
+
const searchId = useId();
|
|
104
|
+
const [events, setEvents] = useState<AgentEvent[] | null>(null);
|
|
105
|
+
const [total, setTotal] = useState(0);
|
|
106
|
+
const [nextCursor, setNextCursor] = useState<string | null>(null);
|
|
107
|
+
const [error, setError] = useState<string | null>(null);
|
|
108
|
+
const [loadingMore, setLoadingMore] = useState(false);
|
|
109
|
+
const [typeFilter, setTypeFilter] = useState<TypeFilter>('all');
|
|
110
|
+
const [errorsOnly, setErrorsOnly] = useState(false);
|
|
111
|
+
const [query, setQuery] = useState('');
|
|
112
|
+
// "Today" and "Yesterday" are decided against the moment the panel opened —
|
|
113
|
+
// read once, so a re-render never shifts a separator on its own.
|
|
114
|
+
const [now] = useState(() => Date.now());
|
|
115
|
+
|
|
116
|
+
// Generation of the newest first-page load: a "Try again" pressed while an
|
|
117
|
+
// earlier attempt is still out must not let that attempt land afterwards.
|
|
118
|
+
const loadGen = useRef(0);
|
|
119
|
+
const loadFirstPage = useCallback(() => {
|
|
120
|
+
const gen = ++loadGen.current;
|
|
121
|
+
listEvents(kind, id, { limit: PAGE_SIZE })
|
|
122
|
+
.then((page) => {
|
|
123
|
+
if (gen !== loadGen.current) return;
|
|
124
|
+
setEvents(page.events);
|
|
125
|
+
setTotal(page.total ?? 0);
|
|
126
|
+
setNextCursor(page.nextCursor);
|
|
127
|
+
setError(null);
|
|
128
|
+
})
|
|
129
|
+
.catch((err) => {
|
|
130
|
+
if (gen !== loadGen.current) return;
|
|
131
|
+
setError(err instanceof Error ? err.message : "Couldn't load events.");
|
|
132
|
+
});
|
|
133
|
+
}, [kind, id]);
|
|
134
|
+
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
loadFirstPage();
|
|
137
|
+
return () => {
|
|
138
|
+
// Unmounting retires every attempt in flight.
|
|
139
|
+
loadGen.current += 1;
|
|
140
|
+
};
|
|
141
|
+
}, [loadFirstPage]);
|
|
142
|
+
|
|
143
|
+
const loadOlder = useCallback(async () => {
|
|
144
|
+
if (!nextCursor || loadingMore) return;
|
|
145
|
+
setLoadingMore(true);
|
|
146
|
+
try {
|
|
147
|
+
const page = await listEvents(kind, id, { before: nextCursor, limit: PAGE_SIZE });
|
|
148
|
+
setEvents((prev) => [...(prev ?? []), ...page.events]);
|
|
149
|
+
// A cursor page carries no total: the first page's stands.
|
|
150
|
+
if (page.total !== null) setTotal(page.total);
|
|
151
|
+
setNextCursor(page.nextCursor);
|
|
152
|
+
setError(null);
|
|
153
|
+
} catch (err) {
|
|
154
|
+
setError(err instanceof Error ? err.message : "Couldn't load older events.");
|
|
155
|
+
} finally {
|
|
156
|
+
setLoadingMore(false);
|
|
157
|
+
}
|
|
158
|
+
}, [kind, id, nextCursor, loadingMore]);
|
|
159
|
+
|
|
160
|
+
const q = query.trim().toLowerCase();
|
|
161
|
+
const visible = useMemo(
|
|
162
|
+
() =>
|
|
163
|
+
(events ?? []).filter(
|
|
164
|
+
(e) =>
|
|
165
|
+
(typeFilter === 'all' || e.kind === typeFilter) &&
|
|
166
|
+
(!errorsOnly || e.outcome !== 'ok') &&
|
|
167
|
+
(!q || e.name.toLowerCase().includes(q) || (e.manual ?? '').toLowerCase().includes(q)),
|
|
168
|
+
),
|
|
169
|
+
[events, typeFilter, errorsOnly, q],
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
// Day separators are derived at render: a separator before the first event
|
|
173
|
+
// of each day, in the (newest-first) order the rows already have.
|
|
174
|
+
const rows: Array<{ day: string } | { event: AgentEvent }> = [];
|
|
175
|
+
let lastDay: string | null = null;
|
|
176
|
+
for (const event of visible) {
|
|
177
|
+
const day = dayLabel(event.at, now);
|
|
178
|
+
if (day !== lastDay) {
|
|
179
|
+
rows.push({ day });
|
|
180
|
+
lastDay = day;
|
|
181
|
+
}
|
|
182
|
+
rows.push({ event });
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (error && events === null) {
|
|
186
|
+
// The panel stays mounted across a collapse, so without a way to re-ask
|
|
187
|
+
// a failed first load would be this row's permanent state.
|
|
188
|
+
return (
|
|
189
|
+
<Banner tone="danger" role="alert" className="text-detail">
|
|
190
|
+
{error}
|
|
191
|
+
<Button variant="outline" size="sm" className="ml-3" onClick={loadFirstPage}>
|
|
192
|
+
Try again
|
|
193
|
+
</Button>
|
|
194
|
+
</Banner>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
if (events === null) return <div className="text-xs text-ink-muted">Loading…</div>;
|
|
198
|
+
if (events.length === 0) {
|
|
199
|
+
return (
|
|
200
|
+
<div className="text-detail text-ink-muted text-center py-3">
|
|
201
|
+
Nothing called yet. Events appear here the first time this {kind === 'agent' ? 'agent' : 'key'} uses a
|
|
202
|
+
tool, a skill, or a Hexis capability.
|
|
203
|
+
</div>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<div className="space-y-2">
|
|
209
|
+
<div className="flex flex-wrap items-center justify-between gap-x-3 gap-y-2 text-detail text-ink-muted">
|
|
210
|
+
<div className="flex flex-wrap gap-1" role="group" aria-label={`Filter ${label}'s events by type`}>
|
|
211
|
+
{TYPE_FILTERS.map((f) => (
|
|
212
|
+
<button
|
|
213
|
+
key={f.id}
|
|
214
|
+
type="button"
|
|
215
|
+
aria-pressed={typeFilter === f.id}
|
|
216
|
+
onClick={() => setTypeFilter(f.id)}
|
|
217
|
+
className={cn(
|
|
218
|
+
'inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-meta',
|
|
219
|
+
typeFilter === f.id
|
|
220
|
+
? 'border-line bg-white text-ink shadow-card'
|
|
221
|
+
: 'border-transparent text-ink-muted hover:bg-hover hover:text-ink',
|
|
222
|
+
)}
|
|
223
|
+
>
|
|
224
|
+
{f.id !== 'all' && <span aria-hidden className={cn('size-2 rounded-[2px]', KIND_MARK[f.id])} />}
|
|
225
|
+
{f.label}
|
|
226
|
+
</button>
|
|
227
|
+
))}
|
|
228
|
+
</div>
|
|
229
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
230
|
+
<label className="flex items-center gap-1.5 cursor-pointer select-none">
|
|
231
|
+
<input type="checkbox" checked={errorsOnly} onChange={(e) => setErrorsOnly(e.target.checked)} />
|
|
232
|
+
Errors only
|
|
233
|
+
</label>
|
|
234
|
+
<input
|
|
235
|
+
id={searchId}
|
|
236
|
+
value={query}
|
|
237
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
238
|
+
placeholder="Filter by name"
|
|
239
|
+
aria-label={`Filter ${label}'s events by name`}
|
|
240
|
+
className="bg-white border border-line rounded-sm px-2 py-1 text-detail text-ink focus:outline-none focus:border-accent min-w-[180px]"
|
|
241
|
+
/>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
{error && (
|
|
246
|
+
<Banner tone="danger" role="alert" className="text-detail">
|
|
247
|
+
{error}
|
|
248
|
+
</Banner>
|
|
249
|
+
)}
|
|
250
|
+
|
|
251
|
+
<div className="bg-white border border-line rounded-sm overflow-hidden">
|
|
252
|
+
<div className="overflow-x-auto">
|
|
253
|
+
<table className="w-full min-w-[560px] border-collapse text-detail">
|
|
254
|
+
<thead>
|
|
255
|
+
<tr className="text-label uppercase tracking-[0.09em] text-ink-faint">
|
|
256
|
+
<th className="text-left font-semibold px-3 py-1.5 border-b border-line">What was called</th>
|
|
257
|
+
<th className="text-left font-semibold px-3 py-1.5 border-b border-line w-40">Type</th>
|
|
258
|
+
<th className="text-left font-semibold px-3 py-1.5 border-b border-line w-32">Outcome</th>
|
|
259
|
+
<th className="text-left font-semibold px-3 py-1.5 border-b border-line w-28">When</th>
|
|
260
|
+
</tr>
|
|
261
|
+
</thead>
|
|
262
|
+
<tbody>
|
|
263
|
+
{visible.length === 0 && (
|
|
264
|
+
<tr>
|
|
265
|
+
<td colSpan={4} className="px-3 py-3 text-center text-ink-muted">
|
|
266
|
+
No events match these filters.
|
|
267
|
+
</td>
|
|
268
|
+
</tr>
|
|
269
|
+
)}
|
|
270
|
+
{rows.map((row) =>
|
|
271
|
+
'day' in row ? (
|
|
272
|
+
<tr key={`day:${row.day}`}>
|
|
273
|
+
<td colSpan={4} className="bg-sunken px-3 py-0.5 text-meta font-medium text-ink-muted">
|
|
274
|
+
{row.day}
|
|
275
|
+
</td>
|
|
276
|
+
</tr>
|
|
277
|
+
) : (
|
|
278
|
+
<Fragment key={row.event.id}>
|
|
279
|
+
<tr className="hover:bg-surface-hover">
|
|
280
|
+
<td className="px-3 py-1.5 border-t border-line font-mono text-detail">
|
|
281
|
+
<WhatWasCalled event={row.event} />
|
|
282
|
+
</td>
|
|
283
|
+
<td className="px-3 py-1.5 border-t border-line">
|
|
284
|
+
<span className="inline-flex items-center gap-1.5">
|
|
285
|
+
<span aria-hidden className={cn('size-2 rounded-[2px]', KIND_MARK[row.event.kind])} />
|
|
286
|
+
{KIND_LABEL[row.event.kind]}
|
|
287
|
+
</span>
|
|
288
|
+
</td>
|
|
289
|
+
<td className="px-3 py-1.5 border-t border-line">
|
|
290
|
+
<Badge tone={OUTCOME[row.event.outcome].tone}>{OUTCOME[row.event.outcome].label}</Badge>
|
|
291
|
+
</td>
|
|
292
|
+
<td
|
|
293
|
+
className="px-3 py-1.5 border-t border-line text-ink-muted tabular-nums whitespace-nowrap"
|
|
294
|
+
title={new Date(row.event.at).toLocaleString()}
|
|
295
|
+
>
|
|
296
|
+
{timeOf(row.event.at)}
|
|
297
|
+
</td>
|
|
298
|
+
</tr>
|
|
299
|
+
</Fragment>
|
|
300
|
+
),
|
|
301
|
+
)}
|
|
302
|
+
</tbody>
|
|
303
|
+
</table>
|
|
304
|
+
</div>
|
|
305
|
+
<div className="flex items-center justify-between gap-3 px-3 py-1.5 border-t border-line text-meta text-ink-muted">
|
|
306
|
+
<span>
|
|
307
|
+
Showing {events.length.toLocaleString()} of {total.toLocaleString()} {total === 1 ? 'event' : 'events'} ·
|
|
308
|
+
newest first
|
|
309
|
+
</span>
|
|
310
|
+
{nextCursor && (
|
|
311
|
+
<Button variant="outline" size="sm" onClick={() => void loadOlder()} disabled={loadingMore}>
|
|
312
|
+
{loadingMore ? 'Loading…' : 'Load older events'}
|
|
313
|
+
</Button>
|
|
314
|
+
)}
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
);
|
|
319
|
+
}
|