@bevel-software/platform-core-frontend 0.14.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/package.json +3 -3
- package/src/core/CoreAppShell.tsx +34 -26
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +38 -1
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/email.ts +37 -1
- package/src/lib/utils.ts +2 -0
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +781 -76
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +192 -10
- package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
- package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
- package/src/modules/admin/components/AddMemberInput.tsx +268 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
- package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/connection-keys.api.ts +47 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
- package/src/modules/auth/components/AccountPage.tsx +73 -54
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/auth/services/account.api.ts +78 -4
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
- package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
- package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
- package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
- package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
- package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
- package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
- package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
- package/src/modules/change-requests/services/change-requests.api.ts +57 -1
- package/src/modules/change-requests/services/denied-file.api.ts +53 -0
- package/src/modules/change-requests/services/propose.api.ts +97 -8
- package/src/modules/change-requests/utils/approval.ts +15 -0
- package/src/modules/change-requests/utils/author.ts +32 -0
- package/src/modules/change-requests/utils/readFailure.ts +110 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +109 -4
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +104 -99
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +115 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +391 -78
- package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +183 -0
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +75 -0
- package/src/modules/library/__tests__/link-membership.test.ts +129 -0
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +67 -0
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +107 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +149 -34
- package/src/modules/library/components/LibraryLayout.tsx +120 -247
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
- package/src/modules/library/components/LockedPluginView.tsx +63 -35
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +19 -5
- package/src/modules/library/components/PageActions.tsx +31 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +123 -23
- package/src/modules/library/components/PluginExtras.tsx +143 -18
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +234 -38
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +271 -238
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +204 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +132 -23
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +116 -17
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useJoinRequests.ts +48 -18
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +229 -82
- package/src/modules/library/routes/library-paths.ts +46 -35
- package/src/modules/library/services/library.api.ts +89 -17
- package/src/modules/library/services/plugins.api.ts +161 -9
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +268 -37
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +102 -0
- package/src/modules/library/utils/status.ts +204 -35
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +154 -0
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +16 -22
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
- package/src/modules/settings/services/github-facade.api.ts +66 -0
- package/src/modules/settings/settings-nav-items.tsx +10 -2
- package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
- package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
- package/src/modules/setup/__tests__/setup.test.tsx +615 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +711 -40
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +218 -3
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
- package/src/modules/setup/utils/root-folders.ts +46 -0
- package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
- package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
- package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +395 -124
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +659 -36
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +6 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
- package/src/modules/workspace/components/FileRoute.tsx +376 -22
- package/src/modules/workspace/components/FileViewer.tsx +166 -45
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
- package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
- package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +89 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +207 -30
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
- package/src/modules/workspace/services/workspace.api.ts +57 -4
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
- package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
- package/src/modules/workspace/state/open-change-requests.tsx +100 -12
- package/src/modules/workspace/state/workspace.context.ts +130 -16
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +126 -52
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +59 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +118 -0
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +34 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -265
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
|
@@ -1,14 +1,78 @@
|
|
|
1
|
-
import { useRef, useState, type FormEvent } from 'react';
|
|
1
|
+
import { useEffect, useRef, useState, type FormEvent } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_KB_LAYOUT,
|
|
4
|
+
agentsFilePointerSentence,
|
|
5
|
+
type KbLayout,
|
|
6
|
+
} from '@bevel-software/platform-shared';
|
|
2
7
|
import { Banner, Button, Surface, TextField } from '../../../shared/components';
|
|
3
8
|
import { tokenUsernameForHost } from '../utils/git-host';
|
|
9
|
+
import { isRootFolderSuggestion, rootFolderState, type RootFolderState } from '../utils/root-folders';
|
|
10
|
+
import { copyToClipboard } from '../../../lib/clipboard';
|
|
11
|
+
import { MarketplaceSection } from '../../settings/components/MarketplaceSection';
|
|
4
12
|
import {
|
|
5
13
|
saveSettings,
|
|
14
|
+
syncNow,
|
|
15
|
+
syncOutcomeError,
|
|
6
16
|
testConnection,
|
|
17
|
+
KbInitFailed,
|
|
18
|
+
testOidc,
|
|
7
19
|
SettingsProblems,
|
|
8
20
|
type ConnectionTest,
|
|
21
|
+
type KbInitFailure,
|
|
22
|
+
type LastSync,
|
|
23
|
+
type OidcTest,
|
|
24
|
+
type OidcVerification,
|
|
9
25
|
type SettingStatus,
|
|
26
|
+
type SyncNowResult,
|
|
27
|
+
type SyncStatus,
|
|
10
28
|
} from '../services/setup.api';
|
|
11
29
|
|
|
30
|
+
/** A value to paste elsewhere, with the one button such a value needs. */
|
|
31
|
+
function CopyValue({ value, label }: { value: string; label: string }) {
|
|
32
|
+
const [state, setState] = useState<'idle' | 'copied' | 'failed'>('idle');
|
|
33
|
+
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
34
|
+
useEffect(() => () => {
|
|
35
|
+
if (timer.current) clearTimeout(timer.current);
|
|
36
|
+
}, []);
|
|
37
|
+
const copy = async () => {
|
|
38
|
+
// `copyToClipboard` answers false for every ordinary reason a copy does
|
|
39
|
+
// not land (no secure context, no focus, no clipboard at all); the button
|
|
40
|
+
// says so rather than pretending.
|
|
41
|
+
const landed = await copyToClipboard(value);
|
|
42
|
+
setState(landed ? 'copied' : 'failed');
|
|
43
|
+
if (timer.current) clearTimeout(timer.current);
|
|
44
|
+
timer.current = setTimeout(() => setState('idle'), 1500);
|
|
45
|
+
};
|
|
46
|
+
return (
|
|
47
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
48
|
+
<code className="min-w-0 break-all rounded bg-surface px-2 py-1 font-mono text-meta text-ink">
|
|
49
|
+
{value}
|
|
50
|
+
</code>
|
|
51
|
+
<Button type="button" variant="outline" size="sm" onClick={() => void copy()} aria-label={label}>
|
|
52
|
+
{state === 'copied' ? 'Copied' : state === 'failed' ? 'Couldn’t copy' : 'Copy'}
|
|
53
|
+
</Button>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** "main updated, ali/x up to date" — the per-branch outcomes as one phrase. */
|
|
59
|
+
function describeOutcomes(results: LastSync['results']): string {
|
|
60
|
+
if (results.length === 0) return 'nothing to sync yet';
|
|
61
|
+
const word = (r: LastSync['results'][number]): string => {
|
|
62
|
+
switch (r.outcome) {
|
|
63
|
+
case 'up-to-date':
|
|
64
|
+
return 'up to date';
|
|
65
|
+
case 'not-cloned':
|
|
66
|
+
return 'not cloned';
|
|
67
|
+
case 'remote-gone':
|
|
68
|
+
return 'deleted on the host';
|
|
69
|
+
default:
|
|
70
|
+
return r.outcome;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return results.map((r) => `${r.branch} ${word(r)}`).join(', ');
|
|
74
|
+
}
|
|
75
|
+
|
|
12
76
|
/** Copy for each setting: what it is, in the words of someone who has to fill it in. */
|
|
13
77
|
const FIELDS: Record<
|
|
14
78
|
string,
|
|
@@ -40,6 +104,38 @@ const FIELDS: Record<
|
|
|
40
104
|
placeholder: 'knowledge-base',
|
|
41
105
|
advanced: true,
|
|
42
106
|
},
|
|
107
|
+
kbSyncSecret: {
|
|
108
|
+
label: 'Sync secret',
|
|
109
|
+
help: 'Lets your git host tell this deployment when the repository changes, so pushes and merged pull requests show up right away. Add a webhook, action or pipeline step that calls POST /api/sync/<branch> with this value as a bearer token. Optional: without it, only an administrator can trigger a sync. Stored encrypted, and never shown again.',
|
|
110
|
+
placeholder: 'A long random string',
|
|
111
|
+
advanced: true,
|
|
112
|
+
},
|
|
113
|
+
// The three roots are NOT under Advanced: a repository whose skills live in
|
|
114
|
+
// `skills/` connected fine, got an empty `Skills/` scaffolded beside it and
|
|
115
|
+
// imported nothing — a choice that has to be seen to be made.
|
|
116
|
+
knowledgeBaseDir: {
|
|
117
|
+
label: 'Knowledge folder',
|
|
118
|
+
help: 'The top-level folder in the repository that holds the knowledge. Change it only to read a repository laid out by someone else.',
|
|
119
|
+
placeholder: 'KnowledgeBase',
|
|
120
|
+
},
|
|
121
|
+
skillsDir: {
|
|
122
|
+
label: 'Skills folder',
|
|
123
|
+
help: 'The top-level folder that holds shared skills. The three folder names must differ. Case matters: skills and Skills are different folders.',
|
|
124
|
+
placeholder: 'Skills',
|
|
125
|
+
},
|
|
126
|
+
pluginsDir: {
|
|
127
|
+
label: 'Plugins folder',
|
|
128
|
+
help: 'The top-level folder that holds plugins. The three folder names must differ.',
|
|
129
|
+
placeholder: 'Plugins',
|
|
130
|
+
},
|
|
131
|
+
// Beside the folders, and not under Advanced, for the same reason they are
|
|
132
|
+
// not: a repository that already has an `AGENTS.md` of its own loses it to
|
|
133
|
+
// the platform's on the first boot unless this is answered first.
|
|
134
|
+
agentsFile: {
|
|
135
|
+
label: 'Agent guide file',
|
|
136
|
+
help: 'The file the platform writes its own guide to, at the top of the repository. Change it if your repository already has an AGENTS.md you want to keep — that file then stays yours, and the platform never writes to it. Must end in .md.',
|
|
137
|
+
placeholder: 'AGENTS.md',
|
|
138
|
+
},
|
|
43
139
|
defaultBranch: {
|
|
44
140
|
label: 'Main branch',
|
|
45
141
|
help: 'The version everyone sees. Filled in from your repository when you test the connection.',
|
|
@@ -103,6 +199,50 @@ const REQUIRED_KEYS = ['kbRepoUrl', 'gitToken', 'defaultBranch', 'protectedBranc
|
|
|
103
199
|
*/
|
|
104
200
|
const CONNECTION_KEYS = ['kbRepoUrl', 'gitToken', 'gitUsername'];
|
|
105
201
|
|
|
202
|
+
/**
|
|
203
|
+
* The answers the sign-in check proves. Editing one invalidates its result on
|
|
204
|
+
* screen; the scopes, the button text and the allowed domains are not among
|
|
205
|
+
* them, and the server never re-checks a save that changes only those.
|
|
206
|
+
*/
|
|
207
|
+
const OIDC_KEYS = ['oidcIssuerUrl', 'oidcClientId', 'oidcClientSecret'];
|
|
208
|
+
|
|
209
|
+
/** How the configuration in effect is labelled, in both variants. */
|
|
210
|
+
const OIDC_VERIFICATION_LABEL: Record<OidcVerification, string> = {
|
|
211
|
+
verified: 'Verified',
|
|
212
|
+
unverified: 'Unverified — sign in once to confirm',
|
|
213
|
+
'not-configured': 'Not configured',
|
|
214
|
+
unrecordable: 'Not recorded — set SECRETS_ENC_KEY to keep verification',
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/** The three root folder fields, checked against the repository's listing. */
|
|
218
|
+
const ROOT_FOLDER_KEYS = ['knowledgeBaseDir', 'skillsDir', 'pluginsDir'] as const;
|
|
219
|
+
const isRootFolderKey = (key: string): key is (typeof ROOT_FOLDER_KEYS)[number] =>
|
|
220
|
+
(ROOT_FOLDER_KEYS as readonly string[]).includes(key);
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The knowledge-base LAYOUT fields — the three folders and the agent guide's
|
|
224
|
+
* file name — which render together, under the connection test whose listing
|
|
225
|
+
* the folders are checked against, rather than with the connection fields
|
|
226
|
+
* above it.
|
|
227
|
+
*/
|
|
228
|
+
const LAYOUT_KEYS: readonly (keyof KbLayout)[] = [...ROOT_FOLDER_KEYS, 'agentsFile'];
|
|
229
|
+
const isLayoutKey = (key: string): boolean => (LAYOUT_KEYS as readonly string[]).includes(key);
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* The consent that rides along with a renamed guide: keep the platform's
|
|
233
|
+
* one-sentence pointer in the customer's own `AGENTS.md`. Not a text field, so
|
|
234
|
+
* it has no {@link FIELDS} entry and is drawn by hand under the name it
|
|
235
|
+
* belongs to.
|
|
236
|
+
*/
|
|
237
|
+
const AGENTS_LINK_KEY = 'agentsFileLink';
|
|
238
|
+
|
|
239
|
+
/** How a near-miss folder differs from the configured name, as the warning words it. */
|
|
240
|
+
const VARIANT_DIFFERENCE: Record<Extract<RootFolderState, { kind: 'variant' }>['difference'], string> = {
|
|
241
|
+
case: 'differs only by case',
|
|
242
|
+
'trailing-s': 'differs only by a trailing s',
|
|
243
|
+
'case-and-trailing-s': 'differs by case and a trailing s',
|
|
244
|
+
};
|
|
245
|
+
|
|
106
246
|
/** The blocks, in the order they are worked through. */
|
|
107
247
|
const SECTIONS: { id: SettingStatus['section']; title: string; blurb: string }[] = [
|
|
108
248
|
{
|
|
@@ -121,7 +261,16 @@ const SECTIONS: { id: SettingStatus['section']; title: string; blurb: string }[]
|
|
|
121
261
|
|
|
122
262
|
interface Props {
|
|
123
263
|
settings: SettingStatus[];
|
|
124
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* Re-read the status after a save, so the gate can let the app through.
|
|
266
|
+
*
|
|
267
|
+
* The host must let only its LATEST read land (`SetupGate` and
|
|
268
|
+
* `DeploymentPage` both read through `useSetupStatus`, which does): each
|
|
269
|
+
* fresh `kbInit` replaces the failure on
|
|
270
|
+
* screen, so an earlier read answering late — the refresh after a failed
|
|
271
|
+
* save, landing after a retry that succeeded — would otherwise put the
|
|
272
|
+
* cleared failure back.
|
|
273
|
+
*/
|
|
125
274
|
onSaved(): void;
|
|
126
275
|
/**
|
|
127
276
|
* Where the screen is standing. `setup` (the default) is the first-run
|
|
@@ -132,6 +281,19 @@ interface Props {
|
|
|
132
281
|
* and the restart banners must never drift between first run and later.
|
|
133
282
|
*/
|
|
134
283
|
variant?: 'setup' | 'settings';
|
|
284
|
+
/**
|
|
285
|
+
* The remote-sync facts to show beside the sync secret: the address a hook
|
|
286
|
+
* calls, and what the last call did. Absent on a build without the module.
|
|
287
|
+
*/
|
|
288
|
+
sync?: SyncStatus;
|
|
289
|
+
/**
|
|
290
|
+
* A standing knowledge-base initialization failure, from the status
|
|
291
|
+
* endpoint — so the banner is there when the screen is opened, not only
|
|
292
|
+
* right after the save that failed.
|
|
293
|
+
*/
|
|
294
|
+
kbInit?: KbInitFailure;
|
|
295
|
+
/** Whether the single sign-on configuration in effect is proven. Absent from an older server. */
|
|
296
|
+
oidcVerification?: OidcVerification;
|
|
135
297
|
}
|
|
136
298
|
|
|
137
299
|
/**
|
|
@@ -150,8 +312,46 @@ interface Props {
|
|
|
150
312
|
* silently outranking the infrastructure config someone is reviewing in a
|
|
151
313
|
* repo, which is the same rule the server enforces.
|
|
152
314
|
*/
|
|
153
|
-
|
|
315
|
+
/** Two reports of the same initialization failure (a status read builds a new object each time). */
|
|
316
|
+
function sameFailure(a: KbInitFailure, b: KbInitFailure): boolean {
|
|
317
|
+
return a.kind === b.kind && a.cause === b.cause;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit, oidcVerification }: Props) {
|
|
154
321
|
const [draft, setDraft] = useState<Record<string, string>>({});
|
|
322
|
+
/**
|
|
323
|
+
* The initialization failure on screen: the status endpoint's, until a save
|
|
324
|
+
* or a retry from this screen answers more recently. A fresh status read
|
|
325
|
+
* (a new `kbInit` from the host) takes over again — adjusted during render
|
|
326
|
+
* rather than in an effect, so the stale banner never paints. That a fresh
|
|
327
|
+
* prop really is the latest read is the host's promise (see `onSaved`), and
|
|
328
|
+
* each retry or save that clears the failure here also asks for that read.
|
|
329
|
+
*/
|
|
330
|
+
const [initFailure, setInitFailure] = useState<KbInitFailure | null>(kbInit ?? null);
|
|
331
|
+
const [seenKbInit, setSeenKbInit] = useState(kbInit);
|
|
332
|
+
/**
|
|
333
|
+
* The failure a save or retry from THIS screen has just seen cleared, until a
|
|
334
|
+
* status read agrees. A read that went out before the retry — the refresh
|
|
335
|
+
* after the failed save — can still answer after it, reporting that same
|
|
336
|
+
* failure as standing; this screen knows better, so the stale copy is not
|
|
337
|
+
* shown. The guard lifts on the first read without a failure, and never
|
|
338
|
+
* hides a DIFFERENT failure: that is news, whenever it arrives.
|
|
339
|
+
*/
|
|
340
|
+
const [clearedFailure, setClearedFailure] = useState<KbInitFailure | null>(null);
|
|
341
|
+
if (kbInit !== seenKbInit) {
|
|
342
|
+
setSeenKbInit(kbInit);
|
|
343
|
+
if (!kbInit) {
|
|
344
|
+
setClearedFailure(null);
|
|
345
|
+
setInitFailure(null);
|
|
346
|
+
} else if (!(clearedFailure && sameFailure(kbInit, clearedFailure))) {
|
|
347
|
+
setClearedFailure(null);
|
|
348
|
+
setInitFailure(kbInit);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
const [retrying, setRetrying] = useState(false);
|
|
352
|
+
const [syncing, setSyncing] = useState(false);
|
|
353
|
+
/** What the last "Sync now" from THIS page came back with (a failure to ask is `error`). */
|
|
354
|
+
const [syncResult, setSyncResult] = useState<SyncNowResult | null>(null);
|
|
155
355
|
const [problems, setProblems] = useState<Record<string, string>>({});
|
|
156
356
|
const [error, setError] = useState<string | null>(null);
|
|
157
357
|
const [test, setTest] = useState<ConnectionTest | null>(null);
|
|
@@ -171,6 +371,25 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
171
371
|
* shown as if it were about the new ones.
|
|
172
372
|
*/
|
|
173
373
|
const connectionEpoch = useRef(0);
|
|
374
|
+
const [oidcTest, setOidcTest] = useState<OidcTest | null>(null);
|
|
375
|
+
const [oidcTesting, setOidcTesting] = useState(false);
|
|
376
|
+
/** The same staleness guard as {@link connectionEpoch}, for the sign-in answers. */
|
|
377
|
+
const oidcEpoch = useRef(0);
|
|
378
|
+
/**
|
|
379
|
+
* A verification state newer than the one the host last passed in — what a
|
|
380
|
+
* save or a test just answered. Dropped for good the moment the host passes
|
|
381
|
+
* in anything new (its own refresh supersedes it, even one that comes back
|
|
382
|
+
* to the value it replaced) and when a sign-in field is edited.
|
|
383
|
+
*/
|
|
384
|
+
const [latest, setLatest] = useState<OidcVerification | null>(null);
|
|
385
|
+
const [hostVerification, setHostVerification] = useState(oidcVerification);
|
|
386
|
+
if (hostVerification !== oidcVerification) {
|
|
387
|
+
// Adjusting state to a changed prop during render, rather than in an
|
|
388
|
+
// effect: React re-renders at once, before anything stale is painted.
|
|
389
|
+
setHostVerification(oidcVerification);
|
|
390
|
+
setLatest(null);
|
|
391
|
+
}
|
|
392
|
+
const verification = latest ?? oidcVerification;
|
|
174
393
|
|
|
175
394
|
/**
|
|
176
395
|
* What a field would save as, given a set of typed answers: what is in them,
|
|
@@ -199,6 +418,25 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
199
418
|
return typed !== (settings.find((s) => s.key === key)?.value ?? '').trim();
|
|
200
419
|
};
|
|
201
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Something typed that a save would actually store. The retry sends an EMPTY
|
|
423
|
+
* save — pressed now, it would re-run against the stored values while a
|
|
424
|
+
* corrected token sits unsaved in the form — so it waits, and Save (which
|
|
425
|
+
* retries too) is the way to try with the new values. Judged like the
|
|
426
|
+
* connection gate above — an edit put back changes nothing — and a token
|
|
427
|
+
* username that is just what an address answers (the one typed, or the one
|
|
428
|
+
* stored) is not an edit of its own: typing the address fills it in, and once
|
|
429
|
+
* the address is put back or cleared, nothing the admin did is left unsaved.
|
|
430
|
+
*/
|
|
431
|
+
const answeredUsernames = [draft.kbRepoUrl, settings.find((s) => s.key === 'kbRepoUrl')?.value].map(
|
|
432
|
+
(address) => (address ? tokenUsernameForHost(address)?.username : undefined),
|
|
433
|
+
);
|
|
434
|
+
const draftChanged = Object.keys(draft).some(
|
|
435
|
+
(key) =>
|
|
436
|
+
!(key === 'gitUsername' && answeredUsernames.includes(draft.gitUsername)) &&
|
|
437
|
+
connectionKeyChanged(key),
|
|
438
|
+
);
|
|
439
|
+
|
|
202
440
|
/**
|
|
203
441
|
* Whether THIS save has to stand behind the repository connection.
|
|
204
442
|
*
|
|
@@ -227,6 +465,8 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
227
465
|
* reader has already changed.
|
|
228
466
|
*/
|
|
229
467
|
const connectionRejected = mustProveConnection && test?.ok === false;
|
|
468
|
+
/** Of those, the host let the token read but not write — a different fix. */
|
|
469
|
+
const connectionReadOnly = connectionRejected && test?.outcome === 'read-only';
|
|
230
470
|
|
|
231
471
|
function set(key: string, value: string) {
|
|
232
472
|
setDraft((d) => {
|
|
@@ -249,6 +489,12 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
249
489
|
delete next[key];
|
|
250
490
|
return next;
|
|
251
491
|
});
|
|
492
|
+
if (OIDC_KEYS.includes(key)) {
|
|
493
|
+
oidcEpoch.current++;
|
|
494
|
+
setOidcTest(null);
|
|
495
|
+
// A test's "Verified" was about the values before this edit.
|
|
496
|
+
setLatest(null);
|
|
497
|
+
}
|
|
252
498
|
if (CONNECTION_KEYS.includes(key)) {
|
|
253
499
|
// Any in-flight test is now asking about values that are gone; the epoch
|
|
254
500
|
// bump makes its answer land as stale rather than as evidence.
|
|
@@ -349,9 +595,218 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
349
595
|
}
|
|
350
596
|
}
|
|
351
597
|
|
|
598
|
+
/**
|
|
599
|
+
* "Test sign-in configuration": the check a save runs, on the values typed
|
|
600
|
+
* (the server falls back to those in effect). Nothing is saved.
|
|
601
|
+
*/
|
|
602
|
+
async function runOidcTest() {
|
|
603
|
+
setOidcTesting(true);
|
|
604
|
+
setError(null);
|
|
605
|
+
const epoch = oidcEpoch.current;
|
|
606
|
+
const fields = Object.fromEntries(Object.entries(draft).filter(([key]) => OIDC_KEYS.includes(key)));
|
|
607
|
+
try {
|
|
608
|
+
const result = await testOidc(fields);
|
|
609
|
+
if (epoch !== oidcEpoch.current) return;
|
|
610
|
+
setOidcTest(result);
|
|
611
|
+
if (result.oidcVerification) setLatest(result.oidcVerification);
|
|
612
|
+
} catch (err) {
|
|
613
|
+
if (epoch === oidcEpoch.current) {
|
|
614
|
+
setOidcTest({ ok: false, error: err instanceof Error ? err.message : 'Could not test the sign-in configuration.' });
|
|
615
|
+
}
|
|
616
|
+
} finally {
|
|
617
|
+
setOidcTesting(false);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/** What a sign-in test came back with, in words. */
|
|
622
|
+
function describeOidcTest(result: OidcTest): string {
|
|
623
|
+
switch (result.outcome) {
|
|
624
|
+
case 'verified':
|
|
625
|
+
return 'Verified. The provider accepted the application ID and secret.';
|
|
626
|
+
case 'issuer-verified':
|
|
627
|
+
return 'The provider address is a sign-in provider. Enter the application ID and secret to check them too.';
|
|
628
|
+
default:
|
|
629
|
+
return result.error ?? 'The sign-in configuration could not be checked.';
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* The test button, its answer and the verification label: beside the
|
|
635
|
+
* provider fields, or on its own when every one of them is set by the
|
|
636
|
+
* environment.
|
|
637
|
+
*/
|
|
638
|
+
function renderOidcPanel() {
|
|
639
|
+
return (
|
|
640
|
+
<Surface tone="sunken" radius="md" className="p-4">
|
|
641
|
+
{verification && (
|
|
642
|
+
<p className="mb-3 text-detail text-ink-muted">
|
|
643
|
+
Status:{' '}
|
|
644
|
+
<span
|
|
645
|
+
data-testid="oidc-verification"
|
|
646
|
+
className={`font-medium ${
|
|
647
|
+
verification === 'verified'
|
|
648
|
+
? 'text-ok'
|
|
649
|
+
: verification === 'unverified'
|
|
650
|
+
? 'text-wait'
|
|
651
|
+
: 'text-ink-faint'
|
|
652
|
+
}`}
|
|
653
|
+
>
|
|
654
|
+
{OIDC_VERIFICATION_LABEL[verification]}
|
|
655
|
+
</span>
|
|
656
|
+
</p>
|
|
657
|
+
)}
|
|
658
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
659
|
+
<Button
|
|
660
|
+
type="button"
|
|
661
|
+
variant="outline"
|
|
662
|
+
size="sm"
|
|
663
|
+
onClick={() => void runOidcTest()}
|
|
664
|
+
disabled={oidcTesting || saving}
|
|
665
|
+
>
|
|
666
|
+
{oidcTesting ? 'Checking…' : 'Test sign-in configuration'}
|
|
667
|
+
</Button>
|
|
668
|
+
<span className="text-meta text-ink-faint">
|
|
669
|
+
Checks the provider address, then the application ID and secret, with the provider.
|
|
670
|
+
</span>
|
|
671
|
+
</div>
|
|
672
|
+
{oidcTest && (
|
|
673
|
+
<p
|
|
674
|
+
role="status"
|
|
675
|
+
className={`mt-3 text-detail ${
|
|
676
|
+
oidcTest.ok ? 'text-ok' : oidcTest.outcome === 'unverified' ? 'text-wait' : 'text-danger'
|
|
677
|
+
}`}
|
|
678
|
+
>
|
|
679
|
+
{describeOidcTest(oidcTest)}
|
|
680
|
+
</p>
|
|
681
|
+
)}
|
|
682
|
+
</Surface>
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
async function runSync() {
|
|
687
|
+
setSyncing(true);
|
|
688
|
+
setSyncResult(null);
|
|
689
|
+
try {
|
|
690
|
+
setSyncResult(await syncNow());
|
|
691
|
+
// The status carries the last-sync record; refetch so it shows this one.
|
|
692
|
+
onSaved();
|
|
693
|
+
} catch (err) {
|
|
694
|
+
setSyncResult({
|
|
695
|
+
ok: false,
|
|
696
|
+
results: [],
|
|
697
|
+
error: err instanceof Error ? err.message : 'Could not sync.',
|
|
698
|
+
});
|
|
699
|
+
} finally {
|
|
700
|
+
setSyncing(false);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Beside the sync secret: the address a hook calls (in both variants — an
|
|
706
|
+
* admin wiring a hook needs it before first run too), and once the
|
|
707
|
+
* deployment is live, what the last call did plus a button to make one.
|
|
708
|
+
*/
|
|
709
|
+
function renderSyncPanel() {
|
|
710
|
+
if (!sync) return null;
|
|
711
|
+
const last = sync.last;
|
|
712
|
+
return (
|
|
713
|
+
<Surface tone="surface" radius="md" className="mt-3 space-y-3 border border-line p-3">
|
|
714
|
+
<div className="space-y-1.5">
|
|
715
|
+
<span className="text-meta font-medium text-ink">Address for the hook</span>
|
|
716
|
+
<CopyValue value={`${sync.url}/<branch>`} label="Copy the sync address" />
|
|
717
|
+
<p className="text-meta text-ink-faint">
|
|
718
|
+
Replace <code className="font-mono"><branch></code> with the branch that changed;
|
|
719
|
+
send the secret as a bearer token.
|
|
720
|
+
</p>
|
|
721
|
+
</div>
|
|
722
|
+
{variant === 'settings' && (
|
|
723
|
+
<div className="space-y-2">
|
|
724
|
+
<p role="status" className="text-meta text-ink-muted">
|
|
725
|
+
{last
|
|
726
|
+
? `Last sync ${new Date(last.at).toLocaleString()} by ${last.by}: ${describeOutcomes(last.results)}.`
|
|
727
|
+
: 'No sync since this server started.'}
|
|
728
|
+
</p>
|
|
729
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
730
|
+
<Button
|
|
731
|
+
type="button"
|
|
732
|
+
variant="outline"
|
|
733
|
+
size="sm"
|
|
734
|
+
onClick={() => void runSync()}
|
|
735
|
+
disabled={syncing}
|
|
736
|
+
>
|
|
737
|
+
{syncing ? 'Syncing…' : 'Sync now'}
|
|
738
|
+
</Button>
|
|
739
|
+
<span className="text-meta text-ink-faint">
|
|
740
|
+
Pulls every branch from the repository with your own session — the same thing the
|
|
741
|
+
hook does.
|
|
742
|
+
</span>
|
|
743
|
+
</div>
|
|
744
|
+
{syncResult && (
|
|
745
|
+
<p
|
|
746
|
+
role="status"
|
|
747
|
+
// One line per failed branch: the server's sentences are
|
|
748
|
+
// joined with newlines and rendered as such.
|
|
749
|
+
className={`whitespace-pre-line text-detail ${syncResult.ok ? 'text-ok' : 'text-danger'}`}
|
|
750
|
+
>
|
|
751
|
+
{syncResult.error
|
|
752
|
+
? syncResult.error
|
|
753
|
+
: syncResult.ok
|
|
754
|
+
? `Synced: ${describeOutcomes(syncResult.results)}.`
|
|
755
|
+
: (syncResult.results
|
|
756
|
+
.map(syncOutcomeError)
|
|
757
|
+
.filter((e): e is string => !!e)
|
|
758
|
+
.join('\n') ||
|
|
759
|
+
`Not fully synced: ${describeOutcomes(syncResult.results)}.`)}
|
|
760
|
+
</p>
|
|
761
|
+
)}
|
|
762
|
+
</div>
|
|
763
|
+
)}
|
|
764
|
+
</Surface>
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Re-run the knowledge-base initialization. No endpoint of its own: any save
|
|
770
|
+
* while the failure stands re-runs the phase, and an EMPTY one changes no
|
|
771
|
+
* setting — so nothing has to be typed again, and the server's one-save-at-a-
|
|
772
|
+
* time chain covers this exactly as it covers the form.
|
|
773
|
+
*/
|
|
774
|
+
async function retryInitialization() {
|
|
775
|
+
if (retrying || saving || draftChanged) return;
|
|
776
|
+
setRetrying(true);
|
|
777
|
+
setError(null);
|
|
778
|
+
try {
|
|
779
|
+
const result = await saveSettings({});
|
|
780
|
+
setClearedFailure(initFailure);
|
|
781
|
+
setInitFailure(null);
|
|
782
|
+
if (result.awaitingRestart) {
|
|
783
|
+
setNeedsRestart(true);
|
|
784
|
+
// As after a save: the settings page still wants fresh status, or its
|
|
785
|
+
// host keeps the failure this retry just cleared.
|
|
786
|
+
if (variant === 'settings') onSaved();
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
if (result.complete && variant === 'setup') {
|
|
790
|
+
// The same full reload the completing save does, for the same reason:
|
|
791
|
+
// the browser's branch model predates the app it is about to open.
|
|
792
|
+
window.location.reload();
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
onSaved();
|
|
796
|
+
} catch (err) {
|
|
797
|
+
if (err instanceof KbInitFailed) {
|
|
798
|
+
setClearedFailure(null);
|
|
799
|
+
setInitFailure(err.kbInit);
|
|
800
|
+
} else setError(err instanceof Error ? err.message : 'Could not retry the initialization.');
|
|
801
|
+
} finally {
|
|
802
|
+
setRetrying(false);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
352
806
|
async function submit(e: FormEvent) {
|
|
353
807
|
e.preventDefault();
|
|
354
|
-
|
|
808
|
+
// A save during a sign-in check would clear the draft the check is about.
|
|
809
|
+
if (saving || retrying || oidcTesting) return;
|
|
355
810
|
setSaving(true);
|
|
356
811
|
setError(null);
|
|
357
812
|
setProblems({});
|
|
@@ -388,11 +843,15 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
388
843
|
setTesting(true);
|
|
389
844
|
await probe();
|
|
390
845
|
setTesting(false);
|
|
846
|
+
// Includes a probe the server REFUSED (a 4xx comes back as a
|
|
847
|
+
// rejection, not a throw) — that is an answer about these values.
|
|
391
848
|
if (proven && !proven.ok) {
|
|
392
849
|
setError(
|
|
393
|
-
|
|
394
|
-
? 'Not saved.
|
|
395
|
-
:
|
|
850
|
+
proven.outcome === 'read-only'
|
|
851
|
+
? 'Not saved. The token can read the repository but cannot write to it — grant it write access and test again.'
|
|
852
|
+
: variant === 'setup'
|
|
853
|
+
? 'Not saved. Nothing behind this screen works until the repository answers, and it did not — fix the connection above and test it again.'
|
|
854
|
+
: 'Not saved. The repository did not answer with those details — fix the connection above and test it again.',
|
|
396
855
|
);
|
|
397
856
|
return;
|
|
398
857
|
}
|
|
@@ -405,13 +864,19 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
405
864
|
// above fills the same fields from the same answer.
|
|
406
865
|
if (
|
|
407
866
|
!probed &&
|
|
867
|
+
// No address, nothing to look a branch up in.
|
|
868
|
+
!!resolvedIn(payload, 'kbRepoUrl') &&
|
|
408
869
|
(!resolvedIn(payload, 'defaultBranch') || !resolvedIn(payload, 'protectedBranches'))
|
|
409
870
|
) {
|
|
410
871
|
await probe();
|
|
411
872
|
}
|
|
412
873
|
const result = await saveSettings(payload);
|
|
874
|
+
// A save while a failure stands re-ran the initialization, and it held.
|
|
875
|
+
setClearedFailure(initFailure);
|
|
876
|
+
setInitFailure(null);
|
|
413
877
|
setRestartRequired(result.restartRequired);
|
|
414
878
|
setDraft({});
|
|
879
|
+
if (result.oidcVerification) setLatest(result.oidcVerification);
|
|
415
880
|
// A save can succeed and STILL leave the deployment unusable: a blank
|
|
416
881
|
// field means "leave it alone", not "this is wrong", so the server
|
|
417
882
|
// accepts a batch that answers only some of what it needs. Saying so is
|
|
@@ -445,8 +910,24 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
445
910
|
}
|
|
446
911
|
onSaved();
|
|
447
912
|
} catch (err) {
|
|
448
|
-
if (err instanceof SettingsProblems)
|
|
449
|
-
|
|
913
|
+
if (err instanceof SettingsProblems) {
|
|
914
|
+
setProblems(err.problems);
|
|
915
|
+
// A problem about a field this form does not render — the server's
|
|
916
|
+
// connection check blaming a token the environment supplies, say —
|
|
917
|
+
// would otherwise vanish, leaving a save that failed silently.
|
|
918
|
+
const unshown = Object.entries(err.problems).filter(
|
|
919
|
+
([key]) => !editable.some((s) => s.key === key),
|
|
920
|
+
);
|
|
921
|
+
if (unshown.length > 0) setError(unshown.map(([, message]) => message).join(' '));
|
|
922
|
+
} else if (err instanceof KbInitFailed) {
|
|
923
|
+
// The values ARE stored — only the initialization failed. The form
|
|
924
|
+
// shows what was saved, and the banner says what to fix and retries
|
|
925
|
+
// without asking for any of it again.
|
|
926
|
+
setClearedFailure(null);
|
|
927
|
+
setInitFailure(err.kbInit);
|
|
928
|
+
setDraft({});
|
|
929
|
+
onSaved();
|
|
930
|
+
} else setError(err instanceof Error ? err.message : 'Could not save these settings.');
|
|
450
931
|
} finally {
|
|
451
932
|
setSaving(false);
|
|
452
933
|
// The page scrolls now, and every message lands at the top of it while
|
|
@@ -465,11 +946,93 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
465
946
|
*/
|
|
466
947
|
const remoteBranches = test?.ok ? (test.branches ?? []) : [];
|
|
467
948
|
|
|
949
|
+
/**
|
|
950
|
+
* The top-level folders the connection test found, or null when there is
|
|
951
|
+
* nothing to judge the root fields against: no test yet, a failed one, a
|
|
952
|
+
* listing that did not come back — or an EMPTY repository, whose one message
|
|
953
|
+
* already says everything will be set up, and three "will be created" notes
|
|
954
|
+
* beneath it would only repeat that.
|
|
955
|
+
*/
|
|
956
|
+
const remoteRootFolders =
|
|
957
|
+
test?.ok && !test.empty && Array.isArray(test.rootFolders) ? test.rootFolders : null;
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* What the repository holds for one root field, as it would save now. Judged
|
|
961
|
+
* live against the listing — the listing describes the repository, not the
|
|
962
|
+
* field, so correcting the name to the one suggested says "found" at once.
|
|
963
|
+
* Never a problem that blocks the save: an admin may mean to create the
|
|
964
|
+
* folder, or to rename the old one later.
|
|
965
|
+
*/
|
|
966
|
+
function renderRootFolderState(key: keyof KbLayout) {
|
|
967
|
+
if (!remoteRootFolders) return null;
|
|
968
|
+
const name = resolved(key) || DEFAULT_KB_LAYOUT[key];
|
|
969
|
+
const state = rootFolderState(name, remoteRootFolders);
|
|
970
|
+
const folder = (value: string) => <code className="font-mono">{value}</code>;
|
|
971
|
+
return (
|
|
972
|
+
<p id={`${key}-repo-state`} className={`mt-1 text-meta ${state.kind === 'variant' ? 'text-wait' : 'text-ok'}`}>
|
|
973
|
+
{state.kind === 'found' && <>{folder(name)} found in the repository.</>}
|
|
974
|
+
{state.kind === 'missing' && (
|
|
975
|
+
<>{folder(name)} is not in the repository yet — it will be created.</>
|
|
976
|
+
)}
|
|
977
|
+
{state.kind === 'variant' && (
|
|
978
|
+
<>
|
|
979
|
+
Not found — the repository has {folder(state.candidate)} (
|
|
980
|
+
{VARIANT_DIFFERENCE[state.difference]}): set
|
|
981
|
+
this field to {folder(state.candidate)} or rename the folder.
|
|
982
|
+
</>
|
|
983
|
+
)}
|
|
984
|
+
</p>
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Under the guide's name, once it is no longer `AGENTS.md`: the exact
|
|
990
|
+
* sentence the platform would add to the customer's own `AGENTS.md`, and the
|
|
991
|
+
* consent to keep it there.
|
|
992
|
+
*
|
|
993
|
+
* Shown ONLY while the name differs, because that is the only time there is
|
|
994
|
+
* anything to point at — under the default name the guide IS `AGENTS.md`.
|
|
995
|
+
* The sentence is rendered by the same helper the server appends with, so
|
|
996
|
+
* what the admin reads here is what lands in their file, character for
|
|
997
|
+
* character.
|
|
998
|
+
*/
|
|
999
|
+
function renderAgentsFileLink() {
|
|
1000
|
+
const name = resolved('agentsFile') || DEFAULT_KB_LAYOUT.agentsFile;
|
|
1001
|
+
if (name === DEFAULT_KB_LAYOUT.agentsFile) return null;
|
|
1002
|
+
// Unset means on: the server reads an unanswered setting the same way.
|
|
1003
|
+
const on = (draft[AGENTS_LINK_KEY] ?? settings.find((s) => s.key === AGENTS_LINK_KEY)?.value ?? 'true') !== 'false';
|
|
1004
|
+
return (
|
|
1005
|
+
<div className="mt-2 space-y-2" data-testid="agents-file-link">
|
|
1006
|
+
<label className="flex cursor-pointer select-none items-start gap-2 text-detail text-ink">
|
|
1007
|
+
<input
|
|
1008
|
+
type="checkbox"
|
|
1009
|
+
className="mt-0.5"
|
|
1010
|
+
checked={on}
|
|
1011
|
+
onChange={(e) => set(AGENTS_LINK_KEY, e.target.checked ? 'true' : 'false')}
|
|
1012
|
+
/>
|
|
1013
|
+
<span>Keep a pointer to {name} in your own AGENTS.md</span>
|
|
1014
|
+
</label>
|
|
1015
|
+
<CopyValue value={agentsFilePointerSentence(name)} label="Copy the pointer sentence" />
|
|
1016
|
+
<p className="text-meta text-ink-faint">
|
|
1017
|
+
While this is ticked, every start looks for “{name}” in your AGENTS.md and adds the
|
|
1018
|
+
sentence at the end when it is not there — in your own words counts too. Nothing is added
|
|
1019
|
+
if you have no AGENTS.md, and no file is ever created for it. Untick it to stop.
|
|
1020
|
+
</p>
|
|
1021
|
+
</div>
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
468
1025
|
function renderField(setting: SettingStatus) {
|
|
469
1026
|
const copy = FIELDS[setting.key];
|
|
470
1027
|
if (!copy) return null;
|
|
471
1028
|
const isBranchField = setting.key === 'defaultBranch' || setting.key === 'protectedBranches';
|
|
472
|
-
const
|
|
1029
|
+
const isFolderField = isRootFolderKey(setting.key);
|
|
1030
|
+
const suggestions = isBranchField
|
|
1031
|
+
? remoteBranches
|
|
1032
|
+
: isFolderField
|
|
1033
|
+
? (remoteRootFolders ?? []).filter(isRootFolderSuggestion)
|
|
1034
|
+
: [];
|
|
1035
|
+
const listId = suggestions.length > 0 ? `${setting.key}-options` : undefined;
|
|
473
1036
|
return (
|
|
474
1037
|
<div key={setting.key}>
|
|
475
1038
|
<label className="block space-y-1.5">
|
|
@@ -491,12 +1054,15 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
491
1054
|
</label>
|
|
492
1055
|
{listId && (
|
|
493
1056
|
<datalist id={listId}>
|
|
494
|
-
{
|
|
1057
|
+
{suggestions.map((b) => (
|
|
495
1058
|
<option key={b} value={b} />
|
|
496
1059
|
))}
|
|
497
1060
|
</datalist>
|
|
498
1061
|
)}
|
|
499
1062
|
<p className="mt-1 text-meta text-ink-faint">{copy.help}</p>
|
|
1063
|
+
{isRootFolderKey(setting.key) && renderRootFolderState(setting.key)}
|
|
1064
|
+
{setting.key === 'agentsFile' && renderAgentsFileLink()}
|
|
1065
|
+
{setting.key === 'kbSyncSecret' && renderSyncPanel()}
|
|
500
1066
|
{/* Only AFTER setup: on first run there is nothing yet to lose, so
|
|
501
1067
|
the caution would be noise. Once a deployment is live, this field
|
|
502
1068
|
is the one whose careless edit strands everything. */}
|
|
@@ -538,6 +1104,31 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
538
1104
|
)}
|
|
539
1105
|
|
|
540
1106
|
<div ref={noticeRef}>
|
|
1107
|
+
{/* Saved, but the knowledge base behind the gate was never set up.
|
|
1108
|
+
The cause is the server's classified sentence — what to fix, not
|
|
1109
|
+
what git said — and the retry needs nothing re-entered. */}
|
|
1110
|
+
{initFailure && (
|
|
1111
|
+
<Banner tone="danger" role="alert" className="mt-6" data-testid="kb-init-failure">
|
|
1112
|
+
<p className="font-semibold">Saved, but the knowledge base could not be initialized</p>
|
|
1113
|
+
<p className="mt-1">{initFailure.cause}</p>
|
|
1114
|
+
{draftChanged && (
|
|
1115
|
+
<p className="mt-1">
|
|
1116
|
+
The form has unsaved changes — saving them retries the initialization with them.
|
|
1117
|
+
</p>
|
|
1118
|
+
)}
|
|
1119
|
+
<Button
|
|
1120
|
+
type="button"
|
|
1121
|
+
variant="outline"
|
|
1122
|
+
size="sm"
|
|
1123
|
+
className="mt-3"
|
|
1124
|
+
onClick={() => void retryInitialization()}
|
|
1125
|
+
disabled={retrying || saving || testing || draftChanged}
|
|
1126
|
+
>
|
|
1127
|
+
{retrying ? 'Initializing…' : 'Retry initialization'}
|
|
1128
|
+
</Button>
|
|
1129
|
+
</Banner>
|
|
1130
|
+
)}
|
|
1131
|
+
|
|
541
1132
|
{error && (
|
|
542
1133
|
<Banner tone="danger" role="alert" className="mt-6">
|
|
543
1134
|
{error}
|
|
@@ -574,7 +1165,10 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
574
1165
|
</Banner>
|
|
575
1166
|
)}
|
|
576
1167
|
|
|
577
|
-
|
|
1168
|
+
{/* Named so its submit button can sit outside it, below the
|
|
1169
|
+
Marketplace section: the button is the last thing on the page, but
|
|
1170
|
+
Marketplace is deliberately not part of this form (see below). */}
|
|
1171
|
+
<form id="setup-settings-form" onSubmit={submit} className="mt-8 space-y-10">
|
|
578
1172
|
{SECTIONS.map((section) => {
|
|
579
1173
|
const fields = editable.filter((s) => s.section === section.id);
|
|
580
1174
|
// A section whose every field comes from the environment has
|
|
@@ -609,7 +1203,21 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
609
1203
|
</p>
|
|
610
1204
|
)}
|
|
611
1205
|
</div>
|
|
612
|
-
{fields
|
|
1206
|
+
{fields
|
|
1207
|
+
.filter(
|
|
1208
|
+
(f) =>
|
|
1209
|
+
!FIELDS[f.key]?.advanced &&
|
|
1210
|
+
!isLayoutKey(f.key) &&
|
|
1211
|
+
(section.id !== 'sign-in' || OIDC_KEYS.includes(f.key)),
|
|
1212
|
+
)
|
|
1213
|
+
.map((f) => renderField(f))}
|
|
1214
|
+
|
|
1215
|
+
{/* Directly under the three answers it proves. */}
|
|
1216
|
+
{section.id === 'sign-in' && renderOidcPanel()}
|
|
1217
|
+
{section.id === 'sign-in' &&
|
|
1218
|
+
fields
|
|
1219
|
+
.filter((f) => !FIELDS[f.key]?.advanced && !OIDC_KEYS.includes(f.key))
|
|
1220
|
+
.map((f) => renderField(f))}
|
|
613
1221
|
|
|
614
1222
|
{/* Immediately under the two fields it proves, and above the
|
|
615
1223
|
Advanced block it fills in — the middle of the sequence
|
|
@@ -628,13 +1236,13 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
628
1236
|
// Also while SAVING: a save may be asking the remote
|
|
629
1237
|
// itself, and a second test racing it would overwrite
|
|
630
1238
|
// both the result and the versions derived from it.
|
|
631
|
-
disabled={testing || saving}
|
|
1239
|
+
disabled={testing || saving || retrying}
|
|
632
1240
|
>
|
|
633
1241
|
{testing ? 'Checking…' : 'Test connection'}
|
|
634
1242
|
</Button>
|
|
635
1243
|
<span className="text-meta text-ink-faint">
|
|
636
|
-
Checks the address and token against the host,
|
|
637
|
-
|
|
1244
|
+
Checks the address and token against the host, looks for the folders below,
|
|
1245
|
+
and fills in the versions.
|
|
638
1246
|
</span>
|
|
639
1247
|
</div>
|
|
640
1248
|
{test && (
|
|
@@ -654,6 +1262,13 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
654
1262
|
</Surface>
|
|
655
1263
|
)}
|
|
656
1264
|
|
|
1265
|
+
{/* The layout: the three root folders and the agent guide's
|
|
1266
|
+
file name, in the main section, directly under the test
|
|
1267
|
+
whose listing the folders are checked against — the
|
|
1268
|
+
connection fields above it stay next to the button that
|
|
1269
|
+
proves them. */}
|
|
1270
|
+
{fields.filter((f) => isLayoutKey(f.key)).map((f) => renderField(f))}
|
|
1271
|
+
|
|
657
1272
|
{/* Everything a normal setup never touches, out of the way but
|
|
658
1273
|
not hidden: a self-hosted git server does need the token
|
|
659
1274
|
username, and a provider with unusual scopes does need
|
|
@@ -684,38 +1299,94 @@ export function SetupScreen({ settings, onSaved, variant = 'setup' }: Props) {
|
|
|
684
1299
|
</div>
|
|
685
1300
|
</details>
|
|
686
1301
|
)}
|
|
1302
|
+
|
|
1303
|
+
{/* The sync panel normally hangs off the secret's field. When
|
|
1304
|
+
the secret comes from the environment that field is in the
|
|
1305
|
+
locked list below, not here — but the address, the last
|
|
1306
|
+
sync and Sync now are about the deployment, not the secret,
|
|
1307
|
+
and an admin with an env-set secret needs them just as much. */}
|
|
1308
|
+
{section.id === 'knowledge-base' &&
|
|
1309
|
+
sync &&
|
|
1310
|
+
!fields.some((f) => f.key === 'kbSyncSecret') &&
|
|
1311
|
+
renderSyncPanel()}
|
|
687
1312
|
</Surface>
|
|
688
1313
|
);
|
|
689
1314
|
})}
|
|
690
1315
|
|
|
691
1316
|
|
|
692
|
-
{/*
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
<
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
>
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
1317
|
+
{/* When EVERY knowledge-base setting comes from the environment the
|
|
1318
|
+
section above does not render at all, and the sync panel that
|
|
1319
|
+
normally lives inside it would vanish with it. The panel is
|
|
1320
|
+
about the deployment, not about any one editable field, so it
|
|
1321
|
+
gets its own place here in that case. */}
|
|
1322
|
+
{sync && editable.every((s) => s.section !== 'knowledge-base') && (
|
|
1323
|
+
<Surface as="section" tone="surface" radius="lg" elevation="card" className="p-6">
|
|
1324
|
+
<h2 className="text-title font-semibold text-ink">Repository sync</h2>
|
|
1325
|
+
<p className="mt-1 max-w-[60ch] text-detail text-ink-muted">
|
|
1326
|
+
The knowledge-base connection is set by the environment. The sync hook is still
|
|
1327
|
+
yours to wire up and check on here.
|
|
1328
|
+
</p>
|
|
1329
|
+
{renderSyncPanel()}
|
|
1330
|
+
</Surface>
|
|
1331
|
+
)}
|
|
1332
|
+
|
|
1333
|
+
{/* Every sign-in setting from the environment: the section above
|
|
1334
|
+
does not render, but whether that configuration works is still
|
|
1335
|
+
the admin's to see and to test. */}
|
|
1336
|
+
{editable.every((s) => s.section !== 'sign-in') &&
|
|
1337
|
+
verification &&
|
|
1338
|
+
verification !== 'not-configured' && (
|
|
1339
|
+
<Surface as="section" tone="surface" radius="lg" elevation="card" className="p-6 space-y-4">
|
|
1340
|
+
<h2 className="text-title font-semibold text-ink">Single sign-on</h2>
|
|
1341
|
+
{renderOidcPanel()}
|
|
1342
|
+
</Surface>
|
|
715
1343
|
)}
|
|
716
|
-
</div>
|
|
717
1344
|
</form>
|
|
718
1345
|
|
|
1346
|
+
{/* Outside the form: nothing in it is saved by "Save and continue",
|
|
1347
|
+
and on first run it is optional — the gate never waits on it. The
|
|
1348
|
+
same section in both variants, so first run and Deployment
|
|
1349
|
+
settings cannot drift. */}
|
|
1350
|
+
<MarketplaceSection variant={variant} />
|
|
1351
|
+
|
|
1352
|
+
{/* The submit button lives HERE, after Marketplace, though it belongs
|
|
1353
|
+
to the form above — `form=` is what lets those two facts hold at
|
|
1354
|
+
once. It is the last thing on the page because a reader should
|
|
1355
|
+
meet every section, Marketplace included, before the control that
|
|
1356
|
+
leaves the screen; when it sat above Marketplace, the page looked
|
|
1357
|
+
finished while a section was still below it.
|
|
1358
|
+
|
|
1359
|
+
A rejected connection stops here rather than at the far side of
|
|
1360
|
+
it. Saving these answers would finish setup — the server checks
|
|
1361
|
+
that they are present, not that they work — and open the app onto
|
|
1362
|
+
a repository it cannot reach, which reads as a broken product
|
|
1363
|
+
rather than a wrong token. */}
|
|
1364
|
+
<div className="mt-10 flex flex-wrap items-center justify-end gap-3">
|
|
1365
|
+
{connectionRejected && (
|
|
1366
|
+
// Before the button in the DOM so the reason is read first, and
|
|
1367
|
+
// so `justify-end` leaves the button itself at the right edge.
|
|
1368
|
+
// Not a live region: the test panel above already announced the
|
|
1369
|
+
// host's own words, and the save banner announces a blocked
|
|
1370
|
+
// attempt. This is the label for a button that will not move.
|
|
1371
|
+
<span id="connection-refusal" className="text-meta text-danger">
|
|
1372
|
+
{connectionReadOnly
|
|
1373
|
+
? 'That token can read the repository but cannot write to it. Grant write access and test again.'
|
|
1374
|
+
: 'The repository turned that connection down. Fix it above and test again.'}
|
|
1375
|
+
</span>
|
|
1376
|
+
)}
|
|
1377
|
+
<Button
|
|
1378
|
+
type="submit"
|
|
1379
|
+
form="setup-settings-form"
|
|
1380
|
+
variant="primary"
|
|
1381
|
+
disabled={saving || testing || retrying || oidcTesting || connectionRejected}
|
|
1382
|
+
// Described by the refusal, so a reader who lands on a button
|
|
1383
|
+
// that will not move is told why rather than left guessing.
|
|
1384
|
+
aria-describedby={connectionRejected ? 'connection-refusal' : undefined}
|
|
1385
|
+
>
|
|
1386
|
+
{saving ? 'Saving…' : 'Save and continue'}
|
|
1387
|
+
</Button>
|
|
1388
|
+
</div>
|
|
1389
|
+
|
|
719
1390
|
{fromEnv.length > 0 && (
|
|
720
1391
|
<Surface tone="sunken" radius="md" className="mt-10 p-4">
|
|
721
1392
|
<h2 className="text-label font-semibold uppercase text-ink-faint">
|