@bevel-software/platform-core-frontend 0.14.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/package.json +3 -3
- package/src/core/CoreAppShell.tsx +34 -26
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +38 -1
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/email.ts +37 -1
- package/src/lib/utils.ts +2 -0
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +781 -76
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +192 -10
- package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
- package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
- package/src/modules/admin/components/AddMemberInput.tsx +268 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
- package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/connection-keys.api.ts +47 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
- package/src/modules/auth/components/AccountPage.tsx +73 -54
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/auth/services/account.api.ts +78 -4
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
- package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
- package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
- package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
- package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
- package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
- package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
- package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
- package/src/modules/change-requests/services/change-requests.api.ts +57 -1
- package/src/modules/change-requests/services/denied-file.api.ts +53 -0
- package/src/modules/change-requests/services/propose.api.ts +97 -8
- package/src/modules/change-requests/utils/approval.ts +15 -0
- package/src/modules/change-requests/utils/author.ts +32 -0
- package/src/modules/change-requests/utils/readFailure.ts +110 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +109 -4
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +104 -99
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +115 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +391 -78
- package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +183 -0
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +75 -0
- package/src/modules/library/__tests__/link-membership.test.ts +129 -0
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +67 -0
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +107 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +149 -34
- package/src/modules/library/components/LibraryLayout.tsx +120 -247
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
- package/src/modules/library/components/LockedPluginView.tsx +63 -35
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +19 -5
- package/src/modules/library/components/PageActions.tsx +31 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +123 -23
- package/src/modules/library/components/PluginExtras.tsx +143 -18
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +234 -38
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +271 -238
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +204 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +132 -23
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +116 -17
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useJoinRequests.ts +48 -18
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +229 -82
- package/src/modules/library/routes/library-paths.ts +46 -35
- package/src/modules/library/services/library.api.ts +89 -17
- package/src/modules/library/services/plugins.api.ts +161 -9
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +268 -37
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +102 -0
- package/src/modules/library/utils/status.ts +204 -35
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +154 -0
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +16 -22
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
- package/src/modules/settings/services/github-facade.api.ts +66 -0
- package/src/modules/settings/settings-nav-items.tsx +10 -2
- package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
- package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
- package/src/modules/setup/__tests__/setup.test.tsx +615 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +711 -40
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +218 -3
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
- package/src/modules/setup/utils/root-folders.ts +46 -0
- package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
- package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
- package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +395 -124
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +659 -36
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +6 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
- package/src/modules/workspace/components/FileRoute.tsx +376 -22
- package/src/modules/workspace/components/FileViewer.tsx +166 -45
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
- package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
- package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +89 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +207 -30
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
- package/src/modules/workspace/services/workspace.api.ts +57 -4
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
- package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
- package/src/modules/workspace/state/open-change-requests.tsx +100 -12
- package/src/modules/workspace/state/workspace.context.ts +130 -16
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +126 -52
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +59 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +118 -0
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +34 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -265
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
3
3
|
import { readFileOnBranch } from '../services/change-requests.api';
|
|
4
|
+
import { describeReadFailure } from '../services/denied-file.api';
|
|
5
|
+
import type { ReadFailure } from '../utils/readFailure';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A read that has landed, or the fact that it hasn't.
|
|
9
|
+
*
|
|
10
|
+
* `content: null` on its own conflates two different truths — "still in
|
|
11
|
+
* flight" and "this read is never going to succeed" — and a caller holding
|
|
12
|
+
* only that can render exactly one thing for both: "Loading…", forever. A
|
|
13
|
+
* file the default branch simply does not have (the OLD half of a rename, a
|
|
14
|
+
* path outside the caller's access) is the second case, and it deserves a
|
|
15
|
+
* sentence rather than a spinner.
|
|
16
|
+
*/
|
|
17
|
+
export interface BranchFileRead {
|
|
18
|
+
/** The file's raw text once it lands; `null` while pending AND on failure. */
|
|
19
|
+
content: string | null;
|
|
20
|
+
/** True once the read SETTLED as an error — a definitive "no", not a wait. */
|
|
21
|
+
failed: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* WHY it failed, set whenever `failed` is. A permission denial and a broken
|
|
24
|
+
* read are answered by different things — a person, or another attempt — so
|
|
25
|
+
* a caller holding only "failed" can say nothing useful about either.
|
|
26
|
+
*/
|
|
27
|
+
failure?: ReadFailure;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const PENDING: BranchFileRead = { content: null, failed: false };
|
|
4
31
|
|
|
5
32
|
/**
|
|
6
33
|
* The file's RAW text on the default branch.
|
|
@@ -24,6 +51,14 @@ export function useDefaultBranchFile(
|
|
|
24
51
|
return useFileOnBranch(DEFAULT_BRANCH, repoRelativePath, revision);
|
|
25
52
|
}
|
|
26
53
|
|
|
54
|
+
/** The same default-branch read, with a failure distinguishable from a wait. */
|
|
55
|
+
export function useDefaultBranchFileRead(
|
|
56
|
+
repoRelativePath: string | null,
|
|
57
|
+
revision = 0,
|
|
58
|
+
): BranchFileRead {
|
|
59
|
+
return useFileOnBranchRead(DEFAULT_BRANCH, repoRelativePath, revision);
|
|
60
|
+
}
|
|
61
|
+
|
|
27
62
|
/**
|
|
28
63
|
* The same read against ANY branch — `null` branch means "don't fetch". The
|
|
29
64
|
* skill page uses it to seed an incremental proposal: when the caller already
|
|
@@ -36,6 +71,19 @@ export function useFileOnBranch(
|
|
|
36
71
|
repoRelativePath: string | null,
|
|
37
72
|
revision = 0,
|
|
38
73
|
): string | null {
|
|
74
|
+
return useFileOnBranchRead(branch, repoRelativePath, revision).content;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The read itself. Callers that can say something useful about a failure take
|
|
79
|
+
* this; callers that only ever want the text take the `string | null` wrappers
|
|
80
|
+
* above.
|
|
81
|
+
*/
|
|
82
|
+
export function useFileOnBranchRead(
|
|
83
|
+
branch: string | null,
|
|
84
|
+
repoRelativePath: string | null,
|
|
85
|
+
revision = 0,
|
|
86
|
+
): BranchFileRead {
|
|
39
87
|
/**
|
|
40
88
|
* Answers are cached PER KEY, not as "the last one". The skill page's tabs
|
|
41
89
|
* make the path oscillate (SKILL.md → a bundled file → SKILL.md), and with a
|
|
@@ -44,8 +92,12 @@ export function useFileOnBranch(
|
|
|
44
92
|
* null forever and the pane sat on "Loading…". A map keeps every settled
|
|
45
93
|
* answer addressable for as long as the page is mounted (bounded: one entry
|
|
46
94
|
* per file per revision).
|
|
95
|
+
*
|
|
96
|
+
* A FAILURE is cached under its key too, for the same reason the successes
|
|
97
|
+
* are: it is an answer. Storing nothing left the key indistinguishable from
|
|
98
|
+
* one still in flight.
|
|
47
99
|
*/
|
|
48
|
-
const cache = useRef<Map<string,
|
|
100
|
+
const cache = useRef<Map<string, BranchFileRead>>(new Map());
|
|
49
101
|
const asked = useRef<Set<string>>(new Set());
|
|
50
102
|
const [, arrived] = useState(0);
|
|
51
103
|
const key = `${branch ?? ''}::${repoRelativePath ?? ''}::${revision}`;
|
|
@@ -67,14 +119,25 @@ export function useFileOnBranch(
|
|
|
67
119
|
asked.current.add(key);
|
|
68
120
|
readFileOnBranch(branch, repoRelativePath)
|
|
69
121
|
.then((content) => {
|
|
70
|
-
cache.current.set(key, content);
|
|
122
|
+
cache.current.set(key, { content, failed: false });
|
|
71
123
|
arrived((n) => n + 1);
|
|
72
124
|
})
|
|
73
|
-
.catch(() =>
|
|
74
|
-
//
|
|
75
|
-
// "
|
|
76
|
-
|
|
125
|
+
.catch((err: unknown) =>
|
|
126
|
+
// NOT `{ content: '' }`: an empty string would diff as "the whole file
|
|
127
|
+
// was deleted". The failure is recorded as a failure so the caller can
|
|
128
|
+
// say so — and DESCRIBED first, because a denial and an outage are
|
|
129
|
+
// different sentences. Describing costs a round trip of its own, and
|
|
130
|
+
// the key deliberately stays absent (so, pending) until it lands: a
|
|
131
|
+
// caller that published "couldn't be read" and then rewrote it as
|
|
132
|
+
// "you don't have access" would change the reason under the reader.
|
|
133
|
+
describeReadFailure(err, branch, repoRelativePath).then((failure) => {
|
|
134
|
+
cache.current.set(key, { content: null, failed: true, failure });
|
|
135
|
+
arrived((n) => n + 1);
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
77
138
|
}, [branch, repoRelativePath, key]);
|
|
78
139
|
|
|
79
|
-
|
|
140
|
+
// No path (or no branch) is not a failure — it is "nothing was asked for".
|
|
141
|
+
if (!branch || !repoRelativePath) return PENDING;
|
|
142
|
+
return cache.current.get(key) ?? PENDING;
|
|
80
143
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { readFileAtForkPoint } from '../services/change-requests.api';
|
|
3
|
+
import { describeReadFailure } from '../services/denied-file.api';
|
|
4
|
+
import type { BranchFileRead } from './useFileOnBranch';
|
|
5
|
+
|
|
6
|
+
const PENDING: BranchFileRead = { content: null, failed: false };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A file's text at a change request's FORK POINT — where the author started.
|
|
10
|
+
*
|
|
11
|
+
* The request dialog's diffs read their "before" side here rather than on the
|
|
12
|
+
* target as it stands now. Against the tip, anything someone else changed on
|
|
13
|
+
* the target after the proposal shows up inside the proposal as a deletion —
|
|
14
|
+
* a request that appears to undo work its author never saw. Against the fork
|
|
15
|
+
* point the request shows exactly what its author changed; that the target
|
|
16
|
+
* has moved on is said separately, by the dialog's "has changed" notice.
|
|
17
|
+
*
|
|
18
|
+
* `null` sha or path means "don't fetch". Settled reads are kept per key (as
|
|
19
|
+
* `useFileOnBranchRead` does, and for the same no-`cancelled`-flag reason), so
|
|
20
|
+
* flipping between files never shows one file's text under another. A path
|
|
21
|
+
* absent at the fork point settles as a FAILURE: callers only ask for a file
|
|
22
|
+
* the request modifies or moves, so an absent before-side is not an empty file.
|
|
23
|
+
*
|
|
24
|
+
* `opts.targetBranch` is the branch the fork point belongs to — the tree the
|
|
25
|
+
* route checks read authority against, and so the tree to name a folder from
|
|
26
|
+
* when it refuses. `opts.revision` re-reads a key the caller wants tried
|
|
27
|
+
* again; it is what the pane's Retry link moves.
|
|
28
|
+
*/
|
|
29
|
+
export function useForkPointFileRead(
|
|
30
|
+
crNumber: number,
|
|
31
|
+
sha: string | null,
|
|
32
|
+
repoRelativePath: string | null,
|
|
33
|
+
opts: { targetBranch?: string; revision?: number } = {},
|
|
34
|
+
): BranchFileRead {
|
|
35
|
+
const { targetBranch = '', revision = 0 } = opts;
|
|
36
|
+
const [settled, setSettled] = useState<ReadonlyMap<string, BranchFileRead>>(new Map());
|
|
37
|
+
/** Keys already requested — read and written only inside the effect. */
|
|
38
|
+
const asked = useRef<Set<string>>(new Set());
|
|
39
|
+
// `targetBranch` belongs in the key, not only in the effect's deps: the
|
|
40
|
+
// effect skips a key `asked` has already seen, so the same file at the same
|
|
41
|
+
// fork point read against a DIFFERENT branch would keep the first branch's
|
|
42
|
+
// answer — including the folder a denial names.
|
|
43
|
+
const key = `${crNumber}::${sha ?? ''}::${repoRelativePath ?? ''}::${targetBranch}::${revision}`;
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!sha || !repoRelativePath || asked.current.has(key)) return;
|
|
47
|
+
asked.current.add(key);
|
|
48
|
+
const land = (read: BranchFileRead) => setSettled((m) => new Map(m).set(key, read));
|
|
49
|
+
readFileAtForkPoint(crNumber, sha, repoRelativePath)
|
|
50
|
+
.then(({ content }) =>
|
|
51
|
+
land(
|
|
52
|
+
content === null
|
|
53
|
+
? {
|
|
54
|
+
content: null,
|
|
55
|
+
failed: true,
|
|
56
|
+
// Not a refusal and not an outage: the path simply is not in
|
|
57
|
+
// the text the author started from. Said as the reason, and
|
|
58
|
+
// left retryable — another attempt costs one read and the
|
|
59
|
+
// fork point can move under an Update.
|
|
60
|
+
failure: {
|
|
61
|
+
kind: 'error',
|
|
62
|
+
reason: "it wasn't there at the change request's starting point",
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
: { content, failed: false },
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
.catch((err: unknown) =>
|
|
69
|
+
describeReadFailure(err, targetBranch, repoRelativePath).then((failure) =>
|
|
70
|
+
land({ content: null, failed: true, failure }),
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
}, [crNumber, sha, repoRelativePath, targetBranch, key]);
|
|
74
|
+
|
|
75
|
+
if (!sha || !repoRelativePath) return PENDING;
|
|
76
|
+
return settled.get(key) ?? PENDING;
|
|
77
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
FolderChangeRequest,
|
|
3
|
+
FolderChangeRequestRemoval,
|
|
4
|
+
PullRequestSummary,
|
|
5
|
+
} from '@bevel-software/platform-shared';
|
|
2
6
|
import { authFetch } from '../../../lib/api';
|
|
3
7
|
import { handleApiResponse } from '../../git/services/git.api';
|
|
4
8
|
import { getOrCreateWorkspace, readFile } from '../../workspace/services/workspace.api';
|
|
@@ -38,8 +42,60 @@ export async function listMyChangeRequests(
|
|
|
38
42
|
);
|
|
39
43
|
}
|
|
40
44
|
|
|
45
|
+
/**
|
|
46
|
+
* The open change requests proposing files under a KB-repo-relative folder,
|
|
47
|
+
* each with whether the caller may take those files out of it — what a folder
|
|
48
|
+
* delete asks before it offers to remove the proposals too.
|
|
49
|
+
*/
|
|
50
|
+
export async function listChangeRequestsUnderFolder(folder: string): Promise<FolderChangeRequest[]> {
|
|
51
|
+
const data = await handleApiResponse<{ requests: FolderChangeRequest[] }>(
|
|
52
|
+
await authFetch(`/api/workflow/change-requests/under-folder?path=${encodeURIComponent(folder)}`),
|
|
53
|
+
);
|
|
54
|
+
return data.requests;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Take every file under the folder out of every open change request proposing
|
|
59
|
+
* one. A request left empty is withdrawn. Refused as a whole (403) when the
|
|
60
|
+
* caller may not act on one of them.
|
|
61
|
+
*/
|
|
62
|
+
export async function removeFolderFromChangeRequests(folder: string): Promise<FolderChangeRequestRemoval[]> {
|
|
63
|
+
const data = await handleApiResponse<{ results: FolderChangeRequestRemoval[] }>(
|
|
64
|
+
await authFetch('/api/workflow/change-requests/under-folder/remove', {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
headers: { 'Content-Type': 'application/json' },
|
|
67
|
+
body: JSON.stringify({ path: folder }),
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
return data.results;
|
|
71
|
+
}
|
|
72
|
+
|
|
41
73
|
/** Read a file from a branch's shared workspace (bootstraps the clone if needed). */
|
|
42
74
|
export async function readFileOnBranch(branch: string, repoRelativePath: string): Promise<string> {
|
|
43
75
|
const { workspace } = await getOrCreateWorkspace(branch);
|
|
44
76
|
return readFile(workspace.id, `${workspace.kbDirName}/${repoRelativePath}`);
|
|
45
77
|
}
|
|
78
|
+
|
|
79
|
+
/** A file read at a change request's fork point. */
|
|
80
|
+
export interface ForkPointFile {
|
|
81
|
+
/** The file's text there; `null` when the path did not exist at the fork point. */
|
|
82
|
+
content: string | null;
|
|
83
|
+
/** The fork point read; `null` when the branches share no history (nothing was read). */
|
|
84
|
+
forkSha: string | null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A file as it stood at a change request's fork point — the "before" side of
|
|
89
|
+
* every diff of the request. Pass `sha` (the detail's `mergeBaseSha`) when you
|
|
90
|
+
* hold one; `null` asks the server for the request's current fork point.
|
|
91
|
+
*/
|
|
92
|
+
export async function readFileAtForkPoint(
|
|
93
|
+
crNumber: number,
|
|
94
|
+
sha: string | null,
|
|
95
|
+
repoRelativePath: string,
|
|
96
|
+
): Promise<ForkPointFile> {
|
|
97
|
+
const qs = new URLSearchParams({ path: repoRelativePath, ...(sha ? { sha } : {}) });
|
|
98
|
+
return handleApiResponse<ForkPointFile>(
|
|
99
|
+
await authFetch(`/api/workflow/change-requests/${crNumber}/fork-point-file?${qs}`),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { fetchFileAccess } from '../../access/api';
|
|
2
|
+
import { getOrCreateWorkspace } from '../../workspace/services/workspace.api';
|
|
3
|
+
import { failureReason, isDenial, nearestRuleFolder, type ReadFailure } from '../utils/readFailure';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Turning a failed file read into the fact a reviewer can act on.
|
|
7
|
+
*
|
|
8
|
+
* Lives beside the change-request reads rather than inside them because it
|
|
9
|
+
* makes its own request: naming the folder to ask about means resolving the
|
|
10
|
+
* path's access view, which the read that just failed obviously did not bring
|
|
11
|
+
* back. Kept in its own module so the read services stay one round trip each.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The nearest folder whose access rules govern `repoRelativePath`, or `null`
|
|
16
|
+
* when the app cannot name one.
|
|
17
|
+
*
|
|
18
|
+
* `GET /access` answers for any authenticated caller — it reports who may
|
|
19
|
+
* reach a path, which is not itself privileged — so a path the caller was just
|
|
20
|
+
* refused is still describable. Every failure here is swallowed: the folder is
|
|
21
|
+
* a courtesy on top of the denial, and a reviewer who cannot be told which
|
|
22
|
+
* folder to ask about still has to be told they were refused.
|
|
23
|
+
*/
|
|
24
|
+
export async function governingRuleFolder(
|
|
25
|
+
branch: string,
|
|
26
|
+
repoRelativePath: string,
|
|
27
|
+
): Promise<string | null> {
|
|
28
|
+
try {
|
|
29
|
+
const { workspace } = await getOrCreateWorkspace(branch);
|
|
30
|
+
const access = await fetchFileAccess(workspace.id, repoRelativePath);
|
|
31
|
+
// Grants AND denials: a 403 is as often a `deny` written nearer the file
|
|
32
|
+
// as it is a grant the reader is missing, and the folder worth asking
|
|
33
|
+
// about is whichever rule sits closest to the path.
|
|
34
|
+
return nearestRuleFolder(access.sources, access.denials);
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The failure, described: a denial (with the folder to ask about when there is
|
|
42
|
+
* one) or a retryable error with the reason the server gave. Async because
|
|
43
|
+
* naming the folder is a second read — callers keep showing "Loading…" until
|
|
44
|
+
* it settles rather than publishing a sentence they are about to rewrite.
|
|
45
|
+
*/
|
|
46
|
+
export async function describeReadFailure(
|
|
47
|
+
err: unknown,
|
|
48
|
+
branch: string,
|
|
49
|
+
repoRelativePath: string,
|
|
50
|
+
): Promise<ReadFailure> {
|
|
51
|
+
if (!isDenial(err)) return { kind: 'error', reason: failureReason(err) };
|
|
52
|
+
return { kind: 'denied', folder: await governingRuleFolder(branch, repoRelativePath) };
|
|
53
|
+
}
|
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
suggestionsBranchPrefixFor,
|
|
5
5
|
type PullRequestSummary,
|
|
6
6
|
} from '@bevel-software/platform-shared';
|
|
7
|
-
import { createBranch, deleteBranch } from '../../git/services/git.api';
|
|
7
|
+
import { createBranch, deleteBranch, GitApiError } from '../../git/services/git.api';
|
|
8
8
|
import { getOrCreateWorkspace, writeFile } from '../../workspace/services/workspace.api';
|
|
9
9
|
import { openChangeRequest } from '../../pr/services/pr-open.api';
|
|
10
|
+
import { fetchPrDetail } from '../../pr/services/pr-detail.api';
|
|
10
11
|
import { listMyChangeRequests } from './change-requests.api';
|
|
11
12
|
|
|
12
13
|
/** The default branch's workspace id (id = encodeURIComponent(branch)), read lazily. */
|
|
@@ -93,11 +94,33 @@ export interface KnowledgeSuggestionTarget {
|
|
|
93
94
|
existingCr: PullRequestSummary | null;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
|
|
97
|
+
/**
|
|
98
|
+
* The workspace ensure in flight for a branch — same in-flight-only contract
|
|
99
|
+
* as {@link openingByBranch}. Two proposals started together would otherwise
|
|
100
|
+
* each pay the fresh list read (the slow call), each try to create the same
|
|
101
|
+
* branch, and each reach the same conclusion; one answer serves both.
|
|
102
|
+
*/
|
|
103
|
+
const ensuringByBranch = new Map<string, Promise<KnowledgeSuggestionTarget>>();
|
|
104
|
+
|
|
105
|
+
export function ensureKnowledgeSuggestionWorkspace(
|
|
97
106
|
user: ProposalAuthor,
|
|
98
107
|
): Promise<KnowledgeSuggestionTarget> {
|
|
99
108
|
const branch = knowledgeSuggestionBranchFor(user);
|
|
109
|
+
const inFlight = ensuringByBranch.get(branch);
|
|
110
|
+
// Joining saves a duplicate of work that would have reached the same
|
|
111
|
+
// answer — it does not make the first flow's FAILURE this caller's answer.
|
|
112
|
+
// The map entry is already gone by the time this rejects (the `finally`
|
|
113
|
+
// below is attached first), so the fallback is a fresh attempt, not a
|
|
114
|
+
// re-join of the same dead promise.
|
|
115
|
+
if (inFlight) return inFlight.catch(() => ensureKnowledgeSuggestionWorkspace(user));
|
|
116
|
+
const ensuring = ensureFresh(branch).finally(() => {
|
|
117
|
+
if (ensuringByBranch.get(branch) === ensuring) ensuringByBranch.delete(branch);
|
|
118
|
+
});
|
|
119
|
+
ensuringByBranch.set(branch, ensuring);
|
|
120
|
+
return ensuring;
|
|
121
|
+
}
|
|
100
122
|
|
|
123
|
+
async function ensureFresh(branch: string): Promise<KnowledgeSuggestionTarget> {
|
|
101
124
|
// FRESH, not the 30s cache: a second proposal inside the cache window must
|
|
102
125
|
// see the request the first one just opened, or it opens a duplicate
|
|
103
126
|
// against the same branch.
|
|
@@ -138,22 +161,88 @@ export async function ensureKnowledgeSuggestionWorkspace(
|
|
|
138
161
|
return { branch, workspaceId: workspace.id, kbDirName: workspace.kbDirName, existingCr };
|
|
139
162
|
}
|
|
140
163
|
|
|
164
|
+
/**
|
|
165
|
+
* The number of the open request the server says already covers this
|
|
166
|
+
* (source, target) pair, or null when the failure was anything else. The
|
|
167
|
+
* refusal carries the number precisely so a client can reach the request
|
|
168
|
+
* instead of treating the state as broken (`DuplicateChangeRequestError`).
|
|
169
|
+
*/
|
|
170
|
+
function duplicateRequestNumber(err: unknown): number | null {
|
|
171
|
+
if (!(err instanceof GitApiError) || err.status !== 409) return null;
|
|
172
|
+
const body = err.body as { kind?: unknown; existingNumber?: unknown } | null | undefined;
|
|
173
|
+
if (!body || typeof body !== 'object' || body.kind !== 'duplicate-change-request') return null;
|
|
174
|
+
return typeof body.existingNumber === 'number' ? body.existingNumber : null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The open request being made for a branch right now, so a second proposal
|
|
179
|
+
* joins it instead of racing it. In-flight ONLY, never a cache: whether the
|
|
180
|
+
* caller still has an open request is the server's answer to give, and a
|
|
181
|
+
* withdrawn or merged one must not be remembered here.
|
|
182
|
+
*/
|
|
183
|
+
const openingByBranch = new Map<string, Promise<PullRequestSummary | null>>();
|
|
184
|
+
|
|
141
185
|
/**
|
|
142
186
|
* Open the caller's one Knowledge change request, unless it already exists.
|
|
143
187
|
* Returns the request either way (the server's created row, or the existing
|
|
144
188
|
* one) so callers can announce it — the optimistic suggestion rows need its
|
|
145
189
|
* number and branch the moment the write lands.
|
|
190
|
+
*
|
|
191
|
+
* Two proposals started before either had opened the request both read
|
|
192
|
+
* `existingCr: null` from `ensureKnowledgeSuggestionWorkspace`, and the
|
|
193
|
+
* second one used to fail the whole proposal on the server's
|
|
194
|
+
* one-open-request-per-pair refusal — a 409 the user saw as "Couldn't add
|
|
195
|
+
* change request". The window is exactly how long the fresh list read takes,
|
|
196
|
+
* which grows with the number of open requests, so "propose again while the
|
|
197
|
+
* first is still loading" hit it reliably. Both halves are closed here:
|
|
198
|
+
*
|
|
199
|
+
* - concurrently, the second call JOINS the first's open rather than issuing
|
|
200
|
+
* its own, so there is only ever one request in flight per branch; and
|
|
201
|
+
* - sequentially — or from another tab, or another device, where no
|
|
202
|
+
* client-side coordination can help — the duplicate refusal is read for
|
|
203
|
+
* what it is. It names the request that already exists, which is the state
|
|
204
|
+
* this function is trying to reach, so it adopts it instead of failing.
|
|
146
205
|
*/
|
|
147
|
-
export
|
|
206
|
+
export function ensureKnowledgeChangeRequest(
|
|
148
207
|
target: KnowledgeSuggestionTarget,
|
|
149
208
|
userName: string,
|
|
150
209
|
): Promise<PullRequestSummary | null> {
|
|
151
|
-
if (target.existingCr) return target.existingCr;
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
210
|
+
if (target.existingCr) return Promise.resolve(target.existingCr);
|
|
211
|
+
const inFlight = openingByBranch.get(target.branch);
|
|
212
|
+
// A joined open that fails is not this caller's verdict. The first flow's
|
|
213
|
+
// error says nothing about what this one's own attempt would meet — and in
|
|
214
|
+
// the case that matters (the connection dropped AFTER the server created
|
|
215
|
+
// the row) its own attempt meets the duplicate refusal and adopts the
|
|
216
|
+
// request, where joining would report "Couldn't add change request" about a
|
|
217
|
+
// request that exists. So a rejection falls back to one attempt of its own.
|
|
218
|
+
if (inFlight) return inFlight.catch(() => ensureKnowledgeChangeRequest(target, userName));
|
|
219
|
+
const opening = openKnowledgeChangeRequest(target, userName).finally(() => {
|
|
220
|
+
if (openingByBranch.get(target.branch) === opening) openingByBranch.delete(target.branch);
|
|
156
221
|
});
|
|
222
|
+
openingByBranch.set(target.branch, opening);
|
|
223
|
+
return opening;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function openKnowledgeChangeRequest(
|
|
227
|
+
target: KnowledgeSuggestionTarget,
|
|
228
|
+
userName: string,
|
|
229
|
+
): Promise<PullRequestSummary | null> {
|
|
230
|
+
let created: unknown;
|
|
231
|
+
try {
|
|
232
|
+
created = await openChangeRequest({
|
|
233
|
+
sourceBranch: target.branch,
|
|
234
|
+
targetBranch: DEFAULT_BRANCH,
|
|
235
|
+
title: `Changes from ${userName}. Knowledge`,
|
|
236
|
+
});
|
|
237
|
+
} catch (err) {
|
|
238
|
+
const existing = duplicateRequestNumber(err);
|
|
239
|
+
// Anything else is a real failure and stays one — the caller reports it.
|
|
240
|
+
if (existing === null) throw err;
|
|
241
|
+
// The request exists; read it so the caller can still announce its rows.
|
|
242
|
+
// A failed read is only a missing announcement, never a failed proposal:
|
|
243
|
+
// the bytes are committed and the request is open either way.
|
|
244
|
+
return await fetchPrDetail(existing, { fresh: true }).catch(() => null);
|
|
245
|
+
}
|
|
157
246
|
// The endpoint returns the created request; treat an unexpected shape as
|
|
158
247
|
// "no summary to announce" rather than a failure — the request exists.
|
|
159
248
|
return created && typeof (created as PullRequestSummary).number === 'number'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FileApprovalState } from '@bevel-software/platform-shared';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether the viewer's OWN current confirmation is on the file — the undo
|
|
5
|
+
* toggles yours, nobody else's, and stale rows stay for audit without arming
|
|
6
|
+
* it (presplit PrFileRow's rule, kept verbatim).
|
|
7
|
+
*/
|
|
8
|
+
export function hasOwnApproval(approval: FileApprovalState | undefined, viewerEmail: string) {
|
|
9
|
+
const email = viewerEmail.trim().toLowerCase();
|
|
10
|
+
return (
|
|
11
|
+
!!email &&
|
|
12
|
+
!!approval?.approvedBy.some((a) => a.email.toLowerCase() === email && !a.isStale)
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
@@ -45,3 +45,35 @@ export function formatWhen(iso: string): string {
|
|
|
45
45
|
if (days === 1) return 'yesterday';
|
|
46
46
|
return then.toLocaleDateString(undefined, { day: 'numeric', month: 'short' });
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* How many approvers besides the viewer a proposal is still waiting on — the
|
|
51
|
+
* "N" in "Waiting on you and N others".
|
|
52
|
+
*
|
|
53
|
+
* Called only for a viewer who can decide, so the viewer is always one of the
|
|
54
|
+
* pending approvers. The count is over GRANTS — the frontend never learns how
|
|
55
|
+
* many people a role holds — so a role counts once. The viewer's own user
|
|
56
|
+
* grant (matched by email, case-insensitively) is not "someone else". A viewer
|
|
57
|
+
* with no user grant of their own decides through a role, so one role grant is
|
|
58
|
+
* theirs: a file written only by `Admin` reads "Waiting on you" for an Admin,
|
|
59
|
+
* not "Waiting on you and 1 other". The viewer's roles are not known here, so
|
|
60
|
+
* one role is credited to them whichever it is.
|
|
61
|
+
*/
|
|
62
|
+
export function othersPendingBesides(
|
|
63
|
+
approvers: { roles: string[]; users: { email: string }[] },
|
|
64
|
+
viewerEmail: string | null | undefined,
|
|
65
|
+
): number {
|
|
66
|
+
const me = viewerEmail?.trim().toLowerCase();
|
|
67
|
+
const otherUsers = approvers.users.filter((u) => !me || u.email.trim().toLowerCase() !== me);
|
|
68
|
+
const viewerHasUserGrant = otherUsers.length < approvers.users.length;
|
|
69
|
+
const otherRoles = viewerHasUserGrant
|
|
70
|
+
? approvers.roles.length
|
|
71
|
+
: Math.max(0, approvers.roles.length - 1);
|
|
72
|
+
return otherRoles + otherUsers.length;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** "Waiting on you", or "Waiting on you and 2 others" when more are pending. */
|
|
76
|
+
export function waitingOnViewerLabel(othersPending: number): string {
|
|
77
|
+
if (othersPending <= 0) return 'Waiting on you';
|
|
78
|
+
return `Waiting on you and ${othersPending} ${othersPending === 1 ? 'other' : 'others'}`;
|
|
79
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { AccessResponse, GrantSources } from '../../access/api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WHY a copy of a file could not be read.
|
|
5
|
+
*
|
|
6
|
+
* The change-request view used to keep one `unreadable` flag per file and
|
|
7
|
+
* render one sentence for every failure, so a permission denial and a broken
|
|
8
|
+
* read looked the same. They are not the same fact and they do not have the
|
|
9
|
+
* same answer: a denial is settled by asking a person for access, a failure by
|
|
10
|
+
* trying the read again. A tester who was simply not allowed to see a file
|
|
11
|
+
* went looking for an outage that did not exist.
|
|
12
|
+
*/
|
|
13
|
+
export type ReadFailure =
|
|
14
|
+
/** The server refused on access grounds. `folder` is the nearest folder
|
|
15
|
+
* whose access rules govern the path, or `null` when none can be named. */
|
|
16
|
+
| { kind: 'denied'; folder: string | null }
|
|
17
|
+
/** Anything else — said with the reason, and retryable. */
|
|
18
|
+
| { kind: 'error'; reason: string };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The HTTP status an API error carries, when it carries one. Both
|
|
22
|
+
* `WorkspaceApiError` and `GitApiError` expose `status`; a network drop and a
|
|
23
|
+
* plain `Error` expose nothing, which is not a denial.
|
|
24
|
+
*/
|
|
25
|
+
export function statusOf(err: unknown): number | null {
|
|
26
|
+
const status = (err as { status?: unknown } | null | undefined)?.status;
|
|
27
|
+
return typeof status === 'number' ? status : null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A read the server refused because the caller may not see the path. */
|
|
31
|
+
export function isDenial(err: unknown): boolean {
|
|
32
|
+
return statusOf(err) === 403;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The parenthesised `<reason>` of the retryable sentence: the server's own
|
|
37
|
+
* words when it sent any (both API error classes carry the `{ error }` body as
|
|
38
|
+
* their message, falling back to `HTTP <status>`), and a plain statement for a
|
|
39
|
+
* read that never reached the server at all.
|
|
40
|
+
*/
|
|
41
|
+
export function failureReason(err: unknown): string {
|
|
42
|
+
const message = err instanceof Error ? err.message.trim() : '';
|
|
43
|
+
return message === '' ? 'the request never completed' : message;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** How deep a repo-relative folder sits; the root (`''`) is depth 0. */
|
|
47
|
+
const depthOf = (folder: string): number => (folder === '' ? 0 : folder.split('/').length);
|
|
48
|
+
|
|
49
|
+
/** The folders named by the `ancestor` entries of one per-principal map. */
|
|
50
|
+
function ancestorFolders(map: Record<string, GrantSources> | undefined): string[] {
|
|
51
|
+
return Object.values(map ?? {})
|
|
52
|
+
.flatMap((verbs) => Object.values(verbs ?? {}))
|
|
53
|
+
.flatMap((list) => list ?? [])
|
|
54
|
+
.filter((source) => source.kind === 'ancestor')
|
|
55
|
+
.map((source) => (source as { path: string }).path.replace(/(^|\/)access\.md$/, ''));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The nearest folder with an access rule for the path, read off the resolved
|
|
60
|
+
* access view's `sources` AND `denials` maps.
|
|
61
|
+
*
|
|
62
|
+
* Every `ancestor` entry in either map names the `access.md` that settles a
|
|
63
|
+
* principal's verb — which is exactly "a folder with an access rule for this
|
|
64
|
+
* path". The denials are read too, and that is the point: the refusal being
|
|
65
|
+
* explained is often a `deny` written in a folder BELOW the one that grants
|
|
66
|
+
* read, and naming only grant folders would send the reader to ask an owner
|
|
67
|
+
* who does not hold the rule that stopped them — or, where the deny is the
|
|
68
|
+
* only ancestor rule at all, to "this file". Resolution is closeness-first,
|
|
69
|
+
* so the DEEPEST folder either map names is the one to ask about. A path
|
|
70
|
+
* whose only rules are its own frontmatter has no ancestor entry and
|
|
71
|
+
* therefore no folder to name: `null`, and the sentence says "this file"
|
|
72
|
+
* instead of inventing a directory.
|
|
73
|
+
*/
|
|
74
|
+
export function nearestRuleFolder(
|
|
75
|
+
sources: AccessResponse['sources'] | undefined,
|
|
76
|
+
denials?: AccessResponse['denials'],
|
|
77
|
+
): string | null {
|
|
78
|
+
const folders = [...ancestorFolders(sources), ...ancestorFolders(denials)];
|
|
79
|
+
if (folders.length === 0) return null;
|
|
80
|
+
return folders.reduce((best, folder) => (depthOf(folder) > depthOf(best) ? folder : best));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* What the repository root is called when it is the folder to ask about — a
|
|
85
|
+
* rule written there reaches everything, and "" is not a name. The same words
|
|
86
|
+
* the Manage access dialog uses for it.
|
|
87
|
+
*/
|
|
88
|
+
const WHOLE_WORKSPACE = 'the whole workspace';
|
|
89
|
+
|
|
90
|
+
/** How the folder reads inside the sentence; `null` falls back to the file. */
|
|
91
|
+
export function askAboutLabel(folder: string | null): string {
|
|
92
|
+
if (folder === null) return 'this file';
|
|
93
|
+
return folder === '' ? WHOLE_WORKSPACE : folder;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The denial, said as the reason it is: not an outage, an access decision. */
|
|
97
|
+
export function deniedSentence(folder: string | null): string {
|
|
98
|
+
return (
|
|
99
|
+
"You don't have access to read this file, so its content can't be shown here. " +
|
|
100
|
+
`Ask an owner of ${askAboutLabel(folder)} for read access if you need to review it.`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The retryable sentence up to the Retry link, which the pane renders as a
|
|
106
|
+
* control (and so cannot live in a string): the caller appends "Try again."
|
|
107
|
+
*/
|
|
108
|
+
export function readErrorLead(reason: string): string {
|
|
109
|
+
return `This file couldn't be read right now (${reason}).`;
|
|
110
|
+
}
|
|
@@ -151,4 +151,24 @@ describe('FileHistoryPanel', () => {
|
|
|
151
151
|
expect(await screen.findByText(/No file changes in this save/i)).toBeInTheDocument();
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
+
// A past save's images are not the checked-out tree's: the panel passes no
|
|
155
|
+
// resolver, so both sides name the file rather than show today's bytes.
|
|
156
|
+
it('names the images in a past save instead of showing the checked-out copies', async () => {
|
|
157
|
+
const history = [makeAttr({ sha: 'aaaaaaa0000000000', subject: 'edit' })];
|
|
158
|
+
const { container } = renderWith(
|
|
159
|
+
makeGit({
|
|
160
|
+
fetchFileHistory: async () => history,
|
|
161
|
+
fetchFileAtChange: async () => ({
|
|
162
|
+
baseline: '\n',
|
|
163
|
+
current: '\n',
|
|
164
|
+
}),
|
|
165
|
+
}),
|
|
166
|
+
);
|
|
167
|
+
fireEvent.click(await screen.findByText('edit'));
|
|
168
|
+
expect(
|
|
169
|
+
await screen.findByRole('img', { name: /Baseline image not shown: \.\/assets\/old.png/ }),
|
|
170
|
+
).toBeInTheDocument();
|
|
171
|
+
expect(screen.getByRole('img', { name: /Image not shown: \.\/assets\/new.png/ })).toBeInTheDocument();
|
|
172
|
+
expect(container.querySelector('img')).toBeNull();
|
|
173
|
+
});
|
|
154
174
|
});
|