@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,177 @@
|
|
|
1
|
+
import { useState, type KeyboardEvent, type ReactNode } from 'react';
|
|
2
|
+
import { Check, ChevronLeft, ChevronRight, RotateCcw } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../../shared/components';
|
|
4
|
+
import { ScreenshotStep } from './ScreenshotStep';
|
|
5
|
+
import type { Shot } from './claude-setup-shots';
|
|
6
|
+
|
|
7
|
+
export interface CarouselSlide {
|
|
8
|
+
/** The word in the progress strip. Short, because five or six share a row. */
|
|
9
|
+
shortLabel: string;
|
|
10
|
+
/** The half of the setup this slide belongs to, named in the eyebrow. */
|
|
11
|
+
stage: string;
|
|
12
|
+
title: string;
|
|
13
|
+
instruction: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Usually one. The connector slide is two, because it is one action across
|
|
16
|
+
* a list and the dialog it opens; splitting it would put the check that it
|
|
17
|
+
* worked on a different slide from the button that does it.
|
|
18
|
+
*/
|
|
19
|
+
shots: Shot[];
|
|
20
|
+
/**
|
|
21
|
+
* Anything that belongs to this slide and is not a screenshot — today only
|
|
22
|
+
* the generated credentials, on the Add-configuration slide. An ELEMENT,
|
|
23
|
+
* not a component: creating it costs nothing, and it is mounted only while
|
|
24
|
+
* its own slide is the active one, which is what keeps a client secret out
|
|
25
|
+
* of the DOM of the five slides that do not ask for it.
|
|
26
|
+
*/
|
|
27
|
+
extra?: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* One decision at a time, for both Claude setup routes: the personal one on
|
|
32
|
+
* External agent access and the admin's registration steps in Deployment
|
|
33
|
+
* settings. ONE shell, so the two cannot drift into different keyboard
|
|
34
|
+
* handling or a different idea of where "Review again" lives.
|
|
35
|
+
*
|
|
36
|
+
* Only the active slide is mounted. That is what keeps nine full-size
|
|
37
|
+
* screenshots from becoming a very long page, and it is also the rule the
|
|
38
|
+
* credentials rely on.
|
|
39
|
+
*/
|
|
40
|
+
export function SetupCarousel({ label, slides }: { label: string; slides: CarouselSlide[] }) {
|
|
41
|
+
const [current, setCurrent] = useState(0);
|
|
42
|
+
const active = slides[current];
|
|
43
|
+
const atStart = current === 0;
|
|
44
|
+
const atEnd = current === slides.length - 1;
|
|
45
|
+
|
|
46
|
+
function handleKeys(event: KeyboardEvent<HTMLElement>) {
|
|
47
|
+
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const last = slides.length - 1;
|
|
51
|
+
const next =
|
|
52
|
+
event.key === 'ArrowLeft'
|
|
53
|
+
? Math.max(0, current - 1)
|
|
54
|
+
: event.key === 'ArrowRight'
|
|
55
|
+
? Math.min(last, current + 1)
|
|
56
|
+
: event.key === 'Home'
|
|
57
|
+
? 0
|
|
58
|
+
: event.key === 'End'
|
|
59
|
+
? last
|
|
60
|
+
: current;
|
|
61
|
+
// Only a key that actually moves the carousel is ours to swallow. Left on
|
|
62
|
+
// the first slide, Right on the last, Home at the start and End at the
|
|
63
|
+
// end change nothing here, so they stay with the browser — a reader who
|
|
64
|
+
// tabbed onto a screenshot link keeps the default scroll rather than
|
|
65
|
+
// finding those keys dead inside the section.
|
|
66
|
+
if (next === current) return;
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
setCurrent(next);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<section
|
|
73
|
+
aria-label={label}
|
|
74
|
+
aria-roledescription="carousel"
|
|
75
|
+
onKeyDown={handleKeys}
|
|
76
|
+
className="overflow-hidden rounded-xl border border-line bg-surface"
|
|
77
|
+
>
|
|
78
|
+
{/* The column count is the slide count, so a route with six steps does
|
|
79
|
+
not have to remember to change a `grid-cols-5` somewhere else. */}
|
|
80
|
+
<nav
|
|
81
|
+
aria-label="Setup progress"
|
|
82
|
+
className="grid border-b border-line"
|
|
83
|
+
style={{ gridTemplateColumns: `repeat(${slides.length}, minmax(0, 1fr))` }}
|
|
84
|
+
>
|
|
85
|
+
{slides.map((item, index) => {
|
|
86
|
+
const complete = index < current;
|
|
87
|
+
const selected = index === current;
|
|
88
|
+
return (
|
|
89
|
+
<button
|
|
90
|
+
key={item.shortLabel}
|
|
91
|
+
type="button"
|
|
92
|
+
aria-label={`Go to step ${index + 1}: ${item.shortLabel}`}
|
|
93
|
+
aria-current={selected ? 'step' : undefined}
|
|
94
|
+
onClick={() => setCurrent(index)}
|
|
95
|
+
className={`flex min-w-0 items-center justify-center gap-1.5 border-r border-line px-1.5 py-2 text-meta transition-colors last:border-r-0 hover:bg-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ink-muted ${
|
|
96
|
+
selected ? 'bg-sunken font-medium text-ink' : 'text-ink-muted'
|
|
97
|
+
}`}
|
|
98
|
+
>
|
|
99
|
+
<span
|
|
100
|
+
aria-hidden="true"
|
|
101
|
+
className={`flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-micro ${
|
|
102
|
+
selected
|
|
103
|
+
? 'bg-accent text-white'
|
|
104
|
+
: complete
|
|
105
|
+
? 'bg-ok-soft text-ok'
|
|
106
|
+
: 'bg-sunken text-ink-faint'
|
|
107
|
+
}`}
|
|
108
|
+
>
|
|
109
|
+
{complete ? <Check size={11} strokeWidth={2.5} /> : index + 1}
|
|
110
|
+
</span>
|
|
111
|
+
<span className="hidden truncate min-[640px]:inline">{item.shortLabel}</span>
|
|
112
|
+
</button>
|
|
113
|
+
);
|
|
114
|
+
})}
|
|
115
|
+
</nav>
|
|
116
|
+
|
|
117
|
+
{/* Live, because moving between slides never moves focus: the reader
|
|
118
|
+
stays on Next or on a progress button while the title, instruction
|
|
119
|
+
and screenshot underneath them all change. The eyebrow inside names
|
|
120
|
+
the new position, so the footer counter does not repeat it. */}
|
|
121
|
+
<div
|
|
122
|
+
role="group"
|
|
123
|
+
aria-roledescription="slide"
|
|
124
|
+
aria-live="polite"
|
|
125
|
+
aria-label={`Step ${current + 1} of ${slides.length}: ${active.title}`}
|
|
126
|
+
>
|
|
127
|
+
<div className="space-y-1.5 border-b border-line px-3 py-3 sm:px-4">
|
|
128
|
+
<div className="text-label uppercase text-accent">
|
|
129
|
+
Step {current + 1} of {slides.length} · {active.stage}
|
|
130
|
+
</div>
|
|
131
|
+
<h3 className="text-head font-medium text-ink">{active.title}</h3>
|
|
132
|
+
<p className="max-w-4xl text-detail leading-relaxed text-ink-muted">
|
|
133
|
+
{active.instruction}
|
|
134
|
+
</p>
|
|
135
|
+
{active.extra}
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<div className="space-y-2 bg-sunken p-2 sm:p-3">
|
|
139
|
+
{active.shots.map((shot) => (
|
|
140
|
+
<ScreenshotStep key={shot.src} shot={shot} />
|
|
141
|
+
))}
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div className="flex items-center justify-between gap-3 border-t border-line px-3 py-2.5 sm:px-4">
|
|
146
|
+
<Button
|
|
147
|
+
variant="quiet"
|
|
148
|
+
size="sm"
|
|
149
|
+
leadingIcon={<ChevronLeft size={14} />}
|
|
150
|
+
disabled={atStart}
|
|
151
|
+
onClick={() => setCurrent((step) => Math.max(0, step - 1))}
|
|
152
|
+
>
|
|
153
|
+
Back
|
|
154
|
+
</Button>
|
|
155
|
+
<span className="text-meta text-ink-faint">
|
|
156
|
+
{current + 1} / {slides.length}
|
|
157
|
+
</span>
|
|
158
|
+
{/* One control that relabels itself, rather than two behind a
|
|
159
|
+
ternary. Same rendered result — React reconciles same-type
|
|
160
|
+
siblings in place, so either way the reader who pressed Next to
|
|
161
|
+
reach the end keeps focus on it — but here that is the structure
|
|
162
|
+
rather than a property of the reconciler, and a later `key` or an
|
|
163
|
+
extra wrapper cannot quietly unmount the button under their
|
|
164
|
+
focus. Losing it would take the arrow keys with it: this section
|
|
165
|
+
is what handles them. */}
|
|
166
|
+
<Button
|
|
167
|
+
variant={atEnd ? 'outline' : 'primary'}
|
|
168
|
+
size="sm"
|
|
169
|
+
trailingIcon={atEnd ? <RotateCcw size={13} /> : <ChevronRight size={14} />}
|
|
170
|
+
onClick={() => setCurrent((step) => (step === slides.length - 1 ? 0 : step + 1))}
|
|
171
|
+
>
|
|
172
|
+
{atEnd ? 'Review again' : 'Next'}
|
|
173
|
+
</Button>
|
|
174
|
+
</div>
|
|
175
|
+
</section>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
6
|
+
import { configureBranchModel } from '@bevel-software/platform-shared';
|
|
7
|
+
import { AgentInstructionsCard } from '../AgentInstructionsCard';
|
|
8
|
+
import { AdminContext, type AdminContextValue } from '../../../admin/state/admin.context';
|
|
9
|
+
import { WorkspaceContext, type WorkspaceContextValue } from '../../../workspace/state/workspace.context';
|
|
10
|
+
import type { AgentInstructions } from '../../services/agent-instructions.api';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The card shows what the server SENDS, organised around what the admin can
|
|
14
|
+
* change: their description with its count, the fixed platform message
|
|
15
|
+
* folded away, and no repository/file-format implementation copy. The Edit
|
|
16
|
+
* action belongs to admins, and only once the KB dir name is known.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const { fetchMock, fetchEditableMock, saveMock } = vi.hoisted(() => ({
|
|
20
|
+
fetchMock: vi.fn(),
|
|
21
|
+
fetchEditableMock: vi.fn(),
|
|
22
|
+
saveMock: vi.fn(),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
vi.mock('../../services/agent-instructions.api', async (importOriginal) => ({
|
|
26
|
+
...(await importOriginal<typeof import('../../services/agent-instructions.api')>()),
|
|
27
|
+
fetchAgentInstructions: fetchMock,
|
|
28
|
+
fetchEditableAgentDescription: fetchEditableMock,
|
|
29
|
+
saveAgentDescription: saveMock,
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const nonAdmin: AdminContextValue = {
|
|
33
|
+
isAdmin: false,
|
|
34
|
+
unreadCount: 0,
|
|
35
|
+
lastSeen: null,
|
|
36
|
+
markSeen: vi.fn(),
|
|
37
|
+
refresh: vi.fn(),
|
|
38
|
+
rolesConfigCorrupted: false,
|
|
39
|
+
rolesConfigErrors: [],
|
|
40
|
+
runRolesRecovery: vi.fn(),
|
|
41
|
+
};
|
|
42
|
+
const asAdmin: AdminContextValue = { ...nonAdmin, isAdmin: true };
|
|
43
|
+
|
|
44
|
+
const HEADER = "Hexis is this organisation's knowledge base.";
|
|
45
|
+
const LINE = "This organisation's knowledge base. Search it before answering from memory.";
|
|
46
|
+
|
|
47
|
+
const composed = (over: Partial<AgentInstructions> = {}): AgentInstructions => ({
|
|
48
|
+
instructions: `${HEADER}\n\nAcme builds solar farms.\n\n## What is where\n\n- Projects/`,
|
|
49
|
+
header: HEADER,
|
|
50
|
+
preamble: 'Acme builds solar farms.\n\n## What is where\n\n- Projects/',
|
|
51
|
+
toolPrefix: `${LINE} Acme builds solar farms.`,
|
|
52
|
+
toolPrefixLine: LINE,
|
|
53
|
+
truncated: false,
|
|
54
|
+
preambleChars: 1240,
|
|
55
|
+
toolPrefixTruncated: false,
|
|
56
|
+
toolPrefixChars: 212,
|
|
57
|
+
unterminatedComment: false,
|
|
58
|
+
...over,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
function mount(
|
|
62
|
+
opts: { admin?: AdminContextValue | null; kbDirName?: string | null | 'no-provider'; strict?: boolean } = {},
|
|
63
|
+
) {
|
|
64
|
+
const admin = opts.admin === undefined ? nonAdmin : opts.admin;
|
|
65
|
+
const kb = opts.kbDirName === undefined ? 'knowledge-base' : opts.kbDirName;
|
|
66
|
+
let tree = <AgentInstructionsCard />;
|
|
67
|
+
if (kb !== 'no-provider') {
|
|
68
|
+
tree = (
|
|
69
|
+
<WorkspaceContext.Provider value={{ kbDirName: kb } as unknown as WorkspaceContextValue}>{tree}</WorkspaceContext.Provider>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
if (admin !== null) tree = <AdminContext.Provider value={admin}>{tree}</AdminContext.Provider>;
|
|
73
|
+
tree = <MemoryRouter>{tree}</MemoryRouter>;
|
|
74
|
+
// The app mounts under StrictMode, so the load effect is set up, torn down
|
|
75
|
+
// and set up again on the SAME card. Anything the teardown disarms has to
|
|
76
|
+
// be re-armed on the way back in.
|
|
77
|
+
return render(opts.strict ? <StrictMode>{tree}</StrictMode> : tree);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
beforeEach(() => {
|
|
81
|
+
configureBranchModel({ defaultBranch: 'target-company-state', protectedBranches: ['current-company-state', 'target-company-state'] });
|
|
82
|
+
fetchMock.mockReset();
|
|
83
|
+
fetchMock.mockResolvedValue(composed());
|
|
84
|
+
fetchEditableMock.mockReset();
|
|
85
|
+
fetchEditableMock.mockResolvedValue({
|
|
86
|
+
workspaceId: 'target-company-state',
|
|
87
|
+
source: '<!-- private starter notes -->\n',
|
|
88
|
+
description: '',
|
|
89
|
+
});
|
|
90
|
+
saveMock.mockReset();
|
|
91
|
+
saveMock.mockResolvedValue(undefined);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('the description', () => {
|
|
95
|
+
it('centres the admin\'s description, with its count, and folds the platform message away', async () => {
|
|
96
|
+
mount();
|
|
97
|
+
expect(await screen.findByRole('heading', { name: 'Your description' })).toBeInTheDocument();
|
|
98
|
+
expect(screen.getByTestId('preamble-count')).toHaveTextContent('1,240 / 6,000 characters');
|
|
99
|
+
const description = screen.getByTestId('description-text');
|
|
100
|
+
expect(description).toHaveTextContent('Acme builds solar farms.');
|
|
101
|
+
expect(description).not.toHaveTextContent(HEADER); // the fixed part is not mixed into the admin's
|
|
102
|
+
// The platform message is there, closed, and not editable.
|
|
103
|
+
const drawer = screen.getByText('Platform message (fixed, sent first)');
|
|
104
|
+
expect(drawer.tagName).toBe('SUMMARY');
|
|
105
|
+
expect((drawer.closest('details') as HTMLDetailsElement).open).toBe(false);
|
|
106
|
+
expect(screen.getByTestId('header-text')).toHaveTextContent(HEADER);
|
|
107
|
+
// Says that access does not gate it.
|
|
108
|
+
expect(screen.getByText(/whatever it may read/)).toBeInTheDocument();
|
|
109
|
+
expect(screen.queryByRole('alert')).toBeNull();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('still lands under StrictMode, whose teardown and second setup run on the same card', async () => {
|
|
113
|
+
mount({ strict: true });
|
|
114
|
+
expect(await screen.findByTestId('description-text')).toHaveTextContent('Acme builds solar farms.');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('explains an empty description instead of showing an empty box', async () => {
|
|
118
|
+
fetchMock.mockResolvedValue(composed({ preamble: '', preambleChars: 0, toolPrefix: LINE, toolPrefixChars: LINE.length }));
|
|
119
|
+
mount();
|
|
120
|
+
expect(await screen.findByTestId('description-empty')).toHaveTextContent('platform message only');
|
|
121
|
+
expect(screen.queryByTestId('description-text')).toBeNull();
|
|
122
|
+
expect(screen.getByTestId('preamble-count')).toHaveTextContent('0 / 6,000 characters');
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('the Edit action', () => {
|
|
127
|
+
it('is offered to admins as an inline action, not a link to another page', async () => {
|
|
128
|
+
mount({ admin: asAdmin });
|
|
129
|
+
const edit = await screen.findByRole('button', { name: /Edit description/ });
|
|
130
|
+
expect(edit.tagName).toBe('BUTTON');
|
|
131
|
+
expect(screen.queryByRole('link', { name: /Edit description/ })).toBeNull();
|
|
132
|
+
expect(screen.queryByText(/mcp-description\.md at the repository root/)).toBeNull();
|
|
133
|
+
expect(screen.queryByText(/first paragraph is automatically reused/)).toBeNull();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('edits and saves the description in place, then refreshes the preview', async () => {
|
|
137
|
+
const empty = composed({ preamble: '', preambleChars: 0, toolPrefix: LINE, toolPrefixChars: LINE.length });
|
|
138
|
+
const saved = composed({
|
|
139
|
+
preamble: 'Acme builds solar farms.',
|
|
140
|
+
preambleChars: 'Acme builds solar farms.'.length,
|
|
141
|
+
toolPrefix: `${LINE} Acme builds solar farms.`,
|
|
142
|
+
toolPrefixChars: `${LINE} Acme builds solar farms.`.length,
|
|
143
|
+
});
|
|
144
|
+
fetchMock.mockResolvedValueOnce(empty).mockResolvedValueOnce(saved);
|
|
145
|
+
const user = userEvent.setup();
|
|
146
|
+
mount({ admin: asAdmin });
|
|
147
|
+
|
|
148
|
+
await user.click(await screen.findByRole('button', { name: 'Edit description' }));
|
|
149
|
+
const editor = await screen.findByRole('textbox', { name: 'Your description' });
|
|
150
|
+
expect(editor).toHaveValue('');
|
|
151
|
+
expect(editor).toHaveAttribute('rows', '1');
|
|
152
|
+
expect(editor.className).toContain('[field-sizing:content]');
|
|
153
|
+
expect(editor.className).not.toContain('min-h-40');
|
|
154
|
+
expect(fetchEditableMock).toHaveBeenCalledWith('knowledge-base');
|
|
155
|
+
|
|
156
|
+
await user.type(editor, 'Acme builds solar farms.');
|
|
157
|
+
expect(screen.getByTestId('preamble-count')).toHaveTextContent('24 / 6,000 characters');
|
|
158
|
+
await user.click(screen.getByRole('button', { name: 'Save description' }));
|
|
159
|
+
|
|
160
|
+
await waitFor(() => {
|
|
161
|
+
expect(saveMock).toHaveBeenCalledWith(
|
|
162
|
+
'target-company-state',
|
|
163
|
+
'knowledge-base',
|
|
164
|
+
'<!-- private starter notes -->\n',
|
|
165
|
+
'Acme builds solar farms.',
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
expect(await screen.findByTestId('description-text')).toHaveTextContent('Acme builds solar farms.');
|
|
169
|
+
expect(screen.queryByRole('textbox', { name: 'Your description' })).toBeNull();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('keeps the post-save preview when the initial load answers after it', async () => {
|
|
173
|
+
// The initial request is still in flight while the admin edits and saves.
|
|
174
|
+
// Its response arrives last and must land nowhere: the page would
|
|
175
|
+
// otherwise show the pre-save text as though the save had not happened.
|
|
176
|
+
const before = composed({ preamble: 'Before.', preambleChars: 6 });
|
|
177
|
+
const after = composed({ preamble: 'After.', preambleChars: 5 });
|
|
178
|
+
let releaseInitialLoad: () => void = () => {};
|
|
179
|
+
const initialLoad = new Promise<AgentInstructions>((resolve) => {
|
|
180
|
+
releaseInitialLoad = () => resolve(before);
|
|
181
|
+
});
|
|
182
|
+
fetchMock.mockReturnValueOnce(initialLoad).mockResolvedValueOnce(after);
|
|
183
|
+
fetchEditableMock.mockResolvedValue({
|
|
184
|
+
workspaceId: 'target-company-state',
|
|
185
|
+
source: 'Before.',
|
|
186
|
+
description: 'Before.',
|
|
187
|
+
});
|
|
188
|
+
const user = userEvent.setup();
|
|
189
|
+
mount({ admin: asAdmin });
|
|
190
|
+
|
|
191
|
+
await user.click(await screen.findByRole('button', { name: 'Edit description' }));
|
|
192
|
+
const editor = await screen.findByRole('textbox', { name: 'Your description' });
|
|
193
|
+
await user.clear(editor);
|
|
194
|
+
await user.type(editor, 'After.');
|
|
195
|
+
await user.click(screen.getByRole('button', { name: 'Save description' }));
|
|
196
|
+
|
|
197
|
+
expect(await screen.findByTestId('description-text')).toHaveTextContent('After.');
|
|
198
|
+
releaseInitialLoad();
|
|
199
|
+
await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(2));
|
|
200
|
+
expect(screen.getByTestId('description-text')).toHaveTextContent('After.');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('keeps the inline editor open and shows the save error', async () => {
|
|
204
|
+
fetchEditableMock.mockResolvedValue({
|
|
205
|
+
workspaceId: 'target-company-state',
|
|
206
|
+
source: 'Before.',
|
|
207
|
+
description: 'Before.',
|
|
208
|
+
});
|
|
209
|
+
saveMock.mockRejectedValue(new Error('File is locked by Ada.'));
|
|
210
|
+
const user = userEvent.setup();
|
|
211
|
+
mount({ admin: asAdmin });
|
|
212
|
+
|
|
213
|
+
await user.click(await screen.findByRole('button', { name: 'Edit description' }));
|
|
214
|
+
const editor = await screen.findByRole('textbox', { name: 'Your description' });
|
|
215
|
+
await user.clear(editor);
|
|
216
|
+
await user.type(editor, 'After.');
|
|
217
|
+
await user.click(screen.getByRole('button', { name: 'Save description' }));
|
|
218
|
+
|
|
219
|
+
expect(await screen.findByRole('alert')).toHaveTextContent('File is locked by Ada.');
|
|
220
|
+
expect(screen.getByRole('textbox', { name: 'Your description' })).toHaveValue('After.');
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('still opens the editor when the composed preview could not load', async () => {
|
|
224
|
+
fetchMock.mockRejectedValue(new Error('Preview unavailable.'));
|
|
225
|
+
fetchEditableMock.mockResolvedValue({
|
|
226
|
+
workspaceId: 'target-company-state',
|
|
227
|
+
source: 'Editable source.',
|
|
228
|
+
description: 'Editable source.',
|
|
229
|
+
});
|
|
230
|
+
const user = userEvent.setup();
|
|
231
|
+
mount({ admin: asAdmin });
|
|
232
|
+
|
|
233
|
+
expect(await screen.findByRole('alert')).toHaveTextContent('Preview unavailable.');
|
|
234
|
+
await user.click(screen.getByRole('button', { name: 'Edit description' }));
|
|
235
|
+
|
|
236
|
+
expect(await screen.findByRole('textbox', { name: 'Your description' })).toHaveValue('Editable source.');
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('is withheld from non-admins without exposing repository implementation details', async () => {
|
|
240
|
+
mount({ admin: nonAdmin });
|
|
241
|
+
await screen.findByRole('heading', { name: 'Your description' });
|
|
242
|
+
expect(screen.queryByRole('button', { name: /Edit/ })).toBeNull();
|
|
243
|
+
expect(screen.queryByText(/mcp-description\.md at the repository root/)).toBeNull();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('waits for the KB dir name: no edit action with a missing save path, ever', async () => {
|
|
247
|
+
mount({ admin: asAdmin, kbDirName: null });
|
|
248
|
+
await screen.findByRole('heading', { name: 'Your description' });
|
|
249
|
+
expect(screen.queryByRole('button', { name: /Edit/ })).toBeNull();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('offers no edit action for an empty KB dir name either — a button that could not save', async () => {
|
|
253
|
+
mount({ admin: asAdmin, kbDirName: '' });
|
|
254
|
+
await screen.findByRole('heading', { name: 'Your description' });
|
|
255
|
+
expect(screen.queryByRole('button', { name: /Edit/ })).toBeNull();
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('tolerates absent providers: no admin context and no workspace context still render the card', async () => {
|
|
259
|
+
mount({ admin: null, kbDirName: 'no-provider' });
|
|
260
|
+
expect(await screen.findByRole('heading', { name: 'Your description' })).toBeInTheDocument();
|
|
261
|
+
expect(screen.queryByRole('button', { name: /Edit/ })).toBeNull();
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
describe('warnings', () => {
|
|
266
|
+
it('warns when the description is over its cap, with the count over the cap', async () => {
|
|
267
|
+
fetchMock.mockResolvedValue(composed({ truncated: true, preambleChars: 7350 }));
|
|
268
|
+
mount();
|
|
269
|
+
const alert = await screen.findByRole('alert');
|
|
270
|
+
expect(alert).toHaveTextContent('agents receive only the first 6,000 characters');
|
|
271
|
+
expect(screen.getByTestId('preamble-count')).toHaveTextContent('7,350 / 6,000 characters');
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('warns about an open comment and, for an admin, names the action on THIS page', async () => {
|
|
275
|
+
// The file is hidden from the tree by this change, so "close it in
|
|
276
|
+
// mcp-description.md" would be a repair the admin cannot reach.
|
|
277
|
+
fetchMock.mockResolvedValue(composed({ unterminatedComment: true }));
|
|
278
|
+
mount({ admin: asAdmin });
|
|
279
|
+
const alert = await screen.findByRole('alert');
|
|
280
|
+
expect(alert).toHaveTextContent('A comment is left open');
|
|
281
|
+
expect(alert).toHaveTextContent('withheld from agents');
|
|
282
|
+
expect(alert).toHaveTextContent('Open the editor and save');
|
|
283
|
+
expect(alert).not.toHaveTextContent('mcp-description.md');
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('tells a non-admin who can fix it', async () => {
|
|
287
|
+
fetchMock.mockResolvedValue(composed({ unterminatedComment: true }));
|
|
288
|
+
mount({ admin: nonAdmin });
|
|
289
|
+
const alert = await screen.findByRole('alert');
|
|
290
|
+
expect(alert).toHaveTextContent('An admin can close it from this page');
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('warns when the tool-description channel is cutting the first paragraph', async () => {
|
|
294
|
+
// The composer still cuts the prefix at its own cap and still reports it;
|
|
295
|
+
// dropping the short-version preview must not drop the only signal.
|
|
296
|
+
fetchMock.mockResolvedValue(composed({ toolPrefixTruncated: true, toolPrefixChars: 415 }));
|
|
297
|
+
mount();
|
|
298
|
+
const alert = await screen.findByRole('alert');
|
|
299
|
+
// The count is the FIXED LINE plus the paragraph, so the warning must not
|
|
300
|
+
// blame the paragraph alone: a 225-character paragraph trips a 300 cap.
|
|
301
|
+
expect(alert).toHaveTextContent('The fixed line and your first paragraph');
|
|
302
|
+
expect(alert).toHaveTextContent('together they are over');
|
|
303
|
+
expect(alert).toHaveTextContent('300-character');
|
|
304
|
+
expect(alert).toHaveTextContent('415');
|
|
305
|
+
// Names WHO is affected, so an admin can tell whether this matters to
|
|
306
|
+
// their deployment rather than guessing what "ignores the handshake" means.
|
|
307
|
+
expect(alert).toHaveTextContent('claude.ai on the web, the Agent SDK and Cline');
|
|
308
|
+
expect(alert).toHaveTextContent('Claude Code, Claude Desktop and Cursor');
|
|
309
|
+
expect(alert).toHaveTextContent('Shorten the first paragraph');
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('lets an admin save a file whose only problem is the hidden open comment', async () => {
|
|
313
|
+
// Save used to be disabled while the VISIBLE text was unchanged, so the
|
|
314
|
+
// one repair for an open comment was unreachable.
|
|
315
|
+
fetchEditableMock.mockResolvedValue({
|
|
316
|
+
workspaceId: 'target-company-state',
|
|
317
|
+
source: 'Public text.\n<!-- a note that was never closed',
|
|
318
|
+
description: 'Public text.',
|
|
319
|
+
});
|
|
320
|
+
const user = userEvent.setup();
|
|
321
|
+
mount({ admin: asAdmin });
|
|
322
|
+
|
|
323
|
+
await user.click(await screen.findByRole('button', { name: 'Edit description' }));
|
|
324
|
+
await screen.findByRole('textbox', { name: 'Your description' });
|
|
325
|
+
const save = screen.getByRole('button', { name: 'Save and close the comment' });
|
|
326
|
+
expect(save).toBeEnabled();
|
|
327
|
+
|
|
328
|
+
await user.click(save);
|
|
329
|
+
|
|
330
|
+
await waitFor(() => {
|
|
331
|
+
expect(saveMock).toHaveBeenCalledWith(
|
|
332
|
+
'target-company-state',
|
|
333
|
+
'knowledge-base',
|
|
334
|
+
'Public text.\n<!-- a note that was never closed',
|
|
335
|
+
'Public text.',
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it('keeps Save disabled when there is genuinely nothing to save', async () => {
|
|
341
|
+
fetchEditableMock.mockResolvedValue({
|
|
342
|
+
workspaceId: 'target-company-state',
|
|
343
|
+
source: 'Public text.',
|
|
344
|
+
description: 'Public text.',
|
|
345
|
+
});
|
|
346
|
+
const user = userEvent.setup();
|
|
347
|
+
mount({ admin: asAdmin });
|
|
348
|
+
|
|
349
|
+
await user.click(await screen.findByRole('button', { name: 'Edit description' }));
|
|
350
|
+
await screen.findByRole('textbox', { name: 'Your description' });
|
|
351
|
+
expect(screen.getByRole('button', { name: 'Save description' })).toBeDisabled();
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('shows each warning only when flagged', async () => {
|
|
355
|
+
fetchMock.mockResolvedValue(composed({ truncated: true, unterminatedComment: true }));
|
|
356
|
+
mount();
|
|
357
|
+
const alerts = await screen.findAllByRole('alert');
|
|
358
|
+
expect(alerts).toHaveLength(2);
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
describe('a failed fetch', () => {
|
|
363
|
+
it('shows an inline message and nothing else breaks', async () => {
|
|
364
|
+
fetchMock.mockRejectedValue(new Error('boom'));
|
|
365
|
+
mount();
|
|
366
|
+
expect(await screen.findByRole('alert')).toHaveTextContent('boom');
|
|
367
|
+
expect(screen.getByRole('heading', { name: 'What agents are told about this knowledge base' })).toBeInTheDocument();
|
|
368
|
+
expect(screen.queryByRole('heading', { name: 'Your description' })).toBeNull();
|
|
369
|
+
});
|
|
370
|
+
});
|