@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
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { useEffect, useId, useState, type ReactNode } from 'react';
|
|
2
2
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
|
3
3
|
import { ChevronRight } from 'lucide-react';
|
|
4
|
+
import { HEADER_BAND, HEADER_BAND_LEAD, PAGE_HEADER_TESTID } from '../../../../shared/theme/header';
|
|
4
5
|
import { cn } from '../../../../lib/utils';
|
|
5
6
|
import { Banner, Button, buttonClasses } from '../../../../shared/components';
|
|
7
|
+
import { announceToolCredentialsChanged } from '../../../../core/events';
|
|
6
8
|
import { useToolPage } from '../../hooks/useToolPage';
|
|
7
9
|
import { useToolSource } from '../../hooks/useToolSource';
|
|
8
10
|
import { McpServerSection } from './McpServerSection';
|
|
9
|
-
import { libraryHomeForItemPath, LIBRARY_ROOT } from '../../routes/library-paths';
|
|
11
|
+
import { libraryHomeForItemPath, pathForPlugin, LIBRARY_ROOT } from '../../routes/library-paths';
|
|
10
12
|
import { useLibrary } from '../../state/library-data';
|
|
11
|
-
import { pluginLabel, pluginNameForPath } from '../../utils/plugin-summary';
|
|
13
|
+
import { pluginHoldingPath, pluginLabel, pluginNameForPath } from '../../utils/plugin-summary';
|
|
12
14
|
import { readOAuthFragment } from '../../utils/oauth-fragment';
|
|
13
15
|
import type { ToolCapability } from '../../services/tools.api';
|
|
14
16
|
import type { LibrarySkillSummary } from '../../services/library.api';
|
|
15
17
|
import { ToolConnectionSection } from './ToolConnectionSection';
|
|
16
18
|
import { ToolLogo } from '../ToolLogo';
|
|
19
|
+
import { PageActions } from '../PageActions';
|
|
20
|
+
import { DeleteToolDialog } from './DeleteToolDialog';
|
|
21
|
+
import { copyToClipboard } from '../../utils/clipboard';
|
|
22
|
+
import { useLibraryToast } from '../../state/toast.context';
|
|
23
|
+
import { NameWithBadges } from '../NameWithBadges';
|
|
17
24
|
|
|
18
25
|
/**
|
|
19
26
|
* One tool, as a page.
|
|
@@ -59,15 +66,22 @@ export function ToolPage({
|
|
|
59
66
|
* endpoint must not survive the change.
|
|
60
67
|
*/
|
|
61
68
|
const [serverRevision, setServerRevision] = useState(0);
|
|
69
|
+
/** Whether the tool's delete confirmation is up. */
|
|
70
|
+
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
62
71
|
|
|
63
72
|
useEffect(() => {
|
|
64
73
|
// Consume the OAuth `#…` fragment, KEEPING the query string: on an
|
|
65
74
|
// mcp-declared tool the `?server=<slug>` param is the page's identity, and
|
|
66
75
|
// replacing with the bare pathname stranded a refresh (or any URL copy) on
|
|
67
76
|
// the ambiguous mcp.json address, which bounces to the plugin page.
|
|
68
|
-
if (oauthOutcome)
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
if (!oauthOutcome) return;
|
|
78
|
+
window.history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
79
|
+
// Authorized OR error: a round-trip we did not perform ourselves has just
|
|
80
|
+
// had its say about this tool's sign-in, so what the catalog believes
|
|
81
|
+
// about it is an answer from before the browser left. An error is not a
|
|
82
|
+
// failed save — nothing here wrote anything, and the outcome we were
|
|
83
|
+
// handed is the only evidence either way — so both outcomes re-read.
|
|
84
|
+
announceToolCredentialsChanged();
|
|
71
85
|
}, [oauthOutcome]);
|
|
72
86
|
|
|
73
87
|
// Same rule as the skill page: back goes to the page the tool LIVES on —
|
|
@@ -86,6 +100,17 @@ export function ToolPage({
|
|
|
86
100
|
{`‹ ${home.label}`}
|
|
87
101
|
</Button>
|
|
88
102
|
);
|
|
103
|
+
const toast = useLibraryToast();
|
|
104
|
+
// Ownership of the plugin the tool LIVES IN — not of the tool file, which
|
|
105
|
+
// has no rules of its own. The same folder verdict the backend re-derives,
|
|
106
|
+
// so the menu item and the endpoint agree about who may delete.
|
|
107
|
+
//
|
|
108
|
+
// AND its links have to be ours to write: a plugin read from an external
|
|
109
|
+
// format is edited in its own repository, and the DELETE route refuses one
|
|
110
|
+
// (422). Offering the item to its owner would be offering a button whose
|
|
111
|
+
// only outcome is that refusal.
|
|
112
|
+
const holder = toolPath ? pluginHoldingPath(toolPath, data.pluginSummaries) : null;
|
|
113
|
+
const canDelete = (holder?.isOwner ?? false) && (holder?.linksAreManaged ?? false);
|
|
89
114
|
|
|
90
115
|
if (page.loading) {
|
|
91
116
|
return <div className="py-16 text-center text-ui text-ink-muted">Loading…</div>;
|
|
@@ -134,23 +159,71 @@ export function ToolPage({
|
|
|
134
159
|
</Banner>
|
|
135
160
|
)}
|
|
136
161
|
|
|
137
|
-
|
|
162
|
+
<header>
|
|
163
|
+
{/* The logo and the name are the title BAR — one band, the height the
|
|
164
|
+
sidebar's header row is. The description reads below it: a line of
|
|
165
|
+
prose inside the row would make this page's header taller than
|
|
166
|
+
every other page's, which is the drift the band removes. The way
|
|
167
|
+
back rides ON the band, as its leading item, for the same reason:
|
|
168
|
+
a back link in a row above would push the title bar off the line
|
|
169
|
+
the sidebar's header row holds. (The error and not-found returns
|
|
170
|
+
above still lead with it on its own row — they have no title bar
|
|
171
|
+
to hold a line with.) */}
|
|
172
|
+
<div data-testid={PAGE_HEADER_TESTID} className={cn(HEADER_BAND, 'gap-4')}>
|
|
173
|
+
<div className={HEADER_BAND_LEAD}>{backLink}</div>
|
|
174
|
+
{/* The mark and the title through `NameWithBadges`, so this page
|
|
175
|
+
states its name the way a card and a plugin row do: truncated
|
|
176
|
+
with an ellipsis, whole in the DOM, whole in `title`.
|
|
138
177
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
178
|
+
What it does NOT take is the floor, and the reason is the band.
|
|
179
|
+
A floor is only worth having where something can give the space
|
|
180
|
+
back, and the only thing that can is a badge taking a second
|
|
181
|
+
line. This header has no badges, and it could not wrap them if
|
|
182
|
+
it had: `HEADER_BAND` is one row tall, exactly as tall as the
|
|
183
|
+
sidebar's header row beside it, so a second line here hangs out
|
|
184
|
+
of the band rather than growing it. A floor granted against the
|
|
185
|
+
back link — which is not even inside this component — bought
|
|
186
|
+
nothing and cost the title its place on the band at every phone
|
|
187
|
+
width. `wrap={false}` says that out loud, so the day somebody
|
|
188
|
+
adds a badge the band clips instead of quietly growing.
|
|
189
|
+
|
|
190
|
+
`overflow-hidden` is the other half of a row that cannot wrap,
|
|
191
|
+
exactly as on the plugin page: with nowhere to go, anything
|
|
192
|
+
past the width goes across the way back unless it is clipped.
|
|
193
|
+
Clipped, the title gives way first and the way back stays
|
|
194
|
+
clickable. */}
|
|
195
|
+
<NameWithBadges
|
|
196
|
+
as="h1"
|
|
197
|
+
wrap={false}
|
|
198
|
+
className="min-w-0 flex-1 overflow-hidden"
|
|
199
|
+
gap="gap-4"
|
|
200
|
+
leading={<ToolLogo slug={tool.slug} name={tool.name} size="lg" />}
|
|
201
|
+
name={tool.name}
|
|
202
|
+
nameClassName="text-display font-semibold text-ink"
|
|
203
|
+
/>
|
|
148
204
|
</div>
|
|
205
|
+
{page.detail?.description && (
|
|
206
|
+
<p className="mt-1.5 max-w-[56ch] text-lede text-ink-muted">
|
|
207
|
+
{page.detail.description}
|
|
208
|
+
</p>
|
|
209
|
+
)}
|
|
149
210
|
{/* No `Manage access` here, deliberately. Access is decided at the
|
|
150
211
|
PLUGIN — a tool inherits its folder's `access.md`, so an editor on
|
|
151
212
|
this page would either duplicate the plugin's one or quietly write a
|
|
152
213
|
per-file override that nobody looking at the plugin would see. The
|
|
153
|
-
plugin's `Share` panel is the single place.
|
|
214
|
+
plugin's `Share` panel is the single place.
|
|
215
|
+
|
|
216
|
+
The `⋯` menu, though, is the same one the plugin page carries, in
|
|
217
|
+
the same spot — Delete belongs where people already look for it.
|
|
218
|
+
`onAdd` is absent: there is nothing to add to a tool. */}
|
|
219
|
+
<PageActions
|
|
220
|
+
onCopyLink={() => copyToClipboard(window.location.href)}
|
|
221
|
+
// The OWNER's verb, and the same verdict the DELETE route enforces
|
|
222
|
+
// (ownership of the plugin holding the tool) — so the item appears
|
|
223
|
+
// for exactly the people the backend will let through.
|
|
224
|
+
onDelete={canDelete ? () => setDeleteOpen(true) : undefined}
|
|
225
|
+
deleteLabel="Delete tool"
|
|
226
|
+
/>
|
|
154
227
|
</header>
|
|
155
228
|
|
|
156
229
|
{actionError && (
|
|
@@ -210,6 +283,23 @@ export function ToolPage({
|
|
|
210
283
|
make this tool — the `.tool`, or the plugin `mcp.json` that declares
|
|
211
284
|
the server. */}
|
|
212
285
|
<SourceSection path={tool.path} />
|
|
286
|
+
|
|
287
|
+
{deleteOpen && (
|
|
288
|
+
<DeleteToolDialog
|
|
289
|
+
slug={tool.slug}
|
|
290
|
+
name={tool.name}
|
|
291
|
+
onClose={() => setDeleteOpen(false)}
|
|
292
|
+
onDeleted={(plugin) => {
|
|
293
|
+
toast(`Deleted ${tool.name}.`);
|
|
294
|
+
// This page's subject just ceased to exist — the plugin it lived
|
|
295
|
+
// in is the honest landing, as the plugin delete lands on the
|
|
296
|
+
// index. Reloads follow so the cards and the sidebar agree.
|
|
297
|
+
navigate(pathForPlugin(plugin));
|
|
298
|
+
data.reload();
|
|
299
|
+
data.reloadPlugins();
|
|
300
|
+
}}
|
|
301
|
+
/>
|
|
302
|
+
)}
|
|
213
303
|
</Article>
|
|
214
304
|
);
|
|
215
305
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState, type ReactNode } from 'react';
|
|
2
2
|
import { Badge, Button, ListRow, TextField } from '../../../../shared/components';
|
|
3
3
|
import { startToolOAuth } from '../../../secrets-vault/services/connect.api';
|
|
4
4
|
import {
|
|
@@ -43,12 +43,16 @@ export interface ToolVarRowProps {
|
|
|
43
43
|
/** Where the OAuth round-trip should land — a bare path, no fragment. */
|
|
44
44
|
returnTo: string;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* the
|
|
46
|
+
* This variable is REQUIRED and has no value yet.
|
|
47
|
+
*
|
|
48
|
+
* The section used to say this in a banner above the rows, which re-listed
|
|
49
|
+
* every label and status the rows already carried. The row is where the
|
|
50
|
+
* label, the status and the button live, so it is where the colour lives
|
|
51
|
+
* too — and the count the banner used to give is now simply how many rows
|
|
52
|
+
* are amber. Sighted readers get the tone; `sr-only` text carries the same
|
|
53
|
+
* sentence to everyone else.
|
|
50
54
|
*/
|
|
51
|
-
|
|
55
|
+
unset?: boolean;
|
|
52
56
|
onChanged(): void;
|
|
53
57
|
/**
|
|
54
58
|
* A credential was WRITTEN (not deleted) — a typed value or an owner's client
|
|
@@ -68,7 +72,7 @@ export function ToolVarRow({
|
|
|
68
72
|
canWrite,
|
|
69
73
|
setupKind,
|
|
70
74
|
returnTo,
|
|
71
|
-
|
|
75
|
+
unset = false,
|
|
72
76
|
onChanged,
|
|
73
77
|
onSaved,
|
|
74
78
|
onError,
|
|
@@ -76,35 +80,9 @@ export function ToolVarRow({
|
|
|
76
80
|
const [editor, setEditor] = useState<Editor>(null);
|
|
77
81
|
const [value, setValue] = useState('');
|
|
78
82
|
const [busy, setBusy] = useState(false);
|
|
79
|
-
const rootRef = useRef<HTMLDivElement>(null);
|
|
80
83
|
|
|
81
84
|
const label = variable.label ?? variable.name;
|
|
82
85
|
|
|
83
|
-
// Opening from a distance is a PROP CHANGE, not an event, so the editor state
|
|
84
|
-
// is adjusted during render against the previous signal — React's documented
|
|
85
|
-
// pattern for deriving state from a changed prop. It used to be an effect,
|
|
86
|
-
// which set state after paint: one frame of the row rendered closed, and the
|
|
87
|
-
// synchronous setState in an effect body is what `set-state-in-effect` flags.
|
|
88
|
-
// `seenSignal` starts undefined rather than at `editSignal` so a row that
|
|
89
|
-
// MOUNTS with a signal already on it still opens, as the effect version did.
|
|
90
|
-
const [seenSignal, setSeenSignal] = useState<number | undefined>(undefined);
|
|
91
|
-
if (editSignal !== seenSignal) {
|
|
92
|
-
setSeenSignal(editSignal);
|
|
93
|
-
if (editSignal) {
|
|
94
|
-
setValue('');
|
|
95
|
-
setEditor('value');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// The scroll stays an effect: it is a real DOM side effect and has to happen
|
|
100
|
-
// after the editor it scrolls to has been committed. The banner's button
|
|
101
|
-
// targets exactly one row; scrolling brings the editor to where the click
|
|
102
|
-
// happened conceptually — "fix THIS".
|
|
103
|
-
useEffect(() => {
|
|
104
|
-
if (!editSignal) return;
|
|
105
|
-
rootRef.current?.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
106
|
-
}, [editSignal]);
|
|
107
|
-
|
|
108
86
|
function open(next: Exclude<Editor, null>) {
|
|
109
87
|
setValue('');
|
|
110
88
|
setEditor(next);
|
|
@@ -158,7 +136,7 @@ export function ToolVarRow({
|
|
|
158
136
|
// or the owner can rotate the client. The caller needs a way back into
|
|
159
137
|
// consent that doesn't wait for the scope check to notice.
|
|
160
138
|
meta.push(
|
|
161
|
-
<Button key="reconnect" size="
|
|
139
|
+
<Button key="reconnect" size="sm" variant="quiet" disabled={busy} onClick={() => void signIn()}>
|
|
162
140
|
Reconnect
|
|
163
141
|
</Button>,
|
|
164
142
|
// "Signed in", not "Connected": at ROW level all we know is that a token
|
|
@@ -171,7 +149,7 @@ export function ToolVarRow({
|
|
|
171
149
|
);
|
|
172
150
|
if (mayEditClientSecret) {
|
|
173
151
|
meta.push(
|
|
174
|
-
<Button key="secret" size="
|
|
152
|
+
<Button key="secret" size="sm" variant="quiet" onClick={() => open('client-secret')}>
|
|
175
153
|
Replace client secret
|
|
176
154
|
</Button>,
|
|
177
155
|
);
|
|
@@ -196,7 +174,7 @@ export function ToolVarRow({
|
|
|
196
174
|
description = "The tool owner hasn't finished the sign-in setup yet.";
|
|
197
175
|
if (mayEditClientSecret) {
|
|
198
176
|
meta.push(
|
|
199
|
-
<Button key="secret" size="
|
|
177
|
+
<Button key="secret" size="sm" onClick={() => open('client-secret')}>
|
|
200
178
|
Set client secret
|
|
201
179
|
</Button>,
|
|
202
180
|
);
|
|
@@ -218,12 +196,12 @@ export function ToolVarRow({
|
|
|
218
196
|
);
|
|
219
197
|
if (canWrite) {
|
|
220
198
|
meta.push(
|
|
221
|
-
<Button key="replace" size="
|
|
199
|
+
<Button key="replace" size="sm" variant="quiet" onClick={() => open('value')}>
|
|
222
200
|
Replace
|
|
223
201
|
</Button>,
|
|
224
202
|
<Button
|
|
225
203
|
key="remove"
|
|
226
|
-
size="
|
|
204
|
+
size="sm"
|
|
227
205
|
variant="quiet"
|
|
228
206
|
disabled={busy}
|
|
229
207
|
onClick={() => void run(() => deleteAdminVar(slug, variable.name))}
|
|
@@ -239,7 +217,7 @@ export function ToolVarRow({
|
|
|
239
217
|
description = 'One value for the whole team';
|
|
240
218
|
if (canWrite) {
|
|
241
219
|
meta.push(
|
|
242
|
-
<Button key="set" size="
|
|
220
|
+
<Button key="set" size="sm" onClick={() => open('value')}>
|
|
243
221
|
Set key
|
|
244
222
|
</Button>,
|
|
245
223
|
);
|
|
@@ -290,9 +268,32 @@ export function ToolVarRow({
|
|
|
290
268
|
);
|
|
291
269
|
};
|
|
292
270
|
|
|
271
|
+
// Ahead of the row's own action, so a screen reader reads the label, what
|
|
272
|
+
// the variable is, that it is still needed, and then the button that
|
|
273
|
+
// supplies it. `sr-only` is out of flow, so the sighted layout is untouched.
|
|
274
|
+
if (unset) {
|
|
275
|
+
meta.unshift(
|
|
276
|
+
<span key="unset-sr" className="sr-only">
|
|
277
|
+
Required, not set
|
|
278
|
+
</span>,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
293
282
|
return (
|
|
294
|
-
<div
|
|
295
|
-
<ListRow
|
|
283
|
+
<div className="flex flex-col gap-1.5">
|
|
284
|
+
<ListRow
|
|
285
|
+
density="row"
|
|
286
|
+
label={label}
|
|
287
|
+
description={description}
|
|
288
|
+
meta={meta}
|
|
289
|
+
data-testid="tool-var-row"
|
|
290
|
+
// The Banner's own `wait` ground, so an unset row and the amber
|
|
291
|
+
// notices elsewhere on this page read as the same state. The border
|
|
292
|
+
// goes to full-strength `wait` rather than staying `line`: between two
|
|
293
|
+
// white rows a tint alone is easy to scroll past, and being missable
|
|
294
|
+
// is the entire complaint the banner existed to answer.
|
|
295
|
+
className={unset ? 'border-wait bg-wait-soft' : undefined}
|
|
296
|
+
/>
|
|
296
297
|
|
|
297
298
|
{editor && (
|
|
298
299
|
<div className="flex items-center gap-2 rounded-lg border border-line bg-surface px-3.5 py-3">
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { renderHook, waitFor, act } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
const api = vi.hoisted(() => ({
|
|
5
|
+
listSkills: vi.fn(),
|
|
6
|
+
getSkill: vi.fn(),
|
|
7
|
+
listPendingSkills: vi.fn(),
|
|
8
|
+
listToolSecrets: vi.fn(),
|
|
9
|
+
listPendingTools: vi.fn(),
|
|
10
|
+
fetchFileAccessBatch: vi.fn(),
|
|
11
|
+
listOpenChangeRequests: vi.fn(),
|
|
12
|
+
listMyChangeRequests: vi.fn(),
|
|
13
|
+
}));
|
|
14
|
+
vi.mock('../../services/library.api', () => ({
|
|
15
|
+
defaultWorkspaceId: () => 'main',
|
|
16
|
+
listSkills: api.listSkills,
|
|
17
|
+
getSkill: api.getSkill,
|
|
18
|
+
listPendingSkills: api.listPendingSkills,
|
|
19
|
+
}));
|
|
20
|
+
vi.mock('../../../secrets-vault/services/tool-secrets.api', () => ({ listToolSecrets: api.listToolSecrets }));
|
|
21
|
+
vi.mock('../../services/tools.api', () => ({ listPendingTools: api.listPendingTools }));
|
|
22
|
+
vi.mock('../../../access/api', () => ({ fetchFileAccessBatch: api.fetchFileAccessBatch }));
|
|
23
|
+
vi.mock('../../../change-requests/services/change-requests.api', () => ({
|
|
24
|
+
listOpenChangeRequests: api.listOpenChangeRequests,
|
|
25
|
+
listMyChangeRequests: api.listMyChangeRequests,
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
import { useLibraryData } from '../useLibraryData';
|
|
29
|
+
|
|
30
|
+
const SKILL = { name: 'deploy', description: '', path: 'Skills/Eng/deploy' };
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
for (const fn of Object.values(api)) fn.mockReset();
|
|
34
|
+
api.listSkills.mockResolvedValue([SKILL]);
|
|
35
|
+
api.getSkill.mockResolvedValue({ allowedTools: [] });
|
|
36
|
+
api.listPendingSkills.mockResolvedValue([]);
|
|
37
|
+
api.listToolSecrets.mockResolvedValue([]);
|
|
38
|
+
api.listPendingTools.mockResolvedValue([]);
|
|
39
|
+
api.fetchFileAccessBatch.mockResolvedValue({ results: {} });
|
|
40
|
+
api.listOpenChangeRequests.mockResolvedValue([]);
|
|
41
|
+
api.listMyChangeRequests.mockResolvedValue([]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The library is re-read after every access edit, credential save and
|
|
46
|
+
* change-request event, and a load is many round trips. Only the FIRST load
|
|
47
|
+
* is loud; a reload keeps what is on screen until the new answer lands —
|
|
48
|
+
* closing a Manage access dialog that changed nothing used to blank the page
|
|
49
|
+
* to "Loading the library…" for as long as the re-read took.
|
|
50
|
+
*/
|
|
51
|
+
describe('useLibraryData', () => {
|
|
52
|
+
it('the first load is loud, a reload is quiet: the catalog stays until the new answer lands', async () => {
|
|
53
|
+
const { result } = renderHook(() => useLibraryData());
|
|
54
|
+
expect(result.current.loading).toBe(true);
|
|
55
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
56
|
+
expect(result.current.skills).toEqual([SKILL]);
|
|
57
|
+
|
|
58
|
+
// The reload's answer is held back.
|
|
59
|
+
let answer!: (skills: typeof SKILL[]) => void;
|
|
60
|
+
api.listSkills.mockReturnValueOnce(
|
|
61
|
+
new Promise((resolve) => {
|
|
62
|
+
answer = resolve;
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
act(() => result.current.reload());
|
|
66
|
+
expect(result.current.loading).toBe(false);
|
|
67
|
+
expect(result.current.refreshing).toBe(true);
|
|
68
|
+
expect(result.current.skills).toEqual([SKILL]);
|
|
69
|
+
|
|
70
|
+
await act(async () => answer([]));
|
|
71
|
+
await waitFor(() => expect(result.current.refreshing).toBe(false));
|
|
72
|
+
expect(result.current.skills).toEqual([]);
|
|
73
|
+
expect(result.current.loading).toBe(false);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('a retry after a FAILED first load is loud again: there is nothing on screen to keep', async () => {
|
|
77
|
+
api.listSkills.mockRejectedValueOnce(new Error('network down'));
|
|
78
|
+
const { result } = renderHook(() => useLibraryData());
|
|
79
|
+
await waitFor(() => expect(result.current.error).toBe('network down'));
|
|
80
|
+
expect(result.current.loading).toBe(false);
|
|
81
|
+
act(() => result.current.reload());
|
|
82
|
+
expect(result.current.loading).toBe(true);
|
|
83
|
+
expect(result.current.error).toBeNull();
|
|
84
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
85
|
+
expect(result.current.skills).toEqual([SKILL]);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('a reload that fails keeps the catalog and reports the error, without going loud', async () => {
|
|
89
|
+
const { result } = renderHook(() => useLibraryData());
|
|
90
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
91
|
+
api.listSkills.mockRejectedValueOnce(new Error('network down'));
|
|
92
|
+
act(() => result.current.reload());
|
|
93
|
+
await waitFor(() => expect(result.current.error).toBe('network down'));
|
|
94
|
+
expect(result.current.loading).toBe(false);
|
|
95
|
+
expect(result.current.refreshing).toBe(false);
|
|
96
|
+
expect(result.current.skills).toEqual([SKILL]);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import type { PullRequestSummary } from '@bevel-software/platform-shared';
|
|
3
3
|
import { fetchFileAccessBatch } from '../../access/api';
|
|
4
4
|
import { listToolSecrets, type ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
|
|
5
|
+
import { listPendingTools, type PendingToolSummary } from '../services/tools.api';
|
|
5
6
|
import {
|
|
6
7
|
defaultWorkspaceId,
|
|
7
8
|
getSkill,
|
|
@@ -21,19 +22,37 @@ import {
|
|
|
21
22
|
* - skills — `GET /api/skills` (default-branch catalog, canRead-filtered)
|
|
22
23
|
* - tools — `GET /api/secrets/tools` (variables + per-user config status
|
|
23
24
|
* + per-tool `canWrite`)
|
|
24
|
-
* - ownership — "owned by me" =
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
* - ownership — "owned by me" = named in an `owner:` grant (directly or by
|
|
26
|
+
* role) on the skill's `SKILL.md` or the tool's `.tool` file:
|
|
27
|
+
* ONE `POST /workspace/:id/access/batch` with `verb: owner`
|
|
28
|
+
* on the default-branch workspace, skills and tools together
|
|
29
|
+
* (one more per 500 paths past the endpoint's cap).
|
|
30
|
+
* Write alone is not ownership — an Admin writes everywhere.
|
|
31
|
+
* - write — the skills' `SKILL.md` write verdict, the same batch without
|
|
32
|
+
* a verb; it drives the editor-side affordances, which a
|
|
33
|
+
* writer keeps whether or not they own. Tools reuse the
|
|
34
|
+
* `canWrite` the secrets route already computes
|
|
28
35
|
* - change requests — all open + the caller's own, for the review layer
|
|
29
36
|
* - pending skills — `GET /api/skills/pending`, the skills that exist only on
|
|
30
37
|
* an open change request's branch (author + approvers only)
|
|
38
|
+
* - pending tools — `GET /api/tools/pending`, the same for a `.tool` manual or
|
|
39
|
+
* an `mcp.json` server proposed on an open change request
|
|
31
40
|
*
|
|
32
41
|
* Non-critical failures degrade to empty sets rather than blocking the page —
|
|
33
42
|
* only the skills+tools pair failing surfaces as a load error.
|
|
34
43
|
*/
|
|
35
44
|
export interface LibraryData {
|
|
45
|
+
/**
|
|
46
|
+
* True until the FIRST load answers. A reload keeps what is on screen and
|
|
47
|
+
* swaps it when the new answer lands: the library is re-read after every
|
|
48
|
+
* access edit, credential save and change-request event, and a load is
|
|
49
|
+
* many round trips (one per skill for its frontmatter), so dropping the
|
|
50
|
+
* page to "Loading…" each time meant a long blank after closing a dialog
|
|
51
|
+
* that changed nothing.
|
|
52
|
+
*/
|
|
36
53
|
loading: boolean;
|
|
54
|
+
/** A load is in flight behind what is on screen. Absent means no. */
|
|
55
|
+
refreshing?: boolean;
|
|
37
56
|
error: string | null;
|
|
38
57
|
skills: LibrarySkillSummary[];
|
|
39
58
|
/**
|
|
@@ -43,8 +62,19 @@ export interface LibraryData {
|
|
|
43
62
|
*/
|
|
44
63
|
pendingSkills: PendingSkillSummary[];
|
|
45
64
|
tools: ToolSecrets[];
|
|
46
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Proposed tools, not yet released. Kept SEPARATE from `tools` for exactly
|
|
67
|
+
* the reason `pendingSkills` is kept out of `skills`: everything downstream
|
|
68
|
+
* of `tools` treats an entry as an integration that exists — it has a page, a
|
|
69
|
+
* connection state, secrets to fill in — and a proposal has none of that.
|
|
70
|
+
*/
|
|
71
|
+
pendingTools: PendingToolSummary[];
|
|
72
|
+
/** Skill names (folder ids) whose SKILL.md names the caller in an `owner:` grant. */
|
|
47
73
|
ownedSkills: Set<string>;
|
|
74
|
+
/** Skill names (folder ids) whose SKILL.md the caller can write. */
|
|
75
|
+
writableSkills: Set<string>;
|
|
76
|
+
/** Tool slugs whose `.tool` file names the caller in an `owner:` grant. */
|
|
77
|
+
ownedTools: Set<string>;
|
|
48
78
|
/**
|
|
49
79
|
* Per-skill `allowed-tools` frontmatter (name → entries), used to derive
|
|
50
80
|
* which integrations a skill needs. Loaded via one `getSkill` per catalog
|
|
@@ -61,34 +91,59 @@ export interface LibraryData {
|
|
|
61
91
|
export function useLibraryData(): LibraryData {
|
|
62
92
|
const [state, setState] = useState<Omit<LibraryData, 'reload'>>({
|
|
63
93
|
loading: true,
|
|
94
|
+
refreshing: false,
|
|
64
95
|
error: null,
|
|
65
96
|
skills: [],
|
|
66
97
|
pendingSkills: [],
|
|
98
|
+
pendingTools: [],
|
|
67
99
|
tools: [],
|
|
68
100
|
ownedSkills: new Set(),
|
|
101
|
+
writableSkills: new Set(),
|
|
102
|
+
ownedTools: new Set(),
|
|
69
103
|
allowedToolsBySkill: new Map(),
|
|
70
104
|
crs: [],
|
|
71
105
|
myCrNumbers: new Set(),
|
|
72
106
|
});
|
|
73
107
|
const [revision, setRevision] = useState(0);
|
|
108
|
+
/** Whether any load has answered with a catalog — what makes a reload quiet. */
|
|
109
|
+
const loadedOnce = useRef(false);
|
|
74
110
|
|
|
75
111
|
useEffect(() => {
|
|
76
112
|
let cancelled = false;
|
|
77
|
-
setState((s) => ({ ...s, loading: true, error: null }));
|
|
78
113
|
|
|
79
114
|
(async () => {
|
|
80
115
|
const [skills, tools] = await Promise.all([listSkills(), listToolSecrets()]);
|
|
81
116
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
117
|
+
const skillProbes = skills.map((s) => `${s.path}/SKILL.md`);
|
|
118
|
+
const ownerProbes = [...skillProbes, ...tools.map((t) => t.path)];
|
|
119
|
+
// The batch endpoint refuses more than 500 paths per request, so a large
|
|
120
|
+
// catalog goes out in slices of that size and the verdicts are merged.
|
|
121
|
+
// A failed slice is "no verdicts" for its paths: nothing pilled, nothing
|
|
122
|
+
// unlocked — and the other slices still stand. Slices go one after
|
|
123
|
+
// another, so a large catalog costs more round trips, never a burst: at
|
|
124
|
+
// most one request per verb is in flight. A load that was superseded
|
|
125
|
+
// (unmount, reload) stops sending slices; its verdicts are discarded.
|
|
126
|
+
const BATCH_LIMIT = 500;
|
|
127
|
+
const verdicts = async (paths: string[], verb: 'write' | 'owner') => {
|
|
128
|
+
const results: Record<string, boolean> = {};
|
|
129
|
+
for (let i = 0; i < paths.length && !cancelled; i += BATCH_LIMIT) {
|
|
130
|
+
const part = await fetchFileAccessBatch(
|
|
131
|
+
defaultWorkspaceId(),
|
|
132
|
+
paths.slice(i, i + BATCH_LIMIT),
|
|
133
|
+
verb,
|
|
134
|
+
).catch(() => ({ results: {} as Record<string, boolean> }));
|
|
135
|
+
Object.assign(results, part.results);
|
|
136
|
+
}
|
|
137
|
+
return { results };
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const [writable, ownership, crs, mine, pending, pendingTools, details] = await Promise.all([
|
|
141
|
+
verdicts(skillProbes, 'write'),
|
|
142
|
+
verdicts(ownerProbes, 'owner'),
|
|
89
143
|
listOpenChangeRequests().catch(() => [] as PullRequestSummary[]),
|
|
90
144
|
listMyChangeRequests().catch(() => [] as PullRequestSummary[]),
|
|
91
145
|
listPendingSkills().catch(() => [] as PendingSkillSummary[]),
|
|
146
|
+
listPendingTools().catch(() => [] as PendingToolSummary[]),
|
|
92
147
|
Promise.all(
|
|
93
148
|
skills.map(
|
|
94
149
|
(s): Promise<[string, string[]]> =>
|
|
@@ -100,16 +155,21 @@ export function useLibraryData(): LibraryData {
|
|
|
100
155
|
]);
|
|
101
156
|
|
|
102
157
|
if (cancelled) return;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
158
|
+
// Fail closed: a path missing from the verdicts is a no.
|
|
159
|
+
const skillsWhere = (results: Record<string, boolean>) =>
|
|
160
|
+
new Set(skills.filter((s) => results[`${s.path}/SKILL.md`] === true).map((s) => s.name));
|
|
161
|
+
loadedOnce.current = true;
|
|
106
162
|
setState({
|
|
107
163
|
loading: false,
|
|
164
|
+
refreshing: false,
|
|
108
165
|
error: null,
|
|
109
166
|
skills,
|
|
110
167
|
pendingSkills: pending,
|
|
111
168
|
tools,
|
|
112
|
-
|
|
169
|
+
pendingTools,
|
|
170
|
+
ownedSkills: skillsWhere(ownership.results),
|
|
171
|
+
writableSkills: skillsWhere(writable.results),
|
|
172
|
+
ownedTools: new Set(tools.filter((t) => ownership.results[t.path] === true).map((t) => t.slug)),
|
|
113
173
|
allowedToolsBySkill: new Map(details),
|
|
114
174
|
crs: crs.filter((c) => c.state === 'open'),
|
|
115
175
|
myCrNumbers: new Set(mine.map((c) => c.number)),
|
|
@@ -119,6 +179,7 @@ export function useLibraryData(): LibraryData {
|
|
|
119
179
|
setState((s) => ({
|
|
120
180
|
...s,
|
|
121
181
|
loading: false,
|
|
182
|
+
refreshing: false,
|
|
122
183
|
error: err instanceof Error ? err.message : "Couldn't load the library.",
|
|
123
184
|
}));
|
|
124
185
|
});
|
|
@@ -128,7 +189,19 @@ export function useLibraryData(): LibraryData {
|
|
|
128
189
|
};
|
|
129
190
|
}, [revision]);
|
|
130
191
|
|
|
131
|
-
|
|
192
|
+
// The flags are flipped HERE, from the event that asks for the load, not
|
|
193
|
+
// in the effect (a synchronous setState there costs a cascading render on
|
|
194
|
+
// every revision). The first load is loud — `useState(true)` above — and a
|
|
195
|
+
// reload is quiet: `refreshing` behind what is on screen, the error
|
|
196
|
+
// cleared for the new attempt.
|
|
197
|
+
const reload = useCallback(() => {
|
|
198
|
+
// Quiet only once a load has ANSWERED: a retry after a failed first load
|
|
199
|
+
// has nothing on screen to keep, and goes loud like the first attempt.
|
|
200
|
+
setState((s) =>
|
|
201
|
+
s.loading ? s : loadedOnce.current ? { ...s, refreshing: true, error: null } : { ...s, loading: true, error: null },
|
|
202
|
+
);
|
|
203
|
+
setRevision((r) => r + 1);
|
|
204
|
+
}, []);
|
|
132
205
|
|
|
133
206
|
return { ...state, reload };
|
|
134
207
|
}
|