@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
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
FileEdit,
|
|
9
9
|
FilePlus2,
|
|
10
10
|
FileX2,
|
|
11
|
-
|
|
11
|
+
Lock,
|
|
12
12
|
} from 'lucide-react';
|
|
13
13
|
import type { FileApprovalState, PrFileStatus } from '@bevel-software/platform-shared';
|
|
14
14
|
import { cn } from '../../../lib/utils';
|
|
15
|
+
import { hasOwnApproval } from '../utils/approval';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* The change request's files as a TREE — the Knowledge sidebar's visual
|
|
@@ -24,9 +25,11 @@ import { cn } from '../../../lib/utils';
|
|
|
24
25
|
* - INLINE after the name: the approval STATE — green ✓ confirmed, amber
|
|
25
26
|
* clock for outdated confirmations, grey clock waiting — with the
|
|
26
27
|
* eligible approvers in the tooltip.
|
|
27
|
-
* -
|
|
28
|
-
* green check
|
|
29
|
-
*
|
|
28
|
+
* - For a file that is the VIEWER's to approve, the state is theirs instead:
|
|
29
|
+
* a filled green check "Approved by you", or an outlined one "Waiting on
|
|
30
|
+
* your approval". A status mark, not a control — approving is the labelled
|
|
31
|
+
* button in the selected file's header, where the reviewer is reading
|
|
32
|
+
* (an unlabelled check on a tree row was not findable).
|
|
30
33
|
*
|
|
31
34
|
* Right-click a revertable file for the destructive verb, armed inside its
|
|
32
35
|
* own context menu. Selection (which file the diff shows) stays a plain
|
|
@@ -43,19 +46,25 @@ export interface CrTreeFileState {
|
|
|
43
46
|
/** Git status when changed (drives the kind icon). */
|
|
44
47
|
status?: PrFileStatus;
|
|
45
48
|
approval?: FileApprovalState;
|
|
49
|
+
/**
|
|
50
|
+
* The access sentence when this file's copy came back REFUSED — the lock
|
|
51
|
+
* glyph's tooltip, and the reason it is there. The same sentence the pane
|
|
52
|
+
* shows, so a reader who meets the lock in the list and the sentence in the
|
|
53
|
+
* pane is told one thing, not two. Absent for every other file, including
|
|
54
|
+
* one whose read merely broke: that is retryable and says so in the pane.
|
|
55
|
+
*/
|
|
56
|
+
deniedNote?: string;
|
|
46
57
|
}
|
|
47
58
|
|
|
48
59
|
interface CrFileTreeProps {
|
|
49
60
|
files: CrTreeFileState[];
|
|
50
61
|
selected: string;
|
|
51
|
-
/** The viewer — whose own current confirmation the
|
|
62
|
+
/** The viewer — whose own current confirmation the status mark reads. */
|
|
52
63
|
currentUserEmail: string;
|
|
53
64
|
onSelect(path: string): void;
|
|
54
|
-
/** Confirm `path`, or withdraw the viewer's own confirmation of it. */
|
|
55
|
-
onToggleApprove(path: string, hasOwnApproval: boolean): void;
|
|
56
65
|
/** Revert `path` on the source branch. Only called when approvable+changed. */
|
|
57
66
|
onRevert(path: string): void;
|
|
58
|
-
/** Disables the
|
|
67
|
+
/** Disables the revert verb while one is in flight. */
|
|
59
68
|
busy: boolean;
|
|
60
69
|
}
|
|
61
70
|
|
|
@@ -96,7 +105,6 @@ export function CrFileTree({
|
|
|
96
105
|
selected,
|
|
97
106
|
currentUserEmail,
|
|
98
107
|
onSelect,
|
|
99
|
-
onToggleApprove,
|
|
100
108
|
onRevert,
|
|
101
109
|
busy,
|
|
102
110
|
}: CrFileTreeProps) {
|
|
@@ -121,12 +129,10 @@ export function CrFileTree({
|
|
|
121
129
|
selected={selected}
|
|
122
130
|
currentUserEmail={currentUserEmail}
|
|
123
131
|
onSelect={onSelect}
|
|
124
|
-
onToggleApprove={onToggleApprove}
|
|
125
132
|
onContextMenu={(path, e) => {
|
|
126
133
|
e.preventDefault();
|
|
127
134
|
setMenu({ path, x: e.clientX, y: e.clientY });
|
|
128
135
|
}}
|
|
129
|
-
busy={busy}
|
|
130
136
|
/>
|
|
131
137
|
{menu && (
|
|
132
138
|
<RevertMenu
|
|
@@ -151,9 +157,7 @@ function Level({
|
|
|
151
157
|
selected,
|
|
152
158
|
currentUserEmail,
|
|
153
159
|
onSelect,
|
|
154
|
-
onToggleApprove,
|
|
155
160
|
onContextMenu,
|
|
156
|
-
busy,
|
|
157
161
|
}: {
|
|
158
162
|
folder: TreeFolder;
|
|
159
163
|
depth: number;
|
|
@@ -162,9 +166,7 @@ function Level({
|
|
|
162
166
|
selected: string;
|
|
163
167
|
currentUserEmail: string;
|
|
164
168
|
onSelect(path: string): void;
|
|
165
|
-
onToggleApprove(path: string, hasOwnApproval: boolean): void;
|
|
166
169
|
onContextMenu(path: string, e: React.MouseEvent): void;
|
|
167
|
-
busy: boolean;
|
|
168
170
|
}) {
|
|
169
171
|
return (
|
|
170
172
|
<>
|
|
@@ -196,9 +198,7 @@ function Level({
|
|
|
196
198
|
selected={selected}
|
|
197
199
|
currentUserEmail={currentUserEmail}
|
|
198
200
|
onSelect={onSelect}
|
|
199
|
-
onToggleApprove={onToggleApprove}
|
|
200
201
|
onContextMenu={onContextMenu}
|
|
201
|
-
busy={busy}
|
|
202
202
|
/>
|
|
203
203
|
)}
|
|
204
204
|
</div>
|
|
@@ -208,15 +208,19 @@ function Level({
|
|
|
208
208
|
const name = file.path.slice(file.path.lastIndexOf('/') + 1);
|
|
209
209
|
const on = selected === file.path;
|
|
210
210
|
const eligible = file.changed && file.approval?.viewerCanApprove === true;
|
|
211
|
-
// The
|
|
212
|
-
//
|
|
213
|
-
//
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
)
|
|
211
|
+
// The viewer's own state wins the slot when there is one: approved
|
|
212
|
+
// by them, or still waiting on them. Otherwise the general badge.
|
|
213
|
+
// "Waiting" means the gate needs them: one eligible approval satisfies
|
|
214
|
+
// a file, so once someone else has confirmed it the file waits on
|
|
215
|
+
// nobody and reads "Confirmed" — the footer's count agrees. The header
|
|
216
|
+
// still lets them add their own.
|
|
217
|
+
const viewerMark = !eligible
|
|
218
|
+
? null
|
|
219
|
+
: hasOwnApproval(file.approval, currentUserEmail)
|
|
220
|
+
? 'approved'
|
|
221
|
+
: file.approval?.inMergeGate && !file.approval.isApproved
|
|
222
|
+
? 'waiting'
|
|
223
|
+
: null;
|
|
220
224
|
return (
|
|
221
225
|
<div
|
|
222
226
|
key={file.path}
|
|
@@ -243,33 +247,11 @@ function Level({
|
|
|
243
247
|
>
|
|
244
248
|
{name}
|
|
245
249
|
</button>
|
|
246
|
-
|
|
247
|
-
{
|
|
248
|
-
<
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
type="button"
|
|
252
|
-
disabled={busy}
|
|
253
|
-
title="Withdraw your confirmation"
|
|
254
|
-
aria-label={`Withdraw your confirmation of ${file.path}`}
|
|
255
|
-
onClick={() => onToggleApprove(file.path, true)}
|
|
256
|
-
className="rounded-sm p-1 text-ok transition-colors hover:bg-danger-soft hover:text-danger disabled:cursor-not-allowed disabled:opacity-40"
|
|
257
|
-
>
|
|
258
|
-
<X size={12} />
|
|
259
|
-
</button>
|
|
260
|
-
) : (
|
|
261
|
-
<button
|
|
262
|
-
type="button"
|
|
263
|
-
disabled={busy}
|
|
264
|
-
title="Confirm this file"
|
|
265
|
-
aria-label={`Confirm ${file.path}`}
|
|
266
|
-
onClick={() => onToggleApprove(file.path, false)}
|
|
267
|
-
className="rounded-sm bg-ok p-1 text-white transition-colors hover:opacity-85 disabled:cursor-not-allowed disabled:opacity-40"
|
|
268
|
-
>
|
|
269
|
-
<Check size={12} />
|
|
270
|
-
</button>
|
|
271
|
-
)}
|
|
272
|
-
</span>
|
|
250
|
+
{file.deniedNote && <DeniedMark note={file.deniedNote} />}
|
|
251
|
+
{viewerMark ? (
|
|
252
|
+
<ViewerApprovalMark state={viewerMark} />
|
|
253
|
+
) : (
|
|
254
|
+
<ApprovalStateBadge approval={file.changed ? file.approval : undefined} />
|
|
273
255
|
)}
|
|
274
256
|
</div>
|
|
275
257
|
);
|
|
@@ -298,16 +280,50 @@ function KindIcon({ status }: { status?: PrFileStatus }) {
|
|
|
298
280
|
}
|
|
299
281
|
}
|
|
300
282
|
|
|
283
|
+
/**
|
|
284
|
+
* A file whose copy the viewer may not read. Beside the name rather than in
|
|
285
|
+
* place of the kind icon: what the request DID to the file is still true and
|
|
286
|
+
* still worth seeing, and the lock is the extra fact — this one you can't open.
|
|
287
|
+
*/
|
|
288
|
+
function DeniedMark({ note }: { note: string }) {
|
|
289
|
+
return (
|
|
290
|
+
<span
|
|
291
|
+
role="img"
|
|
292
|
+
aria-label={note}
|
|
293
|
+
title={note}
|
|
294
|
+
className="flex flex-none items-center text-ink-faint"
|
|
295
|
+
>
|
|
296
|
+
<Lock size={11} />
|
|
297
|
+
</span>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** The viewer's own approval state on a file that is theirs to approve. */
|
|
302
|
+
function ViewerApprovalMark({ state }: { state: 'approved' | 'waiting' }) {
|
|
303
|
+
const label = state === 'approved' ? 'Approved by you' : 'Waiting on your approval';
|
|
304
|
+
return (
|
|
305
|
+
<span
|
|
306
|
+
role="img"
|
|
307
|
+
aria-label={label}
|
|
308
|
+
title={label}
|
|
309
|
+
className={cn(
|
|
310
|
+
'flex flex-none items-center rounded-sm p-0.5',
|
|
311
|
+
state === 'approved' ? 'bg-ok text-white' : 'border border-ok text-ok',
|
|
312
|
+
)}
|
|
313
|
+
>
|
|
314
|
+
<Check size={11} />
|
|
315
|
+
</span>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
301
319
|
/**
|
|
302
320
|
* The approval STATE, inline after the name — presplit PrApprovalBadge:
|
|
303
321
|
* green ✓ confirmed, amber clock for outdated confirmations, grey clock
|
|
304
|
-
* waiting; nothing at all for files outside the gate (keeps the tree quiet
|
|
322
|
+
* waiting; nothing at all for files outside the gate (keeps the tree quiet,
|
|
323
|
+
* and names no one the gate does not wait on — the footer's rule).
|
|
305
324
|
*/
|
|
306
325
|
function ApprovalStateBadge({ approval }: { approval?: FileApprovalState }) {
|
|
307
|
-
if (!approval) return null;
|
|
308
|
-
const hasEligible =
|
|
309
|
-
approval.eligibleApprovers.roles.length > 0 || approval.eligibleApprovers.users.length > 0;
|
|
310
|
-
if (!hasEligible) return null;
|
|
326
|
+
if (!approval?.inMergeGate) return null;
|
|
311
327
|
const who = [
|
|
312
328
|
...approval.eligibleApprovers.roles,
|
|
313
329
|
...approval.eligibleApprovers.users.map((u) => u.name || u.email),
|
|
@@ -4,9 +4,8 @@ import { Banner, Button } from '../../../shared/components';
|
|
|
4
4
|
import { cancelPullRequest } from '../../pr/services/pr-cancel.api';
|
|
5
5
|
import { useOpenChangeRequests } from '../../workspace/hooks/useOpenChangeRequests';
|
|
6
6
|
import { PR_STALE_EVENT } from '../../../core/events';
|
|
7
|
-
import { useApplyChangeRequest } from '../hooks/useApplyChangeRequest';
|
|
7
|
+
import { refusalLine, useApplyChangeRequest } from '../hooks/useApplyChangeRequest';
|
|
8
8
|
import { useCrFileDiffs } from '../hooks/useCrFileDiffs';
|
|
9
|
-
import { useDefaultBranchFile } from '../hooks/useFileOnBranch';
|
|
10
9
|
import { changeAuthorName, formatWhen } from '../utils/author';
|
|
11
10
|
import { conflictResolutionPrompt } from '../utils/conflict';
|
|
12
11
|
import { isBinaryFile } from '../../workspace/components/renderers';
|
|
@@ -22,6 +21,11 @@ export interface FileChangeBoxesProps {
|
|
|
22
21
|
canDecide: boolean;
|
|
23
22
|
/** Who the decision waits on, for the non-owner's footer. */
|
|
24
23
|
ownersLabel: string;
|
|
24
|
+
/**
|
|
25
|
+
* For a viewer who can decide: how many approvers besides them the file
|
|
26
|
+
* still waits on. Feeds "Waiting on you and N others".
|
|
27
|
+
*/
|
|
28
|
+
othersPending?: number;
|
|
25
29
|
/** The default branch just changed under this file — a request landed. */
|
|
26
30
|
onApplied(): void;
|
|
27
31
|
}
|
|
@@ -33,8 +37,8 @@ export interface FileChangeBoxesProps {
|
|
|
33
37
|
* text become that text?") is unanswerable without the text, which is why
|
|
34
38
|
* this is not a banner pointing at a review queue somewhere else.
|
|
35
39
|
*
|
|
36
|
-
* Owns the whole decision loop: per-request diffs
|
|
37
|
-
*
|
|
40
|
+
* Owns the whole decision loop: per-request diffs from each request's fork
|
|
41
|
+
* point (see `useCrFileDiffs`), Approve (approvals → merge → wait for the outcome event),
|
|
38
42
|
* Decline, the author's Withdraw, and "Read the whole change" opening the
|
|
39
43
|
* shared {@link ChangeRequestDialog}. Resolutions dispatch
|
|
40
44
|
* {@link PR_STALE_EVENT} so the tree dots, the tabs and this very list
|
|
@@ -45,6 +49,7 @@ export function FileChangeBoxes({
|
|
|
45
49
|
requests,
|
|
46
50
|
canDecide,
|
|
47
51
|
ownersLabel,
|
|
52
|
+
othersPending,
|
|
48
53
|
onApplied,
|
|
49
54
|
}: FileChangeBoxesProps) {
|
|
50
55
|
const { mineNumbers } = useOpenChangeRequests();
|
|
@@ -61,8 +66,7 @@ export function FileChangeBoxes({
|
|
|
61
66
|
// Binary files never diff (see the box's `binary` prop) — so never fetch
|
|
62
67
|
// and decode their default-branch bytes either.
|
|
63
68
|
const binary = isBinaryFile(repoRelativePath);
|
|
64
|
-
const
|
|
65
|
-
const crDiffs = useCrFileDiffs(requests, repoRelativePath, rawOnMain, revision);
|
|
69
|
+
const crDiffs = useCrFileDiffs(requests, repoRelativePath, revision);
|
|
66
70
|
|
|
67
71
|
const resolved = useCallback(() => {
|
|
68
72
|
setApplied(true);
|
|
@@ -119,7 +123,8 @@ export function FileChangeBoxes({
|
|
|
119
123
|
// `[]` is the diff hook's "overtaken" answer — the proposal and the
|
|
120
124
|
// file now say the same thing — distinct from `null`, which only
|
|
121
125
|
// means a side has not arrived yet.
|
|
122
|
-
const
|
|
126
|
+
const read = crDiffs.get(cr.number) ?? null;
|
|
127
|
+
const fileDiff = read === 'unreadable' ? null : read;
|
|
123
128
|
return (
|
|
124
129
|
<ChangeBox
|
|
125
130
|
key={cr.number}
|
|
@@ -127,20 +132,19 @@ export function FileChangeBoxes({
|
|
|
127
132
|
author={changeAuthorName(cr)}
|
|
128
133
|
when={formatWhen(cr.createdAt)}
|
|
129
134
|
mine={mine}
|
|
130
|
-
|
|
135
|
+
// Approval rights come from the file, not from authorship: an
|
|
136
|
+
// eligible approver decides their own proposal too (the gate
|
|
137
|
+
// accepts it and records it as a self-approval).
|
|
138
|
+
canDecide={canDecide}
|
|
131
139
|
diff={fileDiff}
|
|
132
140
|
binary={binary}
|
|
141
|
+
unreadable={read === 'unreadable'}
|
|
133
142
|
upToDate={fileDiff !== null && fileDiff.length === 0}
|
|
134
143
|
blocked={blockedCrs.has(cr.number)}
|
|
135
144
|
conflictPrompt={conflictResolutionPrompt(cr)}
|
|
136
|
-
|
|
137
|
-
// refusal line would say the same thing twice in one box.
|
|
138
|
-
refusal={
|
|
139
|
-
applying.refusals.get(cr.number)?.conflicts === false
|
|
140
|
-
? (applying.refusals.get(cr.number)?.reason ?? null)
|
|
141
|
-
: null
|
|
142
|
-
}
|
|
145
|
+
refusal={refusalLine(cr, applying.refusals)}
|
|
143
146
|
owner={ownersLabel}
|
|
147
|
+
othersPending={othersPending}
|
|
144
148
|
busy={busyCr === cr.number || applying.activeCr === cr.number}
|
|
145
149
|
phase={applying.activeCr === cr.number ? applying.phase : 'idle'}
|
|
146
150
|
onApprove={() => applying.apply(cr)}
|
|
@@ -22,6 +22,39 @@ export type ApplyPhase = 'idle' | 'approving' | 'applying';
|
|
|
22
22
|
export interface ApplyRefusal {
|
|
23
23
|
reason: string;
|
|
24
24
|
conflicts: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* When it failed (ISO): the server's instant for a refusal the server
|
|
27
|
+
* reported — the same one it persists — else this tab's clock.
|
|
28
|
+
*/
|
|
29
|
+
at?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The refusal line a change box shows for `cr`. This tab's own attempt speaks
|
|
34
|
+
* first, and a conflict there says nothing here because the box's blocked state
|
|
35
|
+
* already does — unless the request carries a LATER refusal, from somebody
|
|
36
|
+
* else's attempt since. Otherwise the refusal PERSISTED on the request, which
|
|
37
|
+
* is how the author and every other viewer learn that somebody's apply failed.
|
|
38
|
+
* That one never withdraws the button: the author may already have fixed the
|
|
39
|
+
* cause, and only a new attempt can say so.
|
|
40
|
+
*/
|
|
41
|
+
export function refusalLine(
|
|
42
|
+
cr: PullRequestSummary,
|
|
43
|
+
refusals: ReadonlyMap<number, ApplyRefusal>,
|
|
44
|
+
): string | null {
|
|
45
|
+
const own = refusals.get(cr.number);
|
|
46
|
+
const persisted = cr.lastApplyFailure ?? null;
|
|
47
|
+
if (own && !isLater(persisted?.at, own.at)) return own.conflicts ? null : own.reason;
|
|
48
|
+
return persisted?.reason ?? null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** True when `a` is a strictly later instant than `b`; unknown is never later. */
|
|
52
|
+
function isLater(a: string | undefined, b: string | undefined): boolean {
|
|
53
|
+
if (!a) return false;
|
|
54
|
+
if (!b) return true;
|
|
55
|
+
const ta = Date.parse(a);
|
|
56
|
+
const tb = Date.parse(b);
|
|
57
|
+
return Number.isFinite(ta) && Number.isFinite(tb) && ta > tb;
|
|
25
58
|
}
|
|
26
59
|
|
|
27
60
|
export interface ApplyChangeRequest {
|
|
@@ -40,8 +73,8 @@ export interface ApplyChangeRequest {
|
|
|
40
73
|
* calling `mergePullRequest` and awaiting it:
|
|
41
74
|
*
|
|
42
75
|
* 1. **Approving is not merging.** The merge gate requires a recorded per-file
|
|
43
|
-
* approval from an eligible approver for every
|
|
44
|
-
*
|
|
76
|
+
* approval from an eligible approver for every file that has owners,
|
|
77
|
+
* whatever its type — which is precisely the case the skill page is built for, since a
|
|
45
78
|
* SKILL.md inside a plugin folder inherits that folder's `access.md`. Going
|
|
46
79
|
* straight to merge is refused with "Waiting on approval for …". So the
|
|
47
80
|
* owner's click records the approvals FIRST, then merges. Files the caller
|
|
@@ -111,7 +144,8 @@ export function useApplyChangeRequest(opts: {
|
|
|
111
144
|
const fail = useCallback(
|
|
112
145
|
(number: number, refusal: ApplyRefusal) => {
|
|
113
146
|
stop();
|
|
114
|
-
|
|
147
|
+
const at = refusal.at ?? new Date().toISOString();
|
|
148
|
+
setRefusals((m) => new Map(m).set(number, { ...refusal, at }));
|
|
115
149
|
onFailedRef.current?.(number, refusal);
|
|
116
150
|
},
|
|
117
151
|
[stop],
|
|
@@ -133,6 +167,7 @@ export function useApplyChangeRequest(opts: {
|
|
|
133
167
|
fail(e.number, {
|
|
134
168
|
reason: e.reason || "Couldn't apply this change.",
|
|
135
169
|
conflicts: e.conflicts === true,
|
|
170
|
+
at: e.at,
|
|
136
171
|
});
|
|
137
172
|
});
|
|
138
173
|
return () => {
|
|
@@ -173,10 +208,9 @@ export function useApplyChangeRequest(opts: {
|
|
|
173
208
|
|
|
174
209
|
for (const a of detail.approvals) {
|
|
175
210
|
if (a.isApproved) continue;
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (!gateCares) continue;
|
|
211
|
+
// The server's verdict on whether the gate binds the file at all —
|
|
212
|
+
// a file it ignores gets no recorded approval.
|
|
213
|
+
if (!a.inMergeGate) continue;
|
|
180
214
|
// A refusal here is "not your file", which is normal on a change
|
|
181
215
|
// request spanning several owners — let the gate below decide
|
|
182
216
|
// whether what did get approved is enough.
|
|
@@ -1,79 +1,237 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import type { PullRequestSummary } from '@bevel-software/platform-shared';
|
|
3
|
-
import { readFileOnBranch } from '../services/change-requests.api';
|
|
3
|
+
import { readFileAtForkPoint, readFileOnBranch, type ForkPointFile } from '../services/change-requests.api';
|
|
4
|
+
import { subscribePrStale } from '../../../core/events';
|
|
4
5
|
import { isBinaryFile } from '../../workspace/components/renderers';
|
|
6
|
+
import { WorkspaceApiError } from '../../workspace/services/workspace.api';
|
|
5
7
|
import { diffLines, hasChanges, type DiffLine } from '../utils/diff';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
|
-
* For each open change request touching `repoRelativePath`,
|
|
9
|
-
*
|
|
10
|
+
* For each open change request touching `repoRelativePath`, what THAT REQUEST
|
|
11
|
+
* changes in the file: its branch's copy diffed against the file as it stood
|
|
12
|
+
* at the request's fork point — the text its author started from.
|
|
10
13
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* Not against current main. Diffing against the tip showed every edit made on
|
|
15
|
+
* main after the proposal as something the proposal DELETES: a reader saw
|
|
16
|
+
* another person's direct edit struck through inside somebody else's request,
|
|
17
|
+
* and feared approving it would undo that edit. (Applying is a merge, and keeps
|
|
18
|
+
* the newer edit.) The request dialog reads the same fork point, so the box and
|
|
19
|
+
* the whole-change view never disagree about what a request does.
|
|
14
20
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
21
|
+
* The TARGET branch's text is the "before" in exactly one case: branches with
|
|
22
|
+
* no shared history have no fork point to read, and the target's tip is the
|
|
23
|
+
* only text left. That read is made HERE — against the request's own
|
|
24
|
+
* `base`, which is not always the default branch — and only once a fork read
|
|
25
|
+
* comes back without a fork point, so it carries the same generation as the
|
|
26
|
+
* two sides it joins. A copy passed in from the page would keep whatever
|
|
27
|
+
* moment the page last read it at, and pair a fresh branch copy with a stale
|
|
28
|
+
* target.
|
|
29
|
+
*
|
|
30
|
+
* Branch reads are keyed by CR number + path + revision so a tab switch or a
|
|
31
|
+
* reload can never show the previous file's diff under this file's heading.
|
|
32
|
+
* Fork reads carry no revision: resolving a fork point costs the server two
|
|
33
|
+
* branch fetches and a `merge-base` per box, and a revision bump (a tab
|
|
34
|
+
* switch, an apply elsewhere on the page) does not move any request's fork
|
|
35
|
+
* point. The one thing that does — an Update — announces itself with
|
|
36
|
+
* {@link PR_STALE_EVENT}.
|
|
37
|
+
*
|
|
38
|
+
* BOTH keys carry that event's epoch, because the two sides of one diff have
|
|
39
|
+
* to describe the same moment. Re-reading only the fork point after an Update
|
|
40
|
+
* paired the merged target's text with the branch copy cached from before the
|
|
41
|
+
* merge, and the target's own newer lines rendered as deletions inside the
|
|
42
|
+
* request — the exact reading this hook exists to prevent, arriving seconds
|
|
43
|
+
* after the Update that was supposed to settle it. Under a new epoch neither
|
|
44
|
+
* side is cached, so a box waits rather than mixing two moments.
|
|
45
|
+
*
|
|
46
|
+
* Each arrival drops what earlier generations left behind, so a page left open
|
|
47
|
+
* through many applies and pulls holds one set of reads, not one per event.
|
|
48
|
+
*
|
|
49
|
+
* Per request: the diff; `[]` when the proposal has been overtaken; `null`
|
|
50
|
+
* while a read is in flight; `'unreadable'` when a read failed, so the box
|
|
51
|
+
* can say so instead of loading forever.
|
|
17
52
|
*/
|
|
53
|
+
export type CrFileDiff = DiffLine[] | null | 'unreadable';
|
|
54
|
+
|
|
18
55
|
export function useCrFileDiffs(
|
|
19
56
|
crs: PullRequestSummary[],
|
|
20
57
|
repoRelativePath: string,
|
|
21
|
-
mainRaw: string | null,
|
|
22
58
|
revision = 0,
|
|
23
|
-
): Map<number,
|
|
59
|
+
): Map<number, CrFileDiff> {
|
|
24
60
|
const [contents, setContents] = useState<Map<string, string>>(new Map());
|
|
61
|
+
const [forkReads, setForkReads] = useState<Map<string, ForkPointFile>>(new Map());
|
|
62
|
+
/** Keys whose branch, fork or main read failed — no comparison is coming. */
|
|
63
|
+
const [failed, setFailed] = useState<Set<string>>(new Set());
|
|
25
64
|
/** Requests already made, so a failed read is not retried on every render. */
|
|
26
65
|
const asked = useRef<Set<string>>(new Set());
|
|
66
|
+
const forkAsked = useRef<Set<string>>(new Set());
|
|
67
|
+
const targetAsked = useRef<Set<string>>(new Set());
|
|
68
|
+
/**
|
|
69
|
+
* Bumped when something moved a request — an apply, a cancel, an Update.
|
|
70
|
+
* Both sides are re-read: a request that moved has a new head as well as a
|
|
71
|
+
* new fork point, and half a re-read is a diff between two moments.
|
|
72
|
+
*/
|
|
73
|
+
const [staleEpoch, setStaleEpoch] = useState(0);
|
|
74
|
+
useEffect(
|
|
75
|
+
() =>
|
|
76
|
+
subscribePrStale(() => {
|
|
77
|
+
asked.current.clear();
|
|
78
|
+
forkAsked.current.clear();
|
|
79
|
+
targetAsked.current.clear();
|
|
80
|
+
setStaleEpoch((e) => e + 1);
|
|
81
|
+
}),
|
|
82
|
+
[],
|
|
83
|
+
);
|
|
27
84
|
|
|
28
85
|
// Only the change requests that actually touch this file have anything to show.
|
|
29
86
|
const relevant = useMemo(
|
|
30
87
|
() => crs.filter((c) => c.touchedNodePaths.includes(repoRelativePath)),
|
|
31
88
|
[crs, repoRelativePath],
|
|
32
89
|
);
|
|
33
|
-
const key = (n: number) => `${n}::${repoRelativePath}::${revision}`;
|
|
90
|
+
const key = (n: number) => `${n}::${repoRelativePath}::${revision}::${staleEpoch}`;
|
|
91
|
+
const forkKey = (n: number) => `${n}::${repoRelativePath}::${staleEpoch}`;
|
|
92
|
+
/**
|
|
93
|
+
* The fallback read is keyed by the TARGET BRANCH, not just the path: a
|
|
94
|
+
* request does not have to target the default branch, and two requests on
|
|
95
|
+
* one file can aim at different ones. Keying by path alone served whichever
|
|
96
|
+
* target happened to be read first to every no-history request on the file.
|
|
97
|
+
*/
|
|
98
|
+
const targetKey = (base: string) => `target:${base}::${repoRelativePath}::${staleEpoch}`;
|
|
34
99
|
const wanted = relevant.map((c) => `${c.number}|${c.branch}`).join(',');
|
|
35
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Exactly the keys the CURRENT generation reads under. Held in a ref and
|
|
103
|
+
* refreshed before the reads are started, because the alternative — each
|
|
104
|
+
* callback testing against the generation it closed over — lets a slow read
|
|
105
|
+
* from an older generation prune the newer one's answers on arrival, and
|
|
106
|
+
* the `asked` guard then never fetches them again: a box loading forever.
|
|
107
|
+
* Anything not in this set is either a generation that has passed or a
|
|
108
|
+
* request that is no longer on this file, and neither is worth keeping.
|
|
109
|
+
*/
|
|
110
|
+
const liveKeys = useRef<Set<string>>(new Set());
|
|
111
|
+
const live = (k: string) => liveKeys.current.has(k);
|
|
112
|
+
const prunedMap = <V,>(m: Map<string, V>) => new Map([...m].filter(([k]) => live(k)));
|
|
113
|
+
const prunedSet = (s: Set<string>) => new Set([...s].filter(live));
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
liveKeys.current = new Set([
|
|
116
|
+
...relevant.map((cr) => key(cr.number)),
|
|
117
|
+
...relevant.map((cr) => forkKey(cr.number)),
|
|
118
|
+
...relevant.map((cr) => targetKey(cr.base)),
|
|
119
|
+
]);
|
|
120
|
+
// Declared BEFORE the read effect so it has already run when those reads
|
|
121
|
+
// are started, and so before any of their answers can arrive.
|
|
122
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
123
|
+
}, [wanted, repoRelativePath, revision, staleEpoch]);
|
|
124
|
+
|
|
36
125
|
/**
|
|
37
126
|
* No `cancelled` flag — see `useDefaultBranchFile` for why one would deadlock
|
|
38
127
|
* against the `asked` guard under StrictMode. Stale answers are discarded by
|
|
39
|
-
* the KEY (cr + path + revision), not by cleanup.
|
|
128
|
+
* the KEY (cr + path + revision + epoch), not by cleanup.
|
|
40
129
|
*/
|
|
41
130
|
useEffect(() => {
|
|
42
131
|
// A binary file has no honest text diff, and line-diffing decoded binary
|
|
43
132
|
// bytes is quadratic enough to hang the tab — never even read it. The
|
|
44
133
|
// boxes render their own binary notice instead of a diff.
|
|
45
134
|
if (isBinaryFile(repoRelativePath)) return;
|
|
135
|
+
// The guards are refs, so they outlive the generation that filled them.
|
|
136
|
+
for (const set of [asked.current, forkAsked.current, targetAsked.current]) {
|
|
137
|
+
for (const k of [...set]) if (!live(k)) set.delete(k);
|
|
138
|
+
}
|
|
46
139
|
for (const cr of relevant) {
|
|
47
140
|
const k = key(cr.number);
|
|
48
141
|
if (asked.current.has(k)) continue;
|
|
49
142
|
asked.current.add(k);
|
|
50
143
|
readFileOnBranch(cr.branch, repoRelativePath)
|
|
51
|
-
.then((content) =>
|
|
144
|
+
.then((content) => {
|
|
145
|
+
if (live(k)) setContents((m) => prunedMap(m).set(k, content));
|
|
146
|
+
})
|
|
147
|
+
.catch((err: unknown) => {
|
|
148
|
+
if (!live(k)) return;
|
|
149
|
+
// A 404 is the branch's own answer that the file is not there: the
|
|
150
|
+
// request DELETES it, and every line removed is exactly its diff.
|
|
151
|
+
if (err instanceof WorkspaceApiError && err.status === 404) {
|
|
152
|
+
setContents((m) => prunedMap(m).set(k, ''));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// Anything else is deliberately NOT `''`. Storing empty for an
|
|
156
|
+
// unreadable branch copy would diff as "every line deleted" and
|
|
157
|
+
// present a proposal to erase the file. No content means no claim:
|
|
158
|
+
// the box says it couldn't read.
|
|
159
|
+
setFailed((s) => prunedSet(s).add(k));
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
for (const cr of relevant) {
|
|
163
|
+
const fk = forkKey(cr.number);
|
|
164
|
+
if (forkAsked.current.has(fk)) continue;
|
|
165
|
+
forkAsked.current.add(fk);
|
|
166
|
+
readFileAtForkPoint(cr.number, null, repoRelativePath)
|
|
167
|
+
.then((read) => {
|
|
168
|
+
if (!live(fk)) return;
|
|
169
|
+
setForkReads((m) => prunedMap(m).set(fk, read));
|
|
170
|
+
// No fork point (no shared history): main's tip is the only "before"
|
|
171
|
+
// left, and it is read now, under this generation's key.
|
|
172
|
+
const tk = targetKey(cr.base);
|
|
173
|
+
if (read.forkSha === null && !targetAsked.current.has(tk)) {
|
|
174
|
+
targetAsked.current.add(tk);
|
|
175
|
+
readFileOnBranch(cr.base, repoRelativePath)
|
|
176
|
+
.then((content) => {
|
|
177
|
+
if (live(tk)) setContents((m) => prunedMap(m).set(tk, content));
|
|
178
|
+
})
|
|
179
|
+
.catch((err: unknown) => {
|
|
180
|
+
if (!live(tk)) return;
|
|
181
|
+
// Absent on the target is a real answer: the request adds the file.
|
|
182
|
+
if (err instanceof WorkspaceApiError && err.status === 404) {
|
|
183
|
+
setContents((m) => prunedMap(m).set(tk, ''));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
setFailed((s) => prunedSet(s).add(tk));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
})
|
|
52
190
|
.catch(() => {
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
//
|
|
191
|
+
if (!live(fk)) return;
|
|
192
|
+
// Same rule for the before side: an unreadable fork point is no
|
|
193
|
+
// claim, and falling back to main would bring back the very
|
|
194
|
+
// "deletions" this reads the fork point to avoid.
|
|
195
|
+
setFailed((s) => prunedSet(s).add(fk));
|
|
56
196
|
});
|
|
57
197
|
}
|
|
58
198
|
// `contents` is intentionally out: it changes on every arrival, and the
|
|
59
199
|
// `asked` guard already makes each (cr, file, revision) fetch once.
|
|
60
200
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
-
}, [wanted, repoRelativePath, revision]);
|
|
201
|
+
}, [wanted, repoRelativePath, revision, staleEpoch]);
|
|
62
202
|
|
|
63
203
|
return useMemo(() => {
|
|
64
|
-
const out = new Map<number,
|
|
204
|
+
const out = new Map<number, CrFileDiff>();
|
|
65
205
|
for (const cr of relevant) {
|
|
206
|
+
const fork = forkReads.get(forkKey(cr.number));
|
|
207
|
+
const noSharedHistory = fork !== undefined && fork.forkSha === null;
|
|
208
|
+
if (
|
|
209
|
+
failed.has(key(cr.number)) ||
|
|
210
|
+
failed.has(forkKey(cr.number)) ||
|
|
211
|
+
(noSharedHistory && failed.has(targetKey(cr.base)))
|
|
212
|
+
) {
|
|
213
|
+
out.set(cr.number, 'unreadable');
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
66
216
|
const branchRaw = contents.get(key(cr.number));
|
|
67
|
-
|
|
217
|
+
// The before side: the fork point's text; '' when the request ADDS the
|
|
218
|
+
// file (absent at the fork point); main only when there is no fork point.
|
|
219
|
+
const before =
|
|
220
|
+
fork === undefined
|
|
221
|
+
? null
|
|
222
|
+
: noSharedHistory
|
|
223
|
+
? (contents.get(targetKey(cr.base)) ?? null)
|
|
224
|
+
: (fork.content ?? '');
|
|
225
|
+
if (before === null || branchRaw === undefined) {
|
|
68
226
|
out.set(cr.number, null);
|
|
69
227
|
continue;
|
|
70
228
|
}
|
|
71
|
-
const d = diffLines(
|
|
72
|
-
// A proposal
|
|
73
|
-
// empty diff would ask for a decision about nothing.
|
|
229
|
+
const d = diffLines(before, branchRaw);
|
|
230
|
+
// A proposal that no longer changes anything has been overtaken — showing
|
|
231
|
+
// an empty diff would ask for a decision about nothing.
|
|
74
232
|
out.set(cr.number, hasChanges(d) ? d : []);
|
|
75
233
|
}
|
|
76
234
|
return out;
|
|
77
235
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
|
-
}, [relevant, contents,
|
|
236
|
+
}, [relevant, contents, forkReads, failed, repoRelativePath, revision, staleEpoch]);
|
|
79
237
|
}
|