@bevel-software/platform-core-frontend 0.14.0 → 0.19.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 +34 -26
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +38 -1
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/email.ts +37 -1
- package/src/lib/utils.ts +2 -0
- 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 +781 -76
- 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__/plugin-token.test.ts +21 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +192 -10
- package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
- 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__/ConnectionKeysPage.test.tsx +266 -0
- 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/ConnectionKeysPage.tsx +269 -0
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/connection-keys.api.ts +47 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- 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/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- 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 +109 -4
- 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 +104 -99
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
- 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 +115 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
- 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 +391 -78
- package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
- 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 +183 -0
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +75 -0
- package/src/modules/library/__tests__/link-membership.test.ts +129 -0
- 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 +67 -0
- 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/__tests__/useJoinRequests.test.tsx +46 -0
- 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 +107 -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 +149 -34
- package/src/modules/library/components/LibraryLayout.tsx +120 -247
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
- package/src/modules/library/components/LockedPluginView.tsx +63 -35
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +19 -5
- package/src/modules/library/components/PageActions.tsx +31 -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 +123 -23
- package/src/modules/library/components/PluginExtras.tsx +143 -18
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +234 -38
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +271 -238
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +204 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- 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 +132 -23
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
- 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 +116 -17
- 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/useJoinRequests.ts +48 -18
- 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 +229 -82
- package/src/modules/library/routes/library-paths.ts +46 -35
- package/src/modules/library/services/library.api.ts +89 -17
- package/src/modules/library/services/plugins.api.ts +161 -9
- 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 +268 -37
- 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 +102 -0
- package/src/modules/library/utils/status.ts +204 -35
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
- 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 +154 -0
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +16 -22
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
- package/src/modules/settings/services/github-facade.api.ts +66 -0
- package/src/modules/settings/settings-nav-items.tsx +10 -2
- 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 +615 -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 +711 -40
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +218 -3
- 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 +395 -124
- 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 +659 -36
- 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 +6 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
- package/src/modules/workspace/components/FileRoute.tsx +376 -22
- package/src/modules/workspace/components/FileViewer.tsx +166 -45
- 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 +2473 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -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 +89 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +207 -30
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -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 +130 -16
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
- 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 +126 -52
- 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 +59 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -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 +118 -0
- 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 +34 -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 -265
- 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,17 +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';
|
|
12
|
+
import { useLibrary } from '../../state/library-data';
|
|
13
|
+
import { pluginHoldingPath, pluginLabel, pluginNameForPath } from '../../utils/plugin-summary';
|
|
10
14
|
import { readOAuthFragment } from '../../utils/oauth-fragment';
|
|
11
15
|
import type { ToolCapability } from '../../services/tools.api';
|
|
12
16
|
import type { LibrarySkillSummary } from '../../services/library.api';
|
|
13
17
|
import { ToolConnectionSection } from './ToolConnectionSection';
|
|
14
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';
|
|
15
24
|
|
|
16
25
|
/**
|
|
17
26
|
* One tool, as a page.
|
|
@@ -57,26 +66,51 @@ export function ToolPage({
|
|
|
57
66
|
* endpoint must not survive the change.
|
|
58
67
|
*/
|
|
59
68
|
const [serverRevision, setServerRevision] = useState(0);
|
|
69
|
+
/** Whether the tool's delete confirmation is up. */
|
|
70
|
+
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
60
71
|
|
|
61
72
|
useEffect(() => {
|
|
62
73
|
// Consume the OAuth `#…` fragment, KEEPING the query string: on an
|
|
63
74
|
// mcp-declared tool the `?server=<slug>` param is the page's identity, and
|
|
64
75
|
// replacing with the bare pathname stranded a refresh (or any URL copy) on
|
|
65
76
|
// the ambiguous mcp.json address, which bounces to the plugin page.
|
|
66
|
-
if (oauthOutcome)
|
|
67
|
-
|
|
68
|
-
|
|
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();
|
|
69
85
|
}, [oauthOutcome]);
|
|
70
86
|
|
|
71
87
|
// Same rule as the skill page: back goes to the page the tool LIVES on —
|
|
72
88
|
// its plugin, or the personal page — never to a root the reader may not
|
|
73
|
-
// have come from.
|
|
74
|
-
|
|
89
|
+
// have come from. While the tool is still loading the path is empty, so
|
|
90
|
+
// the home is the root; a resolved identity of null falls back to the folder.
|
|
91
|
+
const data = useLibrary();
|
|
92
|
+
const toolPath = page.tool?.path ?? '';
|
|
93
|
+
const home = libraryHomeForItemPath(
|
|
94
|
+
toolPath,
|
|
95
|
+
toolPath ? pluginNameForPath(toolPath, data.pluginSummaries) : undefined,
|
|
96
|
+
(n) => pluginLabel(n, data.pluginSummaries),
|
|
97
|
+
);
|
|
75
98
|
const backLink = (
|
|
76
99
|
<Button variant="quiet" size="sm" onClick={() => navigate(home.path)}>
|
|
77
100
|
{`‹ ${home.label}`}
|
|
78
101
|
</Button>
|
|
79
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);
|
|
80
114
|
|
|
81
115
|
if (page.loading) {
|
|
82
116
|
return <div className="py-16 text-center text-ui text-ink-muted">Loading…</div>;
|
|
@@ -125,23 +159,71 @@ export function ToolPage({
|
|
|
125
159
|
</Banner>
|
|
126
160
|
)}
|
|
127
161
|
|
|
128
|
-
|
|
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`.
|
|
177
|
+
|
|
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.
|
|
129
189
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
+
/>
|
|
139
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
|
+
)}
|
|
140
210
|
{/* No `Manage access` here, deliberately. Access is decided at the
|
|
141
211
|
PLUGIN — a tool inherits its folder's `access.md`, so an editor on
|
|
142
212
|
this page would either duplicate the plugin's one or quietly write a
|
|
143
213
|
per-file override that nobody looking at the plugin would see. The
|
|
144
|
-
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
|
+
/>
|
|
145
227
|
</header>
|
|
146
228
|
|
|
147
229
|
{actionError && (
|
|
@@ -201,6 +283,23 @@ export function ToolPage({
|
|
|
201
283
|
make this tool — the `.tool`, or the plugin `mcp.json` that declares
|
|
202
284
|
the server. */}
|
|
203
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
|
+
)}
|
|
204
303
|
</Article>
|
|
205
304
|
);
|
|
206
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
|
+
});
|
|
@@ -40,16 +40,41 @@ export interface JoinRequestsState {
|
|
|
40
40
|
reload(): void;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Where the requests come from. The default is a plugin's join requests; a
|
|
45
|
+
* skill page passes the skill's write-access endpoints instead — same
|
|
46
|
+
* proposals, same accept-by-grant, a different folder.
|
|
47
|
+
*/
|
|
48
|
+
export interface JoinRequestsApi {
|
|
49
|
+
list(name: string): Promise<JoinRequest[]>;
|
|
50
|
+
reconcile(name: string, number: number): Promise<boolean>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Lazy wrappers, not the functions themselves: the plugin API is resolved at
|
|
54
|
+
// call time, so a surface that never lists requests never needs those exports.
|
|
55
|
+
const PLUGIN_JOIN_API: JoinRequestsApi = {
|
|
56
|
+
list: (name) => listJoinRequests(name),
|
|
57
|
+
reconcile: (name, number) => reconcileJoinRequest(name, number),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export function useJoinRequests(
|
|
61
|
+
plugin: string,
|
|
62
|
+
folder: string | null,
|
|
63
|
+
api: JoinRequestsApi = PLUGIN_JOIN_API,
|
|
64
|
+
): JoinRequestsState {
|
|
65
|
+
// Keyed by the plugin they came from: a page that moves from skill A to
|
|
66
|
+
// skill B without unmounting must not show A's requests until B's arrive —
|
|
67
|
+
// a banner that lets an editor grant A's proposal against B's folder.
|
|
68
|
+
const [loaded, setLoaded] = useState<{ plugin: string; rows: JoinRequest[] } | null>(null);
|
|
69
|
+
const requests = loaded?.plugin === plugin ? loaded.rows : [];
|
|
45
70
|
const [revision, setRevision] = useState(0);
|
|
46
71
|
const toast = useLibraryToast();
|
|
47
72
|
|
|
48
73
|
useEffect(() => {
|
|
49
74
|
let cancelled = false;
|
|
50
|
-
|
|
75
|
+
api.list(plugin)
|
|
51
76
|
.then((rows) => {
|
|
52
|
-
if (!cancelled)
|
|
77
|
+
if (!cancelled) setLoaded({ plugin, rows });
|
|
53
78
|
})
|
|
54
79
|
.catch(() => {
|
|
55
80
|
// Silent: a manager surface that fails must not put an error banner in
|
|
@@ -58,7 +83,7 @@ export function useJoinRequests(plugin: string, folder: string | null): JoinRequ
|
|
|
58
83
|
return () => {
|
|
59
84
|
cancelled = true;
|
|
60
85
|
};
|
|
61
|
-
}, [plugin, revision]);
|
|
86
|
+
}, [plugin, revision, api]);
|
|
62
87
|
|
|
63
88
|
const reload = useCallback(() => setRevision((r) => r + 1), []);
|
|
64
89
|
|
|
@@ -79,23 +104,28 @@ export function useJoinRequests(plugin: string, folder: string | null): JoinRequ
|
|
|
79
104
|
}
|
|
80
105
|
// Drop the accepted proposal locally so the row goes immediately; the
|
|
81
106
|
// refetch below is what makes it true.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
107
|
+
setLoaded((cur) =>
|
|
108
|
+
cur && cur.plugin === plugin
|
|
109
|
+
? {
|
|
110
|
+
...cur,
|
|
111
|
+
rows: cur.rows.map((r) =>
|
|
112
|
+
r.number === request.number
|
|
113
|
+
? {
|
|
114
|
+
...r,
|
|
115
|
+
proposals: r.proposals.filter(
|
|
116
|
+
(p) => !(p.id === proposal.id && p.verb === proposal.verb),
|
|
117
|
+
),
|
|
118
|
+
}
|
|
119
|
+
: r,
|
|
120
|
+
),
|
|
121
|
+
}
|
|
122
|
+
: cur,
|
|
93
123
|
);
|
|
94
124
|
toast(`${proposal.label} now has ${proposal.verb} access.`);
|
|
95
|
-
await
|
|
125
|
+
await api.reconcile(plugin, request.number).catch(() => false);
|
|
96
126
|
setRevision((r) => r + 1);
|
|
97
127
|
},
|
|
98
|
-
[folder, plugin, toast],
|
|
128
|
+
[folder, plugin, toast, api],
|
|
99
129
|
);
|
|
100
130
|
|
|
101
131
|
const decline = useCallback(
|