@bevel-software/platform-core-frontend 0.13.6 → 0.15.1
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 +18 -17
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/bootstrap.ts +30 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/__tests__/utils.test.ts +43 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/utils.ts +17 -7
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +111 -1
- package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
- package/src/modules/access/api.ts +52 -4
- package/src/modules/access/components/ManageAccessDialog.tsx +112 -83
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- package/src/modules/layout/components/SidebarFrame.tsx +1 -1
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +2 -1
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +1 -1
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +121 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +6 -0
- package/src/modules/library/__tests__/McpServerSection.test.tsx +7 -1
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +5 -4
- package/src/modules/library/__tests__/PluginExtras.test.tsx +15 -0
- package/src/modules/library/__tests__/PluginPage.test.tsx +195 -1
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +1 -1
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +1 -1
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +64 -3
- package/src/modules/library/__tests__/SkillPage.test.tsx +9 -2
- package/src/modules/library/__tests__/SkillsTree.test.tsx +172 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +216 -8
- package/src/modules/library/__tests__/ToolPage.test.tsx +23 -3
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +7 -7
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +115 -4
- package/src/modules/library/__tests__/library-data.stale.test.tsx +90 -0
- package/src/modules/library/__tests__/library-paths.test.ts +32 -0
- package/src/modules/library/__tests__/link-membership.test.ts +120 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +32 -0
- package/src/modules/library/__tests__/status.test.ts +84 -0
- package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +33 -0
- package/src/modules/library/components/LibraryCard.tsx +21 -1
- package/src/modules/library/components/LibraryLayout.tsx +24 -14
- package/src/modules/library/components/LinkSkillPanel.tsx +171 -0
- package/src/modules/library/components/LockedPluginView.tsx +2 -2
- package/src/modules/library/components/NewPluginDialog.tsx +4 -4
- package/src/modules/library/components/PageActions.tsx +21 -1
- package/src/modules/library/components/PersonalPluginPage.tsx +2 -1
- package/src/modules/library/components/PluginExtras.tsx +3 -1
- package/src/modules/library/components/PluginPage.tsx +92 -12
- package/src/modules/library/components/PluginsIndexPage.tsx +11 -6
- package/src/modules/library/components/PluginsSidebar.tsx +110 -53
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/SkillsTree.tsx +91 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- package/src/modules/library/components/plugin-page-parts.tsx +32 -9
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +218 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +75 -7
- package/src/modules/library/components/tool-page/McpServerSection.tsx +9 -1
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +223 -8
- package/src/modules/library/components/tool-page/ToolPage.tsx +30 -2
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +30 -8
- package/src/modules/library/hooks/useJoinRequests.ts +48 -18
- package/src/modules/library/hooks/useToolPage.ts +28 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +180 -83
- package/src/modules/library/routes/library-paths.ts +21 -8
- package/src/modules/library/services/library.api.ts +55 -1
- package/src/modules/library/services/plugins.api.ts +94 -3
- package/src/modules/library/state/library-data.tsx +115 -22
- package/src/modules/library/utils/plugin-summary.ts +36 -0
- package/src/modules/library/utils/status.ts +173 -17
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +3 -2
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +29 -14
- package/src/modules/secrets-vault/components/SecretsPage.tsx +4 -1
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +4 -1
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +36 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +169 -0
- package/src/modules/settings/components/DeploymentPage.tsx +15 -1
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +10 -0
- package/src/modules/settings/services/github-facade.api.ts +43 -0
- package/src/modules/setup/__tests__/setup.test.tsx +118 -0
- package/src/modules/setup/components/SetupGate.tsx +1 -1
- package/src/modules/setup/components/SetupScreen.tsx +195 -2
- package/src/modules/setup/services/setup.api.ts +78 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +301 -93
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +129 -6
- package/src/modules/toolbar/services/external-api-keys.api.ts +2 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +1 -0
- package/src/modules/workspace/components/FileExplorer.tsx +292 -236
- package/src/modules/workspace/components/FileRoute.tsx +37 -0
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +1 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +70 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +17 -3
- package/src/modules/workspace/routing/kb-routes.ts +1 -1
- package/src/modules/workspace/state/workspace.context.ts +8 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +15 -0
- package/src/modules/workspace/utils/fileTree.ts +14 -16
- package/src/shared/__tests__/marketplace-url.test.ts +54 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -1
- package/src/shared/marketplace-url.ts +90 -0
- package/src/shared/theme/tokens.css +9 -0
|
@@ -3,7 +3,6 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
|
3
3
|
import { ArrowLeft, History } from 'lucide-react';
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_BRANCH,
|
|
6
|
-
pluginOfPath,
|
|
7
6
|
type PullRequestSummary,
|
|
8
7
|
} from '@bevel-software/platform-shared';
|
|
9
8
|
import '../../library.css';
|
|
@@ -33,9 +32,14 @@ import { useLibrary } from '../../state/library-data';
|
|
|
33
32
|
import { useLibraryToast } from '../../state/toast.context';
|
|
34
33
|
import { libraryHomeForItemPath, urlForSkillFile } from '../../routes/library-paths';
|
|
35
34
|
import { changeAuthorName, formatWhen } from '../../../change-requests/utils/author';
|
|
36
|
-
import { ownersTextOf } from '../../utils/plugin-summary';
|
|
35
|
+
import { ownersTextOf, pluginLabel } from '../../utils/plugin-summary';
|
|
37
36
|
import { neededToolsFor, toolStatus } from '../../utils/status';
|
|
38
37
|
import { StatusDot } from '../StatusDot';
|
|
38
|
+
import { SharedViaPlugins } from './SharedViaPlugins';
|
|
39
|
+
import { AccessRequestsBanner } from '../AccessRequestsBanner';
|
|
40
|
+
import { useJoinRequests, type JoinRequestsApi } from '../../hooks/useJoinRequests';
|
|
41
|
+
import { listSkillAccessRequests, reconcileSkillAccessRequest } from '../../services/library.api';
|
|
42
|
+
import { ManageAccessDialog } from '../../../access/components/ManageAccessDialog';
|
|
39
43
|
import { ChangeRequestDock } from '../ChangeRequestDock';
|
|
40
44
|
import { ChangeRequestDialog } from '../../../change-requests/components/ChangeRequestDialog';
|
|
41
45
|
import { SkillFileTabs } from './SkillFileTabs';
|
|
@@ -136,17 +140,37 @@ export function SkillPage({
|
|
|
136
140
|
const skillPath = skill?.path ?? '';
|
|
137
141
|
const prefix = `${skillPath}/`;
|
|
138
142
|
|
|
143
|
+
/** Every plugin holding this skill, from the catalog's decoration. */
|
|
144
|
+
const memberships = useMemo(
|
|
145
|
+
() => data.items.find((i) => i.kind === 'skill' && i.id === name)?.plugins ?? [],
|
|
146
|
+
[data.items, name],
|
|
147
|
+
);
|
|
148
|
+
/**
|
|
149
|
+
* Write-access requests on this skill, for its editors. The endpoint answers
|
|
150
|
+
* `[]` to everyone else, so the fetch is unconditional and the banner hides
|
|
151
|
+
* itself; `owned` only spares a pointless call.
|
|
152
|
+
*/
|
|
153
|
+
const skillRequestsApi = useMemo<JoinRequestsApi>(
|
|
154
|
+
() => ({ list: listSkillAccessRequests, reconcile: reconcileSkillAccessRequest }),
|
|
155
|
+
[],
|
|
156
|
+
);
|
|
157
|
+
const accessRequests = useJoinRequests(name, skillPath || null, skillRequestsApi);
|
|
158
|
+
const [manageOpen, setManageOpen] = useState(false);
|
|
159
|
+
|
|
139
160
|
/**
|
|
140
161
|
* Who has to say yes. A skill has no owner of its own — it inherits its plugin
|
|
141
162
|
* folder's `access.md` — so the people who review a change to it are the
|
|
142
163
|
* plugin's owners. Naming the wrong reviewer is worse than naming none, hence
|
|
143
164
|
* the neutral fallback when the plugin index hasn't resolved.
|
|
144
165
|
*/
|
|
166
|
+
const itemPlugin = useMemo(
|
|
167
|
+
() => data.items.find((i) => i.kind === 'skill' && i.id === name)?.plugin ?? null,
|
|
168
|
+
[data.items, name],
|
|
169
|
+
);
|
|
145
170
|
const ownerName = useMemo(() => {
|
|
146
|
-
const
|
|
147
|
-
const summary = plugin ? data.pluginSummaries.find((g) => g.name === plugin) : undefined;
|
|
171
|
+
const summary = itemPlugin ? data.pluginSummaries.find((g) => g.name === itemPlugin) : undefined;
|
|
148
172
|
return summary ? ownersTextOf(summary) : 'the owner';
|
|
149
|
-
}, [
|
|
173
|
+
}, [itemPlugin, data.pluginSummaries]);
|
|
150
174
|
|
|
151
175
|
const files = useMemo(
|
|
152
176
|
() => ['SKILL.md', ...(skill?.files ?? []).map((f) => f.slice(prefix.length))],
|
|
@@ -467,7 +491,7 @@ export function SkillPage({
|
|
|
467
491
|
// The page the skill lives on, not the Library root: "back" from a skill
|
|
468
492
|
// you opened off its plugin page must land on that plugin page. Derived from
|
|
469
493
|
// the path, so a deep link gets the same honest destination as a click.
|
|
470
|
-
const home = libraryHomeForItemPath(skillPath);
|
|
494
|
+
const home = libraryHomeForItemPath(skillPath, itemPlugin, (n) => pluginLabel(n, data.pluginSummaries));
|
|
471
495
|
const backLink = (
|
|
472
496
|
<Button variant="quiet" size="sm" onClick={() => navigate(home.path)}>
|
|
473
497
|
{`‹ ${home.label}`}
|
|
@@ -590,8 +614,48 @@ export function SkillPage({
|
|
|
590
614
|
those rules are decided. Same call the tool page made. */}
|
|
591
615
|
</header>
|
|
592
616
|
|
|
617
|
+
{/* Not before the folder is known: Accept grants ON the folder and
|
|
618
|
+
Manage access opens it, and both are no-ops against ''. */}
|
|
619
|
+
{owned && skillPath && (
|
|
620
|
+
<AccessRequestsBanner
|
|
621
|
+
plugin={name}
|
|
622
|
+
folders={[skillPath]}
|
|
623
|
+
requests={accessRequests.requests}
|
|
624
|
+
onManage={() => setManageOpen(true)}
|
|
625
|
+
onAccept={(r, p) => void accessRequests.accept(r, p)}
|
|
626
|
+
onDecline={(r) => void accessRequests.decline(r)}
|
|
627
|
+
/>
|
|
628
|
+
)}
|
|
629
|
+
{manageOpen && kbDirName && skillPath && (
|
|
630
|
+
<ManageAccessDialog
|
|
631
|
+
// The Library speaks the DEFAULT branch: a skill's rules are edited
|
|
632
|
+
// where the catalog reads them, whatever branch the ambient
|
|
633
|
+
// workspace happens to be on.
|
|
634
|
+
workspaceId={encodeURIComponent(DEFAULT_BRANCH)}
|
|
635
|
+
entry={{ name, relativePath: `${kbDirName}/${skillPath}`, type: 'directory' }}
|
|
636
|
+
onClose={() => {
|
|
637
|
+
setManageOpen(false);
|
|
638
|
+
accessRequests.reload();
|
|
639
|
+
data.reload();
|
|
640
|
+
}}
|
|
641
|
+
/>
|
|
642
|
+
)}
|
|
643
|
+
|
|
593
644
|
<IntegrationsSection needed={needed} onConnect={() => navigate('/connect')} />
|
|
594
645
|
|
|
646
|
+
{skill && (
|
|
647
|
+
<SharedViaPlugins
|
|
648
|
+
skillName={name}
|
|
649
|
+
skillPath={skillPath}
|
|
650
|
+
memberships={memberships}
|
|
651
|
+
owned={owned}
|
|
652
|
+
onChanged={() => {
|
|
653
|
+
data.reload();
|
|
654
|
+
data.reloadPlugins();
|
|
655
|
+
}}
|
|
656
|
+
/>
|
|
657
|
+
)}
|
|
658
|
+
|
|
595
659
|
<SkillFileTabs
|
|
596
660
|
files={files}
|
|
597
661
|
selected={active}
|
|
@@ -832,7 +896,11 @@ function IntegrationsSection({
|
|
|
832
896
|
<div className="min-w-0">
|
|
833
897
|
<b className="block text-detail font-semibold text-ink">{t.name}</b>
|
|
834
898
|
<small className="block text-meta text-ink-faint">
|
|
835
|
-
{status.
|
|
899
|
+
{/* `status.text`, never a hardcoded "Connected": this list is
|
|
900
|
+
built from what is stored, and nothing here has probed
|
|
901
|
+
anything — so it says "Key saved"/"Signed in" and keeps the
|
|
902
|
+
reassurance that no action is needed. */}
|
|
903
|
+
{status.state === 'ok' ? `${status.text}. Nothing to do` : status.text}
|
|
836
904
|
</small>
|
|
837
905
|
</div>
|
|
838
906
|
<div className="ml-auto flex shrink-0 items-center gap-2">
|
|
@@ -32,12 +32,20 @@ import { pathForTool } from '../../routes/library-paths';
|
|
|
32
32
|
export function McpServerSection({
|
|
33
33
|
slug,
|
|
34
34
|
configuredCount,
|
|
35
|
+
reloadSignal,
|
|
35
36
|
onSaved,
|
|
36
37
|
onError,
|
|
37
38
|
}: {
|
|
38
39
|
slug: string;
|
|
39
40
|
/** Configured secrets + sign-ins under this server's name — what a rename disconnects. */
|
|
40
41
|
configuredCount: number;
|
|
42
|
+
/**
|
|
43
|
+
* Changes on every page reload, including one that keeps the same slug.
|
|
44
|
+
* Saving a server without renaming it leaves `slug` untouched, and the page
|
|
45
|
+
* no longer remounts on reload — so without this in the dependency list the
|
|
46
|
+
* fetch below never re-runs and the section renders its cleared view.
|
|
47
|
+
*/
|
|
48
|
+
reloadSignal: number;
|
|
41
49
|
/** Called after a save lands; the new slug when the server was renamed. */
|
|
42
50
|
onSaved(newSlug?: string): void;
|
|
43
51
|
onError(message: string): void;
|
|
@@ -74,7 +82,7 @@ export function McpServerSection({
|
|
|
74
82
|
return () => {
|
|
75
83
|
live = false;
|
|
76
84
|
};
|
|
77
|
-
}, [slug]);
|
|
85
|
+
}, [slug, reloadSignal]);
|
|
78
86
|
|
|
79
87
|
if (!server) return null;
|
|
80
88
|
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
2
|
import { Link, useNavigate } from 'react-router-dom';
|
|
3
3
|
import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
4
4
|
import { Banner, Button, buttonClasses } from '../../../../shared/components';
|
|
5
5
|
import { useWorkspace } from '../../../workspace/state/workspace.context';
|
|
6
6
|
import { kbFileUrl } from '../../../workspace/routing/kb-routes';
|
|
7
|
-
import
|
|
7
|
+
import {
|
|
8
|
+
checkToolConnection,
|
|
9
|
+
type ProbeVerdict,
|
|
10
|
+
type ToolSecrets,
|
|
11
|
+
} from '../../../secrets-vault/services/tool-secrets.api';
|
|
8
12
|
import { pathForTool } from '../../routes/library-paths';
|
|
9
|
-
import { toolVariableStatuses } from '../../utils/status';
|
|
13
|
+
import { toolStatus, toolVariableStatuses } from '../../utils/status';
|
|
10
14
|
import { ToolVarRow } from './ToolVarRow';
|
|
11
15
|
|
|
12
16
|
/**
|
|
@@ -24,16 +28,76 @@ import { ToolVarRow } from './ToolVarRow';
|
|
|
24
28
|
|
|
25
29
|
export interface ToolConnectionSectionProps {
|
|
26
30
|
tool: ToolSecrets;
|
|
31
|
+
/**
|
|
32
|
+
* Bumped whenever the tool's DEFINITION changes — today, an mcp.json server
|
|
33
|
+
* edit. A verdict describes the endpoint and headers it was probed against,
|
|
34
|
+
* so changing those makes it a statement about a server that is no longer
|
|
35
|
+
* configured; the badge must stop claiming it. Deliberately NOT bumped by a
|
|
36
|
+
* credential write: that path clears and re-probes on its own, and bumping
|
|
37
|
+
* here would discard the answer it is in the middle of fetching.
|
|
38
|
+
*/
|
|
39
|
+
configRevision: number;
|
|
27
40
|
/** A write landed — the caller refetches so the chips catch up. */
|
|
28
41
|
onChanged(): void;
|
|
29
42
|
onError(message: string): void;
|
|
30
43
|
}
|
|
31
44
|
|
|
32
|
-
export function ToolConnectionSection({
|
|
45
|
+
export function ToolConnectionSection({
|
|
46
|
+
tool,
|
|
47
|
+
configRevision,
|
|
48
|
+
onChanged,
|
|
49
|
+
onError,
|
|
50
|
+
}: ToolConnectionSectionProps) {
|
|
33
51
|
const navigate = useNavigate();
|
|
34
52
|
const { kbDirName } = useWorkspace();
|
|
35
53
|
/** `{varName, n}` — bumping `n` opens that variable's editor from the banner. */
|
|
36
54
|
const [edit, setEdit] = useState<{ name: string; n: number }>({ name: '', n: 0 });
|
|
55
|
+
/**
|
|
56
|
+
* The revision of the probe in flight, or null. `checking` is DERIVED: an
|
|
57
|
+
* in-flight probe owns the Test button only while the definition it dials
|
|
58
|
+
* is still the one on screen, so a config edit mid-probe re-enables the
|
|
59
|
+
* button for the new definition immediately instead of waiting for the
|
|
60
|
+
* orphan to settle.
|
|
61
|
+
*/
|
|
62
|
+
const [inFlight, setInFlight] = useState<{ rev: number } | null>(null);
|
|
63
|
+
const checking = inFlight !== null && inFlight.rev === configRevision;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A probe's TRANSPORT failure (network, access — not a verdict about the
|
|
67
|
+
* credential), held here rather than raised to the page's shared error
|
|
68
|
+
* banner. Page-level state outlived its subject twice over: another
|
|
69
|
+
* action's error could be cleared by a probe that happened to recover,
|
|
70
|
+
* and a probe of the PREVIOUS tool (this section is keyed by slug) could
|
|
71
|
+
* clear or raise it after unmount. Section state dies with the section,
|
|
72
|
+
* and the revision stamp makes it self-invalidating, exactly like the
|
|
73
|
+
* verdict: shown only while it describes the configuration on screen.
|
|
74
|
+
*/
|
|
75
|
+
const [probeError, setProbeError] = useState<{ rev: number; message: string } | null>(null);
|
|
76
|
+
const shownProbeError = probeError && probeError.rev === configRevision ? probeError.message : null;
|
|
77
|
+
/**
|
|
78
|
+
* The last probe's answer, and the ONLY place one exists.
|
|
79
|
+
*
|
|
80
|
+
* Nothing persists a verdict, so this state IS the evidence behind the word
|
|
81
|
+
* "Connected" — which is why the claim can be trusted: it cannot outlive the
|
|
82
|
+
* page that watched the call succeed.
|
|
83
|
+
*
|
|
84
|
+
* Stored WITH the config revision it was probed under, and read back only
|
|
85
|
+
* when that still matches. Comparing rather than clearing keeps it pure: an
|
|
86
|
+
* effect that cleared on change would race the probe it is meant to protect,
|
|
87
|
+
* since a credential save starts a probe and a refetch at the same moment.
|
|
88
|
+
*/
|
|
89
|
+
const [probed, setProbed] = useState<{ rev: number; value: ProbeVerdict } | null>(null);
|
|
90
|
+
const verdict = probed && probed.rev === configRevision ? probed.value : null;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Which probe is allowed to publish. Two saves in quick succession start two
|
|
94
|
+
* probes, and the first can answer last — so a result is applied only while
|
|
95
|
+
* it is still the newest one asked for. Without it the older credential's
|
|
96
|
+
* verdict wins by finishing late, which is the same stale-answer bug this
|
|
97
|
+
* whole feature exists to remove, one layer up.
|
|
98
|
+
*/
|
|
99
|
+
const probeSeq = useRef(0);
|
|
100
|
+
|
|
37
101
|
|
|
38
102
|
const setupKind = tool.setup?.kind ?? null;
|
|
39
103
|
// Not just "kind is oauth-manual": once the owner declares the provider and
|
|
@@ -92,15 +156,145 @@ export function ToolConnectionSection({ tool, onChanged, onError }: ToolConnecti
|
|
|
92
156
|
</Button>
|
|
93
157
|
) : null;
|
|
94
158
|
|
|
159
|
+
/**
|
|
160
|
+
* The health line, shown only once every variable is provided.
|
|
161
|
+
*
|
|
162
|
+
* While something is still missing, the amber banner above already names it,
|
|
163
|
+
* and a second line saying the connection is untested would be answering a
|
|
164
|
+
* question nobody has reached yet. Once nothing is missing, this is the only
|
|
165
|
+
* remaining question — and the one the badge used to answer by guessing.
|
|
166
|
+
*/
|
|
167
|
+
const health = toolStatus(tool, verdict);
|
|
168
|
+
// Every variable genuinely provided — NOT merely `missing.length === 0`, which
|
|
169
|
+
// excludes a pending sign-in on a configured provider. A tool nobody has
|
|
170
|
+
// signed into yet has no credential to test, and saying so would put a health
|
|
171
|
+
// line above a row that already says "Needs your sign-in".
|
|
172
|
+
// Vacuously true for a tool that declares no variables: a no-auth MCP server
|
|
173
|
+
// has nothing to set up and is still worth probing — its handshake is exactly
|
|
174
|
+
// the kind of thing that can be reachable one day and not the next.
|
|
175
|
+
//
|
|
176
|
+
// But `!setupUnfinished` first: an `oauth-manual` server whose sign-in nobody
|
|
177
|
+
// has declared YET also has no variables, and `every([])` would call that
|
|
178
|
+
// settled — offering Test connection and the words "No key needed" directly
|
|
179
|
+
// above a banner telling the owner to go configure OAuth.
|
|
180
|
+
const settled =
|
|
181
|
+
!setupUnfinished && toolVariableStatuses(tool).every(({ status }) => status.state === 'ok');
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Run a probe and keep its answer.
|
|
185
|
+
*
|
|
186
|
+
* `checking` lives here, beside the button it disables, so it is still true
|
|
187
|
+
* while the request is in flight — the reason a save no longer blanks the
|
|
188
|
+
* page (see `useToolPage`): a remount would drop both this flag and the
|
|
189
|
+
* verdict, leaving an enabled "Test connection" over a probe already running.
|
|
190
|
+
*/
|
|
191
|
+
async function runCheck() {
|
|
192
|
+
const mine = ++probeSeq.current;
|
|
193
|
+
const rev = configRevision;
|
|
194
|
+
setInFlight({ rev });
|
|
195
|
+
// A replacement probe makes the previous transport failure history the
|
|
196
|
+
// moment it starts — leaving the alert up while "Testing…" runs reads as
|
|
197
|
+
// the new attempt already having failed.
|
|
198
|
+
setProbeError(null);
|
|
199
|
+
try {
|
|
200
|
+
const value = await checkToolConnection(tool.slug);
|
|
201
|
+
// Newest-probe guard only: everything published is REVISION-STAMPED
|
|
202
|
+
// and compared at render, so a probe that raced a definition change
|
|
203
|
+
// stores state that simply never shows — no clock to synchronise, no
|
|
204
|
+
// ref to read mid-render.
|
|
205
|
+
if (probeSeq.current === mine) {
|
|
206
|
+
setProbed({ rev, value });
|
|
207
|
+
setProbeError(null);
|
|
208
|
+
}
|
|
209
|
+
} catch (err) {
|
|
210
|
+
// A rejected credential resolves with `status: 'failed'`; only a
|
|
211
|
+
// transport or access failure lands here, and that is not a verdict about
|
|
212
|
+
// the credential — so the badge keeps saying "untested" rather than
|
|
213
|
+
// inventing a result from our own network trouble.
|
|
214
|
+
// Inside the guard too: an older probe rejecting after a newer one has
|
|
215
|
+
// already answered would otherwise raise a transport error over a verdict
|
|
216
|
+
// that is currently correct.
|
|
217
|
+
if (probeSeq.current === mine) {
|
|
218
|
+
setProbed(null);
|
|
219
|
+
setProbeError({ rev, message: err instanceof Error ? err.message : "Couldn't test this connection." });
|
|
220
|
+
}
|
|
221
|
+
} finally {
|
|
222
|
+
// Only the newest probe releases the slot: an older one finishing late
|
|
223
|
+
// must not clear a newer probe's in-flight marker.
|
|
224
|
+
if (probeSeq.current === mine) setInFlight(null);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* A credential write LANDED (save or delete, from the banner's editor or a
|
|
230
|
+
* row). Everything a pending probe could still say is about a credential
|
|
231
|
+
* that no longer exists in that form, so the write ORPHANS it outright —
|
|
232
|
+
* the sequence bump takes its voice (a delete starts no replacement probe,
|
|
233
|
+
* so nothing else would), the in-flight slot is released, and the old
|
|
234
|
+
* transport alert goes with them.
|
|
235
|
+
*/
|
|
236
|
+
function changed() {
|
|
237
|
+
probeSeq.current++;
|
|
238
|
+
setInFlight(null);
|
|
239
|
+
setProbeError(null);
|
|
240
|
+
// The VERDICT too: after a delete, “Connected” would otherwise keep
|
|
241
|
+
// describing a credential that no longer exists while the refetch is
|
|
242
|
+
// still in flight.
|
|
243
|
+
setProbed(null);
|
|
244
|
+
onChanged();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* A credential was just SAVED: whatever the last probe concluded was about
|
|
249
|
+
* the key it replaced, so drop it and test the new one straight away —
|
|
250
|
+
* while the user still has it to hand, which is when a wrong key is
|
|
251
|
+
* cheapest to fix. (The row calls `changed` too, which orphans the old
|
|
252
|
+
* probe; the fresh `runCheck` claims the sequence for the new key.)
|
|
253
|
+
*/
|
|
254
|
+
function onSaved() {
|
|
255
|
+
setProbed(null);
|
|
256
|
+
void runCheck();
|
|
257
|
+
}
|
|
258
|
+
|
|
95
259
|
return (
|
|
96
260
|
<section className="mt-8">
|
|
97
261
|
<div className="mb-2.5 flex items-center justify-between gap-3">
|
|
98
262
|
<h2 className="text-label font-semibold uppercase text-ink-faint">Your connection</h2>
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
263
|
+
<div className="flex items-center gap-2">
|
|
264
|
+
{/* A healthy connection stays QUIET — this section's rule is that only
|
|
265
|
+
things needing a person get a banner, and a working tool needs
|
|
266
|
+
nobody. But it still has to be sayable: the word plus its evidence
|
|
267
|
+
on hover is how "Connected" stops being an assumption, and the
|
|
268
|
+
button is the only way to ask the question on demand. A REJECTED
|
|
269
|
+
credential does need a person, so it escalates to a banner below. */}
|
|
270
|
+
{settled && health.state !== 'err' && (
|
|
271
|
+
<span className="text-meta text-ink-faint" title={health.hint} data-testid="tool-health">
|
|
272
|
+
{health.text}
|
|
273
|
+
</span>
|
|
274
|
+
)}
|
|
275
|
+
{settled && (
|
|
276
|
+
<Button
|
|
277
|
+
variant="quiet"
|
|
278
|
+
size="tiny"
|
|
279
|
+
disabled={checking}
|
|
280
|
+
onClick={() => void runCheck()}
|
|
281
|
+
aria-label={`Test connection: ${tool.name}`}
|
|
282
|
+
>
|
|
283
|
+
{checking ? 'Testing…' : 'Test connection'}
|
|
284
|
+
</Button>
|
|
285
|
+
)}
|
|
286
|
+
<Link to="/secrets" className={buttonClasses({ variant: 'quiet', size: 'tiny' })}>
|
|
287
|
+
Open Secrets
|
|
288
|
+
</Link>
|
|
289
|
+
</div>
|
|
102
290
|
</div>
|
|
103
291
|
|
|
292
|
+
{shownProbeError && (
|
|
293
|
+
<Banner tone="danger" role="alert" className="mb-2.5" data-testid="tool-probe-error">
|
|
294
|
+
{shownProbeError}
|
|
295
|
+
</Banner>
|
|
296
|
+
)}
|
|
297
|
+
|
|
104
298
|
{setupUnfinished && (
|
|
105
299
|
<Banner tone="wait" role="status" className="mb-2.5">
|
|
106
300
|
{tool.canWrite && signInDeclared ? (
|
|
@@ -167,6 +361,22 @@ export function ToolConnectionSection({ tool, onChanged, onError }: ToolConnecti
|
|
|
167
361
|
</Banner>
|
|
168
362
|
)}
|
|
169
363
|
|
|
364
|
+
{/* The one health state that needs a person: the provider tested this
|
|
365
|
+
credential and refused it. Everything is configured, so no other
|
|
366
|
+
banner covers it, and the row below cannot know — only a real call
|
|
367
|
+
could tell us. `alert`, not `status`: this is the case the whole
|
|
368
|
+
feature exists to surface. */}
|
|
369
|
+
{settled && health.state === 'err' && (
|
|
370
|
+
<Banner tone="danger" role="alert" className="mb-2.5" data-testid="tool-health-failed">
|
|
371
|
+
<div className="flex items-center gap-3">
|
|
372
|
+
<span className="min-w-0 flex-1">
|
|
373
|
+
<span className="font-semibold">{health.text}.</span>
|
|
374
|
+
{health.hint && <span> {health.hint}</span>}
|
|
375
|
+
</span>
|
|
376
|
+
</div>
|
|
377
|
+
</Banner>
|
|
378
|
+
)}
|
|
379
|
+
|
|
170
380
|
{tool.variables.length === 0 ? (
|
|
171
381
|
<p className="text-body text-ink-muted">Nothing to set up</p>
|
|
172
382
|
) : (
|
|
@@ -180,7 +390,12 @@ export function ToolConnectionSection({ tool, onChanged, onError }: ToolConnecti
|
|
|
180
390
|
setupKind={setupKind}
|
|
181
391
|
returnTo={pathForTool(tool.slug)}
|
|
182
392
|
editSignal={edit.name === variable.name ? edit.n : undefined}
|
|
183
|
-
onChanged={
|
|
393
|
+
onChanged={changed}
|
|
394
|
+
// Test the moment a key is entered — while the user still has it
|
|
395
|
+
// to hand, which is when a typo is cheapest to fix. Waiting for
|
|
396
|
+
// an agent to trip over it is how the wrong key got to look
|
|
397
|
+
// connected in the first place.
|
|
398
|
+
onSaved={onSaved}
|
|
184
399
|
onError={onError}
|
|
185
400
|
/>
|
|
186
401
|
))}
|
|
@@ -7,6 +7,8 @@ import { useToolPage } from '../../hooks/useToolPage';
|
|
|
7
7
|
import { useToolSource } from '../../hooks/useToolSource';
|
|
8
8
|
import { McpServerSection } from './McpServerSection';
|
|
9
9
|
import { libraryHomeForItemPath, LIBRARY_ROOT } from '../../routes/library-paths';
|
|
10
|
+
import { useLibrary } from '../../state/library-data';
|
|
11
|
+
import { pluginLabel, pluginNameForPath } from '../../utils/plugin-summary';
|
|
10
12
|
import { readOAuthFragment } from '../../utils/oauth-fragment';
|
|
11
13
|
import type { ToolCapability } from '../../services/tools.api';
|
|
12
14
|
import type { LibrarySkillSummary } from '../../services/library.api';
|
|
@@ -50,6 +52,13 @@ export function ToolPage({
|
|
|
50
52
|
// `actionError` so a successful reload can't clear a callback failure.
|
|
51
53
|
const [oauthOutcome] = useState(readOAuthFragment);
|
|
52
54
|
const [actionError, setActionError] = useState<string | null>(null);
|
|
55
|
+
/**
|
|
56
|
+
* Bumped when the tool's DEFINITION changes — an mcp.json server edit. Lives
|
|
57
|
+
* here rather than in the connection section because the section is not the
|
|
58
|
+
* component that knows a server was edited, and a probe verdict about the old
|
|
59
|
+
* endpoint must not survive the change.
|
|
60
|
+
*/
|
|
61
|
+
const [serverRevision, setServerRevision] = useState(0);
|
|
53
62
|
|
|
54
63
|
useEffect(() => {
|
|
55
64
|
// Consume the OAuth `#…` fragment, KEEPING the query string: on an
|
|
@@ -63,8 +72,15 @@ export function ToolPage({
|
|
|
63
72
|
|
|
64
73
|
// Same rule as the skill page: back goes to the page the tool LIVES on —
|
|
65
74
|
// its plugin, or the personal page — never to a root the reader may not
|
|
66
|
-
// have come from.
|
|
67
|
-
|
|
75
|
+
// have come from. While the tool is still loading the path is empty, so
|
|
76
|
+
// the home is the root; a resolved identity of null falls back to the folder.
|
|
77
|
+
const data = useLibrary();
|
|
78
|
+
const toolPath = page.tool?.path ?? '';
|
|
79
|
+
const home = libraryHomeForItemPath(
|
|
80
|
+
toolPath,
|
|
81
|
+
toolPath ? pluginNameForPath(toolPath, data.pluginSummaries) : undefined,
|
|
82
|
+
(n) => pluginLabel(n, data.pluginSummaries),
|
|
83
|
+
);
|
|
68
84
|
const backLink = (
|
|
69
85
|
<Button variant="quiet" size="sm" onClick={() => navigate(home.path)}>
|
|
70
86
|
{`‹ ${home.label}`}
|
|
@@ -143,8 +159,15 @@ export function ToolPage({
|
|
|
143
159
|
</Banner>
|
|
144
160
|
)}
|
|
145
161
|
|
|
162
|
+
{/* Keyed by slug: the section's probe verdict and `checking` flag are
|
|
163
|
+
component state about THIS tool. Navigating between two canonical
|
|
164
|
+
tools re-renders the same component instance, and without the key
|
|
165
|
+
the previous tool's "Connected" (or its failure banner) survives
|
|
166
|
+
under the next tool's heading. */}
|
|
146
167
|
<ToolConnectionSection
|
|
168
|
+
key={tool.slug}
|
|
147
169
|
tool={tool}
|
|
170
|
+
configRevision={serverRevision}
|
|
148
171
|
onChanged={() => {
|
|
149
172
|
setActionError(null);
|
|
150
173
|
page.reload();
|
|
@@ -160,8 +183,13 @@ export function ToolPage({
|
|
|
160
183
|
<McpServerSection
|
|
161
184
|
slug={tool.slug}
|
|
162
185
|
configuredCount={tool.variables.filter((v) => v.adminConfigured || v.userConfigured || v.authorized === true).length}
|
|
186
|
+
reloadSignal={page.revision}
|
|
163
187
|
onSaved={() => {
|
|
164
188
|
setActionError(null);
|
|
189
|
+
// The endpoint or headers may have just changed, so any verdict the
|
|
190
|
+
// connection section is holding describes a server that is no
|
|
191
|
+
// longer configured.
|
|
192
|
+
setServerRevision((r) => r + 1);
|
|
165
193
|
page.reload();
|
|
166
194
|
}}
|
|
167
195
|
onError={setActionError}
|
|
@@ -50,6 +50,13 @@ export interface ToolVarRowProps {
|
|
|
50
50
|
*/
|
|
51
51
|
editSignal?: number;
|
|
52
52
|
onChanged(): void;
|
|
53
|
+
/**
|
|
54
|
+
* A credential was WRITTEN (not deleted) — a typed value or an owner's client
|
|
55
|
+
* secret. The one moment worth testing the connection, because it is the only
|
|
56
|
+
* one that can turn a broken tool into a working one. Deletes still call
|
|
57
|
+
* `onChanged`; they just have nothing to prove.
|
|
58
|
+
*/
|
|
59
|
+
onSaved?(): void;
|
|
53
60
|
onError(message: string): void;
|
|
54
61
|
}
|
|
55
62
|
|
|
@@ -63,6 +70,7 @@ export function ToolVarRow({
|
|
|
63
70
|
returnTo,
|
|
64
71
|
editSignal,
|
|
65
72
|
onChanged,
|
|
73
|
+
onSaved,
|
|
66
74
|
onError,
|
|
67
75
|
}: ToolVarRowProps) {
|
|
68
76
|
const [editor, setEditor] = useState<Editor>(null);
|
|
@@ -108,12 +116,13 @@ export function ToolVarRow({
|
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
/** Every write funnels through here so busy/close/report is identical. */
|
|
111
|
-
async function run(action: () => Promise<void
|
|
119
|
+
async function run(action: () => Promise<void>, saved = false) {
|
|
112
120
|
setBusy(true);
|
|
113
121
|
try {
|
|
114
122
|
await action();
|
|
115
123
|
close();
|
|
116
124
|
onChanged();
|
|
125
|
+
if (saved) onSaved?.();
|
|
117
126
|
} catch (err) {
|
|
118
127
|
onError(err instanceof Error ? err.message : String(err));
|
|
119
128
|
} finally {
|
|
@@ -152,8 +161,12 @@ export function ToolVarRow({
|
|
|
152
161
|
<Button key="reconnect" size="tiny" variant="quiet" disabled={busy} onClick={() => void signIn()}>
|
|
153
162
|
Reconnect
|
|
154
163
|
</Button>,
|
|
164
|
+
// "Signed in", not "Connected": at ROW level all we know is that a token
|
|
165
|
+
// exists. Whether it still works is the tool-level health line's claim,
|
|
166
|
+
// and it is the only place in the UI allowed to say "Connected" — one
|
|
167
|
+
// word, one meaning, backed by a real call.
|
|
155
168
|
<Badge key="chip" tone="ok">
|
|
156
|
-
|
|
169
|
+
Signed in
|
|
157
170
|
</Badge>,
|
|
158
171
|
);
|
|
159
172
|
if (mayEditClientSecret) {
|
|
@@ -242,8 +255,12 @@ export function ToolVarRow({
|
|
|
242
255
|
description = 'Each person sets their own';
|
|
243
256
|
if (variable.userConfigured) {
|
|
244
257
|
meta.push(
|
|
258
|
+
// "Key saved", not "Connected": a stored value is the whole of what
|
|
259
|
+
// this row knows. Whether it WORKS is the tool-level health line's
|
|
260
|
+
// claim, and letting a row make it was how a mistyped key came to
|
|
261
|
+
// render as a connection.
|
|
245
262
|
<Badge key="chip" tone="ok">
|
|
246
|
-
|
|
263
|
+
Key saved
|
|
247
264
|
</Badge>,
|
|
248
265
|
);
|
|
249
266
|
} else {
|
|
@@ -259,12 +276,17 @@ export function ToolVarRow({
|
|
|
259
276
|
const save = () => {
|
|
260
277
|
const secret = value;
|
|
261
278
|
if (isClientSecret) {
|
|
262
|
-
|
|
279
|
+
// Also a credential change: a replaced client secret can invalidate the
|
|
280
|
+
// tokens minted under the old one, so the tool's health is now unknown
|
|
281
|
+
// and worth re-testing — same as any other saved value.
|
|
282
|
+
return run(() => setOAuthClientSecret(slug, variable.name, secret), true);
|
|
263
283
|
}
|
|
264
|
-
return run(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
284
|
+
return run(
|
|
285
|
+
() =>
|
|
286
|
+
variable.scope === 'admin'
|
|
287
|
+
? setAdminVar(slug, variable.name, secret)
|
|
288
|
+
: setUserVar(slug, variable.name, secret),
|
|
289
|
+
true,
|
|
268
290
|
);
|
|
269
291
|
};
|
|
270
292
|
|