@bevel-software/platform-core-frontend 0.15.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/package.json +3 -3
- package/src/core/CoreAppShell.tsx +20 -9
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +11 -3
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/email.ts +37 -1
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +140 -6
- package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
- package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
- package/src/modules/admin/components/AddMemberInput.tsx +268 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/audit/__tests__/AuditLogPage.test.tsx +312 -0
- package/src/modules/audit/components/AuditEventsPanel.tsx +319 -0
- package/src/modules/audit/components/AuditLogPage.tsx +373 -0
- package/src/modules/audit/components/principal-grouping.ts +49 -0
- package/src/modules/audit/services/audit.api.ts +98 -0
- package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
- package/src/modules/auth/components/AccountPage.tsx +73 -54
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/auth/services/account.api.ts +78 -4
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
- package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
- package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
- package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
- package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
- package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
- package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
- package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
- package/src/modules/change-requests/services/change-requests.api.ts +57 -1
- package/src/modules/change-requests/services/denied-file.api.ts +53 -0
- package/src/modules/change-requests/services/propose.api.ts +97 -8
- package/src/modules/change-requests/utils/approval.ts +15 -0
- package/src/modules/change-requests/utils/author.ts +32 -0
- package/src/modules/change-requests/utils/readFailure.ts +110 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +108 -3
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
- package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +47 -4
- package/src/modules/library/__tests__/link-membership.test.ts +13 -4
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +146 -45
- package/src/modules/library/components/LibraryLayout.tsx +119 -256
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
- package/src/modules/library/components/LockedPluginView.tsx +62 -34
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +16 -2
- package/src/modules/library/components/PageActions.tsx +11 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
- package/src/modules/library/components/PluginExtras.tsx +140 -17
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +157 -41
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +239 -263
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +141 -28
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +103 -17
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
- package/src/modules/library/routes/library-paths.ts +26 -28
- package/src/modules/library/services/library.api.ts +38 -20
- package/src/modules/library/services/plugins.api.ts +69 -8
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +170 -32
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +75 -9
- package/src/modules/library/utils/status.ts +135 -33
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +10 -30
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +7 -6
- package/src/modules/settings/services/github-facade.api.ts +23 -0
- package/src/modules/settings/settings-nav-items.tsx +13 -3
- package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
- package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
- package/src/modules/setup/__tests__/setup.test.tsx +497 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +532 -43
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +141 -4
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
- package/src/modules/setup/utils/root-folders.ts +46 -0
- package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
- package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
- package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
- package/src/modules/workspace/components/FileRoute.tsx +353 -36
- package/src/modules/workspace/components/FileViewer.tsx +172 -46
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
- package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
- package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2533 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +381 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +206 -29
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +134 -1
- package/src/modules/workspace/services/workspace.api.ts +57 -4
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
- package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
- package/src/modules/workspace/state/open-change-requests.tsx +100 -12
- package/src/modules/workspace/state/workspace.context.ts +125 -19
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +112 -36
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +6 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +33 -5
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +25 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The form Copy path puts on the clipboard: root-anchored, `/<kbDirName>/…`.
|
|
3
|
+
*
|
|
4
|
+
* Markdown reads a slash-less path as relative to the CURRENT file's folder,
|
|
5
|
+
* so `knowledge-base/KnowledgeBase/x.md` pasted into a link in a subfolder
|
|
6
|
+
* resolves to a doubled path and the page says File not found. The leading
|
|
7
|
+
* slash anchors it at the workspace root, where it resolves from any folder.
|
|
8
|
+
*/
|
|
9
|
+
export function rootAnchoredPath(relativePath: string): string {
|
|
10
|
+
return relativePath.startsWith('/') ? relativePath : `/${relativePath}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `[` and `]` in a label would close the link early. Backslashes go first: a
|
|
15
|
+
* label already holding `\]` would otherwise become `\\]`, where Markdown
|
|
16
|
+
* reads the doubled backslash as one literal and the bracket as the close.
|
|
17
|
+
*/
|
|
18
|
+
function escapeLabel(label: string): string {
|
|
19
|
+
return label.replace(/\\/g, '\\\\').replace(/[[\]]/g, '\\$&');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Whether a root-anchored path names a file the way the explorer would: every
|
|
24
|
+
* segment a real name. A `..` would resolve to a different place than the
|
|
25
|
+
* text says, an empty segment doubles a slash, and a backslash is never part
|
|
26
|
+
* of a workspace path — such a clipboard is pasted as text, not turned into a
|
|
27
|
+
* link to somewhere else. One trailing slash is how a folder's path is
|
|
28
|
+
* copied and is allowed; a second one is an empty segment like any other.
|
|
29
|
+
*/
|
|
30
|
+
function isPlainWorkspacePath(text: string): boolean {
|
|
31
|
+
const segments = text.replace(/\/$/, '').split('/').slice(1);
|
|
32
|
+
return segments.every((s) => s !== '' && s !== '.' && s !== '..' && !s.includes('\\'));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A destination with a space or a bracket goes in angle brackets
|
|
37
|
+
* (`(<Some File.md>)`) — plain CommonMark, and the same form the renderer's
|
|
38
|
+
* `escapeSpacesInLinkDestinations` produces.
|
|
39
|
+
*/
|
|
40
|
+
function destination(target: string): string {
|
|
41
|
+
return /[\s()<>]/.test(target) ? `<${target}>` : target;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** `Foo.md` → `Foo`; a dotfile or an extension-less name stays whole. */
|
|
45
|
+
function stem(name: string): string {
|
|
46
|
+
const dot = name.lastIndexOf('.');
|
|
47
|
+
return dot > 0 ? name.slice(0, dot) : name;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* What pasting `clipboard` over `selection` should insert, or `null` for an
|
|
52
|
+
* ordinary paste.
|
|
53
|
+
*
|
|
54
|
+
* Only a clipboard that is exactly ONE bare workspace path (`/<kbDirName>/…`,
|
|
55
|
+
* spaces in folder names allowed) or ONE `http(s)` URL becomes a link. The
|
|
56
|
+
* label is the selection when there is one; otherwise the file name without
|
|
57
|
+
* its extension for a path, and host plus path for a URL. The path stays in
|
|
58
|
+
* its root-anchored form, so the link works from any folder.
|
|
59
|
+
*/
|
|
60
|
+
export function markdownLinkForPaste(
|
|
61
|
+
clipboard: string,
|
|
62
|
+
kbDirName: string | null,
|
|
63
|
+
selection = '',
|
|
64
|
+
): string | null {
|
|
65
|
+
const text = clipboard.trim();
|
|
66
|
+
if (!text || /[\r\n]/.test(text)) return null;
|
|
67
|
+
|
|
68
|
+
if (kbDirName && text.startsWith(`/${kbDirName}/`)) {
|
|
69
|
+
if (!isPlainWorkspacePath(text)) return null;
|
|
70
|
+
const name = text.replace(/\/$/, '').split('/').pop() ?? '';
|
|
71
|
+
if (!name || name === kbDirName) return null;
|
|
72
|
+
// The link resolver splits at the first `#` and percent-decodes the rest,
|
|
73
|
+
// so a literal `#` or `%` in a file name is encoded to survive both.
|
|
74
|
+
const target = text.replace(/%/g, '%25').replace(/#/g, '%23');
|
|
75
|
+
return `[${escapeLabel(selection || stem(name))}](${destination(target)})`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (/^https?:\/\/\S+$/i.test(text)) {
|
|
79
|
+
let url: URL;
|
|
80
|
+
try {
|
|
81
|
+
url = new URL(text);
|
|
82
|
+
} catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const label = selection || `${url.host}${url.pathname.replace(/\/+$/, '')}`;
|
|
86
|
+
return `[${escapeLabel(label)}](${destination(text)})`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isPlatformFile,
|
|
3
|
+
isPlatformRestoreShape,
|
|
4
|
+
isRootPlatformFile,
|
|
5
|
+
platformFileRefusal,
|
|
6
|
+
type FileTreeEntry,
|
|
7
|
+
} from '@bevel-software/platform-shared';
|
|
8
|
+
import {
|
|
9
|
+
parsePluginPrincipalToken,
|
|
10
|
+
pluginPrincipalLabel,
|
|
11
|
+
type AccessPrincipalRef,
|
|
12
|
+
type PathPrincipals,
|
|
13
|
+
type ProspectiveAccess,
|
|
14
|
+
} from '../../access/api';
|
|
15
|
+
import { KB_ROOT_DIRS } from './fileTree';
|
|
16
|
+
|
|
17
|
+
// What the tree's delete and move confirmations say — see
|
|
18
|
+
// `components/TreeActionConfirm.tsx` for the dialog that says it.
|
|
19
|
+
|
|
20
|
+
/** The repo-relative form of a workspace-relative path, or null outside the KB clone. */
|
|
21
|
+
function repoRelative(wsRelativePath: string, kbDirName: string | null): string | null {
|
|
22
|
+
if (!kbDirName) return null;
|
|
23
|
+
const prefix = `${kbDirName}/`;
|
|
24
|
+
return wsRelativePath.startsWith(prefix) ? wsRelativePath.slice(prefix.length) : null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Why this row may not be renamed, moved or dragged — the same sentence the
|
|
29
|
+
* server refuses with — or null when it may.
|
|
30
|
+
*
|
|
31
|
+
* Judged on the path's REPO-relative form, because that is what the platform
|
|
32
|
+
* reads: `roles.yaml` and the agent guide (`AGENTS.md` unless this deployment
|
|
33
|
+
* named it something else) count at the repository root only, so a nested file
|
|
34
|
+
* of either name is ordinary content and stays draggable. Outside
|
|
35
|
+
* the KB clone, and before `kbDirName` is known, nothing is refused here — the
|
|
36
|
+
* server is the gate and says the same sentence.
|
|
37
|
+
*/
|
|
38
|
+
export function platformFileMoveRefusal(
|
|
39
|
+
wsRelativePath: string,
|
|
40
|
+
kbDirName: string | null,
|
|
41
|
+
): string | null {
|
|
42
|
+
const rel = repoRelative(wsRelativePath, kbDirName);
|
|
43
|
+
if (rel === null) return null;
|
|
44
|
+
return isPlatformFile(rel) ? platformFileRefusal(rel) : null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Why this row may not be DRAGGED, or null when it may — the rename refusal
|
|
49
|
+
* minus the one move that is a repair.
|
|
50
|
+
*
|
|
51
|
+
* An admin may put a misplaced platform file back where the platform reads it
|
|
52
|
+
* (a stray `access.md` into a folder that has none, a stray `.bevelignore`
|
|
53
|
+
* onto the root), and dragging it there is how a person does that. Refusing
|
|
54
|
+
* the drag on the row would leave that recovery reachable only over the API —
|
|
55
|
+
* for `access.md`, which is a platform file wherever it sits, not reachable
|
|
56
|
+
* from the sidebar at all — while the sentence shown promised what the server
|
|
57
|
+
* would say and the server would have said yes.
|
|
58
|
+
*
|
|
59
|
+
* So the row's own copy of the rule keeps only the part that is certain: the
|
|
60
|
+
* ROOT's copy never moves, and nobody but an admin moves any of them. What is
|
|
61
|
+
* left — which destination, and whether the disk agrees — the drop's own
|
|
62
|
+
* response says, because only the server knows it. A rename is never a
|
|
63
|
+
* repair (it lands the file beside the name the platform reads, not on it),
|
|
64
|
+
* so it keeps the full refusal.
|
|
65
|
+
*/
|
|
66
|
+
export function platformFileDragRefusal(
|
|
67
|
+
wsRelativePath: string,
|
|
68
|
+
kbDirName: string | null,
|
|
69
|
+
isAdmin: boolean,
|
|
70
|
+
): string | null {
|
|
71
|
+
const refusal = platformFileMoveRefusal(wsRelativePath, kbDirName);
|
|
72
|
+
if (refusal === null || !isAdmin) return refusal;
|
|
73
|
+
const rel = repoRelative(wsRelativePath, kbDirName);
|
|
74
|
+
return rel === null || isRootPlatformFile(rel) ? refusal : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Every file under a folder, at any depth — what a folder delete takes with it.
|
|
79
|
+
* `isProposed` names the rows that are only proposed (a change request's file
|
|
80
|
+
* this branch does not have): they are not on the branch, so the delete does
|
|
81
|
+
* not take them, and they are not counted.
|
|
82
|
+
*/
|
|
83
|
+
export function countFiles(entry: FileTreeEntry, isProposed: (path: string) => boolean = () => false): number {
|
|
84
|
+
if (entry.type === 'file') return isProposed(entry.relativePath) ? 0 : 1;
|
|
85
|
+
return (entry.children ?? []).reduce((n, child) => n + countFiles(child, isProposed), 0);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The reserved root a workspace-relative path sits in (`KnowledgeBase`,
|
|
90
|
+
* `Skills`, `Data`, …), or null when it sits in none — outside the KB clone,
|
|
91
|
+
* at its top level, or in a stray top-level folder.
|
|
92
|
+
*/
|
|
93
|
+
export function rootOf(path: string, kbDirName: string | null): string | null {
|
|
94
|
+
if (!kbDirName || !path.startsWith(`${kbDirName}/`)) return null;
|
|
95
|
+
const first = path.slice(kbDirName.length + 1).split('/')[0];
|
|
96
|
+
return first && KB_ROOT_DIRS.has(first) ? first : null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const possessive = (name: string) => (/s$/i.test(name) ? `${name}'` : `${name}'s`);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The delete question. A folder's count is of the files this listing SHOWS:
|
|
103
|
+
* when the caller's read rules kept entries out of THIS folder (`partial`),
|
|
104
|
+
* the delete still takes every file under it, seen or not, so the sentence
|
|
105
|
+
* says "everything in it" and gives the visible count as what it is.
|
|
106
|
+
*/
|
|
107
|
+
export function deleteSentence(
|
|
108
|
+
entry: FileTreeEntry,
|
|
109
|
+
isProposed?: (path: string) => boolean,
|
|
110
|
+
partial = false,
|
|
111
|
+
): string {
|
|
112
|
+
if (entry.type === 'file') return `Delete ${entry.name}?`;
|
|
113
|
+
const n = countFiles(entry, isProposed);
|
|
114
|
+
const files = `${n} ${n === 1 ? 'file' : 'files'}`;
|
|
115
|
+
// "On this branch": a proposed-only row is shown but not counted, since the
|
|
116
|
+
// delete does not take it.
|
|
117
|
+
if (partial) return `Delete ${entry.name} and everything in it? (${files} on this branch you can see; it holds more you can't.)`;
|
|
118
|
+
return `Delete ${entry.name} and its ${files}?`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** `#12 "Title" by Ana (2 files)` — one open change request as a folder delete names it. */
|
|
122
|
+
export function folderRequestLine(request: {
|
|
123
|
+
number: number;
|
|
124
|
+
title: string;
|
|
125
|
+
authorName: string | null;
|
|
126
|
+
mine: boolean;
|
|
127
|
+
paths: string[];
|
|
128
|
+
}): string {
|
|
129
|
+
const by = request.mine ? 'by you' : request.authorName ? `by ${request.authorName}` : null;
|
|
130
|
+
const n = request.paths.length;
|
|
131
|
+
return `#${request.number} “${request.title}”${by ? ` ${by}` : ''} (${n} proposed ${n === 1 ? 'file' : 'files'})`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The move question on its own. The dialog follows it with what the access
|
|
136
|
+
* lookup found: the lose and gain blocks, "Nobody's access changes.", or —
|
|
137
|
+
* when the lookup could not answer — {@link moveSentence}'s older sentence
|
|
138
|
+
* and a note saying so.
|
|
139
|
+
*/
|
|
140
|
+
export function moveQuestion(name: string, destination: string): string {
|
|
141
|
+
return `Move ${name} to ${destination}?`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The move question with the one sentence it used to carry alone. Still what
|
|
146
|
+
* the dialog says when the access change is not known: a tester read this as
|
|
147
|
+
* unclear, which is why the blocks exist, but it is honest where a list of
|
|
148
|
+
* names would be a guess.
|
|
149
|
+
*/
|
|
150
|
+
export function moveSentence(name: string, destination: string): string {
|
|
151
|
+
return `${moveQuestion(name, destination)} Access to it will follow ${possessive(destination)} rules from now on.`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** What the dialog reads when the lookup answered and found no change. */
|
|
155
|
+
export const NO_ACCESS_CHANGE = "Nobody's access changes.";
|
|
156
|
+
|
|
157
|
+
/** What the dialog reads when the lookup failed or ran out of its two seconds. */
|
|
158
|
+
export const ACCESS_CHANGE_UNKNOWN = "Couldn't work out the access change.";
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The whole budget for the access lookup. Past it the dialog stops claiming to
|
|
162
|
+
* know: a confirmation the user is staring at may not wait on a resolver.
|
|
163
|
+
*/
|
|
164
|
+
export const ACCESS_LOOKUP_TIMEOUT_MS = 2000;
|
|
165
|
+
|
|
166
|
+
/** Lines past this many are folded into "and N more". */
|
|
167
|
+
const ACCESS_BLOCK_CAP = 6;
|
|
168
|
+
|
|
169
|
+
/** The two verbs the move compares, in the order their lines are listed. */
|
|
170
|
+
const ACCESS_VERBS = ['read', 'write'] as const;
|
|
171
|
+
|
|
172
|
+
/** How each verb reads to someone who is not thinking about access grammar. */
|
|
173
|
+
const VERB_WORD: Record<(typeof ACCESS_VERBS)[number], string> = {
|
|
174
|
+
read: 'open',
|
|
175
|
+
write: 'edit',
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* A principal as the Manage access dialog names it — the same spelling in both
|
|
180
|
+
* places, so the confirmation and the sheet never describe one grant two ways.
|
|
181
|
+
* A plugin principal's raw `plugin/<Name>/<verb>` token becomes "GTM ·
|
|
182
|
+
* readers"; the built-in `everyone` role becomes "Everyone".
|
|
183
|
+
*/
|
|
184
|
+
export function principalLabel(principal: AccessPrincipalRef): string {
|
|
185
|
+
if (principal.kind === 'plugin') {
|
|
186
|
+
const parsed = parsePluginPrincipalToken(principal.name);
|
|
187
|
+
return parsed ? pluginPrincipalLabel(parsed.plugin, parsed.verb) : principal.name;
|
|
188
|
+
}
|
|
189
|
+
if (principal.kind === 'role' && principal.name.trim().toLowerCase() === 'everyone') {
|
|
190
|
+
return 'Everyone';
|
|
191
|
+
}
|
|
192
|
+
// A person granted directly, with no display name on record, is still
|
|
193
|
+
// someone: their email names them better than a blank line does.
|
|
194
|
+
if (principal.kind === 'person') return principal.name || (principal.email ?? '');
|
|
195
|
+
return principal.name;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* One principal's identity across the two sides of the move. People are the
|
|
200
|
+
* same person at the same address whatever name each side carries; a
|
|
201
|
+
* collective is the same principal at the same name and kind — a group and a
|
|
202
|
+
* role sharing a name are two principals, as everywhere else in access.
|
|
203
|
+
*/
|
|
204
|
+
function principalKey(principal: AccessPrincipalRef): string {
|
|
205
|
+
return principal.kind === 'person'
|
|
206
|
+
? `person:${(principal.email ?? principal.name).toLowerCase()}`
|
|
207
|
+
: `${principal.kind}:${principal.name.toLowerCase()}`;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** The lose and gain blocks of one move, each already capped. */
|
|
211
|
+
export interface AccessChange {
|
|
212
|
+
lose: string[];
|
|
213
|
+
gain: string[];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Six lines, then "and N more" for the rest. */
|
|
217
|
+
function capped(lines: string[]): string[] {
|
|
218
|
+
if (lines.length <= ACCESS_BLOCK_CAP) return lines;
|
|
219
|
+
return [...lines.slice(0, ACCESS_BLOCK_CAP), `and ${lines.length - ACCESS_BLOCK_CAP} more`];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Who loses and who gains access in one move: per verb, the principals
|
|
224
|
+
* present before and absent after, and absent before and present after.
|
|
225
|
+
*
|
|
226
|
+
* Lines are grouped by principal in the order the lists name them — the
|
|
227
|
+
* resolver's order, collectives before directly granted people — and within a
|
|
228
|
+
* principal, opening before editing. A principal that loses one verb and
|
|
229
|
+
* gains another appears in both blocks, which is what happened.
|
|
230
|
+
*/
|
|
231
|
+
export function accessChangeLines(before: PathPrincipals, after: PathPrincipals): AccessChange {
|
|
232
|
+
const lose: string[] = [];
|
|
233
|
+
const gain: string[] = [];
|
|
234
|
+
// First-seen order over every list, so a principal's lines sit together
|
|
235
|
+
// wherever the verb that introduced it came from.
|
|
236
|
+
const order: AccessPrincipalRef[] = [];
|
|
237
|
+
const seen = new Set<string>();
|
|
238
|
+
for (const side of [before, after]) {
|
|
239
|
+
for (const verb of ACCESS_VERBS) {
|
|
240
|
+
for (const principal of side[verb]) {
|
|
241
|
+
const key = principalKey(principal);
|
|
242
|
+
if (seen.has(key)) continue;
|
|
243
|
+
seen.add(key);
|
|
244
|
+
order.push(principal);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const keysOf = (list: AccessPrincipalRef[]) => new Set(list.map(principalKey));
|
|
249
|
+
const sides = {
|
|
250
|
+
before: { read: keysOf(before.read), write: keysOf(before.write) },
|
|
251
|
+
after: { read: keysOf(after.read), write: keysOf(after.write) },
|
|
252
|
+
};
|
|
253
|
+
for (const principal of order) {
|
|
254
|
+
const key = principalKey(principal);
|
|
255
|
+
const label = principalLabel(principal);
|
|
256
|
+
for (const verb of ACCESS_VERBS) {
|
|
257
|
+
const had = sides.before[verb].has(key);
|
|
258
|
+
const has = sides.after[verb].has(key);
|
|
259
|
+
if (had && !has) lose.push(`${label}: can no longer ${VERB_WORD[verb]}`);
|
|
260
|
+
if (!had && has) gain.push(`${label}: can ${VERB_WORD[verb]}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return { lose: capped(lose), gain: capped(gain) };
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** {@link accessChangeLines} over a whole prospective-access answer. */
|
|
267
|
+
export function accessChangeOf(access: ProspectiveAccess): AccessChange {
|
|
268
|
+
return accessChangeLines(access.before, access.after);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* The warnings that apply to one move, in a fixed order.
|
|
273
|
+
*
|
|
274
|
+
* `canWrite` is the caller's write permission on the destination: `false`
|
|
275
|
+
* adds the refusal warning, `null` (not known yet, or the lookup failed) adds
|
|
276
|
+
* nothing — the dialog never blocks on it, and the server stays the gate.
|
|
277
|
+
* A move into a folder the caller may not write is REFUSED today: the move
|
|
278
|
+
* route acquires the write lock on both ends, and the lock gate throws
|
|
279
|
+
* AccessDeniedError on a protected branch (`WorkflowService.acquireLock`).
|
|
280
|
+
* Only uploads are rerouted to a suggestion; a move is not.
|
|
281
|
+
*/
|
|
282
|
+
export function moveWarnings(opts: {
|
|
283
|
+
sourcePath: string;
|
|
284
|
+
targetDir: string;
|
|
285
|
+
destinationLabel: string;
|
|
286
|
+
kbDirName: string | null;
|
|
287
|
+
canWrite: boolean | null;
|
|
288
|
+
/**
|
|
289
|
+
* Whether the person making the move is an admin. Only the restore line
|
|
290
|
+
* reads it, and it must: a nested `roles.yaml` is ordinary content, so
|
|
291
|
+
* ANYONE can drag one at the root, and telling a non-admin their move is
|
|
292
|
+
* "allowed for an Admin" would promise them what the server will refuse.
|
|
293
|
+
*/
|
|
294
|
+
isAdmin?: boolean;
|
|
295
|
+
}): string[] {
|
|
296
|
+
const name = opts.sourcePath.split('/').pop() ?? opts.sourcePath;
|
|
297
|
+
const warnings: string[] = [];
|
|
298
|
+
if (opts.canWrite === false) {
|
|
299
|
+
// A restore is the one move allowed past a destination that refuses the
|
|
300
|
+
// write, so for the admin who may make it "the move will be refused" is
|
|
301
|
+
// the wrong prediction. For everyone else it is the right one.
|
|
302
|
+
const destination = opts.targetDir ? `${opts.targetDir}/${name}` : name;
|
|
303
|
+
const from = repoRelative(opts.sourcePath, opts.kbDirName);
|
|
304
|
+
const to = repoRelative(destination, opts.kbDirName);
|
|
305
|
+
const restore =
|
|
306
|
+
opts.isAdmin === true && from !== null && to !== null && isPlatformRestoreShape(from, to);
|
|
307
|
+
warnings.push(
|
|
308
|
+
restore
|
|
309
|
+
? `You can't write to ${opts.destinationLabel}, but putting ${name} back where the platform reads it is allowed for an Admin.`
|
|
310
|
+
: `You can't write to ${opts.destinationLabel} — the move will be refused.`,
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
// No platform-file warning here: moving one out of its folder breaks the
|
|
314
|
+
// workspace, so the tree refuses it outright (`platformFileMoveRefusal`)
|
|
315
|
+
// instead of offering it as something to confirm. The only platform file
|
|
316
|
+
// that still reaches this dialog is a misplaced one an admin is putting
|
|
317
|
+
// back, and there is nothing to warn about in a repair.
|
|
318
|
+
const fromRoot = rootOf(opts.sourcePath, opts.kbDirName);
|
|
319
|
+
const toRoot = rootOf(opts.targetDir ? `${opts.targetDir}/${name}` : name, opts.kbDirName);
|
|
320
|
+
if (fromRoot && toRoot && fromRoot !== toRoot) {
|
|
321
|
+
warnings.push(`This moves it out of ${fromRoot}/ into ${toRoot}/ — the two roots are handled differently.`);
|
|
322
|
+
}
|
|
323
|
+
return warnings;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* What a withdraw asks before it takes a suggestion back.
|
|
328
|
+
*
|
|
329
|
+
* Withdrawal is per REQUEST, never per file: a multi-file drop became ONE
|
|
330
|
+
* change request, and cancelling it cancels all of it. The user right-clicked
|
|
331
|
+
* a single row, so the count is said out loud — learning afterwards that two
|
|
332
|
+
* other files went with it is the one outcome this sentence exists to prevent.
|
|
333
|
+
*/
|
|
334
|
+
export function withdrawSentence(files: string[]): string {
|
|
335
|
+
if (files.length > 1) return `This withdraws the whole suggestion: ${files.length} files`;
|
|
336
|
+
const name = files[0]?.split('/').pop();
|
|
337
|
+
return name ? `Withdraw ${name}?` : 'Withdraw this suggestion?';
|
|
338
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What to do about a refused upload.
|
|
3
|
+
*
|
|
4
|
+
* The error banner ends with a next step because the reason alone leaves the
|
|
5
|
+
* user holding a file and no idea where to put it — and the refusals that
|
|
6
|
+
* have a specific answer want different ones.
|
|
7
|
+
*
|
|
8
|
+
* The HTTP STATUS decides, not the wording: the backend answers 401 for a
|
|
9
|
+
* session that lapsed, 403 for a folder the caller may not write and 413 for
|
|
10
|
+
* a file over the upload cap, and each maps onto its own step. Classifying on the
|
|
11
|
+
* server's prose instead meant any rewording of a message — or a change to
|
|
12
|
+
* the size cap the advice used to restate — silently started telling users
|
|
13
|
+
* the wrong thing, with nothing failing to say so. The message is for the
|
|
14
|
+
* banner's reason line and nothing else.
|
|
15
|
+
*
|
|
16
|
+
* `status` is absent for a failure that never reached an HTTP response (the
|
|
17
|
+
* network, or the folder walker); "try again" is the honest step for those.
|
|
18
|
+
*
|
|
19
|
+
* Lives here rather than beside the banner so it can be read and tested
|
|
20
|
+
* without rendering a tree.
|
|
21
|
+
*/
|
|
22
|
+
export function uploadErrorNextStep(status: number | undefined): string {
|
|
23
|
+
// A lapsed session is not a refused folder: another folder fails the same
|
|
24
|
+
// way and its owner refused nothing. Signing in again is the step.
|
|
25
|
+
if (status === 401) return 'Sign in again, then try once more.';
|
|
26
|
+
if (status === 403) return 'Try another folder or ask its owner.';
|
|
27
|
+
if (status === 413) return 'That file is over the upload size limit — try a smaller one.';
|
|
28
|
+
return 'Try again, or pick another folder.';
|
|
29
|
+
}
|
|
@@ -29,7 +29,12 @@ describe('marketplace git url', () => {
|
|
|
29
29
|
expect(cmds.claude).toBe(
|
|
30
30
|
'claude plugin marketplace add https://key:bevel_abc@kb.acme.com/git/marketplace.git && claude plugin install hexis-all@hexis',
|
|
31
31
|
);
|
|
32
|
-
expect(cmds.codex
|
|
32
|
+
expect(cmds.codex.split('\n')).toEqual([
|
|
33
|
+
'codex plugin marketplace add https://key:bevel_abc@kb.acme.com/git/marketplace.git',
|
|
34
|
+
'codex plugin add skills-and-knowledge@hexis',
|
|
35
|
+
'codex mcp login hexis',
|
|
36
|
+
'codex exec --skip-git-repo-check "Call the hexis MCP server\'s list_tools tool and print the tool names it returns."',
|
|
37
|
+
]);
|
|
33
38
|
expect(cmds.skills).toBe('npx skills add https://key:bevel_abc@kb.acme.com/git/marketplace.git --all -y');
|
|
34
39
|
});
|
|
35
40
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
2
|
import { cn } from '../../lib/utils';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -68,6 +68,14 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
68
68
|
leadingIcon?: ReactNode;
|
|
69
69
|
/** Rendered after the label. */
|
|
70
70
|
trailingIcon?: ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* Declared explicitly because `ButtonHTMLAttributes` does not carry `ref`
|
|
73
|
+
* (the same contract as `IconButton`). A labelled button that opens a menu
|
|
74
|
+
* has to be referenceable: dismissing on Escape hands focus back to it, and
|
|
75
|
+
* an outside-click handler has to tell "clicked the trigger" from "clicked
|
|
76
|
+
* away", or one click closes and reopens.
|
|
77
|
+
*/
|
|
78
|
+
ref?: Ref<HTMLButtonElement>;
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
export function Button({
|
|
@@ -78,10 +86,16 @@ export function Button({
|
|
|
78
86
|
className,
|
|
79
87
|
children,
|
|
80
88
|
type = 'button',
|
|
89
|
+
ref,
|
|
81
90
|
...rest
|
|
82
91
|
}: ButtonProps) {
|
|
83
92
|
return (
|
|
84
|
-
<button
|
|
93
|
+
<button
|
|
94
|
+
ref={ref}
|
|
95
|
+
type={type}
|
|
96
|
+
className={buttonClasses({ variant, size, className })}
|
|
97
|
+
{...rest}
|
|
98
|
+
>
|
|
85
99
|
{leadingIcon}
|
|
86
100
|
{children}
|
|
87
101
|
{trailingIcon}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from 'react';
|
|
7
7
|
import { X } from 'lucide-react';
|
|
8
8
|
import { useModalLayer } from './useModalLayer';
|
|
9
|
+
import { useLatestRef } from './useLatestRef';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* The one centered-modal primitive for the app. Before this existed every
|
|
@@ -78,20 +79,29 @@ export function Dialog({
|
|
|
78
79
|
|
|
79
80
|
// Callers pass a fresh `onClose` arrow each render; mirror it into a ref so
|
|
80
81
|
// the trap effect below doesn't re-fire (and re-snapshot focus) every render.
|
|
81
|
-
const onCloseRef =
|
|
82
|
-
|
|
83
|
-
onCloseRef.current = onClose;
|
|
84
|
-
}, [onClose]);
|
|
85
|
-
|
|
86
|
-
const busyRef = useRef(busy);
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
busyRef.current = busy;
|
|
89
|
-
}, [busy]);
|
|
82
|
+
const onCloseRef = useLatestRef(onClose);
|
|
83
|
+
const busyRef = useLatestRef(busy);
|
|
90
84
|
|
|
91
85
|
// Only the topmost open modal layer reacts to Escape / backdrop clicks, so a
|
|
92
86
|
// nested modal (its own or a hand-rolled one that opts in) can be dismissed
|
|
93
87
|
// without also closing this dialog behind it.
|
|
94
88
|
const isTopLayer = useModalLayer(open);
|
|
89
|
+
// Whether the pointer went DOWN on the scrim itself, with this dialog as
|
|
90
|
+
// the top layer. Both halves matter, and both must be judged at mousedown:
|
|
91
|
+
//
|
|
92
|
+
// - A menu inside the dialog dismisses itself on `mousedown` and pops its
|
|
93
|
+
// layer as it unmounts, so by the time the scrim's `click` fires the
|
|
94
|
+
// dialog is topmost again — and would close on the same gesture that
|
|
95
|
+
// closed the menu. Escape peels one layer at a time; so does the scrim.
|
|
96
|
+
// - A drag that STARTS inside the panel and releases on the scrim (text
|
|
97
|
+
// selection overshooting the panel edge) makes the browser fire `click`
|
|
98
|
+
// on their common ancestor — this scrim container. The panel's own
|
|
99
|
+
// stopPropagation can't help: the click never happened inside it. Only
|
|
100
|
+
// the mousedown target says where the gesture began.
|
|
101
|
+
//
|
|
102
|
+
// Recorded here rather than in each menu, so no menu has to learn to defer
|
|
103
|
+
// its own pop.
|
|
104
|
+
const scrimPointerDown = useRef(false);
|
|
95
105
|
|
|
96
106
|
// Dialog a11y: move focus into the panel on open, trap focus + Escape closes
|
|
97
107
|
// + restore focus on close.
|
|
@@ -140,15 +150,21 @@ export function Dialog({
|
|
|
140
150
|
document.removeEventListener('keydown', onKeyDown);
|
|
141
151
|
previouslyFocused?.focus?.();
|
|
142
152
|
};
|
|
143
|
-
|
|
153
|
+
// The refs are stable for the component's life; listed for the linter.
|
|
154
|
+
}, [open, isTopLayer, onCloseRef, busyRef]);
|
|
144
155
|
|
|
145
156
|
if (!open) return null;
|
|
146
157
|
|
|
147
158
|
return (
|
|
148
159
|
<div
|
|
149
160
|
className="fixed inset-0 z-50 bg-scrim flex items-center justify-center p-4"
|
|
161
|
+
onMouseDown={(e) => {
|
|
162
|
+
scrimPointerDown.current = e.target === e.currentTarget && isTopLayer();
|
|
163
|
+
}}
|
|
150
164
|
onClick={() => {
|
|
151
|
-
|
|
165
|
+
const startedOnScrim = scrimPointerDown.current;
|
|
166
|
+
scrimPointerDown.current = false;
|
|
167
|
+
if (busy || !startedOnScrim || !isTopLayer()) return;
|
|
152
168
|
onClose();
|
|
153
169
|
}}
|
|
154
170
|
>
|
|
@@ -35,6 +35,14 @@ export function MenuPanel({ className, children, ...rest }: MenuPanelProps) {
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* `aria-disabled` is styled the same as `disabled`, and is the spelling to
|
|
40
|
+
* reach for when the item must still be HOVERABLE and FOCUSABLE — a native
|
|
41
|
+
* `disabled` button suppresses pointer events on most engines, which takes its
|
|
42
|
+
* `title` tooltip with it, and drops the item out of the tab order so the
|
|
43
|
+
* keyboard user never learns it exists. It does not block activation on its
|
|
44
|
+
* own: an `aria-disabled` item's `onClick` must return early.
|
|
45
|
+
*/
|
|
38
46
|
export interface MenuItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
39
47
|
tone?: 'default' | 'danger';
|
|
40
48
|
/** Visual checked/current state. Set `aria-checked`/`aria-current` yourself. */
|
|
@@ -58,9 +66,13 @@ export function MenuItem({
|
|
|
58
66
|
className={cn(
|
|
59
67
|
'flex w-full items-center gap-2 rounded-sm px-2.5 py-2 text-left text-ui',
|
|
60
68
|
'transition-colors disabled:cursor-not-allowed disabled:opacity-50',
|
|
69
|
+
'aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent',
|
|
61
70
|
tone === 'danger'
|
|
62
71
|
? 'text-danger hover:bg-danger-soft'
|
|
63
|
-
|
|
72
|
+
// The aria-disabled text override is tone-local because the hover it
|
|
73
|
+
// undoes is: only the default tone brightens to `text-ink`, and a
|
|
74
|
+
// disabled row that still lights up on hover reads as usable.
|
|
75
|
+
: 'text-ink-muted hover:bg-hover hover:text-ink aria-disabled:hover:text-ink-muted',
|
|
64
76
|
active && 'font-medium text-ink',
|
|
65
77
|
className,
|
|
66
78
|
)}
|
|
@@ -9,19 +9,21 @@ export type PageShellWidth = keyof typeof WIDTH_CLASS;
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Minimal shared chrome for the shell's standalone routed pages (Secrets,
|
|
12
|
-
* External agent access,
|
|
12
|
+
* External agent access, App roles): a full-height scrolling canvas
|
|
13
13
|
* with a centered max-width column, a page-title row and a white content
|
|
14
14
|
* card. Deliberately tiny — it mirrors the Tailwind idioms the tools
|
|
15
15
|
* explorer page already uses; it is not a design system.
|
|
16
16
|
*
|
|
17
17
|
* `padded` drops the card's default padding for pages that own their inner
|
|
18
18
|
* layout (e.g. a tab strip flush against the card's top edge).
|
|
19
|
+
* `card={false}` leaves surface ownership to pages with multiple peer cards.
|
|
19
20
|
*/
|
|
20
21
|
export function PageShell({
|
|
21
22
|
title,
|
|
22
23
|
actions,
|
|
23
24
|
width = '3xl',
|
|
24
25
|
padded = true,
|
|
26
|
+
card = true,
|
|
25
27
|
children,
|
|
26
28
|
}: {
|
|
27
29
|
title: string;
|
|
@@ -29,6 +31,7 @@ export function PageShell({
|
|
|
29
31
|
actions?: ReactNode;
|
|
30
32
|
width?: PageShellWidth;
|
|
31
33
|
padded?: boolean;
|
|
34
|
+
card?: boolean;
|
|
32
35
|
children: ReactNode;
|
|
33
36
|
}) {
|
|
34
37
|
return (
|
|
@@ -41,13 +44,15 @@ export function PageShell({
|
|
|
41
44
|
<h1 className="text-lg font-semibold text-ink">{title}</h1>
|
|
42
45
|
{actions && <div className="flex items-center gap-2">{actions}</div>}
|
|
43
46
|
</header>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
{card ? (
|
|
48
|
+
<section
|
|
49
|
+
className={`bg-white border border-line rounded-lg ${
|
|
50
|
+
padded ? 'p-4' : 'overflow-hidden'
|
|
51
|
+
}`}
|
|
52
|
+
>
|
|
53
|
+
{children}
|
|
54
|
+
</section>
|
|
55
|
+
) : children}
|
|
51
56
|
</div>
|
|
52
57
|
</div>
|
|
53
58
|
);
|