@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
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import { DEFAULT_KB_LAYOUT, configureKbLayout } from '@bevel-software/platform-shared';
|
|
3
|
+
import type { AccessPrincipalRef, PathPrincipals } from '../../../access/api';
|
|
4
|
+
import type { FileTreeEntry } from '@bevel-software/platform-shared';
|
|
5
|
+
import {
|
|
6
|
+
accessChangeLines,
|
|
7
|
+
deleteSentence,
|
|
8
|
+
moveQuestion,
|
|
9
|
+
moveSentence,
|
|
10
|
+
moveWarnings,
|
|
11
|
+
platformFileDragRefusal,
|
|
12
|
+
platformFileMoveRefusal,
|
|
13
|
+
principalLabel,
|
|
14
|
+
} from '../treeConfirm';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The delete question counts what the listing shows. When the caller's read
|
|
18
|
+
* rules kept entries out of it, the delete still takes them, so the sentence
|
|
19
|
+
* stops naming a count as the whole and says what the count is.
|
|
20
|
+
*/
|
|
21
|
+
describe('deleteSentence', () => {
|
|
22
|
+
const folder: FileTreeEntry = {
|
|
23
|
+
name: 'Sales',
|
|
24
|
+
relativePath: 'knowledge-base/KnowledgeBase/Sales',
|
|
25
|
+
type: 'directory',
|
|
26
|
+
children: [
|
|
27
|
+
{ name: 'a.md', relativePath: 'knowledge-base/KnowledgeBase/Sales/a.md', type: 'file' },
|
|
28
|
+
{ name: 'b.md', relativePath: 'knowledge-base/KnowledgeBase/Sales/b.md', type: 'file' },
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
it('counts the files it can see when the listing is whole', () => {
|
|
33
|
+
expect(deleteSentence(folder)).toBe('Delete Sales and its 2 files?');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('says "everything in it" when the folder had entries withheld', () => {
|
|
37
|
+
expect(deleteSentence(folder, undefined, true)).toBe(
|
|
38
|
+
'Delete Sales and everything in it? (2 files on this branch you can see; it holds more you can\'t.)',
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* What the move confirmation says about access. The tester who failed the
|
|
45
|
+
* previous move warning asked for names — "these people would lose the
|
|
46
|
+
* following access, these people would gain the following access" — so these
|
|
47
|
+
* cases are the sentences, not the resolution: the resolver's before and after
|
|
48
|
+
* lists go in, the lines the dialog reads go out.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
const group = (name: string): AccessPrincipalRef => ({ kind: 'group', name });
|
|
52
|
+
const role = (name: string): AccessPrincipalRef => ({ kind: 'role', name });
|
|
53
|
+
const person = (name: string, email: string): AccessPrincipalRef => ({ kind: 'person', name, email });
|
|
54
|
+
const plugin = (token: string): AccessPrincipalRef => ({ kind: 'plugin', name: token });
|
|
55
|
+
|
|
56
|
+
/** The layout is module state shared by the whole file; each test that names one puts the defaults back. */
|
|
57
|
+
afterEach(() => configureKbLayout({ ...DEFAULT_KB_LAYOUT }));
|
|
58
|
+
|
|
59
|
+
const side = (read: AccessPrincipalRef[], write: AccessPrincipalRef[] = []): PathPrincipals => ({
|
|
60
|
+
read,
|
|
61
|
+
write,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('accessChangeLines', () => {
|
|
65
|
+
it('names who loses access, by verb', () => {
|
|
66
|
+
const change = accessChangeLines(
|
|
67
|
+
side([group('Engineering')], [group('Engineering')]),
|
|
68
|
+
side([], []),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(change.lose).toEqual([
|
|
72
|
+
'Engineering: can no longer open',
|
|
73
|
+
'Engineering: can no longer edit',
|
|
74
|
+
]);
|
|
75
|
+
expect(change.gain).toEqual([]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('names who gains access, by verb', () => {
|
|
79
|
+
const change = accessChangeLines(side([], []), side([group('Product')], [group('Product')]));
|
|
80
|
+
|
|
81
|
+
expect(change.lose).toEqual([]);
|
|
82
|
+
expect(change.gain).toEqual(['Product: can open', 'Product: can edit']);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('lists both blocks when the move costs one group and serves another', () => {
|
|
86
|
+
const change = accessChangeLines(side([group('Engineering')]), side([group('Product')]));
|
|
87
|
+
|
|
88
|
+
expect(change.lose).toEqual(['Engineering: can no longer open']);
|
|
89
|
+
expect(change.gain).toEqual(['Product: can open']);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('reports no change at all when both sides resolve the same', () => {
|
|
93
|
+
const both = side([group('Engineering'), person('Ali Raza', 'ali@x.io')], [group('Engineering')]);
|
|
94
|
+
|
|
95
|
+
expect(accessChangeLines(both, both)).toEqual({ lose: [], gain: [] });
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('is unmoved by the order the resolver happens to list principals in', () => {
|
|
99
|
+
const before = side([group('Engineering'), group('Product')]);
|
|
100
|
+
const after = side([group('Product'), group('Engineering')]);
|
|
101
|
+
|
|
102
|
+
expect(accessChangeLines(before, after)).toEqual({ lose: [], gain: [] });
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('names a directly granted person, by the name on the grant', () => {
|
|
106
|
+
const change = accessChangeLines(side([person('Ali Raza', 'ali@x.io')]), side([]));
|
|
107
|
+
|
|
108
|
+
expect(change.lose).toEqual(['Ali Raza: can no longer open']);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('matches a person on their address, whatever name each side carries', () => {
|
|
112
|
+
const change = accessChangeLines(
|
|
113
|
+
side([person('Ali Raza', 'ali@x.io')]),
|
|
114
|
+
side([person('ali@x.io', 'ALI@x.io')]),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
expect(change).toEqual({ lose: [], gain: [] });
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('falls back to a nameless person’s address rather than an empty line', () => {
|
|
121
|
+
const change = accessChangeLines(side([]), side([person('', 'ali@x.io')]));
|
|
122
|
+
|
|
123
|
+
expect(change.gain).toEqual(['ali@x.io: can open']);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('keeps a group and a same-named role apart — they are different principals', () => {
|
|
127
|
+
const change = accessChangeLines(side([group('Design')]), side([role('Design')]));
|
|
128
|
+
|
|
129
|
+
expect(change.lose).toEqual(['Design: can no longer open']);
|
|
130
|
+
expect(change.gain).toEqual(['Design: can open']);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('names a plugin principal as the share sheet does', () => {
|
|
134
|
+
const change = accessChangeLines(side([]), side([plugin('plugin/GTM/read')]));
|
|
135
|
+
|
|
136
|
+
expect(change.gain).toEqual(['GTM · readers: can open']);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('names the built-in everyone role Everyone', () => {
|
|
140
|
+
const change = accessChangeLines(side([role('everyone')]), side([]));
|
|
141
|
+
|
|
142
|
+
expect(change.lose).toEqual(['Everyone: can no longer open']);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('puts one principal’s two verbs together, opening before editing', () => {
|
|
146
|
+
const change = accessChangeLines(
|
|
147
|
+
side([group('Engineering'), group('Ops')], [group('Ops')]),
|
|
148
|
+
side([]),
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
expect(change.lose).toEqual([
|
|
152
|
+
'Engineering: can no longer open',
|
|
153
|
+
'Ops: can no longer open',
|
|
154
|
+
'Ops: can no longer edit',
|
|
155
|
+
]);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('lists a principal in both blocks when it trades one verb for another', () => {
|
|
159
|
+
const change = accessChangeLines(
|
|
160
|
+
side([group('Engineering')], [group('Engineering')]),
|
|
161
|
+
side([group('Engineering')], []),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
expect(change.lose).toEqual(['Engineering: can no longer edit']);
|
|
165
|
+
expect(change.gain).toEqual([]);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('shows six lines and folds the rest into "and N more"', () => {
|
|
169
|
+
const many = Array.from({ length: 9 }, (_, i) => group(`Team ${i + 1}`));
|
|
170
|
+
const change = accessChangeLines(side(many), side([]));
|
|
171
|
+
|
|
172
|
+
expect(change.lose).toHaveLength(7);
|
|
173
|
+
expect(change.lose[5]).toBe('Team 6: can no longer open');
|
|
174
|
+
expect(change.lose[6]).toBe('and 3 more');
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('caps at six without a count when there are exactly six', () => {
|
|
178
|
+
const six = Array.from({ length: 6 }, (_, i) => group(`Team ${i + 1}`));
|
|
179
|
+
const change = accessChangeLines(side([]), side(six));
|
|
180
|
+
|
|
181
|
+
expect(change.gain).toHaveLength(6);
|
|
182
|
+
expect(change.gain.at(-1)).toBe('Team 6: can open');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('caps each block on its own', () => {
|
|
186
|
+
const losers = Array.from({ length: 8 }, (_, i) => group(`Old ${i + 1}`));
|
|
187
|
+
const change = accessChangeLines(side(losers), side([group('Product')]));
|
|
188
|
+
|
|
189
|
+
expect(change.lose.at(-1)).toBe('and 2 more');
|
|
190
|
+
expect(change.gain).toEqual(['Product: can open']);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe('the move question', () => {
|
|
195
|
+
it('asks it plainly, for the blocks to answer under', () => {
|
|
196
|
+
expect(moveQuestion('contract.pdf', 'Sales')).toBe('Move contract.pdf to Sales?');
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// The fallback sentence, still said when the access change is not known.
|
|
200
|
+
it("uses 's for a destination that does not end in s", () => {
|
|
201
|
+
expect(moveSentence('contract.pdf', 'Old')).toBe(
|
|
202
|
+
"Move contract.pdf to Old? Access to it will follow Old's rules from now on.",
|
|
203
|
+
);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("uses a bare ' for one that does", () => {
|
|
207
|
+
expect(moveSentence('contract.pdf', 'Sales')).toBe(
|
|
208
|
+
"Move contract.pdf to Sales? Access to it will follow Sales' rules from now on.",
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
describe('principalLabel', () => {
|
|
214
|
+
it('leaves a malformed plugin token as written rather than inventing a name', () => {
|
|
215
|
+
expect(principalLabel(plugin('plugin/GTM/delete'))).toBe('plugin/GTM/delete');
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const KB = 'knowledge-base';
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* What the tree refuses before it asks, and what it no longer warns about.
|
|
223
|
+
*
|
|
224
|
+
* The refusal is the server's sentence, decided by the shared predicate, so
|
|
225
|
+
* the sidebar cannot drift from the endpoint it would have called.
|
|
226
|
+
*/
|
|
227
|
+
describe('platformFileMoveRefusal', () => {
|
|
228
|
+
it('refuses the four platform files where the platform reads them', () => {
|
|
229
|
+
expect(platformFileMoveRefusal(`${KB}/access.md`, KB))
|
|
230
|
+
.toBe('access.md is a platform file and stays in its folder.');
|
|
231
|
+
expect(platformFileMoveRefusal(`${KB}/Sales/access.md`, KB))
|
|
232
|
+
.toBe('access.md is a platform file and stays in its folder.');
|
|
233
|
+
expect(platformFileMoveRefusal(`${KB}/Sales/.bevelignore`, KB))
|
|
234
|
+
.toBe('.bevelignore is a platform file and stays in its folder.');
|
|
235
|
+
expect(platformFileMoveRefusal(`${KB}/roles.yaml`, KB))
|
|
236
|
+
.toBe('roles.yaml is a platform file and stays in its folder.');
|
|
237
|
+
expect(platformFileMoveRefusal(`${KB}/AGENTS.md`, KB))
|
|
238
|
+
.toBe('AGENTS.md is a platform file and stays in its folder.');
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('leaves content alone, including a nested roles.yaml or AGENTS.md the platform never reads', () => {
|
|
242
|
+
expect(platformFileMoveRefusal(`${KB}/Sales/deal.md`, KB)).toBeNull();
|
|
243
|
+
expect(platformFileMoveRefusal(`${KB}/Sales/roles.yaml`, KB)).toBeNull();
|
|
244
|
+
expect(platformFileMoveRefusal(`${KB}/Sales/AGENTS.md`, KB)).toBeNull();
|
|
245
|
+
// Exact spelling, as the platform reads it.
|
|
246
|
+
expect(platformFileMoveRefusal(`${KB}/Sales/Access.md`, KB)).toBeNull();
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The tree's copy of the rule reads the layout the browser was served, so a
|
|
251
|
+
* deployment that renamed its guide gets the same two answers here as it
|
|
252
|
+
* does from the server: ours is managed, theirs is a page.
|
|
253
|
+
*/
|
|
254
|
+
it('follows the configured guide name — and lets go of AGENTS.md when it differs', () => {
|
|
255
|
+
configureKbLayout({ ...DEFAULT_KB_LAYOUT, agentsFile: 'HEXIS.md' });
|
|
256
|
+
expect(platformFileMoveRefusal(`${KB}/HEXIS.md`, KB))
|
|
257
|
+
.toBe('HEXIS.md is a platform file and stays in its folder.');
|
|
258
|
+
// The customer's own conventions file moves, renames and deletes like any
|
|
259
|
+
// page — which is the whole point of naming ours something else.
|
|
260
|
+
expect(platformFileMoveRefusal(`${KB}/AGENTS.md`, KB)).toBeNull();
|
|
261
|
+
expect(platformFileDragRefusal(`${KB}/AGENTS.md`, KB, false)).toBeNull();
|
|
262
|
+
// Root-only, like `roles.yaml`: a nested copy of ours is content too.
|
|
263
|
+
expect(platformFileMoveRefusal(`${KB}/Sales/HEXIS.md`, KB)).toBeNull();
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('refuses nothing outside the KB clone, or before the clone folder is known', () => {
|
|
267
|
+
// No repo-relative form to judge — the server is the gate and says the
|
|
268
|
+
// same sentence, so the tree stays quiet rather than guessing.
|
|
269
|
+
expect(platformFileMoveRefusal(`${KB}/access.md`, null)).toBeNull();
|
|
270
|
+
expect(platformFileMoveRefusal('scratch/access.md', KB)).toBeNull();
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
describe('platformFileDragRefusal', () => {
|
|
275
|
+
const sentence = (n: string) => `${n} is a platform file and stays in its folder.`;
|
|
276
|
+
|
|
277
|
+
it('is the rename refusal for anyone who is not an admin', () => {
|
|
278
|
+
for (const p of [`${KB}/access.md`, `${KB}/Sales/access.md`, `${KB}/Sales/.bevelignore`]) {
|
|
279
|
+
expect(platformFileDragRefusal(p, KB, false)).toBe(platformFileMoveRefusal(p, KB));
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('lets an admin drag a MISPLACED copy — the drag that puts one back', () => {
|
|
284
|
+
expect(platformFileDragRefusal(`${KB}/Sales/access.md`, KB, true)).toBeNull();
|
|
285
|
+
expect(platformFileDragRefusal(`${KB}/Sales/.bevelignore`, KB, true)).toBeNull();
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("never lets go of the root's own copy, which is the one a restore puts back", () => {
|
|
289
|
+
expect(platformFileDragRefusal(`${KB}/access.md`, KB, true)).toBe(sentence('access.md'));
|
|
290
|
+
expect(platformFileDragRefusal(`${KB}/roles.yaml`, KB, true)).toBe(sentence('roles.yaml'));
|
|
291
|
+
expect(platformFileDragRefusal(`${KB}/.bevelignore`, KB, true)).toBe(sentence('.bevelignore'));
|
|
292
|
+
expect(platformFileDragRefusal(`${KB}/AGENTS.md`, KB, true)).toBe(sentence('AGENTS.md'));
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('leaves ordinary content alone for either of them', () => {
|
|
296
|
+
for (const admin of [true, false]) {
|
|
297
|
+
expect(platformFileDragRefusal(`${KB}/Sales/deal.md`, KB, admin)).toBeNull();
|
|
298
|
+
expect(platformFileDragRefusal(`${KB}/access.md`, null, admin)).toBeNull();
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
describe('moveWarnings', () => {
|
|
304
|
+
it('no longer warns about a platform file — the move never reaches the dialog', () => {
|
|
305
|
+
expect(
|
|
306
|
+
moveWarnings({
|
|
307
|
+
sourcePath: `${KB}/KnowledgeBase/Legal/access.md`,
|
|
308
|
+
targetDir: `${KB}/KnowledgeBase/Sales`,
|
|
309
|
+
destinationLabel: 'Sales',
|
|
310
|
+
kbDirName: KB,
|
|
311
|
+
canWrite: null,
|
|
312
|
+
}),
|
|
313
|
+
).toEqual([]);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('still says what it alone knows: a denied destination and a change of root', () => {
|
|
317
|
+
expect(
|
|
318
|
+
moveWarnings({
|
|
319
|
+
sourcePath: `${KB}/KnowledgeBase/Legal/contract.pdf`,
|
|
320
|
+
targetDir: `${KB}/Data`,
|
|
321
|
+
destinationLabel: 'Data',
|
|
322
|
+
kbDirName: KB,
|
|
323
|
+
canWrite: false,
|
|
324
|
+
}),
|
|
325
|
+
).toEqual([
|
|
326
|
+
"You can't write to Data — the move will be refused.",
|
|
327
|
+
'This moves it out of KnowledgeBase/ into Data/ — the two roots are handled differently.',
|
|
328
|
+
]);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('does not predict a refusal for the one move a denied destination still takes', () => {
|
|
332
|
+
// The admin's restore: a misplaced access.md into a folder that has none.
|
|
333
|
+
// "The move will be refused" would be the wrong prediction — this is the
|
|
334
|
+
// move the destination's rules are bypassed for.
|
|
335
|
+
expect(
|
|
336
|
+
moveWarnings({
|
|
337
|
+
sourcePath: `${KB}/KnowledgeBase/Misplaced/access.md`,
|
|
338
|
+
targetDir: `${KB}/KnowledgeBase/Legal`,
|
|
339
|
+
destinationLabel: 'Legal',
|
|
340
|
+
kbDirName: KB,
|
|
341
|
+
canWrite: false,
|
|
342
|
+
isAdmin: true,
|
|
343
|
+
}),
|
|
344
|
+
).toEqual([
|
|
345
|
+
"You can't write to Legal, but putting access.md back where the platform reads it is allowed for an Admin.",
|
|
346
|
+
]);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it('promises a non-admin nothing: the exception is not theirs to use', () => {
|
|
350
|
+
// A nested `roles.yaml` is ordinary content, so anyone can drag one at
|
|
351
|
+
// the root — and for anyone but an admin the destination's refusal is
|
|
352
|
+
// exactly what happens.
|
|
353
|
+
expect(
|
|
354
|
+
moveWarnings({
|
|
355
|
+
sourcePath: `${KB}/KnowledgeBase/Misplaced/roles.yaml`,
|
|
356
|
+
targetDir: KB,
|
|
357
|
+
destinationLabel: 'the top level',
|
|
358
|
+
kbDirName: KB,
|
|
359
|
+
canWrite: false,
|
|
360
|
+
isAdmin: false,
|
|
361
|
+
}),
|
|
362
|
+
).toEqual(["You can't write to the top level — the move will be refused."]);
|
|
363
|
+
});
|
|
364
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { uploadErrorNextStep } from '../uploadError';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The banner's last line, pinned directly — it used to be reachable only by
|
|
6
|
+
* rendering a tree, which is exactly the coupling that let the classifier
|
|
7
|
+
* drift: the advice was picked by matching the backend's prose, so a reworded
|
|
8
|
+
* refusal silently started telling the user the wrong thing and no test said
|
|
9
|
+
* so. The status is the contract now.
|
|
10
|
+
*/
|
|
11
|
+
describe('uploadErrorNextStep', () => {
|
|
12
|
+
it('sends a refused writer to another folder, or to the owner', () => {
|
|
13
|
+
expect(uploadErrorNextStep(403)).toBe('Try another folder or ask its owner.');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('sends a lapsed session back to sign in — another folder would refuse the same way', () => {
|
|
17
|
+
expect(uploadErrorNextStep(401)).toBe('Sign in again, then try once more.');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('asks for a smaller file when the upload was too big', () => {
|
|
21
|
+
expect(uploadErrorNextStep(413)).toContain('try a smaller one');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('does not restate the size cap, which lives in the backend', () => {
|
|
25
|
+
// The old copy promised "Files up to 50 MB". The number is the
|
|
26
|
+
// backend's (`MAX_UPLOAD_BYTES`), and a change there must not leave this
|
|
27
|
+
// line quietly lying; the server's own reason carries the limit.
|
|
28
|
+
expect(uploadErrorNextStep(413)).not.toMatch(/\d/);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('says "try again" for anything else, including a failure with no response', () => {
|
|
32
|
+
expect(uploadErrorNextStep(500)).toBe('Try again, or pick another folder.');
|
|
33
|
+
expect(uploadErrorNextStep(undefined)).toBe('Try again, or pick another folder.');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in console diagnostics for the file page (`?trace=files`).
|
|
3
|
+
*
|
|
4
|
+
* Exists to reproduce a report where a file click changes the URL but the page
|
|
5
|
+
* stays on the empty state with no tab strip. `FileRoute` waits on two gates
|
|
6
|
+
* before it opens a file (the git status branch equals the URL branch, and the
|
|
7
|
+
* workspace for that branch bootstrapped), and while either is closed nothing
|
|
8
|
+
* is shown. The trace logs every run of that decision with its inputs, so a
|
|
9
|
+
* browser console tells which gate held the page.
|
|
10
|
+
*
|
|
11
|
+
* The flag is read from the query string once and kept in `sessionStorage`,
|
|
12
|
+
* because a tree click navigates to a clean file URL and would otherwise drop
|
|
13
|
+
* it after the first click. `?trace=off` clears it. Nothing here changes what
|
|
14
|
+
* the page does; with the flag off every call is a no-op.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const FILE_TRACE_STORAGE_KEY = 'hexis.trace.files';
|
|
18
|
+
const PREFIX = '[trace:files]';
|
|
19
|
+
|
|
20
|
+
// Stands in for `sessionStorage` when it is unavailable (private mode quotas,
|
|
21
|
+
// sandboxed frames), so the flag still holds for this page load.
|
|
22
|
+
let memoryFlag = false;
|
|
23
|
+
|
|
24
|
+
/** Reads `?trace=` from `search`, remembering or forgetting the flag for the session. */
|
|
25
|
+
export function syncFileTraceFlag(search: string): boolean {
|
|
26
|
+
const value = new URLSearchParams(search).get('trace');
|
|
27
|
+
if (value === 'off') memoryFlag = false;
|
|
28
|
+
try {
|
|
29
|
+
if (value === 'files') sessionStorage.setItem(FILE_TRACE_STORAGE_KEY, '1');
|
|
30
|
+
else if (value === 'off') sessionStorage.removeItem(FILE_TRACE_STORAGE_KEY);
|
|
31
|
+
} catch {
|
|
32
|
+
// Storage unavailable: `memoryFlag` carries it.
|
|
33
|
+
if (value === 'files') memoryFlag = true;
|
|
34
|
+
}
|
|
35
|
+
return isFileTraceEnabled();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function isFileTraceEnabled(): boolean {
|
|
39
|
+
try {
|
|
40
|
+
return sessionStorage.getItem(FILE_TRACE_STORAGE_KEY) === '1' || memoryFlag;
|
|
41
|
+
} catch {
|
|
42
|
+
return memoryFlag;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Logs one trace event when the flag is on. `fields` is logged as-is. */
|
|
47
|
+
export function traceFiles(event: string, fields: Record<string, unknown>): void {
|
|
48
|
+
if (!isFileTraceEnabled()) return;
|
|
49
|
+
console.info(PREFIX, event, { at: Math.round(performance.now()), ...fields });
|
|
50
|
+
}
|
|
@@ -1,45 +1,86 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AGENTS_DIR,
|
|
3
|
-
DATA_DIR,
|
|
4
2
|
KNOWLEDGE_BASE_DIR,
|
|
5
|
-
|
|
6
|
-
PLUGINS_DIR,
|
|
3
|
+
reservedRootDirNames,
|
|
7
4
|
type FileTreeEntry,
|
|
8
5
|
} from '@bevel-software/platform-shared';
|
|
9
6
|
import type { PendingEntry } from '../state/workspace.context';
|
|
10
7
|
|
|
11
8
|
// RESERVED is not the same as CREATED (see kb-layout.ts): core only seeds
|
|
12
|
-
// KnowledgeBase/ and Plugins/, but every reserved name renders as its
|
|
13
|
-
// when present — a distribution that owns the execution layer seeds
|
|
14
|
-
// Agents/ and Pipelines/, and a KB that has them must not see them
|
|
15
|
-
// into Knowledge as stray content.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
PIPELINES_DIR,
|
|
21
|
-
PLUGINS_DIR,
|
|
22
|
-
]);
|
|
9
|
+
// KnowledgeBase/, Skills/ and Plugins/, but every reserved name renders as its
|
|
10
|
+
// own root when present — a distribution that owns the execution layer seeds
|
|
11
|
+
// Data/, Agents/ and Pipelines/, and a KB that has them must not see them
|
|
12
|
+
// folded into Knowledge as stray content. A function, not a module-scope set:
|
|
13
|
+
// three of the names are configurable and arrive after this module loads.
|
|
14
|
+
export const KB_ROOT_DIRS = {
|
|
15
|
+
has: (name: string): boolean => reservedRootDirNames().has(name),
|
|
16
|
+
};
|
|
23
17
|
|
|
24
18
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
19
|
+
* The repository checkout inside the workspace tree: the direct child of the
|
|
20
|
+
* workspace root named by the deployment (`workspace.kbDirName`, which the
|
|
21
|
+
* bootstrap response already carries), or null when it is not there.
|
|
22
|
+
*
|
|
23
|
+
* A LOOKUP, not a search. This used to descend the tree until it met a node
|
|
24
|
+
* whose children included a well-known root name (`KnowledgeBase/`,
|
|
25
|
+
* `Plugins/`, …) — which is a guess, and on core-staging it guessed the
|
|
26
|
+
* WORKSPACE ROOT, because a stray `KnowledgeBase/` had been written beside
|
|
27
|
+
* the checkout. Every sidebar then read that directory: the stray became
|
|
28
|
+
* "Knowledge", the real checkout was folded in beneath it as ordinary
|
|
29
|
+
* content, and the Skills tree found no `Skills/` at all. The deployment
|
|
30
|
+
* NAMES the folder, so nothing has to be inferred from what happens to sit
|
|
31
|
+
* next to it.
|
|
32
|
+
*
|
|
33
|
+
* Null is an answer, not a cue to look elsewhere: the caller shows the
|
|
34
|
+
* empty-workspace state rather than rendering some other directory's
|
|
35
|
+
* contents (see `CHECKOUT_MISSING_MESSAGE`).
|
|
29
36
|
*/
|
|
30
|
-
export function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
export function checkoutRoot(
|
|
38
|
+
tree: FileTreeEntry | null,
|
|
39
|
+
kbDirName: string | null,
|
|
40
|
+
): FileTreeEntry | null {
|
|
41
|
+
if (!tree?.children || !kbDirName) return null;
|
|
42
|
+
return tree.children.find((c) => c.type === 'directory' && c.name === kbDirName) ?? null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether the tree shows the caller anything of the knowledge base at all.
|
|
47
|
+
* What does not count: the reserved root folders themselves (every knowledge
|
|
48
|
+
* base has them, and the server keeps them visible even to a reader who may
|
|
49
|
+
* open nothing inside), and the root `.bevelignore` an admin sees in a
|
|
50
|
+
* knowledge base nobody has written to yet. Anything else — a file, or a
|
|
51
|
+
* folder, at any depth — is an entry on screen.
|
|
52
|
+
*
|
|
53
|
+
* Read from the checkout down, like every other surface. A workspace whose
|
|
54
|
+
* checkout is missing shows nothing, whatever else was written beside it.
|
|
55
|
+
*/
|
|
56
|
+
export function treeHasVisibleEntries(tree: FileTreeEntry | null, kbDirName: string | null): boolean {
|
|
57
|
+
const kbRoot = checkoutRoot(tree, kbDirName);
|
|
58
|
+
if (!kbRoot) return false;
|
|
59
|
+
return (kbRoot.children ?? []).some((c) => {
|
|
60
|
+
if (c.type === 'file') return c.name !== '.bevelignore';
|
|
61
|
+
return !KB_ROOT_DIRS.has(c.name) || (c.children?.length ?? 0) > 0;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Whether ONE root of the tree — the folder at `rootPath` — shows anything.
|
|
67
|
+
* The Library renders `Skills/` and `Plugins/` as trees of their own, and each
|
|
68
|
+
* is empty on its own terms: a knowledge base full of notes still has an
|
|
69
|
+
* empty Skills tree, and the notice that says so belongs to that tree. A root
|
|
70
|
+
* that is not in the listing at all shows nothing.
|
|
71
|
+
*/
|
|
72
|
+
export function subtreeHasVisibleEntries(tree: FileTreeEntry | null, rootPath: string): boolean {
|
|
73
|
+
const root = findEntryByPath(tree, rootPath);
|
|
74
|
+
return (root?.children ?? []).some((c) => c.type !== 'file' || c.name !== '.bevelignore');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* How many entries the caller's read rules kept out of ONE folder's subtree —
|
|
79
|
+
* the folder's own `withheld`, which the server sets per directory. 0 for a
|
|
80
|
+
* folder the listing does not have, or one nothing was kept out of.
|
|
81
|
+
*/
|
|
82
|
+
export function subtreeWithheld(tree: FileTreeEntry | null, rootPath: string): number {
|
|
83
|
+
return findEntryByPath(tree, rootPath)?.withheld ?? 0;
|
|
43
84
|
}
|
|
44
85
|
|
|
45
86
|
/** Documents, as opposed to the data, config and archives beside them. */
|
|
@@ -59,26 +100,34 @@ const isAccessRulesFile = (entry: FileTreeEntry): boolean => entry.name.toLowerC
|
|
|
59
100
|
* the top of the knowledge tree, breadth-first, so the opening suggestion is a
|
|
60
101
|
* section heading rather than the fifth file inside the first folder.
|
|
61
102
|
*
|
|
62
|
-
* Scoped to exactly what the explorer browses under "Knowledge"
|
|
63
|
-
* `KnowledgeBase/` plus any
|
|
64
|
-
* Tools app's storage and is not a
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
103
|
+
* Scoped to exactly what the explorer browses under "Knowledge", and scoped
|
|
104
|
+
* to the CHECKOUT: `KnowledgeBase/` plus any content folder beside it inside
|
|
105
|
+
* `<kbDirName>/`. `Plugins/` is the Skills & Tools app's storage and is not a
|
|
106
|
+
* browsing destination here, and the loose files at the checkout root
|
|
107
|
+
* (`access.md`, `roles.yaml`) are how the deployment is configured, not
|
|
108
|
+
* something to read. A clone that predates the split has no named roots at
|
|
109
|
+
* all, so its whole checkout is the knowledge — including the loose files at
|
|
110
|
+
* its root, which in that layout are pages rather than configuration. A
|
|
111
|
+
* workspace with no checkout in it has nothing to offer.
|
|
68
112
|
*
|
|
69
113
|
* Fewer than `limit` — including none at all — is a legitimate answer for a
|
|
70
114
|
* knowledge base that is still empty; the caller says so rather than padding.
|
|
71
115
|
*/
|
|
72
|
-
export function suggestedPages(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
116
|
+
export function suggestedPages(
|
|
117
|
+
tree: FileTreeEntry | null,
|
|
118
|
+
kbDirName: string | null,
|
|
119
|
+
limit: number,
|
|
120
|
+
): FileTreeEntry[] {
|
|
121
|
+
const kbRoot = checkoutRoot(tree, kbDirName);
|
|
122
|
+
const split = kbRoot?.children?.some((c) => c.type === 'directory' && KB_ROOT_DIRS.has(c.name));
|
|
123
|
+
const roots = !kbRoot
|
|
124
|
+
? []
|
|
125
|
+
: split
|
|
126
|
+
? [
|
|
127
|
+
...(kbRoot.children ?? []).filter((c) => c.type === 'directory' && c.name === KNOWLEDGE_BASE_DIR),
|
|
128
|
+
...(kbRoot.children ?? []).filter((c) => c.type === 'directory' && !KB_ROOT_DIRS.has(c.name)),
|
|
129
|
+
]
|
|
130
|
+
: [kbRoot];
|
|
82
131
|
|
|
83
132
|
const pages: FileTreeEntry[] = [];
|
|
84
133
|
let level = roots;
|
|
@@ -93,7 +142,11 @@ export function suggestedPages(tree: FileTreeEntry | null, limit: number): FileT
|
|
|
93
142
|
if (entry.name.startsWith('.')) continue;
|
|
94
143
|
if (entry.type === 'file') {
|
|
95
144
|
if (READABLE_PAGE.test(entry.name) && !isAccessRulesFile(entry)) pages.push(entry);
|
|
96
|
-
} else if (entry.name
|
|
145
|
+
} else if (level === roots || !KB_ROOT_DIRS.has(entry.name)) {
|
|
146
|
+
// Below the roots, the reserved SET decides — not two names: a folder
|
|
147
|
+
// named after any reserved root, at any depth, is the same kind of
|
|
148
|
+
// thing the root selection above keeps out. The roots themselves are
|
|
149
|
+
// the selection's own answer (Knowledge is a reserved name too).
|
|
97
150
|
next.push(...(entry.children ?? []));
|
|
98
151
|
}
|
|
99
152
|
}
|
|
@@ -118,6 +171,28 @@ export function pathExistsInTree(tree: FileTreeEntry | null, relativePath: strin
|
|
|
118
171
|
return findEntryByPath(tree, relativePath) !== null;
|
|
119
172
|
}
|
|
120
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Return the tree without one exact workspace-relative path. Reuses untouched
|
|
176
|
+
* branches so a caller can apply it on every render without cloning the whole
|
|
177
|
+
* file tree when the server has already filtered the path.
|
|
178
|
+
*/
|
|
179
|
+
export function omitPathFromTree(
|
|
180
|
+
tree: FileTreeEntry | null,
|
|
181
|
+
relativePath: string,
|
|
182
|
+
): FileTreeEntry | null {
|
|
183
|
+
if (!tree || tree.relativePath === relativePath) return null;
|
|
184
|
+
if (!tree.children) return tree;
|
|
185
|
+
|
|
186
|
+
let changed = false;
|
|
187
|
+
const children: FileTreeEntry[] = [];
|
|
188
|
+
for (const child of tree.children) {
|
|
189
|
+
const visible = omitPathFromTree(child, relativePath);
|
|
190
|
+
if (visible !== child) changed = true;
|
|
191
|
+
if (visible) children.push(visible);
|
|
192
|
+
}
|
|
193
|
+
return changed ? { ...tree, children } : tree;
|
|
194
|
+
}
|
|
195
|
+
|
|
121
196
|
function collectFilesByBasename(tree: FileTreeEntry | null, basename: string, acc: string[]): void {
|
|
122
197
|
if (!tree) return;
|
|
123
198
|
if (tree.type === 'file' && tree.name === basename) acc.push(tree.relativePath);
|
|
@@ -154,10 +229,9 @@ export function mergePendingIntoTree(
|
|
|
154
229
|
): FileTreeEntry {
|
|
155
230
|
if (pending.size === 0) return tree;
|
|
156
231
|
|
|
232
|
+
// A spread, so what the server set on a folder (`withheld`) survives the copy.
|
|
157
233
|
const cloneNode = (node: FileTreeEntry): FileTreeEntry => ({
|
|
158
|
-
|
|
159
|
-
relativePath: node.relativePath,
|
|
160
|
-
type: node.type,
|
|
234
|
+
...node,
|
|
161
235
|
children: node.children ? node.children.map(cloneNode) : undefined,
|
|
162
236
|
});
|
|
163
237
|
const root = cloneNode(tree);
|