@bevel-software/platform-core-frontend 0.15.1 → 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 +16 -9
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +11 -3
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/email.ts +37 -1
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +140 -6
- package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/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/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +108 -3
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
- package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +47 -4
- package/src/modules/library/__tests__/link-membership.test.ts +13 -4
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +146 -45
- package/src/modules/library/components/LibraryLayout.tsx +119 -256
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
- package/src/modules/library/components/LockedPluginView.tsx +62 -34
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +16 -2
- package/src/modules/library/components/PageActions.tsx +11 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
- package/src/modules/library/components/PluginExtras.tsx +140 -17
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +157 -41
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +239 -263
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +141 -28
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +103 -17
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
- package/src/modules/library/routes/library-paths.ts +26 -28
- package/src/modules/library/services/library.api.ts +38 -20
- package/src/modules/library/services/plugins.api.ts +69 -8
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +170 -32
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +75 -9
- package/src/modules/library/utils/status.ts +135 -33
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +10 -30
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
- package/src/modules/settings/services/github-facade.api.ts +23 -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 +497 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +521 -43
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +140 -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 +177 -118
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +6 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
- package/src/modules/workspace/components/FileRoute.tsx +353 -36
- package/src/modules/workspace/components/FileViewer.tsx +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 +731 -18
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +331 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +206 -29
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +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 +125 -19
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +112 -36
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +6 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +33 -5
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +25 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
DEFAULT_BRANCH,
|
|
3
4
|
type FileDiffPayload,
|
|
4
5
|
type PullRequestDetail,
|
|
5
6
|
type PullRequestSummary,
|
|
@@ -8,20 +9,29 @@ import '../change-requests.css';
|
|
|
8
9
|
import { Banner, Button, Surface } from '../../../shared/components';
|
|
9
10
|
import { useModalLayer } from '../../../shared/components/useModalLayer';
|
|
10
11
|
import { cn } from '../../../lib/utils';
|
|
12
|
+
import { PR_STALE_EVENT } from '../../../core/events';
|
|
11
13
|
import { AuthContext } from '../../auth/state/auth.context';
|
|
12
14
|
import { fetchPrDetail } from '../../pr/services/pr-detail.api';
|
|
15
|
+
import { useEventBus } from '../../workflow/state/event-bus.context';
|
|
13
16
|
import { approvePrFile, revertPrFile, unapprovePrFile } from '../../pr/services/pr-approvals.api';
|
|
14
17
|
import { deleteChangeRequest } from '../../pr/services/pr-cancel.api';
|
|
18
|
+
import { refreshChangeRequestFromTarget } from '../../pr/services/pr-merge.api';
|
|
19
|
+
import { GitApiError } from '../../git/services/git.api';
|
|
15
20
|
import { useApplyChangeRequest } from '../hooks/useApplyChangeRequest';
|
|
16
21
|
import { readFileOnBranch } from '../services/change-requests.api';
|
|
22
|
+
import { describeReadFailure } from '../services/denied-file.api';
|
|
23
|
+
import { deniedSentence, readErrorLead, type ReadFailure } from '../utils/readFailure';
|
|
17
24
|
import { changeAuthorName } from '../utils/author';
|
|
18
25
|
import { conflictResolutionPrompt } from '../utils/conflict';
|
|
19
26
|
import { ConflictHelp } from './ConflictHelp';
|
|
20
|
-
import {
|
|
27
|
+
import { useDefaultBranchFileRead } from '../hooks/useFileOnBranch';
|
|
28
|
+
import { useForkPointFileRead } from '../hooks/useForkPointFile';
|
|
21
29
|
import { diffLines, type DiffLine } from '../utils/diff';
|
|
22
|
-
import { isBinaryFile } from '../../workspace/components/renderers';
|
|
30
|
+
import { hasFileViewer, isBinaryFile, rendersAsText } from '../../workspace/components/renderers';
|
|
31
|
+
import { BranchFileDownload, BranchFilePreview } from './BranchFilePreview';
|
|
23
32
|
import { MarkdownDiffViewer } from '../../review/components/MarkdownDiffViewer';
|
|
24
33
|
import { CrFileTree, type CrTreeFileState } from './CrFileTree';
|
|
34
|
+
import { hasOwnApproval } from '../utils/approval';
|
|
25
35
|
|
|
26
36
|
/**
|
|
27
37
|
* Extra context for the file list — NOT a filter. The dialog always shows
|
|
@@ -40,6 +50,17 @@ export interface ChangeRequestScope {
|
|
|
40
50
|
interface ChangeRequestDialogProps {
|
|
41
51
|
cr: PullRequestSummary;
|
|
42
52
|
scope?: ChangeRequestScope;
|
|
53
|
+
/**
|
|
54
|
+
* The file to land on, repo-relative — for a surface that opened the
|
|
55
|
+
* dialog ABOUT one file (a proposed row in the explorer). Without it the
|
|
56
|
+
* dialog lands on the request's first changed file, as it always has.
|
|
57
|
+
*
|
|
58
|
+
* Read once, as the initial selection: the reader is free to click away,
|
|
59
|
+
* and re-imposing the caller's file on every render would take the dialog
|
|
60
|
+
* back off them. A caller that needs to re-point an OPEN dialog remounts it
|
|
61
|
+
* (key on the path), which is what the explorer does.
|
|
62
|
+
*/
|
|
63
|
+
initialPath?: string;
|
|
43
64
|
onClose(): void;
|
|
44
65
|
/** Applying is the only verdict this view reaches. Declining a change
|
|
45
66
|
* request lives on the skill page, beside the request's own row. */
|
|
@@ -64,15 +85,80 @@ interface ChangeRequestDialogProps {
|
|
|
64
85
|
export function ChangeRequestDialog({
|
|
65
86
|
cr,
|
|
66
87
|
scope,
|
|
88
|
+
initialPath,
|
|
67
89
|
onClose,
|
|
68
90
|
onResolved,
|
|
69
91
|
}: ChangeRequestDialogProps) {
|
|
70
92
|
const [detail, setDetail] = useState<PullRequestDetail | null>(null);
|
|
71
93
|
const [error, setError] = useState<string | null>(null);
|
|
72
94
|
const [branchContents, setBranchContents] = useState<Record<string, string | null>>({});
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Files whose branch copy could not be read, and WHY — shown as such, never
|
|
97
|
+
* guessed at. A flag alone made a refusal and an outage the same sentence,
|
|
98
|
+
* and a reviewer who was simply not allowed to see a file went looking for
|
|
99
|
+
* a problem with the platform.
|
|
100
|
+
*/
|
|
101
|
+
const [branchFailure, setBranchFailure] = useState<Map<string, ReadFailure>>(new Map());
|
|
102
|
+
/**
|
|
103
|
+
* Git refused, so there is nothing left to click — and WHICH refusal, because
|
|
104
|
+
* the two read completely differently to the reader. `apply` is the merge
|
|
105
|
+
* onto the shared version failing; `update` is bringing the request up to
|
|
106
|
+
* date failing. Both end at the same place (the author's agent has to redo
|
|
107
|
+
* the proposal against the text as it stands), so both carry `ConflictHelp`,
|
|
108
|
+
* but telling someone their request "can't be applied" when nobody tried to
|
|
109
|
+
* apply it sends them looking for a decision that was never made.
|
|
110
|
+
*/
|
|
111
|
+
const [blockedBy, setBlockedBy] = useState<null | 'apply' | 'update'>(null);
|
|
112
|
+
const blocked = blockedBy !== null;
|
|
113
|
+
/**
|
|
114
|
+
* The automatic bring-up-to-date this open owes has finished.
|
|
115
|
+
*
|
|
116
|
+
* A request whose target has moved on is brought up to date by OPENING it —
|
|
117
|
+
* no button, no confirmation: a business user should not have to know that
|
|
118
|
+
* a proposal can fall behind, let alone operate the machinery that fixes it.
|
|
119
|
+
* False from the moment the dialog mounts until that update settles.
|
|
120
|
+
*
|
|
121
|
+
* One-way, and per MOUNT, which is what "at most once per open" means: a
|
|
122
|
+
* conflict (or any other refusal) is not retried under the same reader, who
|
|
123
|
+
* would only watch it fail again. Opening the dialog afresh is a new
|
|
124
|
+
* attempt — by then someone may have resolved it.
|
|
125
|
+
*/
|
|
126
|
+
const [autoUpdateSettled, setAutoUpdateSettled] = useState(false);
|
|
127
|
+
/** A bring-up-to-date that landed — the one neutral line, after the fact. */
|
|
128
|
+
const [broughtUpToDate, setBroughtUpToDate] = useState(false);
|
|
129
|
+
/**
|
|
130
|
+
* Bumped when the request's branch has moved under the dialog (an Update
|
|
131
|
+
* merged into it), so the open file's branch copy is read again. Clearing
|
|
132
|
+
* the cached copy alone is not a read: the effect below only runs when its
|
|
133
|
+
* dependencies change, and the selection has not — the pane sat on
|
|
134
|
+
* "Loading…" forever.
|
|
135
|
+
*/
|
|
136
|
+
const [branchRevision, setBranchRevision] = useState(0);
|
|
137
|
+
/**
|
|
138
|
+
* The same, for the OTHER side — the fork point, or the target's tip. Moved
|
|
139
|
+
* only by the Retry link beside a failed read, which has to re-fetch
|
|
140
|
+
* whichever of the two copies was the one that failed and cannot know which.
|
|
141
|
+
*/
|
|
142
|
+
const [baseRevision, setBaseRevision] = useState(0);
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The request has fallen behind AND this reader is one of the people who
|
|
146
|
+
* may bring it up to date (its author, an admin, or anyone who may apply
|
|
147
|
+
* it). The server re-checks the same predicate; this only decides whether
|
|
148
|
+
* the dialog reaches for the update at all.
|
|
149
|
+
*/
|
|
150
|
+
const behindAndUpdatable =
|
|
151
|
+
detail !== null && detail.state === 'open' && detail.behind && detail.viewerCanUpdate;
|
|
152
|
+
/**
|
|
153
|
+
* Mid-update: the dialog shows one status line and NO file content.
|
|
154
|
+
*
|
|
155
|
+
* Derived rather than stored, so it is already true on the very render the
|
|
156
|
+
* detail arrives on — a frame of pre-update files, immediately replaced,
|
|
157
|
+
* would be the dialog showing a version of the change that is about to stop
|
|
158
|
+
* being true. It also holds the file reads back (see the read effect), so
|
|
159
|
+
* nothing is fetched against a head the server is in the middle of moving.
|
|
160
|
+
*/
|
|
161
|
+
const bringingUpToDate = !autoUpdateSettled && behindAndUpdatable && !blocked;
|
|
76
162
|
|
|
77
163
|
const isTop = useModalLayer(true);
|
|
78
164
|
useEffect(() => {
|
|
@@ -86,11 +172,20 @@ export function ChangeRequestDialog({
|
|
|
86
172
|
return () => document.removeEventListener('keydown', onKeyDown);
|
|
87
173
|
}, [isTop, onClose]);
|
|
88
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Every detail read takes a number; only the newest read may publish. The
|
|
177
|
+
* opening read, an event re-read and a post-revert read can overlap, and an
|
|
178
|
+
* older answer resolving last would put back state a newer one replaced —
|
|
179
|
+
* a merged request shown pending again, a cleared refusal back on screen.
|
|
180
|
+
*/
|
|
181
|
+
const detailSeq = useRef(0);
|
|
182
|
+
|
|
89
183
|
useEffect(() => {
|
|
90
184
|
let cancelled = false;
|
|
185
|
+
const seq = ++detailSeq.current;
|
|
91
186
|
fetchPrDetail(cr.number)
|
|
92
187
|
.then((d) => {
|
|
93
|
-
if (!cancelled) setDetail(d);
|
|
188
|
+
if (!cancelled && seq === detailSeq.current) setDetail(d);
|
|
94
189
|
})
|
|
95
190
|
.catch((err) => {
|
|
96
191
|
if (!cancelled) {
|
|
@@ -102,6 +197,33 @@ export function ChangeRequestDialog({
|
|
|
102
197
|
};
|
|
103
198
|
}, [cr.number]);
|
|
104
199
|
|
|
200
|
+
// Somebody else's apply of THIS request just failed or landed. Re-read the
|
|
201
|
+
// detail so a reader with the dialog open sees the refusal the clicker saw
|
|
202
|
+
// (or that there is nothing left to decide), not the state from when it
|
|
203
|
+
// opened. Fresh: the event exists because the cached answer just went stale.
|
|
204
|
+
const bus = useEventBus();
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
if (!bus) return;
|
|
207
|
+
let cancelled = false;
|
|
208
|
+
const reread = (e: { number: number }) => {
|
|
209
|
+
if (e.number !== cr.number) return;
|
|
210
|
+
const seq = ++detailSeq.current;
|
|
211
|
+
fetchPrDetail(cr.number, { fresh: true })
|
|
212
|
+
.then((d) => {
|
|
213
|
+
if (!cancelled && seq === detailSeq.current) setDetail(d);
|
|
214
|
+
})
|
|
215
|
+
.catch(() => undefined);
|
|
216
|
+
};
|
|
217
|
+
const offs = [
|
|
218
|
+
bus.subscribe('change-request-apply-failed', reread),
|
|
219
|
+
bus.subscribe('change-request-merged', reread),
|
|
220
|
+
];
|
|
221
|
+
return () => {
|
|
222
|
+
cancelled = true;
|
|
223
|
+
for (const off of offs) off();
|
|
224
|
+
};
|
|
225
|
+
}, [bus, cr.number]);
|
|
226
|
+
|
|
105
227
|
// EVERYTHING is repo-relative, scoped or not — the scope's baseFiles are
|
|
106
228
|
// lifted to full paths, and every touched file lists whatever folder it is
|
|
107
229
|
// in. The dialog is a decision about the WHOLE request; a file it touches
|
|
@@ -139,10 +261,25 @@ export function ChangeRequestDialog({
|
|
|
139
261
|
* the landing happens on the render the detail arrives rather than one render
|
|
140
262
|
* later. `picked` staying null is what keeps "I haven't chosen yet" distinct
|
|
141
263
|
* from "I chose the first file".
|
|
264
|
+
*
|
|
265
|
+
* A caller that opened the dialog ABOUT a file seeds the pick with it: the
|
|
266
|
+
* row the user clicked IS a choice, made before the dialog existed, and
|
|
267
|
+
* seeding is what makes it survive the detail arriving. The seed holds
|
|
268
|
+
* while the detail is in flight — that is the landing this exists for.
|
|
269
|
+
*
|
|
270
|
+
* Once the detail is here it decides: a pick the request does not contain
|
|
271
|
+
* is DROPPED for the ordinary first-file landing. A `?cr=&file=` link
|
|
272
|
+
* outlives the request it was copied from — the file gets renamed, reverted
|
|
273
|
+
* out of the request, or the link is simply old — and keeping such a seed
|
|
274
|
+
* would read a path off the branch that is not part of the request at all,
|
|
275
|
+
* leaving the pane reporting an unreadable or stale file. Nothing selected
|
|
276
|
+
* is the honest version of that, and the request still opens.
|
|
142
277
|
*/
|
|
143
|
-
const [picked, setPicked] = useState<string | null>(null);
|
|
278
|
+
const [picked, setPicked] = useState<string | null>(initialPath ?? null);
|
|
279
|
+
const pickHolds =
|
|
280
|
+
detail === null || (picked !== null && (changedFiles.has(picked) || mainFiles.includes(picked)));
|
|
144
281
|
const selected =
|
|
145
|
-
picked ?? allFiles.find((f) => changedFiles.has(f)) ?? allFiles[0] ?? '';
|
|
282
|
+
(pickHolds ? picked : null) ?? allFiles.find((f) => changedFiles.has(f)) ?? allFiles[0] ?? '';
|
|
146
283
|
const setSelected = setPicked;
|
|
147
284
|
|
|
148
285
|
/**
|
|
@@ -160,32 +297,191 @@ export function ChangeRequestDialog({
|
|
|
160
297
|
// Markdown renders as a DOCUMENT with red/green change blocks — the same
|
|
161
298
|
// `MarkdownDiffViewer` the review flow and version history use — because the
|
|
162
299
|
// person deciding on a knowledge or skill change reads prose, not source.
|
|
163
|
-
// Everything else keeps the marked-source view below
|
|
164
|
-
|
|
300
|
+
// Everything else keeps the marked-source view below — including a `.md` the
|
|
301
|
+
// file page shows as text (the access rules file), whose `#` comments would
|
|
302
|
+
// otherwise read as headings on both the proposed and the current side.
|
|
303
|
+
const selectedIsMarkdown = /\.md$/i.test(selected) && !rendersAsText(selected);
|
|
165
304
|
|
|
166
|
-
|
|
305
|
+
// Each read holds a token; forgetting a path (Update, a revert) drops its
|
|
306
|
+
// token, so a read that was still in flight lands on nothing instead of
|
|
307
|
+
// writing pre-update content over the read that replaced it.
|
|
308
|
+
const asked = useRef<Map<string, object>>(new Map());
|
|
167
309
|
useEffect(() => {
|
|
168
310
|
// `selected` is '' until the detail names any file in an unscoped dialog —
|
|
169
|
-
// nothing to read yet. Binary files are never read at all (above).
|
|
170
|
-
|
|
171
|
-
|
|
311
|
+
// nothing to read yet. Binary files are never read at all (above). A read
|
|
312
|
+
// held back while the request is being brought up to date is not skipped:
|
|
313
|
+
// `bringingUpToDate` is a dependency, so it fires the moment the update
|
|
314
|
+
// settles — against the head the merge left, never the one it replaced.
|
|
315
|
+
//
|
|
316
|
+
// Nothing is read before the DETAIL either, even though a dialog opened
|
|
317
|
+
// about a file has a selection from the first render (`initialPath`): until
|
|
318
|
+
// the detail says whether this request is behind and whether this reader
|
|
319
|
+
// may update it, there is no way to know that the branch is not about to
|
|
320
|
+
// move. Reading first would spend a request on content the update then
|
|
321
|
+
// throws away, and the pane cannot draw a diff before the detail names its
|
|
322
|
+
// fork point regardless.
|
|
323
|
+
if (
|
|
324
|
+
detail !== null &&
|
|
325
|
+
!bringingUpToDate &&
|
|
326
|
+
selected &&
|
|
327
|
+
!selectedIsBinary &&
|
|
328
|
+
!asked.current.has(selected)
|
|
329
|
+
) {
|
|
330
|
+
const token = {};
|
|
331
|
+
asked.current.set(selected, token);
|
|
332
|
+
const current = () => asked.current.get(selected) === token;
|
|
172
333
|
readFileOnBranch(cr.branch, selected)
|
|
173
|
-
.then((content) =>
|
|
334
|
+
.then((content) => {
|
|
335
|
+
if (current()) setBranchContents((c) => ({ ...c, [selected]: content }));
|
|
336
|
+
})
|
|
174
337
|
// NOT `''`. An unreadable branch copy stored as empty would diff as
|
|
175
338
|
// "every line deleted" — a change request that erases the file.
|
|
176
|
-
|
|
339
|
+
//
|
|
340
|
+
// The failure is described before it is published: naming the folder
|
|
341
|
+
// to ask about is a second read, and the pane stays on "Loading…"
|
|
342
|
+
// until it settles rather than saying "couldn't be read" and then
|
|
343
|
+
// rewriting it as "you don't have access" a moment later.
|
|
344
|
+
.catch((err: unknown) =>
|
|
345
|
+
describeReadFailure(err, cr.branch, selected).then((failure) => {
|
|
346
|
+
if (current()) setBranchFailure((m) => new Map(m).set(selected, failure));
|
|
347
|
+
}),
|
|
348
|
+
);
|
|
177
349
|
}
|
|
178
|
-
}, [selected, selectedIsBinary, cr.branch]);
|
|
350
|
+
}, [selected, selectedIsBinary, cr.branch, branchRevision, bringingUpToDate, detail]);
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Read the selected file again, both sides — the Retry link the retryable
|
|
354
|
+
* form of the pane's failure sentence carries. The cached copy AND the
|
|
355
|
+
* `asked` token have to go: the effect above only re-reads a path it has no
|
|
356
|
+
* token for, and only when a revision moves it.
|
|
357
|
+
*/
|
|
358
|
+
function retrySelectedRead() {
|
|
359
|
+
asked.current.delete(selected);
|
|
360
|
+
setBranchFailure((m) => {
|
|
361
|
+
const next = new Map(m);
|
|
362
|
+
next.delete(selected);
|
|
363
|
+
return next;
|
|
364
|
+
});
|
|
365
|
+
setBranchContents((c) => {
|
|
366
|
+
const next = { ...c };
|
|
367
|
+
delete next[selected];
|
|
368
|
+
return next;
|
|
369
|
+
});
|
|
370
|
+
setBranchRevision((r) => r + 1);
|
|
371
|
+
setBaseRevision((r) => r + 1);
|
|
372
|
+
}
|
|
179
373
|
|
|
180
374
|
const isAdded = addedFiles.includes(selected);
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* The request's own record for the selection — `undefined` for a file it
|
|
378
|
+
* does not touch. Everything below reads the status and the previous path
|
|
379
|
+
* off this one lookup.
|
|
380
|
+
*/
|
|
381
|
+
const selectedFile = useMemo(
|
|
382
|
+
() => (detail?.files ?? []).find((f) => f.path === selected),
|
|
383
|
+
[detail, selected],
|
|
384
|
+
);
|
|
385
|
+
/**
|
|
386
|
+
* The status that cannot be read on the request's branch at all: the path is
|
|
387
|
+
* gone there, so the viewer and the download both have to reach for the
|
|
388
|
+
* target branch's copy — see `selectedPreview`.
|
|
389
|
+
*/
|
|
390
|
+
const isRemoved = selectedFile?.status === 'removed';
|
|
391
|
+
/**
|
|
392
|
+
* A MOVED file's other side lives under its OLD name.
|
|
393
|
+
*
|
|
394
|
+
* The selection is the path on the change request's branch. For a rename
|
|
395
|
+
* that is a path the default branch has never had, so reading it there 404s
|
|
396
|
+
* — and the pane, which could only tell a failed read from a slow one by
|
|
397
|
+
* waiting, sat on "Loading…" for as long as anyone cared to watch. The
|
|
398
|
+
* before-side of a move is the file at `previousPath`; diffing that against
|
|
399
|
+
* the new path is what makes a rename-with-edits read as the edit it is,
|
|
400
|
+
* and a pure move read as no change at all.
|
|
401
|
+
*/
|
|
402
|
+
const move = useMemo(() => {
|
|
403
|
+
if (selectedFile?.status !== 'renamed') return null;
|
|
404
|
+
// `previousPath` is what GitHub populates for a rename; a rename that
|
|
405
|
+
// arrives without one is a move whose before-side we simply cannot name.
|
|
406
|
+
const from = selectedFile.previousPath;
|
|
407
|
+
return { from: from && from !== selectedFile.path ? from : null };
|
|
408
|
+
}, [selectedFile]);
|
|
409
|
+
const movedFrom = move?.from ?? null;
|
|
410
|
+
/** A rename described without a `previousPath` — no before-side to read. */
|
|
411
|
+
const renameWithoutOldPath = move !== null && move.from === null;
|
|
412
|
+
|
|
413
|
+
const touchesSelected = changedFiles.has(selected);
|
|
414
|
+
|
|
181
415
|
// Raw-vs-raw: the skills API hands back SKILL.md's PARSED body (frontmatter
|
|
182
416
|
// stripped), and diffing that against a raw branch read renders the
|
|
183
417
|
// frontmatter as a deletion and the whole file as changed.
|
|
184
|
-
|
|
185
|
-
|
|
418
|
+
// Nothing is read while the request is being brought up to date, on this
|
|
419
|
+
// side either: the fork point is exactly what the merge moves, so a read
|
|
420
|
+
// started now would answer about a fork point that no longer exists.
|
|
421
|
+
const beforePath =
|
|
422
|
+
isAdded || renameWithoutOldPath || !selected || selectedIsBinary || bringingUpToDate
|
|
423
|
+
? null
|
|
424
|
+
: (movedFrom ?? selected);
|
|
425
|
+
/**
|
|
426
|
+
* WHICH "before". A file the request touches is read at the request's FORK
|
|
427
|
+
* POINT — what its author started from — so the diff shows exactly what the
|
|
428
|
+
* author changed. Read against the target's tip, an edit somebody made on
|
|
429
|
+
* the target after the proposal appeared inside this request as a deletion,
|
|
430
|
+
* and the reader feared applying it would undo that edit. The target having
|
|
431
|
+
* moved on is said by the notice above the files instead.
|
|
432
|
+
*
|
|
433
|
+
* A file the request does NOT touch has no fork-point question: it reads as
|
|
434
|
+
* it stands. So does a request whose branches share no history (no fork
|
|
435
|
+
* point to read) — the old reading, which is the only one left.
|
|
436
|
+
*/
|
|
437
|
+
const forkSha = detail?.mergeBaseSha ?? null;
|
|
438
|
+
const readAtFork = touchesSelected && forkSha !== null;
|
|
439
|
+
const forkRead = useForkPointFileRead(
|
|
440
|
+
cr.number,
|
|
441
|
+
readAtFork ? forkSha : null,
|
|
442
|
+
readAtFork ? beforePath : null,
|
|
443
|
+
// The fork point belongs to the TARGET's tree, which is also the tree the
|
|
444
|
+
// route checks read authority against — so it is the tree to name a
|
|
445
|
+
// governing folder from when the read comes back refused.
|
|
446
|
+
{ targetBranch: cr.base || DEFAULT_BRANCH, revision: baseRevision },
|
|
186
447
|
);
|
|
448
|
+
const tipRead = useDefaultBranchFileRead(
|
|
449
|
+
detail !== null && !readAtFork ? beforePath : null,
|
|
450
|
+
baseRevision,
|
|
451
|
+
);
|
|
452
|
+
const mainRead = readAtFork ? forkRead : tipRead;
|
|
453
|
+
const mainRaw = mainRead.content;
|
|
187
454
|
const branchRaw = branchContents[selected] ?? null;
|
|
188
455
|
|
|
456
|
+
/**
|
|
457
|
+
* The default-branch side is definitively gone — the read settled as an
|
|
458
|
+
* error, or a rename arrived with no old path to read at all.
|
|
459
|
+
*
|
|
460
|
+
* Gated on `detail`, because until it lands we do not yet know whether the
|
|
461
|
+
* selection is an ADDED file (whose absence from the default branch is
|
|
462
|
+
* expected and correct) or a moved one (whose old path we would then read
|
|
463
|
+
* instead). Announcing a failure inside that window would flash a wrong
|
|
464
|
+
* sentence at every reader of every new file.
|
|
465
|
+
*/
|
|
466
|
+
const mainMissing = detail !== null && (renameWithoutOldPath || mainRead.failed);
|
|
467
|
+
const isRename = move !== null;
|
|
468
|
+
/**
|
|
469
|
+
* A move we cannot show the before-side of. Review does not stop for it: the
|
|
470
|
+
* pane says the old path could not be read and shows the file's NEW content,
|
|
471
|
+
* unmarked and labelled as such, which is still the thing being proposed.
|
|
472
|
+
*/
|
|
473
|
+
const oldPathUnreadable = isRename && mainMissing;
|
|
474
|
+
/** Any other file whose default-branch copy could not be read. */
|
|
475
|
+
const baseUnreadable = !isRename && mainMissing;
|
|
476
|
+
/**
|
|
477
|
+
* Why that copy could not be read. The read always records a reason when it
|
|
478
|
+
* settles as a failure; the fallback covers the one path into
|
|
479
|
+
* `mainMissing` that never made a read at all (a rename with no old path),
|
|
480
|
+
* which `baseUnreadable` already excludes but the types cannot know.
|
|
481
|
+
*/
|
|
482
|
+
const baseFailure: ReadFailure =
|
|
483
|
+
mainRead.failure ?? { kind: 'error', reason: 'the read did not complete' };
|
|
484
|
+
|
|
189
485
|
/**
|
|
190
486
|
* BOTH sides or nothing.
|
|
191
487
|
*
|
|
@@ -220,7 +516,104 @@ export function ChangeRequestDialog({
|
|
|
220
516
|
: null,
|
|
221
517
|
[selectedIsMarkdown, bothSidesIn, selected, isAdded, mainRaw, branchRaw],
|
|
222
518
|
);
|
|
223
|
-
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* The branch this request is against — where the CURRENT version of
|
|
522
|
+
* everything it touches lives, and the only honest source for a file it
|
|
523
|
+
* doesn't touch. `base` is always populated by the PR APIs; the fallback is
|
|
524
|
+
* for fixtures and for a summary that predates the field.
|
|
525
|
+
*/
|
|
526
|
+
const targetBranch = cr.base || DEFAULT_BRANCH;
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* A binary file the file page has a VIEWER for — so the dialog shows the
|
|
530
|
+
* document rather than describing it.
|
|
531
|
+
*
|
|
532
|
+
* Which version, and from where:
|
|
533
|
+
* - added → the request's branch, "Proposed version". No current one.
|
|
534
|
+
* - changed → the request's branch, "Proposed version", with the current
|
|
535
|
+
* version one click away on the target branch. For a RENAME
|
|
536
|
+
* that current version is under the OLD name.
|
|
537
|
+
* - removed → the TARGET branch, "Current version": the request's branch
|
|
538
|
+
* does not have the path at all, and showing the document
|
|
539
|
+
* about to be deleted is the whole question being asked. The
|
|
540
|
+
* note above the pane says it is a deletion.
|
|
541
|
+
* - untouched→ the TARGET branch, "Current version". Reading the request's
|
|
542
|
+
* branch would work too (its copy is identical), but naming
|
|
543
|
+
* the target is what makes the label true.
|
|
544
|
+
*
|
|
545
|
+
* `null` for everything else — a format with no viewer (a `.zip`, a legacy
|
|
546
|
+
* `.doc`) keeps the note below, and a text or markdown file never reaches
|
|
547
|
+
* here at all: `isBinaryFile` gates this whole branch, so the diff path —
|
|
548
|
+
* including a `.csv`, whose text diff says far more than its bytes would —
|
|
549
|
+
* is untouched.
|
|
550
|
+
*/
|
|
551
|
+
const selectedPreview = useMemo<{
|
|
552
|
+
branch: string;
|
|
553
|
+
label: 'Proposed version' | 'Current version';
|
|
554
|
+
currentVersionBranch: string | null;
|
|
555
|
+
currentVersionPath: string;
|
|
556
|
+
} | null>(() => {
|
|
557
|
+
if (!selectedIsBinary || !hasFileViewer(selected)) return null;
|
|
558
|
+
// Both of these read the target branch, for the same reason: there is no
|
|
559
|
+
// proposed version of the file on the request's branch. An untouched file
|
|
560
|
+
// never had one; a REMOVED file's whole proposal is that it stop existing,
|
|
561
|
+
// and reading `selected` on the request's branch would 404 into a failed
|
|
562
|
+
// viewer.
|
|
563
|
+
if (!touchesSelected || isRemoved) {
|
|
564
|
+
return {
|
|
565
|
+
branch: targetBranch,
|
|
566
|
+
label: 'Current version',
|
|
567
|
+
currentVersionBranch: null,
|
|
568
|
+
currentVersionPath: selected,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
return {
|
|
572
|
+
branch: cr.branch,
|
|
573
|
+
label: 'Proposed version',
|
|
574
|
+
// Nothing to open for an added file, and nothing to point AT for a
|
|
575
|
+
// rename the request described without a `previousPath`.
|
|
576
|
+
currentVersionBranch: isAdded || renameWithoutOldPath ? null : targetBranch,
|
|
577
|
+
// A rename's current version is under its OLD name; `selected` is the
|
|
578
|
+
// proposed one, which the target branch has never had.
|
|
579
|
+
currentVersionPath: movedFrom ?? selected,
|
|
580
|
+
};
|
|
581
|
+
}, [
|
|
582
|
+
selectedIsBinary,
|
|
583
|
+
selected,
|
|
584
|
+
touchesSelected,
|
|
585
|
+
isAdded,
|
|
586
|
+
isRemoved,
|
|
587
|
+
movedFrom,
|
|
588
|
+
renameWithoutOldPath,
|
|
589
|
+
cr.branch,
|
|
590
|
+
targetBranch,
|
|
591
|
+
]);
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* The unmarked reading — the file itself, when there is no honest diff.
|
|
595
|
+
*
|
|
596
|
+
* Two cases reach it: a file this request doesn't touch (nothing to mark),
|
|
597
|
+
* and a move whose before-side could not be read (nothing to mark it
|
|
598
|
+
* AGAINST, but the proposed content is still worth reading). Anything else
|
|
599
|
+
* gets `null` and falls through to the diff.
|
|
600
|
+
*/
|
|
601
|
+
const readsUnmarked = !selectedIsMarkdown && detail !== null && !touchesSelected;
|
|
602
|
+
const rawFallback = oldPathUnreadable ? branchRaw : readsUnmarked ? (mainRaw ?? branchRaw) : null;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Why the selected file cannot be shown — `null` when it can.
|
|
606
|
+
*
|
|
607
|
+
* ONE value, read by the pane and by the file row alike. A failure only
|
|
608
|
+
* gets the last word when there is nothing left to show: a file this
|
|
609
|
+
* request doesn't touch reads fine from whichever copy arrived. Which SIDE
|
|
610
|
+
* failed no longer changes the sentence — the reader's question is why they
|
|
611
|
+
* can't see it, and that answer is the same — so the base copy's denial has
|
|
612
|
+
* to reach the row exactly as the branch copy's does, or a file the pane
|
|
613
|
+
* calls refused would sit in the tree with no lock.
|
|
614
|
+
*/
|
|
615
|
+
const selectedFailure: ReadFailure | null =
|
|
616
|
+
branchFailure.get(selected) ?? (baseUnreadable && !readsUnmarked ? baseFailure : null);
|
|
224
617
|
|
|
225
618
|
/** Per-file approval verdicts, straight from the detail. */
|
|
226
619
|
const approvalByPath = useMemo(
|
|
@@ -233,14 +626,21 @@ export function ChangeRequestDialog({
|
|
|
233
626
|
* either already approved or approvable BY THIS VIEWER (they hold write on
|
|
234
627
|
* it, so their click completes the gate). Anything less and Apply was a
|
|
235
628
|
* button that walked into "Waiting on approval for …" — offering a verdict
|
|
236
|
-
* the viewer cannot actually deliver.
|
|
629
|
+
* the viewer cannot actually deliver. Only files the merge gate binds can
|
|
630
|
+
* hold it up; the rest neither warn nor block on the server, but the viewer
|
|
631
|
+
* still has to hold at least one file of the request to be offered Apply.
|
|
632
|
+
* And only while the request is OPEN: somebody else may apply or decline it
|
|
633
|
+
* with this dialog still up, and the re-read that tells the reader so must
|
|
634
|
+
* not leave a second merge a click away.
|
|
237
635
|
*/
|
|
238
636
|
const canApply =
|
|
239
637
|
detail !== null &&
|
|
638
|
+
detail.state === 'open' &&
|
|
240
639
|
detail.approvals.length > 0 &&
|
|
241
|
-
detail.approvals.every((a) => a.isApproved || a.viewerCanApprove)
|
|
640
|
+
detail.approvals.filter((a) => a.inMergeGate).every((a) => a.isApproved || a.viewerCanApprove) &&
|
|
641
|
+
detail.approvals.some((a) => a.isApproved || a.viewerCanApprove);
|
|
242
642
|
|
|
243
|
-
/** Approve / revert verbs —
|
|
643
|
+
/** Approve / revert verbs — approve from the file header and the footer, revert from the tree. */
|
|
244
644
|
const [verbBusy, setVerbBusy] = useState(false);
|
|
245
645
|
const [verbError, setVerbError] = useState<string | null>(null);
|
|
246
646
|
useEffect(() => {
|
|
@@ -263,6 +663,28 @@ export function ChangeRequestDialog({
|
|
|
263
663
|
}
|
|
264
664
|
}
|
|
265
665
|
|
|
666
|
+
/**
|
|
667
|
+
* Every file still waiting on this viewer, approved one after another —
|
|
668
|
+
* sequential, so the approvals the server hands back after each call are
|
|
669
|
+
* the ones the next reads, and a failure stops the run with one banner
|
|
670
|
+
* instead of one per file.
|
|
671
|
+
*/
|
|
672
|
+
async function approveAllMine(paths: string[]) {
|
|
673
|
+
if (!detail || verbBusy) return;
|
|
674
|
+
setVerbBusy(true);
|
|
675
|
+
setVerbError(null);
|
|
676
|
+
try {
|
|
677
|
+
for (const path of paths) {
|
|
678
|
+
const approvals = await approvePrFile(cr.number, path);
|
|
679
|
+
setDetail((d) => (d ? { ...d, approvals } : d));
|
|
680
|
+
}
|
|
681
|
+
} catch (err) {
|
|
682
|
+
setVerbError(err instanceof Error ? err.message : "Couldn't record that.");
|
|
683
|
+
} finally {
|
|
684
|
+
setVerbBusy(false);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
266
688
|
async function revertFile(path: string) {
|
|
267
689
|
if (!detail || verbBusy) return;
|
|
268
690
|
setVerbBusy(true);
|
|
@@ -286,7 +708,12 @@ export function ChangeRequestDialog({
|
|
|
286
708
|
return next;
|
|
287
709
|
});
|
|
288
710
|
setPicked(null);
|
|
289
|
-
|
|
711
|
+
const seq = ++detailSeq.current;
|
|
712
|
+
const next = await fetchPrDetail(cr.number);
|
|
713
|
+
if (seq === detailSeq.current) setDetail(next);
|
|
714
|
+
// The selection can land back on this same path (a scope base file), and
|
|
715
|
+
// a cleared cache is only re-read when the read effect runs again.
|
|
716
|
+
setBranchRevision((r) => r + 1);
|
|
290
717
|
} catch (err) {
|
|
291
718
|
setVerbError(err instanceof Error ? err.message : "Couldn't revert this file.");
|
|
292
719
|
} finally {
|
|
@@ -295,24 +722,83 @@ export function ChangeRequestDialog({
|
|
|
295
722
|
}
|
|
296
723
|
|
|
297
724
|
// Tolerant read (not useAuth): the dialog renders in tests without the
|
|
298
|
-
// provider, and the email only sharpens the
|
|
725
|
+
// provider, and the email only sharpens the undo affordance.
|
|
299
726
|
const viewerEmail = useContext(AuthContext)?.user?.email ?? '';
|
|
300
727
|
|
|
728
|
+
/**
|
|
729
|
+
* The header's approve button, for the selected file: `approve` when it is
|
|
730
|
+
* the viewer's to approve and they have not, `undo` once their own current
|
|
731
|
+
* confirmation is on it, `null` when they cannot approve it at all.
|
|
732
|
+
*/
|
|
733
|
+
const selectedApproval = touchesSelected ? approvalByPath.get(selected) : undefined;
|
|
734
|
+
const headerVerb: 'approve' | 'undo' | null = !selectedApproval?.viewerCanApprove
|
|
735
|
+
? null
|
|
736
|
+
: hasOwnApproval(selectedApproval, viewerEmail)
|
|
737
|
+
? 'undo'
|
|
738
|
+
: 'approve';
|
|
739
|
+
|
|
740
|
+
/** Files waiting on THIS viewer — theirs to approve and not yet approved. */
|
|
741
|
+
const mine = useMemo(
|
|
742
|
+
() =>
|
|
743
|
+
(detail?.approvals ?? [])
|
|
744
|
+
.filter(
|
|
745
|
+
(a) =>
|
|
746
|
+
a.inMergeGate && a.viewerCanApprove && !a.isApproved && changedFiles.has(a.path),
|
|
747
|
+
)
|
|
748
|
+
.map((a) => a.path),
|
|
749
|
+
[detail, changedFiles],
|
|
750
|
+
);
|
|
751
|
+
/**
|
|
752
|
+
* Who the unapproved files wait on, when none of them is the viewer's —
|
|
753
|
+
* the tree badge's wording, gathered across the request. Files outside the
|
|
754
|
+
* merge gate hold nothing up and name nobody.
|
|
755
|
+
*/
|
|
756
|
+
const waitingOn = useMemo(() => {
|
|
757
|
+
const names = new Set<string>();
|
|
758
|
+
for (const a of detail?.approvals ?? []) {
|
|
759
|
+
if (!a.inMergeGate || a.isApproved || a.viewerCanApprove) continue;
|
|
760
|
+
for (const r of a.eligibleApprovers.roles) names.add(r);
|
|
761
|
+
for (const u of a.eligibleApprovers.users) names.add(u.name || u.email);
|
|
762
|
+
}
|
|
763
|
+
return [...names];
|
|
764
|
+
}, [detail]);
|
|
765
|
+
|
|
301
766
|
/** The tree's per-file state, in the file list's order. */
|
|
302
767
|
const treeFiles: CrTreeFileState[] = useMemo(() => {
|
|
303
768
|
const statusByPath = new Map((detail?.files ?? []).map((f) => [f.path, f.status]));
|
|
304
|
-
return allFiles.map((path) =>
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
769
|
+
return allFiles.map((path) => {
|
|
770
|
+
// Only files the reader has actually opened can carry the lock: the
|
|
771
|
+
// dialog reads one copy at a time, so a denial is a fact about a file
|
|
772
|
+
// that has been asked for, never a guess about the rest of the list.
|
|
773
|
+
// For the open file that means the SAME failure the pane is showing,
|
|
774
|
+
// base copy included — a refusal of the before-side is still a refusal
|
|
775
|
+
// of this file, and the row says so with the pane's own sentence.
|
|
776
|
+
const failure = path === selected ? selectedFailure : branchFailure.get(path);
|
|
777
|
+
return {
|
|
778
|
+
path,
|
|
779
|
+
changed: changedFiles.has(path),
|
|
780
|
+
added: addedFiles.includes(path),
|
|
781
|
+
status: statusByPath.get(path),
|
|
782
|
+
approval: approvalByPath.get(path),
|
|
783
|
+
deniedNote: failure?.kind === 'denied' ? deniedSentence(failure.folder) : undefined,
|
|
784
|
+
};
|
|
785
|
+
});
|
|
786
|
+
}, [
|
|
787
|
+
detail,
|
|
788
|
+
allFiles,
|
|
789
|
+
changedFiles,
|
|
790
|
+
addedFiles,
|
|
791
|
+
approvalByPath,
|
|
792
|
+
branchFailure,
|
|
793
|
+
selected,
|
|
794
|
+
selectedFailure,
|
|
795
|
+
]);
|
|
312
796
|
|
|
313
797
|
/** The footer's verdicts: apply plainly, apply by covering, or wait. */
|
|
314
798
|
const allApproved =
|
|
315
|
-
detail !== null &&
|
|
799
|
+
detail !== null &&
|
|
800
|
+
detail.approvals.length > 0 &&
|
|
801
|
+
detail.approvals.filter((a) => a.inMergeGate).every((a) => a.isApproved);
|
|
316
802
|
|
|
317
803
|
/** Admin-only: delete the request and its branch, with an armed confirm. */
|
|
318
804
|
const [deleteArmed, setDeleteArmed] = useState(false);
|
|
@@ -344,11 +830,109 @@ export function ChangeRequestDialog({
|
|
|
344
830
|
// other refusal (an approval the gate is still waiting on, a transient
|
|
345
831
|
// git error) can change under the reader, so it is reported with the
|
|
346
832
|
// button intact.
|
|
347
|
-
if (refusal.conflicts)
|
|
833
|
+
if (refusal.conflicts) setBlockedBy('apply');
|
|
348
834
|
else setError(refusal.reason);
|
|
349
835
|
},
|
|
350
836
|
});
|
|
351
837
|
const applyBusy = applying.activeCr === cr.number;
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Bring the request up to date: merge the target into its branch on the
|
|
841
|
+
* server, so the proposal sits on the text as it stands now. Success
|
|
842
|
+
* re-reads everything — the head, the fork point, and every file cached
|
|
843
|
+
* from before — and the dialog shows the updated files with one neutral
|
|
844
|
+
* line. A conflict is the same answer an apply conflict is (git refused;
|
|
845
|
+
* nothing was merged), and gets the same help: the prompt for the author's
|
|
846
|
+
* agent.
|
|
847
|
+
*
|
|
848
|
+
* Nobody asks for this: it runs by itself when the dialog opens, from the
|
|
849
|
+
* effect below. There is no button, so the only guards left are the ones
|
|
850
|
+
* that matter — one run per open, and never on top of an apply or of
|
|
851
|
+
* itself.
|
|
852
|
+
*/
|
|
853
|
+
const [updating, setUpdating] = useState(false);
|
|
854
|
+
async function updateFromTarget() {
|
|
855
|
+
if (updating) return;
|
|
856
|
+
setUpdating(true);
|
|
857
|
+
setError(null);
|
|
858
|
+
try {
|
|
859
|
+
await refreshChangeRequestFromTarget(cr.number);
|
|
860
|
+
// The branch moved, so every list and every change box behind this
|
|
861
|
+
// dialog is out of date — including their fork points, which this is
|
|
862
|
+
// the only thing that moves.
|
|
863
|
+
window.dispatchEvent(new Event(PR_STALE_EVENT));
|
|
864
|
+
// The branch has moved: every copy read so far predates the merge.
|
|
865
|
+
// Forget them now, before anything else can fail, so the dialog never
|
|
866
|
+
// goes on showing the pre-update text for a branch the server merged.
|
|
867
|
+
asked.current.clear();
|
|
868
|
+
setBranchContents({});
|
|
869
|
+
setBranchFailure(new Map());
|
|
870
|
+
try {
|
|
871
|
+
// Re-read in the same render the fresh detail (and so the fresh fork
|
|
872
|
+
// point) lands in.
|
|
873
|
+
const seq = ++detailSeq.current;
|
|
874
|
+
const next = await fetchPrDetail(cr.number, { fresh: true });
|
|
875
|
+
if (seq === detailSeq.current) setDetail(next);
|
|
876
|
+
} catch {
|
|
877
|
+
setError("Updated, but couldn't reload this change request. Close it and open it again.");
|
|
878
|
+
} finally {
|
|
879
|
+
setBranchRevision((r) => r + 1);
|
|
880
|
+
}
|
|
881
|
+
setBroughtUpToDate(true);
|
|
882
|
+
} catch (err) {
|
|
883
|
+
const conflicts =
|
|
884
|
+
err instanceof GitApiError &&
|
|
885
|
+
err.status === 409 &&
|
|
886
|
+
(err.body as { kind?: unknown } | undefined)?.kind === 'change-request-conflicts';
|
|
887
|
+
if (conflicts) setBlockedBy('update');
|
|
888
|
+
else setError(err instanceof Error ? err.message : "Couldn't update this change request.");
|
|
889
|
+
} finally {
|
|
890
|
+
setUpdating(false);
|
|
891
|
+
// Settled either way, and settled for good on this open: a refusal that
|
|
892
|
+
// re-armed itself would merge-and-fail on every render the detail
|
|
893
|
+
// changes, and a success has nothing left to do.
|
|
894
|
+
setAutoUpdateSettled(true);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* The open IS the request to bring it up to date.
|
|
900
|
+
*
|
|
901
|
+
* Runs at most once per mount, never against a request that is not open
|
|
902
|
+
* or a reader who may not update it (`behindAndUpdatable`), never on top of
|
|
903
|
+
* a conflict already reported, and never while an apply is running — an
|
|
904
|
+
* apply is a merge on the same branches, and two of them at once is how a
|
|
905
|
+
* request ends up half-landed. An apply that fails without conflicting lets
|
|
906
|
+
* this through afterwards, which is right: the request is still open and
|
|
907
|
+
* still behind.
|
|
908
|
+
*/
|
|
909
|
+
const autoUpdateStarted = useRef(false);
|
|
910
|
+
useEffect(() => {
|
|
911
|
+
if (autoUpdateStarted.current || autoUpdateSettled) return;
|
|
912
|
+
// A viewer who may not update it, a request that is not open or not
|
|
913
|
+
// behind, and a conflict already on screen are all ruled out here rather
|
|
914
|
+
// than recorded: none of them can turn back into an update this open owes.
|
|
915
|
+
if (detail === null || !behindAndUpdatable || blocked) return;
|
|
916
|
+
// An apply is a merge on the same two branches; two at once is how a
|
|
917
|
+
// request ends up half-landed. Not settled — just held, so an apply that
|
|
918
|
+
// fails without conflicting still lets this through afterwards.
|
|
919
|
+
if (applyBusy) return;
|
|
920
|
+
// The ref, not the state, is what makes this once-and-only-once: React
|
|
921
|
+
// re-runs an effect twice on mount under StrictMode, and both runs read
|
|
922
|
+
// the same state.
|
|
923
|
+
autoUpdateStarted.current = true;
|
|
924
|
+
// The synchronous setState this reaches is the in-flight marker every
|
|
925
|
+
// effect that starts async work has to raise — the render it costs is the
|
|
926
|
+
// one that swaps the files for "Bringing this up to date…", which is the
|
|
927
|
+
// whole point. Deferring it would show the pre-update files for a frame.
|
|
928
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
929
|
+
void updateFromTarget();
|
|
930
|
+
// `updateFromTarget` is re-created every render and is deliberately not a
|
|
931
|
+
// dependency: the guards above are what make this run once, not the dep
|
|
932
|
+
// list.
|
|
933
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
934
|
+
}, [autoUpdateSettled, detail, behindAndUpdatable, blocked, applyBusy]);
|
|
935
|
+
|
|
352
936
|
// Name the step: recording approvals and merging are separately slow, and one
|
|
353
937
|
// label over both makes the longer half look stalled.
|
|
354
938
|
const applyLabel = applying.phase === 'approving' ? 'Approving…' : 'Applying…';
|
|
@@ -462,23 +1046,96 @@ export function ChangeRequestDialog({
|
|
|
462
1046
|
</Banner>
|
|
463
1047
|
)}
|
|
464
1048
|
|
|
465
|
-
{
|
|
1049
|
+
{/* A refusal from an attempt this dialog did not make — another
|
|
1050
|
+
owner's, an admin's, or this reader's own in another tab. Its own
|
|
1051
|
+
attempt speaks through `error` / `blocked` above instead. */}
|
|
1052
|
+
{!error && !blocked && !applyBusy && detail?.lastApplyFailure && (
|
|
1053
|
+
<Banner tone="danger" role="alert" className="mx-8 mt-4">
|
|
1054
|
+
<b className="font-semibold">
|
|
1055
|
+
{detail.lastApplyFailure.byName
|
|
1056
|
+
? `${detail.lastApplyFailure.byName} could not apply this`
|
|
1057
|
+
: 'The last apply did not land'}
|
|
1058
|
+
</b>
|
|
1059
|
+
: {detail.lastApplyFailure.reason}
|
|
1060
|
+
</Banner>
|
|
1061
|
+
)}
|
|
1062
|
+
|
|
1063
|
+
{/* Git refused. Both refusals end in the same place — the proposal has
|
|
1064
|
+
to be redone against the text as it stands — so both hand the
|
|
1065
|
+
author's agent the prompt. What differs is what was attempted:
|
|
1066
|
+
saying "can't apply" about an update nobody asked for sends the
|
|
1067
|
+
reader looking for a decision that was never made. Neither
|
|
1068
|
+
sentence names a branch. */}
|
|
1069
|
+
{blockedBy !== null && (
|
|
466
1070
|
<Banner tone="wait" role="alert" className="mx-8 mt-4">
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
1071
|
+
{blockedBy === 'update' ? (
|
|
1072
|
+
<>
|
|
1073
|
+
<b className="font-semibold">Can't bring this up to date</b>: what everyone sees
|
|
1074
|
+
has changed since this was proposed, and the two can't be combined
|
|
1075
|
+
automatically. This request needs a hand.
|
|
1076
|
+
</>
|
|
1077
|
+
) : (
|
|
1078
|
+
<>
|
|
1079
|
+
<b className="font-semibold">Can't apply</b>: files changed after {firstName}{' '}
|
|
1080
|
+
wrote this, so there is no honest before and after to apply. It has to be redone
|
|
1081
|
+
against the current text.
|
|
1082
|
+
</>
|
|
1083
|
+
)}
|
|
470
1084
|
<div className="mt-2.5">
|
|
471
1085
|
<ConflictHelp prompt={conflictResolutionPrompt(cr)} />
|
|
472
1086
|
</div>
|
|
473
1087
|
</Banner>
|
|
474
1088
|
)}
|
|
475
1089
|
|
|
476
|
-
{/*
|
|
1090
|
+
{/* The target moved on after this was proposed, and this reader is not
|
|
1091
|
+
one of the people who can do anything about it. Everyone who can
|
|
1092
|
+
never sees this: the dialog has already brought the request up to
|
|
1093
|
+
date by the time it would render, or is saying so above.
|
|
1094
|
+
"What everyone sees" is the phrase the Deployment page uses for
|
|
1095
|
+
the same thing — a business user does not know what a branch is,
|
|
1096
|
+
and this dialog never tells them. */}
|
|
1097
|
+
{detail !== null &&
|
|
1098
|
+
detail.behind &&
|
|
1099
|
+
detail.state === 'open' &&
|
|
1100
|
+
!detail.viewerCanUpdate &&
|
|
1101
|
+
!blocked && (
|
|
1102
|
+
<Banner tone="neutral" role="status" className="mx-8 mt-4">
|
|
1103
|
+
What everyone sees has changed since this was proposed. Its author, or someone who
|
|
1104
|
+
can apply it, brings it up to date by opening it.
|
|
1105
|
+
</Banner>
|
|
1106
|
+
)}
|
|
1107
|
+
|
|
1108
|
+
{/* It happened, and that is all: one neutral line, no banner, no
|
|
1109
|
+
button. The reader did not ask for the update and has nothing to
|
|
1110
|
+
decide about it — they only need to know the files below are the
|
|
1111
|
+
proposal against the current text, not against the text it was
|
|
1112
|
+
written on. */}
|
|
1113
|
+
{broughtUpToDate && !bringingUpToDate && (
|
|
1114
|
+
<p role="status" className="mt-3 px-8 text-detail text-ink-faint">
|
|
1115
|
+
Brought up to date with what everyone sees.
|
|
1116
|
+
</p>
|
|
1117
|
+
)}
|
|
1118
|
+
|
|
1119
|
+
{/* The update the open is running, in place of the files. NOT beside
|
|
1120
|
+
them: the file content that exists right now is the proposal
|
|
1121
|
+
against text that has already moved, and showing it for the second
|
|
1122
|
+
or two the merge takes would be the dialog answering the reader's
|
|
1123
|
+
question wrongly and then correcting itself. */}
|
|
1124
|
+
{bringingUpToDate ? (
|
|
1125
|
+
<div className="mt-4 min-h-0 flex-1 px-8">
|
|
1126
|
+
<p
|
|
1127
|
+
role="status"
|
|
1128
|
+
className="mx-auto max-w-[52ch] py-10 text-center text-detail text-ink-faint"
|
|
1129
|
+
>
|
|
1130
|
+
Bringing this up to date with what everyone sees…
|
|
1131
|
+
</p>
|
|
1132
|
+
</div>
|
|
1133
|
+
) : /* A request that no longer changes anything — everything it proposed
|
|
477
1134
|
has since landed on (or been removed from) the target, or its only
|
|
478
1135
|
change was one the merge never takes (roles.yaml). The file grid
|
|
479
1136
|
below would render a blank pill over an eternal "Loading…", which
|
|
480
|
-
reads as a hang; the truth is simpler and gets said instead. */
|
|
481
|
-
|
|
1137
|
+
reads as a hang; the truth is simpler and gets said instead. */
|
|
1138
|
+
detail !== null && allFiles.length === 0 ? (
|
|
482
1139
|
<div className="mt-4 min-h-0 flex-1 px-8">
|
|
483
1140
|
<p className="mx-auto max-w-[52ch] py-10 text-center text-detail text-ink-faint">
|
|
484
1141
|
This request doesn't change anything anymore. What it proposed is already part of
|
|
@@ -502,9 +1159,8 @@ export function ChangeRequestDialog({
|
|
|
502
1159
|
selected={selected}
|
|
503
1160
|
currentUserEmail={viewerEmail}
|
|
504
1161
|
onSelect={(p) => setSelected(p)}
|
|
505
|
-
onToggleApprove={(p, approved) => void toggleApprove(p, approved)}
|
|
506
1162
|
onRevert={(p) => void revertFile(p)}
|
|
507
|
-
busy={verbBusy}
|
|
1163
|
+
busy={verbBusy || applyBusy}
|
|
508
1164
|
/>
|
|
509
1165
|
</Surface>
|
|
510
1166
|
|
|
@@ -515,10 +1171,49 @@ export function ChangeRequestDialog({
|
|
|
515
1171
|
{detail === null
|
|
516
1172
|
? ''
|
|
517
1173
|
: touchesSelected
|
|
518
|
-
?
|
|
1174
|
+
? // Nothing is marked in a rendered document: the pane
|
|
1175
|
+
// below shows the proposed version whole, and says so.
|
|
1176
|
+
selectedPreview !== null
|
|
1177
|
+
? ''
|
|
1178
|
+
: ' · what changes is marked'
|
|
519
1179
|
: ' · not touched by this request'}
|
|
520
1180
|
</span>
|
|
1181
|
+
{/* Where the reviewer is reading, labelled — the tree's check is
|
|
1182
|
+
status only. Right after the header text in the tab order. */}
|
|
1183
|
+
{headerVerb && (
|
|
1184
|
+
<Button
|
|
1185
|
+
variant={headerVerb === 'approve' ? 'primary' : 'outline'}
|
|
1186
|
+
size="tiny"
|
|
1187
|
+
className="ml-auto shrink-0"
|
|
1188
|
+
disabled={verbBusy || applyBusy}
|
|
1189
|
+
onClick={() => void toggleApprove(selected, headerVerb === 'undo')}
|
|
1190
|
+
>
|
|
1191
|
+
{headerVerb === 'approve' ? 'Approve this file' : 'Approved – Undo'}
|
|
1192
|
+
</Button>
|
|
1193
|
+
)}
|
|
521
1194
|
</div>
|
|
1195
|
+
{/* The move, named. A rename's diff is otherwise unexplainable —
|
|
1196
|
+
either it reads as an ordinary edit to a file that isn't there
|
|
1197
|
+
under that name, or (a pure move) as no change at all. Sits
|
|
1198
|
+
above the pane so it covers the rendered-markdown reading and
|
|
1199
|
+
the marked-source one alike. */}
|
|
1200
|
+
{movedFrom && (
|
|
1201
|
+
<p className="truncate pb-1 font-mono text-meta text-ink-faint">
|
|
1202
|
+
Moved: {movedFrom} → {selected}
|
|
1203
|
+
</p>
|
|
1204
|
+
)}
|
|
1205
|
+
{isRemoved && selectedPreview !== null && (
|
|
1206
|
+
<p className="pb-1 text-meta text-ink-faint">
|
|
1207
|
+
This request DELETES this file. Below is the version everyone sees today, which
|
|
1208
|
+
would go.
|
|
1209
|
+
</p>
|
|
1210
|
+
)}
|
|
1211
|
+
{oldPathUnreadable && (
|
|
1212
|
+
<p className="pb-1 text-meta text-ink-faint">
|
|
1213
|
+
The old path couldn't be read, so there is nothing to mark this against —
|
|
1214
|
+
showing the file's new content as it stands on the change request.
|
|
1215
|
+
</p>
|
|
1216
|
+
)}
|
|
522
1217
|
{verbError && (
|
|
523
1218
|
<Banner tone="danger" role="alert" className="mb-2">
|
|
524
1219
|
{verbError}
|
|
@@ -529,14 +1224,50 @@ export function ChangeRequestDialog({
|
|
|
529
1224
|
soon as those arrive rather than waiting on the (slow) detail
|
|
530
1225
|
fetch that tells us which files were touched. */}
|
|
531
1226
|
{selectedIsBinary ? (
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
1227
|
+
// Which branch this pane reads — and whether there is a
|
|
1228
|
+
// current version to offer beside it — is a fact about the
|
|
1229
|
+
// FILE LIST, so the pane waits for the detail rather than
|
|
1230
|
+
// guessing and flipping branches under the reader.
|
|
1231
|
+
detail === null ? (
|
|
1232
|
+
<p className="py-6 text-center text-detail text-ink-faint">Loading…</p>
|
|
1233
|
+
) : selectedPreview !== null ? (
|
|
1234
|
+
// The proposed document itself, with the viewer the file
|
|
1235
|
+
// page uses. A file the request does not touch reads from
|
|
1236
|
+
// the TARGET branch instead — there is no proposed version
|
|
1237
|
+
// of it, and the current one is what there is to show.
|
|
1238
|
+
<BranchFilePreview
|
|
1239
|
+
branch={selectedPreview.branch}
|
|
1240
|
+
repoRelativePath={selected}
|
|
1241
|
+
label={selectedPreview.label}
|
|
1242
|
+
currentVersionBranch={selectedPreview.currentVersionBranch}
|
|
1243
|
+
currentVersionPath={selectedPreview.currentVersionPath}
|
|
1244
|
+
/>
|
|
1245
|
+
) : (
|
|
1246
|
+
<div className="flex flex-col items-center gap-4 py-6">
|
|
1247
|
+
<p className="text-center text-detail text-ink-faint">
|
|
1248
|
+
{isRemoved
|
|
1249
|
+
? 'A binary file (an image, a document…) this request DELETES. There is no text to compare; the bytes below are the ones that would go.'
|
|
1250
|
+
: isAdded
|
|
1251
|
+
? 'A new binary file (an image, a document…). There is no text to compare. Apply the request to take it as proposed.'
|
|
1252
|
+
: touchesSelected
|
|
1253
|
+
? 'A binary file (an image, a document…) changed in this request. There is no text to compare.'
|
|
1254
|
+
: 'A binary file. No text to show, and this request does not touch it.'}
|
|
1255
|
+
</p>
|
|
1256
|
+
{/* No viewer renders this format, so the bytes themselves
|
|
1257
|
+
are the only honest offer — from the request's branch,
|
|
1258
|
+
so what downloads is what would be applied. */}
|
|
1259
|
+
<BranchFileDownload
|
|
1260
|
+
branch={touchesSelected && !isRemoved ? cr.branch : targetBranch}
|
|
1261
|
+
repoRelativePath={selected}
|
|
1262
|
+
label={
|
|
1263
|
+
touchesSelected && !isRemoved
|
|
1264
|
+
? 'Download the proposed file'
|
|
1265
|
+
: 'Download the file'
|
|
1266
|
+
}
|
|
1267
|
+
/>
|
|
1268
|
+
</div>
|
|
1269
|
+
)
|
|
1270
|
+
) : mdPayload !== null && !branchFailure.has(selected) ? (
|
|
540
1271
|
// An untouched file arrives here too and simply renders as a
|
|
541
1272
|
// clean document — identical sides diff to all-same blocks —
|
|
542
1273
|
// so the reader gets prose everywhere, marked or not.
|
|
@@ -553,16 +1284,18 @@ export function ChangeRequestDialog({
|
|
|
553
1284
|
// destinations) applies here as it does in the document view.
|
|
554
1285
|
// Navigating away from a modal mid-review would also lose the
|
|
555
1286
|
// review context, so inert is the better default regardless.
|
|
1287
|
+
//
|
|
1288
|
+
// Images are named, not fetched, for the same reason: the
|
|
1289
|
+
// bytes on the checked-out tree are not the request's, and a
|
|
1290
|
+
// screenshot the request adds is not there at all (`?ref=` in
|
|
1291
|
+
// TODOS.md).
|
|
556
1292
|
<MarkdownDiffViewer payload={mdPayload} />
|
|
557
1293
|
) : (
|
|
558
1294
|
<MarkedFile
|
|
559
1295
|
diff={diff}
|
|
560
|
-
raw={
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
: null
|
|
564
|
-
}
|
|
565
|
-
unreadable={unreadable.has(selected)}
|
|
1296
|
+
raw={rawFallback}
|
|
1297
|
+
failure={selectedFailure}
|
|
1298
|
+
onRetry={retrySelectedRead}
|
|
566
1299
|
/>
|
|
567
1300
|
)}
|
|
568
1301
|
</div>
|
|
@@ -573,18 +1306,51 @@ export function ChangeRequestDialog({
|
|
|
573
1306
|
|
|
574
1307
|
{/* The verdict. Fixed to the bottom of the surface — a decision the
|
|
575
1308
|
reader has to scroll to find is one they will make without reading. */}
|
|
576
|
-
<div className="mt-4
|
|
1309
|
+
<div className="mt-4 border-t border-line bg-sunken px-8 py-4">
|
|
1310
|
+
{/* What is the viewer's to approve, above the verdict: a count and
|
|
1311
|
+
one button for all of them, or who everyone is waiting on. */}
|
|
1312
|
+
{/* Nothing to approve or wait on while the files are hidden: the
|
|
1313
|
+
verdict belongs to the request as it will stand after the
|
|
1314
|
+
update, which is a second away. */}
|
|
1315
|
+
{!blocked &&
|
|
1316
|
+
!bringingUpToDate &&
|
|
1317
|
+
detail !== null &&
|
|
1318
|
+
allFiles.length > 0 &&
|
|
1319
|
+
(mine.length > 0 || !canApply) && (
|
|
1320
|
+
<div className="mb-3 flex flex-wrap items-center gap-3">
|
|
1321
|
+
<p className="text-meta font-medium text-ink">
|
|
1322
|
+
{mine.length > 0
|
|
1323
|
+
? `Your approval is needed on ${mine.length} file${mine.length === 1 ? '' : 's'}`
|
|
1324
|
+
: waitingOn.length > 0
|
|
1325
|
+
? `Waiting on ${waitingOn.join(', ')}`
|
|
1326
|
+
: (detail.mergeWarnings[0] ??
|
|
1327
|
+
'Waiting on approval from the files’ owners — applying is theirs to do.')}
|
|
1328
|
+
</p>
|
|
1329
|
+
{mine.length > 1 && (
|
|
1330
|
+
<Button
|
|
1331
|
+
variant="outline"
|
|
1332
|
+
size="sm"
|
|
1333
|
+
disabled={verbBusy || applyBusy}
|
|
1334
|
+
onClick={() => void approveAllMine(mine)}
|
|
1335
|
+
>
|
|
1336
|
+
Approve all mine
|
|
1337
|
+
</Button>
|
|
1338
|
+
)}
|
|
1339
|
+
</div>
|
|
1340
|
+
)}
|
|
1341
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
577
1342
|
<p className="mr-auto max-w-[52ch] text-meta text-ink-muted">
|
|
578
1343
|
{blocked
|
|
579
1344
|
? `Nothing changes for anyone until ${firstName} proposes it again against the current text.`
|
|
580
|
-
:
|
|
1345
|
+
: bringingUpToDate
|
|
1346
|
+
? ''
|
|
1347
|
+
: detail === null
|
|
581
1348
|
? ''
|
|
582
1349
|
: allFiles.length === 0
|
|
583
1350
|
? 'Applying would change nothing, so the button stays away.'
|
|
584
|
-
: canApply
|
|
1351
|
+
: canApply && mine.length === 0
|
|
585
1352
|
? 'Every agent that connects after this picks it up. There is no staged rollout.'
|
|
586
|
-
:
|
|
587
|
-
'Waiting on approval from the files’ owners — applying is theirs to do.'}
|
|
1353
|
+
: ''}
|
|
588
1354
|
</p>
|
|
589
1355
|
{/* Admins carry the moderation verb: delete the request AND its
|
|
590
1356
|
branch, armed on the first click. `viewerCanBypassMerge` is the
|
|
@@ -620,16 +1386,17 @@ export function ChangeRequestDialog({
|
|
|
620
1386
|
but every one of them approvable BY THIS VIEWER (write access) →
|
|
621
1387
|
the same click, named for what it is: their authority covers the
|
|
622
1388
|
missing approvals. Anyone else gets the waiting line above. */}
|
|
623
|
-
{!blocked && canApply && (
|
|
1389
|
+
{!blocked && !bringingUpToDate && canApply && (
|
|
624
1390
|
<Button
|
|
625
1391
|
variant="primary"
|
|
626
1392
|
size="sm"
|
|
627
|
-
disabled={applyBusy}
|
|
1393
|
+
disabled={applyBusy || verbBusy}
|
|
628
1394
|
onClick={() => applying.apply(cr)}
|
|
629
1395
|
>
|
|
630
1396
|
{applyBusy ? applyLabel : allApproved ? 'Apply changes' : 'Bypass approval and apply'}
|
|
631
1397
|
</Button>
|
|
632
1398
|
)}
|
|
1399
|
+
</div>
|
|
633
1400
|
</div>
|
|
634
1401
|
</Surface>
|
|
635
1402
|
</div>
|
|
@@ -663,23 +1430,46 @@ function authorsReason(body: string | undefined): string | null {
|
|
|
663
1430
|
*
|
|
664
1431
|
* Markdown never reaches this view when both sides are in — it renders
|
|
665
1432
|
* through `MarkdownDiffViewer` above. This is the presentation for the files
|
|
666
|
-
* that ARE source (yaml, scripts, config), plus the loading and unreadable
|
|
1433
|
+
* that ARE source (yaml, scripts, config, the access rules file), plus the loading and unreadable
|
|
667
1434
|
* states for everything.
|
|
668
1435
|
*/
|
|
669
1436
|
function MarkedFile({
|
|
670
1437
|
diff,
|
|
671
1438
|
raw,
|
|
672
|
-
|
|
1439
|
+
failure,
|
|
1440
|
+
onRetry,
|
|
673
1441
|
}: {
|
|
674
1442
|
diff: DiffLine[] | null;
|
|
675
1443
|
raw: string | null;
|
|
676
|
-
|
|
1444
|
+
/**
|
|
1445
|
+
* Why the copy this pane needs could not be read — `null` when it could.
|
|
1446
|
+
* Two forms, whichever side failed: a refusal, which a person has to lift,
|
|
1447
|
+
* and everything else, which another attempt might.
|
|
1448
|
+
*/
|
|
1449
|
+
failure?: ReadFailure | null;
|
|
1450
|
+
/** Re-fetch this file. Offered only beside the retryable form. */
|
|
1451
|
+
onRetry(): void;
|
|
677
1452
|
}) {
|
|
678
|
-
if (
|
|
1453
|
+
if (failure) {
|
|
679
1454
|
return (
|
|
680
1455
|
<p className="py-6 text-center text-detail text-ink-faint">
|
|
681
|
-
|
|
682
|
-
|
|
1456
|
+
{failure.kind === 'denied' ? (
|
|
1457
|
+
deniedSentence(failure.folder)
|
|
1458
|
+
) : (
|
|
1459
|
+
<>
|
|
1460
|
+
{readErrorLead(failure.reason)}{' '}
|
|
1461
|
+
{/* The retry IS the sentence's last words — a reader told to try
|
|
1462
|
+
again should not then have to find where. */}
|
|
1463
|
+
<button
|
|
1464
|
+
type="button"
|
|
1465
|
+
className="underline underline-offset-2 transition-colors hover:text-ink"
|
|
1466
|
+
onClick={onRetry}
|
|
1467
|
+
>
|
|
1468
|
+
Try again
|
|
1469
|
+
</button>
|
|
1470
|
+
.
|
|
1471
|
+
</>
|
|
1472
|
+
)}
|
|
683
1473
|
</p>
|
|
684
1474
|
);
|
|
685
1475
|
}
|