@bevel-software/platform-core-frontend 0.26.0 → 0.28.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/package.json +2 -2
- package/src/core/CoreAppShell.tsx +87 -25
- package/src/core/ProductName.tsx +49 -0
- package/src/core/__tests__/ProductName.test.tsx +46 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +22 -0
- package/src/core/__tests__/core-contributions.test.ts +16 -0
- package/src/core/core-contributions.ts +17 -0
- package/src/core/maker-url.ts +30 -0
- package/src/core/registry.ts +78 -1
- package/src/index.css +23 -5
- package/src/index.ts +5 -0
- package/src/lib/__tests__/latest-request.test.ts +48 -0
- package/src/lib/latest-request.ts +45 -0
- package/src/modules/access/__tests__/ManageAccessDialog.no-sso-invite.test.tsx +222 -0
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
- package/src/modules/access/api.ts +19 -3
- package/src/modules/access/components/ManageAccessDialog.tsx +61 -8
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +16 -1
- package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +284 -39
- package/src/modules/admin/components/AdminRolesPage.tsx +13 -14
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
- package/src/modules/admin/components/UserAccountsPage.tsx +91 -107
- package/src/modules/admin/services/roles.api.ts +14 -1
- package/src/modules/auth/__tests__/LoginScreen.test.tsx +80 -5
- package/src/modules/auth/__tests__/sso-strict-probe.test.ts +66 -0
- package/src/modules/auth/components/LoginScreen.tsx +101 -73
- package/src/modules/auth/services/account.api.ts +59 -3
- package/src/modules/auth/services/sso.ts +30 -10
- package/src/modules/auth/state/use-sign-in-methods.ts +41 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +176 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +68 -0
- package/src/modules/change-requests/__tests__/ChangeRequestLink.test.tsx +182 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +1 -1
- package/src/modules/change-requests/__tests__/readFileOnBranch.test.ts +79 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +6 -1
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +45 -15
- package/src/modules/change-requests/components/ChangeRequestLink.tsx +151 -0
- package/src/modules/change-requests/components/CrFileTree.tsx +2 -1
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +4 -2
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +6 -3
- package/src/modules/change-requests/services/change-requests.api.ts +15 -2
- package/src/modules/change-requests/utils/readFailure.ts +22 -0
- package/src/modules/embed/__tests__/EmbedLinkPage.test.tsx +74 -0
- package/src/modules/embed/__tests__/EmbedView.test.tsx +473 -0
- package/src/modules/embed/__tests__/embed-config.test.ts +128 -0
- package/src/modules/embed/__tests__/embed-host.test.ts +111 -0
- package/src/modules/embed/__tests__/mcp-app-view.test.ts +295 -0
- package/src/modules/embed/__tests__/mount.test.tsx +157 -0
- package/src/modules/embed/components/EmbedLinkPage.tsx +109 -0
- package/src/modules/embed/components/EmbedView.tsx +545 -0
- package/src/modules/embed/embed-config.ts +132 -0
- package/src/modules/embed/embed-host.ts +120 -0
- package/src/modules/embed/mount.tsx +80 -0
- package/src/modules/embed/services/embed-token.ts +22 -0
- package/src/modules/embed/services/embed.api.ts +158 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +202 -4
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +59 -1
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +39 -22
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +7 -2
- package/src/modules/git/branch-delete-menu-item.tsx +24 -0
- package/src/modules/git/components/BranchSwitcher.tsx +29 -5
- package/src/modules/git/components/GitSyncFailedBanner.tsx +53 -15
- package/src/modules/git/components/HistoryVersionPreview.tsx +5 -3
- package/src/modules/git/components/PullNeededBanner.tsx +15 -49
- package/src/modules/git/hooks/useAutoPullUpdates.ts +9 -5
- package/src/modules/git/index.ts +15 -0
- package/src/modules/git/services/__tests__/error-messages.test.ts +67 -0
- package/src/modules/git/services/__tests__/pull-failure.test.ts +36 -0
- package/src/modules/git/services/error-messages.ts +58 -1
- package/src/modules/git/services/pull-failure.ts +68 -0
- package/src/modules/git/state/branch-delete-confirm.ts +46 -0
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +1 -0
- package/src/modules/layout/__tests__/breakpoints.test.ts +7 -1
- package/src/modules/layout/breakpoints.ts +8 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +9 -9
- package/src/modules/library/__tests__/PluginPage.test.tsx +8 -1
- package/src/modules/library/__tests__/SkillsTree.test.tsx +13 -4
- package/src/modules/library/components/LibraryPage.tsx +22 -0
- package/src/modules/library/components/PluginExtras.tsx +23 -6
- package/src/modules/library/components/PluginPage.tsx +6 -1
- package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
- package/src/modules/library/services/plugins.api.ts +4 -1
- package/src/modules/library/state/plugins-revision.ts +28 -0
- package/src/modules/onboarding/__tests__/InviteButton.test.tsx +214 -0
- package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
- package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +164 -0
- package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1458 -0
- package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +811 -0
- package/src/modules/onboarding/__tests__/invite-emails.test.ts +247 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
- package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
- package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
- package/src/modules/onboarding/components/GetStartedColumn.tsx +670 -0
- package/src/modules/onboarding/components/InviteButton.tsx +139 -0
- package/src/modules/onboarding/components/InviteDialog.tsx +741 -0
- package/src/modules/onboarding/components/RootLanding.tsx +8 -24
- package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
- package/src/modules/onboarding/first-page-prompt.ts +123 -0
- package/src/modules/onboarding/invite-emails.ts +313 -0
- package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
- package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
- package/src/modules/onboarding/state/agent-connection.ts +167 -0
- package/src/modules/onboarding/state/invite-dialog.context.ts +35 -0
- package/src/modules/onboarding/state/invite-dialog.tsx +39 -0
- package/src/modules/onboarding/state/onboarding.ts +133 -59
- package/src/modules/onboarding/state/starter-packs.ts +169 -0
- package/src/modules/settings/settings-nav-items.tsx +8 -3
- package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
- package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
- package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
- package/src/modules/setup/__tests__/setup.test.tsx +56 -15
- package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
- package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
- package/src/modules/setup/components/SetupGate.tsx +46 -1
- package/src/modules/setup/components/SetupScreen.tsx +81 -84
- package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +3 -3
- package/src/modules/setup/utils/suggested-branch.ts +27 -0
- package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
- package/src/modules/toolbar/commands/actions.tsx +330 -0
- package/src/modules/toolbar/commands/command-menu.ts +44 -0
- package/src/modules/toolbar/commands/useCommandActions.ts +71 -0
- package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +125 -22
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
- package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
- package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
- package/src/modules/toolbar/components/Toolbar.tsx +10 -0
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +230 -52
- package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
- package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +864 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
- package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
- package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
- package/src/modules/toolbar/search/rank.ts +111 -0
- package/src/modules/toolbar/search/sources.ts +169 -0
- package/src/modules/workflow/hooks/useFileLock.ts +10 -7
- package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
- package/src/modules/workflow/services/lock.api.ts +17 -2
- package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
- package/src/modules/workspace/components/EditorTabs.tsx +39 -15
- package/src/modules/workspace/components/FileExplorer.tsx +39 -6
- package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
- package/src/modules/workspace/components/FileRoute.tsx +12 -7
- package/src/modules/workspace/components/FileViewer.tsx +271 -74
- package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +92 -4
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
- package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
- package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
- package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
- package/src/modules/workspace/components/renderers/index.ts +26 -0
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
- package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
- package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
- package/src/modules/workspace/hooks/__tests__/useCreatePage.test.ts +137 -0
- package/src/modules/workspace/hooks/__tests__/useKnowledgeWriteTarget.test.ts +302 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
- package/src/modules/workspace/hooks/useCreatePage.ts +206 -0
- package/src/modules/workspace/hooks/useKnowledgeWriteTarget.ts +238 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
- package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
- package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
- package/src/modules/workspace/routing/kb-routes.ts +66 -12
- package/src/modules/workspace/state/editable-page.ts +42 -0
- package/src/modules/workspace/state/workspace.context.ts +13 -4
- package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +16 -0
- package/src/modules/workspace/utils/display-file-name.ts +102 -0
- package/src/modules/workspace/utils/fileTree.ts +49 -14
- package/src/modules/workspace/utils/treeConfirm.ts +15 -0
- package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
- package/src/shared/components/ConfirmProvider.tsx +156 -0
- package/src/shared/components/Dialog.tsx +7 -0
- package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
- package/src/shared/components/confirm-context.ts +94 -0
- package/src/shared/components/index.ts +3 -0
- package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
- package/src/modules/onboarding/welcome-state.ts +0 -36
|
@@ -3,17 +3,18 @@ import { DEFAULT_KB_LAYOUT, type KbLayout } from '@bevel-software/platform-share
|
|
|
3
3
|
import { Banner, Button, Surface, TextField } from '../../../shared/components';
|
|
4
4
|
import { SlotBoundary } from '../../../shared/components/SlotBoundary';
|
|
5
5
|
import { tokenUsernameForHost } from '../utils/git-host';
|
|
6
|
+
import { suggestedBranch } from '../utils/suggested-branch';
|
|
6
7
|
import { isRootFolderSuggestion, rootFolderState, type RootFolderState } from '../utils/root-folders';
|
|
7
8
|
import { copyToClipboard } from '../../../lib/clipboard';
|
|
8
9
|
import { GitHubRepositoryPanel } from './GitHubRepositoryPanel';
|
|
9
10
|
import { forgetDraft, keepDraft, keptDraft } from '../utils/kept-draft';
|
|
10
11
|
import { useAppRegistry } from '../../../core/registry';
|
|
11
12
|
import { MarketplaceSection } from '../../settings/components/MarketplaceSection';
|
|
13
|
+
import { ConnectionProbeFailed, useConnectionProbe } from '../hooks/useConnectionProbe';
|
|
12
14
|
import {
|
|
13
15
|
saveSettings,
|
|
14
16
|
syncNow,
|
|
15
17
|
syncOutcomeError,
|
|
16
|
-
testConnection,
|
|
17
18
|
KbInitFailed,
|
|
18
19
|
testOidc,
|
|
19
20
|
RepositoryChangeNeedsConfirmation,
|
|
@@ -62,13 +63,13 @@ function CopyValue({ value, label }: { value: string; label: string }) {
|
|
|
62
63
|
|
|
63
64
|
/** "main updated, ali/x up to date" — the per-branch outcomes as one phrase. */
|
|
64
65
|
function describeOutcomes(results: LastSync['results']): string {
|
|
65
|
-
if (results.length === 0) return 'nothing to
|
|
66
|
+
if (results.length === 0) return 'nothing to update yet';
|
|
66
67
|
const word = (r: LastSync['results'][number]): string => {
|
|
67
68
|
switch (r.outcome) {
|
|
68
69
|
case 'up-to-date':
|
|
69
70
|
return 'up to date';
|
|
70
71
|
case 'not-cloned':
|
|
71
|
-
return 'not
|
|
72
|
+
return 'not set up on this server yet';
|
|
72
73
|
case 'remote-gone':
|
|
73
74
|
return 'deleted on the host';
|
|
74
75
|
default:
|
|
@@ -81,7 +82,14 @@ function describeOutcomes(results: LastSync['results']): string {
|
|
|
81
82
|
/** Copy for each setting: what it is, in the words of someone who has to fill it in. */
|
|
82
83
|
const FIELDS: Record<
|
|
83
84
|
string,
|
|
84
|
-
{
|
|
85
|
+
{
|
|
86
|
+
label: string;
|
|
87
|
+
help: string;
|
|
88
|
+
placeholder?: string;
|
|
89
|
+
advanced?: boolean;
|
|
90
|
+
/** An on/off setting, shown as a checkbox and saved as `true` / `false`; `on` is what an unset one means. */
|
|
91
|
+
toggle?: { on: boolean };
|
|
92
|
+
}
|
|
85
93
|
> = {
|
|
86
94
|
kbRepoUrl: {
|
|
87
95
|
label: 'Repository address',
|
|
@@ -110,8 +118,8 @@ const FIELDS: Record<
|
|
|
110
118
|
advanced: true,
|
|
111
119
|
},
|
|
112
120
|
kbSyncSecret: {
|
|
113
|
-
label: '
|
|
114
|
-
help: 'Lets your git host tell this deployment when the repository changes, so
|
|
121
|
+
label: 'Hook secret',
|
|
122
|
+
help: 'Lets your git host tell this deployment when the repository changes, so changes made there show up here 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 bring in updates. Stored encrypted, and never shown again.',
|
|
115
123
|
placeholder: 'A long random string',
|
|
116
124
|
advanced: true,
|
|
117
125
|
},
|
|
@@ -145,6 +153,12 @@ const FIELDS: Record<
|
|
|
145
153
|
placeholder: 'main',
|
|
146
154
|
advanced: true,
|
|
147
155
|
},
|
|
156
|
+
retireMergedBranches: {
|
|
157
|
+
label: 'Remove branches left over from merged change requests',
|
|
158
|
+
help: 'Removes, on its own, a draft whose change request was merged but which is still there: every commit on it is already on the main branch and no request is open from or into it. Runs at startup and whenever the server checks for deleted branches. Merging a change request removes its draft either way. Applies without a restart.',
|
|
159
|
+
advanced: true,
|
|
160
|
+
toggle: { on: true },
|
|
161
|
+
},
|
|
148
162
|
oidcIssuerUrl: {
|
|
149
163
|
label: 'Provider address',
|
|
150
164
|
help: 'From your identity provider. Entra, Okta, Google Workspace, Auth0 and others all publish one.',
|
|
@@ -195,7 +209,7 @@ const BRANCH_MODEL_KEYS = ['defaultBranch', 'protectedBranches'];
|
|
|
195
209
|
|
|
196
210
|
/** What each way of having a repository is called on its tab. */
|
|
197
211
|
const GIT_MODE_LABEL: Record<GitMode, string> = {
|
|
198
|
-
managed: '
|
|
212
|
+
managed: 'Hexis takes care of it',
|
|
199
213
|
'github-app': 'GitHub',
|
|
200
214
|
token: 'Address and token',
|
|
201
215
|
};
|
|
@@ -484,12 +498,10 @@ export function SetupScreen({
|
|
|
484
498
|
const [repositoryChanged, setRepositoryChanged] = useState<RepositoryChangeResult | null>(null);
|
|
485
499
|
const [retrying, setRetrying] = useState(false);
|
|
486
500
|
const [syncing, setSyncing] = useState(false);
|
|
487
|
-
/** What the last "
|
|
501
|
+
/** What the last "Update now" from THIS page came back with (a failure to ask is `error`). */
|
|
488
502
|
const [syncResult, setSyncResult] = useState<SyncNowResult | null>(null);
|
|
489
503
|
const [problems, setProblems] = useState<Record<string, string>>({});
|
|
490
504
|
const [error, setError] = useState<string | null>(null);
|
|
491
|
-
const [test, setTest] = useState<ConnectionTest | null>(null);
|
|
492
|
-
const [testing, setTesting] = useState(false);
|
|
493
505
|
const [saving, setSaving] = useState(false);
|
|
494
506
|
const [restartRequired, setRestartRequired] = useState(false);
|
|
495
507
|
/** Required answers still missing after a save that otherwise succeeded. */
|
|
@@ -498,16 +510,16 @@ export function SetupScreen({
|
|
|
498
510
|
const [needsRestart, setNeedsRestart] = useState(false);
|
|
499
511
|
const noticeRef = useRef<HTMLDivElement>(null);
|
|
500
512
|
/**
|
|
501
|
-
*
|
|
502
|
-
* edit to one of them
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
* shown as if it were about the new ones.
|
|
513
|
+
* The connection test: what the host last said about the answers on screen,
|
|
514
|
+
* cleared by an edit to one of them, with an answer that lands after such
|
|
515
|
+
* an edit held stale rather than shown. The probe is the one mechanism for
|
|
516
|
+
* it, shared with the first-run storage screen.
|
|
506
517
|
*/
|
|
507
|
-
const
|
|
518
|
+
const probe = useConnectionProbe();
|
|
519
|
+
const { result: test, testing } = probe;
|
|
508
520
|
const [oidcTest, setOidcTest] = useState<OidcTest | null>(null);
|
|
509
521
|
const [oidcTesting, setOidcTesting] = useState(false);
|
|
510
|
-
/** The
|
|
522
|
+
/** The probe's staleness guard, for the sign-in answers: a result describes the answers as they were when the request left. */
|
|
511
523
|
const oidcEpoch = useRef(0);
|
|
512
524
|
/**
|
|
513
525
|
* A verification state newer than the one the host last passed in — what a
|
|
@@ -753,34 +765,9 @@ export function SetupScreen({
|
|
|
753
765
|
// A test's "Verified" was about the values before this edit.
|
|
754
766
|
setLatest(null);
|
|
755
767
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
connectionEpoch.current++;
|
|
760
|
-
setTest(null);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
/**
|
|
765
|
-
* Which branch the repository just named, or the best conventional stand-in.
|
|
766
|
-
*
|
|
767
|
-
* Prefer what the remote calls its trunk. Not every host advertises it —
|
|
768
|
-
* older servers answer `ls-remote` without the symref line — so fall back to
|
|
769
|
-
* the conventional names before the first branch it did list. Leaving these
|
|
770
|
-
* blank is the one way a save can succeed and still not finish setup, which
|
|
771
|
-
* is worth a guess the reader can see and correct.
|
|
772
|
-
*/
|
|
773
|
-
function suggestedBranch(result: ConnectionTest): string | null {
|
|
774
|
-
return (
|
|
775
|
-
result.defaultBranch ||
|
|
776
|
-
['main', 'master', 'trunk'].find((name) => result.branches?.includes(name)) ||
|
|
777
|
-
result.branches?.[0] ||
|
|
778
|
-
// An EMPTY repository has no branch to report, but it will be seeded
|
|
779
|
-
// with whatever is configured here, so the conventional name is the
|
|
780
|
-
// right suggestion. Suggesting nothing was the one way "Connected"
|
|
781
|
-
// could still end, silently, in a save that did not finish setup.
|
|
782
|
-
(result.empty ? 'main' : null)
|
|
783
|
-
);
|
|
768
|
+
// Any in-flight test is now asking about values that are gone; its answer
|
|
769
|
+
// lands as stale rather than as evidence.
|
|
770
|
+
if (CONNECTION_KEYS.includes(key)) probe.invalidate();
|
|
784
771
|
}
|
|
785
772
|
|
|
786
773
|
/**
|
|
@@ -800,21 +787,13 @@ export function SetupScreen({
|
|
|
800
787
|
result: ConnectionTest;
|
|
801
788
|
derived: Record<string, string>;
|
|
802
789
|
}> {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
//
|
|
806
|
-
//
|
|
807
|
-
//
|
|
808
|
-
|
|
790
|
+
// The result describes the connection values as they were when the
|
|
791
|
+
// request left. Edited while it was out, it is stale: the probe never
|
|
792
|
+
// shows it, and it comes back to the caller, whose payload is the same
|
|
793
|
+
// snapshot. `derived` is likewise computed against that snapshot, because
|
|
794
|
+
// it travels with the payload.
|
|
795
|
+
const { result, stale } = await probe.ask(draft);
|
|
809
796
|
const suggested = result.ok ? suggestedBranch(result) : null;
|
|
810
|
-
// The result describes the connection values captured above. If they were
|
|
811
|
-
// edited while the request was in flight, showing it would let the OLD
|
|
812
|
-
// values' success (or failure) stand in for the new ones — so it is
|
|
813
|
-
// returned to the caller, whose payload is the same snapshot, but never
|
|
814
|
-
// shown. `derived` is likewise computed against that snapshot, because it
|
|
815
|
-
// travels with the payload.
|
|
816
|
-
const stale = epoch !== connectionEpoch.current;
|
|
817
|
-
if (!stale) setTest(result);
|
|
818
797
|
const derived: Record<string, string> = {};
|
|
819
798
|
if (suggested) {
|
|
820
799
|
if (!resolved('defaultBranch')) derived.defaultBranch = suggested;
|
|
@@ -835,9 +814,7 @@ export function SetupScreen({
|
|
|
835
814
|
}
|
|
836
815
|
|
|
837
816
|
async function runTest() {
|
|
838
|
-
setTesting(true);
|
|
839
817
|
setError(null);
|
|
840
|
-
const epoch = connectionEpoch.current;
|
|
841
818
|
try {
|
|
842
819
|
await probeConnection();
|
|
843
820
|
} catch (err) {
|
|
@@ -845,11 +822,9 @@ export function SetupScreen({
|
|
|
845
822
|
// was edited while this request was out, the error describes values no
|
|
846
823
|
// longer on screen, and showing it would complain about something the
|
|
847
824
|
// reader already changed.
|
|
848
|
-
if (
|
|
825
|
+
if (!(err instanceof ConnectionProbeFailed) || !err.stale) {
|
|
849
826
|
setError(err instanceof Error ? err.message : 'Could not test the connection.');
|
|
850
827
|
}
|
|
851
|
-
} finally {
|
|
852
|
-
setTesting(false);
|
|
853
828
|
}
|
|
854
829
|
}
|
|
855
830
|
|
|
@@ -952,7 +927,7 @@ export function SetupScreen({
|
|
|
952
927
|
setSyncResult({
|
|
953
928
|
ok: false,
|
|
954
929
|
results: [],
|
|
955
|
-
error: err instanceof Error ? err.message : '
|
|
930
|
+
error: err instanceof Error ? err.message : 'Couldn’t get the latest changes.',
|
|
956
931
|
});
|
|
957
932
|
} finally {
|
|
958
933
|
setSyncing(false);
|
|
@@ -971,7 +946,7 @@ export function SetupScreen({
|
|
|
971
946
|
<Surface tone="surface" radius="md" className="mt-3 space-y-3 border border-line p-3">
|
|
972
947
|
<div className="space-y-1.5">
|
|
973
948
|
<span className="text-meta font-medium text-ink">Address for the hook</span>
|
|
974
|
-
<CopyValue value={`${sync.url}/<branch>`} label="Copy the
|
|
949
|
+
<CopyValue value={`${sync.url}/<branch>`} label="Copy the hook address" />
|
|
975
950
|
<p className="text-meta text-ink-faint">
|
|
976
951
|
Replace <code className="font-mono"><branch></code> with the branch that changed;
|
|
977
952
|
send the secret as a bearer token.
|
|
@@ -981,8 +956,8 @@ export function SetupScreen({
|
|
|
981
956
|
<div className="space-y-2">
|
|
982
957
|
<p role="status" className="text-meta text-ink-muted">
|
|
983
958
|
{last
|
|
984
|
-
? `Last
|
|
985
|
-
: 'No
|
|
959
|
+
? `Last update ${new Date(last.at).toLocaleString()} by ${last.by}: ${describeOutcomes(last.results)}.`
|
|
960
|
+
: 'No updates since this server started.'}
|
|
986
961
|
</p>
|
|
987
962
|
<div className="flex flex-wrap items-center gap-3">
|
|
988
963
|
<Button
|
|
@@ -992,11 +967,10 @@ export function SetupScreen({
|
|
|
992
967
|
onClick={() => void runSync()}
|
|
993
968
|
disabled={syncing}
|
|
994
969
|
>
|
|
995
|
-
{syncing ? '
|
|
970
|
+
{syncing ? 'Updating…' : 'Update now'}
|
|
996
971
|
</Button>
|
|
997
972
|
<span className="text-meta text-ink-faint">
|
|
998
|
-
|
|
999
|
-
hook does.
|
|
973
|
+
Gets the latest changes from your git host now, the same as the hook does.
|
|
1000
974
|
</span>
|
|
1001
975
|
</div>
|
|
1002
976
|
{syncResult && (
|
|
@@ -1009,12 +983,12 @@ export function SetupScreen({
|
|
|
1009
983
|
{syncResult.error
|
|
1010
984
|
? syncResult.error
|
|
1011
985
|
: syncResult.ok
|
|
1012
|
-
? `
|
|
986
|
+
? `Updated: ${describeOutcomes(syncResult.results)}.`
|
|
1013
987
|
: (syncResult.results
|
|
1014
988
|
.map(syncOutcomeError)
|
|
1015
989
|
.filter((e): e is string => !!e)
|
|
1016
990
|
.join('\n') ||
|
|
1017
|
-
`Not fully
|
|
991
|
+
`Not fully updated: ${describeOutcomes(syncResult.results)}.`)}
|
|
1018
992
|
</p>
|
|
1019
993
|
)}
|
|
1020
994
|
</div>
|
|
@@ -1088,7 +1062,7 @@ export function SetupScreen({
|
|
|
1088
1062
|
/** What the host said this time, or null when it could not be asked. */
|
|
1089
1063
|
let proven: ConnectionTest | null = test;
|
|
1090
1064
|
let probed = false;
|
|
1091
|
-
const
|
|
1065
|
+
const prove = async () => {
|
|
1092
1066
|
probed = true;
|
|
1093
1067
|
try {
|
|
1094
1068
|
const { result, derived } = await probeConnection();
|
|
@@ -1109,9 +1083,7 @@ export function SetupScreen({
|
|
|
1109
1083
|
// host rejects finishes setup just as well as one it accepts, and the
|
|
1110
1084
|
// gate opens onto an app whose every call fails against a repository
|
|
1111
1085
|
// it cannot clone. This is the one moment that can tell the two apart.
|
|
1112
|
-
|
|
1113
|
-
await probe();
|
|
1114
|
-
setTesting(false);
|
|
1086
|
+
await prove();
|
|
1115
1087
|
// Includes a probe the server REFUSED (a 4xx comes back as a
|
|
1116
1088
|
// rejection, not a throw) — that is an answer about these values.
|
|
1117
1089
|
if (proven && !proven.ok) {
|
|
@@ -1144,7 +1116,7 @@ export function SetupScreen({
|
|
|
1144
1116
|
!!resolvedIn(payload, 'kbRepoUrl') &&
|
|
1145
1117
|
(!resolvedIn(payload, 'defaultBranch') || !resolvedIn(payload, 'protectedBranches'))
|
|
1146
1118
|
) {
|
|
1147
|
-
await
|
|
1119
|
+
await prove();
|
|
1148
1120
|
}
|
|
1149
1121
|
// An ordinary save is sent exactly as it always was — one argument, and
|
|
1150
1122
|
// no `confirmRepositoryChange` in the body. Only the save that answers
|
|
@@ -1290,6 +1262,31 @@ export function SetupScreen({
|
|
|
1290
1262
|
: isFolderField
|
|
1291
1263
|
? (remoteRootFolders ?? []).filter(isRootFolderSuggestion)
|
|
1292
1264
|
: [];
|
|
1265
|
+
if (copy.toggle) {
|
|
1266
|
+
const raw = draft[setting.key] ?? setting.value ?? '';
|
|
1267
|
+
const checked = raw === '' ? copy.toggle.on : raw !== 'false';
|
|
1268
|
+
return (
|
|
1269
|
+
<div key={setting.key}>
|
|
1270
|
+
<label className="flex items-start gap-2">
|
|
1271
|
+
<input
|
|
1272
|
+
type="checkbox"
|
|
1273
|
+
className="mt-1"
|
|
1274
|
+
checked={checked}
|
|
1275
|
+
onChange={(e) => set(setting.key, e.target.checked ? 'true' : 'false')}
|
|
1276
|
+
aria-invalid={problems[setting.key] ? true : undefined}
|
|
1277
|
+
aria-describedby={problems[setting.key] ? `${setting.key}-problem` : undefined}
|
|
1278
|
+
/>
|
|
1279
|
+
<span className="text-detail font-medium text-ink">{copy.label}</span>
|
|
1280
|
+
</label>
|
|
1281
|
+
<p className="mt-1 text-meta text-ink-faint">{copy.help}</p>
|
|
1282
|
+
{problems[setting.key] && (
|
|
1283
|
+
<p id={`${setting.key}-problem`} role="alert" className="mt-1 text-meta text-danger">
|
|
1284
|
+
{problems[setting.key]}
|
|
1285
|
+
</p>
|
|
1286
|
+
)}
|
|
1287
|
+
</div>
|
|
1288
|
+
);
|
|
1289
|
+
}
|
|
1293
1290
|
const listId = suggestions.length > 0 ? `${setting.key}-options` : undefined;
|
|
1294
1291
|
return (
|
|
1295
1292
|
<div key={setting.key}>
|
|
@@ -1742,7 +1739,7 @@ export function SetupScreen({
|
|
|
1742
1739
|
{/* The sync panel normally hangs off the secret's field. When
|
|
1743
1740
|
the secret comes from the environment that field is in the
|
|
1744
1741
|
locked list below, not here — but the address, the last
|
|
1745
|
-
|
|
1742
|
+
update and Update now are about the deployment, not the secret,
|
|
1746
1743
|
and an admin with an env-set secret needs them just as much. */}
|
|
1747
1744
|
{section.id === 'knowledge-base' &&
|
|
1748
1745
|
sync &&
|
|
@@ -1762,10 +1759,10 @@ export function SetupScreen({
|
|
|
1762
1759
|
gets its own place here in that case. */}
|
|
1763
1760
|
{sync && editable.every((s) => s.section !== 'knowledge-base') && (
|
|
1764
1761
|
<Surface as="section" tone="surface" radius="lg" elevation="card" className="p-6">
|
|
1765
|
-
<h2 className="text-title font-semibold text-ink">
|
|
1762
|
+
<h2 className="text-title font-semibold text-ink">Updates from your git host</h2>
|
|
1766
1763
|
<p className="mt-1 max-w-[60ch] text-detail text-ink-muted">
|
|
1767
|
-
The knowledge-base connection is set by the environment. The
|
|
1768
|
-
yours to wire up and check on here.
|
|
1764
|
+
The knowledge-base connection is set by the environment. The hook that brings in
|
|
1765
|
+
updates from your git host is still yours to wire up and check on here.
|
|
1769
1766
|
</p>
|
|
1770
1767
|
{renderSyncPanel()}
|
|
1771
1768
|
</Surface>
|
|
@@ -1820,8 +1817,8 @@ export function SetupScreen({
|
|
|
1820
1817
|
<p className="mt-1">
|
|
1821
1818
|
The move happens as soon as you confirm, with no restart. Unless the new repository holds the
|
|
1822
1819
|
same history, every working copy on this server stops being used and is cloned fresh from the
|
|
1823
|
-
new repository. Anything
|
|
1824
|
-
|
|
1820
|
+
new repository. Anything saved here that hasn’t reached your git host yet goes out of
|
|
1821
|
+
the app with it. Nothing is deleted, but it is only
|
|
1825
1822
|
recoverable from the
|
|
1826
1823
|
<code className="mx-1">replaced-working-copies</code>
|
|
1827
1824
|
folder on the server, by hand.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
import { testConnection, type ConnectionTest } from '../services/setup.api';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The connection test, as every screen that asks it keeps it: the first-run
|
|
6
|
+
* storage screen and the full form. ONE mechanism for what a test needs
|
|
7
|
+
* beyond the request itself — what the host last said about the answers ON
|
|
8
|
+
* SCREEN; that editing one of those answers invalidates it; that an answer
|
|
9
|
+
* landing after such an edit is stale, evidence about values no longer there,
|
|
10
|
+
* and is never shown as if it were about the new ones; and whether a save may
|
|
11
|
+
* lean on the answer on screen instead of asking again — so no two screens
|
|
12
|
+
* can drift on any of them.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The request itself failed: the endpoint is down, the request threw. Not an answer about the credentials. */
|
|
16
|
+
export class ConnectionProbeFailed extends Error {
|
|
17
|
+
/** The answers were edited while the request was out: the failure describes values no longer on screen. */
|
|
18
|
+
readonly stale: boolean;
|
|
19
|
+
|
|
20
|
+
constructor(message: string, stale: boolean) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = 'ConnectionProbeFailed';
|
|
23
|
+
this.stale = stale;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ConnectionProbe {
|
|
28
|
+
/** What the host said about the answers on screen: null until asked, and again after any edit to them. */
|
|
29
|
+
result: ConnectionTest | null;
|
|
30
|
+
/** A request is out. */
|
|
31
|
+
testing: boolean;
|
|
32
|
+
/** The host said yes about the answers on screen: a save may lean on it without asking again. */
|
|
33
|
+
proven: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* An answer the test proves was edited. The result on screen described the
|
|
36
|
+
* old answers and goes; a request still out will land stale.
|
|
37
|
+
*/
|
|
38
|
+
invalidate(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Ask the host about `answers`. Resolves to the host's answer — a refusal is
|
|
41
|
+
* an answer — and whether it is `stale`: the answers were edited, or a newer
|
|
42
|
+
* request went out, while this one was out, so the answer on screen is not
|
|
43
|
+
* this one's to set. A stale answer is not shown; it is the caller's to use
|
|
44
|
+
* only against the snapshot it sent. Rejects with
|
|
45
|
+
* {@link ConnectionProbeFailed} when the request itself failed, flagged
|
|
46
|
+
* stale the same way.
|
|
47
|
+
*/
|
|
48
|
+
ask(answers: Record<string, string>): Promise<{ result: ConnectionTest; stale: boolean }>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function useConnectionProbe(): ConnectionProbe {
|
|
52
|
+
const [result, setResult] = useState<ConnectionTest | null>(null);
|
|
53
|
+
const [testing, setTesting] = useState(false);
|
|
54
|
+
/**
|
|
55
|
+
* Which set of answers is on screen, bumped on every edit to one of them.
|
|
56
|
+
* An answer carries the epoch its request left under; a different one by
|
|
57
|
+
* the time it lands means the answers it describes are gone.
|
|
58
|
+
*/
|
|
59
|
+
const epoch = useRef(0);
|
|
60
|
+
/**
|
|
61
|
+
* Which request is the newest. Two requests for the same answers can land
|
|
62
|
+
* in either order; only the newest one's answer is the answer on screen,
|
|
63
|
+
* or an older response would overwrite a newer one.
|
|
64
|
+
*/
|
|
65
|
+
const newest = useRef(0);
|
|
66
|
+
const inFlight = useRef(0);
|
|
67
|
+
|
|
68
|
+
const invalidate = () => {
|
|
69
|
+
epoch.current++;
|
|
70
|
+
setResult(null);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const ask = async (answers: Record<string, string>) => {
|
|
74
|
+
const asked = epoch.current;
|
|
75
|
+
const request = ++newest.current;
|
|
76
|
+
const isStale = () => asked !== epoch.current || request !== newest.current;
|
|
77
|
+
inFlight.current++;
|
|
78
|
+
setTesting(true);
|
|
79
|
+
try {
|
|
80
|
+
const answer = await testConnection(answers);
|
|
81
|
+
const stale = isStale();
|
|
82
|
+
if (!stale) setResult(answer);
|
|
83
|
+
return { result: answer, stale };
|
|
84
|
+
} catch (err) {
|
|
85
|
+
throw new ConnectionProbeFailed(err instanceof Error ? err.message : 'Could not test the connection.', isStale());
|
|
86
|
+
} finally {
|
|
87
|
+
inFlight.current--;
|
|
88
|
+
if (inFlight.current === 0) setTesting(false);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return { result, testing, proven: result?.ok === true, invalidate, ask };
|
|
93
|
+
}
|
|
@@ -235,7 +235,7 @@ async function readError(res: Response): Promise<never> {
|
|
|
235
235
|
const SYNC_RESPONSE_HEADER = 'x-hexis-sync';
|
|
236
236
|
const SYNC_RESPONSE_MARKER = 'result';
|
|
237
237
|
|
|
238
|
-
/** What "
|
|
238
|
+
/** What "Update now" came back with. A 409 or 503 still carries per-branch results. */
|
|
239
239
|
export interface SyncNowResult {
|
|
240
240
|
/** True for 200 — every branch current. */
|
|
241
241
|
ok: boolean;
|
|
@@ -267,11 +267,11 @@ export async function syncNow(): Promise<SyncNowResult> {
|
|
|
267
267
|
try {
|
|
268
268
|
body = await res.json();
|
|
269
269
|
} catch {
|
|
270
|
-
throw new Error(`
|
|
270
|
+
throw new Error(`Couldn’t get the latest changes (${res.status})`);
|
|
271
271
|
}
|
|
272
272
|
const data = body as { status?: 'synced' | 'partial'; results?: SyncBranchOutcome[]; error?: string };
|
|
273
273
|
if (!Array.isArray(data.results)) {
|
|
274
|
-
return { ok: false, results: [], error: data.error || `
|
|
274
|
+
return { ok: false, results: [], error: data.error || `Couldn’t get the latest changes (${res.status})` };
|
|
275
275
|
}
|
|
276
276
|
return { ok: res.status === 200, status: data.status, results: data.results };
|
|
277
277
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ConnectionTest } from '../services/setup.api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Which branch the repository just named, or the best conventional stand-in.
|
|
5
|
+
*
|
|
6
|
+
* Prefer what the remote calls its trunk. Not every host advertises it —
|
|
7
|
+
* older servers answer `ls-remote` without the symref line — so fall back to
|
|
8
|
+
* the conventional names before the first branch it did list. Leaving these
|
|
9
|
+
* blank is the one way a save can succeed and still not finish setup, which
|
|
10
|
+
* is worth a guess the reader can see and correct.
|
|
11
|
+
*
|
|
12
|
+
* An EMPTY repository has no branch to report, but it will be seeded with
|
|
13
|
+
* whatever is configured, so the conventional name is the right suggestion.
|
|
14
|
+
* Suggesting nothing was the one way "Connected" could still end, silently,
|
|
15
|
+
* in a save that did not finish setup.
|
|
16
|
+
*
|
|
17
|
+
* ONE function for every screen that tests a connection, because two copies
|
|
18
|
+
* of "which branch did it name?" is how two answers drift apart.
|
|
19
|
+
*/
|
|
20
|
+
export function suggestedBranch(result: ConnectionTest): string | null {
|
|
21
|
+
return (
|
|
22
|
+
result.defaultBranch ||
|
|
23
|
+
['main', 'master', 'trunk'].find((name) => result.branches?.includes(name)) ||
|
|
24
|
+
result.branches?.[0] ||
|
|
25
|
+
(result.empty ? 'main' : null)
|
|
26
|
+
);
|
|
27
|
+
}
|