@blackbelt-technology/pi-dashboard-mcp-client-plugin 0.9.0 → 0.10.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 +5 -3
- package/schema/mcp-config.schema.json +11 -1
- package/src/client/FolderMcpPage.tsx +183 -45
- package/src/client/FolderMcpSection.tsx +2 -1
- package/src/client/McpSettings.tsx +56 -39
- package/src/client/ProjectSettings.tsx +217 -0
- package/src/client/ServerList.tsx +430 -169
- package/src/client/api.ts +52 -2
- package/src/client/folder-view.ts +30 -8
- package/src/client/hooks.ts +38 -4
- package/src/client/index.tsx +0 -2
- package/src/client/settings-ui.ts +19 -0
- package/src/core/config-writer.ts +252 -25
- package/src/core/effective-view.ts +63 -9
- package/src/core/index.ts +12 -0
- package/src/core/path-utils.ts +12 -0
- package/src/core/pi-rules.ts +80 -3
- package/src/core/schema-validation.ts +10 -5
- package/src/core/service.ts +48 -3
- package/src/core/types.ts +86 -8
- package/src/server/index.ts +23 -1
- package/src/server/routes.ts +236 -48
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackbelt-technology/pi-dashboard-mcp-client-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "First-party dashboard plugin managing pi's built-in MCP configuration: Pi-global + trusted-folder mcp.json view with live state from `pi mcp list`, validated atomic writes, and global + folder MCP management surfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"wouter": ">=3.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@blackbelt-technology/dashboard-plugin-runtime": "^0.
|
|
50
|
-
"@blackbelt-technology/pi-dashboard-shared": "^0.
|
|
49
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.10.0",
|
|
50
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.10.0",
|
|
51
51
|
"@mdi/js": "^7.4.47",
|
|
52
52
|
"@mdi/react": "^1.6.1",
|
|
53
53
|
"ajv": "^8.17.1"
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
{
|
|
73
73
|
"slot": "settings-section",
|
|
74
74
|
"component": "McpSettingsClaim",
|
|
75
|
+
"module": "./src/client/McpSettings.tsx",
|
|
75
76
|
"tab": "general"
|
|
76
77
|
},
|
|
77
78
|
{
|
|
@@ -85,6 +86,7 @@
|
|
|
85
86
|
{
|
|
86
87
|
"slot": "shell-overlay-route",
|
|
87
88
|
"component": "FolderMcpPage",
|
|
89
|
+
"module": "./src/client/FolderMcpPage.tsx",
|
|
88
90
|
"path": "/folder/:encodedCwd/mcp",
|
|
89
91
|
"depth": 2,
|
|
90
92
|
"parentPath": "/folder/:encodedCwd"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"$id": "https://pi-dashboard.local/schemas/mcp-config.schema.json",
|
|
4
4
|
"title": "pi built-in MCP server entry",
|
|
5
|
-
"description": "Hand-authored from pi 1.
|
|
5
|
+
"description": "Hand-authored from pi 1.1.0 dist/core/mcp-servers.d.ts (McpServerConfig). Describes one `mcpServers.<name>` entry of ~/.pi/agent/mcp.json or <cwd>/.pi/mcp.json so the dashboard client can render editors without hard-coding field lists. Annotations: x-transport marks the two mutually exclusive transports (command xor url); x-secret marks credential-bearing fields (masked in the editor, redacted when inherited, omitted from folder copies); x-global-only marks fields pi reads only from the global file. The writer additionally mirrors pi's validateMcpServerConfig rules (pi-rules.ts).",
|
|
6
6
|
"$defs": {
|
|
7
7
|
"Exposure": {
|
|
8
8
|
"enum": ["codemode", "deferred", "direct", "hidden", "codemode-deferred"],
|
|
@@ -29,6 +29,16 @@
|
|
|
29
29
|
"provider": { "type": "string", "minLength": 1 }
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
"ProjectOverride": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"additionalProperties": false,
|
|
35
|
+
"description": "A project-file entry with no command, url or type: overrides only enabled, exposure and toolExposure of the Pi-global server of the same name (pi >= 1.0.1).",
|
|
36
|
+
"properties": {
|
|
37
|
+
"exposure": { "$ref": "#/$defs/Exposure" },
|
|
38
|
+
"toolExposure": { "type": "object", "additionalProperties": { "$ref": "#/$defs/Exposure" } },
|
|
39
|
+
"enabled": { "type": "boolean" }
|
|
40
|
+
}
|
|
41
|
+
},
|
|
32
42
|
"ServerEntry": {
|
|
33
43
|
"type": "object",
|
|
34
44
|
"additionalProperties": true,
|
|
@@ -6,23 +6,29 @@
|
|
|
6
6
|
* effective-view request is refused (403) for a folder the host does not
|
|
7
7
|
* track, so the page renders a not-allowed empty state with NO retry and no
|
|
8
8
|
* data. Rows carry provenance badges (Pi global / Pi folder) and the
|
|
9
|
-
* whole-entry
|
|
10
|
-
* pre-filled with the complete global entry minus secrets + `auth`,
|
|
11
|
-
* omission flagged
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
9
|
+
* whole-entry replace marker; a global row's "Replace with folder entry…" opens
|
|
10
|
+
* the editor pre-filled with the complete global entry minus secrets + `auth`,
|
|
11
|
+
* each omission flagged, and its "Project settings…" opens the project-override
|
|
12
|
+
* panel (enabled + exposure, credentials untouched). An untrusted folder shows a
|
|
13
|
+
* notice (dashboard-spawned headless sessions trust the folder per run) while
|
|
14
|
+
* editing stays allowed. Folder writes are project-scope only; a folder enable
|
|
15
|
+
* of a whole-entry copy that needs re-entered secrets offers remove-or-reenter
|
|
16
|
+
* (or convert, for a legacy copy); Remove / Reset / Convert keep an undo toast
|
|
17
|
+
* that restores the exact prior entry (override rows via the project-override
|
|
18
|
+
* route, whole entries via the generic PUT).
|
|
16
19
|
*
|
|
17
|
-
* See change: migrate-mcp-to-pi-builtin.
|
|
20
|
+
* See change: migrate-mcp-to-pi-builtin; mcp-client-project-overrides.
|
|
18
21
|
*/
|
|
19
22
|
import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
20
23
|
import type React from "react";
|
|
21
24
|
import { useMemo, useState } from "react";
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
+
import { useLocation } from "wouter";
|
|
26
|
+
import { isProjectOverride } from "../core/pi-rules.js";
|
|
27
|
+
import type { EffectiveServerView, EffectiveView, Provenance, Scope } from "../core/types.js";
|
|
28
|
+
import { ApiError, convertToOverride, removeServer, saveServer, scopeToWire, setProjectOverride } from "./api.js";
|
|
29
|
+
import { folderOverrideDraftOf, isFolderOwned, overrideRestorePatch } from "./folder-view.js";
|
|
25
30
|
import { invalidateEffective, useEffectiveConfig } from "./hooks.js";
|
|
31
|
+
import { ProjectSettingsPanel } from "./ProjectSettings.js";
|
|
26
32
|
import { ServerEditor } from "./ServerEditor.js";
|
|
27
33
|
import type { RowRef } from "./ServerList.js";
|
|
28
34
|
import { ServerList } from "./ServerList.js";
|
|
@@ -77,8 +83,67 @@ function NotAllowed(): React.ReactElement {
|
|
|
77
83
|
);
|
|
78
84
|
}
|
|
79
85
|
|
|
86
|
+
/** Readable label of a dashboard trust source (mirrors the host's labels). */
|
|
87
|
+
const SOURCE_LABEL: Record<string, string> = {
|
|
88
|
+
worktreeInit: "worktree-init trust",
|
|
89
|
+
workflow: "workflow trust",
|
|
90
|
+
pinned: "pinned folder",
|
|
91
|
+
folderWorkspaces: "folder workspace",
|
|
92
|
+
accessGrants: "access grant",
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Who trusts this folder, per the host's decision order: pi's trust store (naming
|
|
97
|
+
* the recorded path), the dashboard (naming source + folder, and the scope), or —
|
|
98
|
+
* rendered by `UntrustedNotice` — neither. Reports the FOLDER's decision, not a
|
|
99
|
+
* session's command-line override. See change: mirror-dashboard-trust-to-pi.
|
|
100
|
+
*/
|
|
101
|
+
function TrustBanner({ view }: { view: EffectiveView }): React.ReactElement | null {
|
|
102
|
+
const t = useT();
|
|
103
|
+
const source = view.trustSource;
|
|
104
|
+
if (view.trusted !== true || !source) return null;
|
|
105
|
+
return (
|
|
106
|
+
<div
|
|
107
|
+
data-testid={source.kind === "dashboard" ? "mcp-folder-trusted-dashboard" : "mcp-folder-trusted-pi"}
|
|
108
|
+
role="status"
|
|
109
|
+
className="text-[11px] px-2 py-1.5 rounded border border-[var(--border-secondary)] text-[var(--text-secondary)]"
|
|
110
|
+
>
|
|
111
|
+
{trustText(source, view.trustCoverInteractive === true, t)}
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** The folder's trust notice: "who trusts it", or the untrusted notice when nobody does. */
|
|
117
|
+
function TrustNotices({ view }: { view: EffectiveView | null }): React.ReactElement | null {
|
|
118
|
+
if (!view) return null;
|
|
119
|
+
return view.trusted === false ? <UntrustedNotice /> : <TrustBanner view={view} />;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function trustText(
|
|
123
|
+
source: NonNullable<EffectiveView["trustSource"]>,
|
|
124
|
+
coverInteractive: boolean,
|
|
125
|
+
t: (key: string, params: undefined, fallback: string) => string,
|
|
126
|
+
): string {
|
|
127
|
+
if (source.kind === "recorded") return `${t("mcpFolderTrustedByPi", undefined, "pi trusts this folder through")} ${source.path}.`;
|
|
128
|
+
if (source.kind === "implicit") {
|
|
129
|
+
return t("mcpFolderTrustedImplicit", undefined, "pi trusts this folder: it has no project resources that need trust.");
|
|
130
|
+
}
|
|
131
|
+
if (source.kind === "default") {
|
|
132
|
+
return t("mcpFolderTrustedDefault", undefined, "pi trusts this folder through its defaultProjectTrust setting.");
|
|
133
|
+
}
|
|
134
|
+
const label = SOURCE_LABEL[source.sourceKind] ?? source.sourceKind;
|
|
135
|
+
const scope = coverInteractive
|
|
136
|
+
? t("mcpFolderTrustedScopeAll", undefined, "This applies to every pi session on this machine.")
|
|
137
|
+
: t("mcpFolderTrustedScopeDashboard", undefined, "This applies to dashboard sessions, not terminal pi.");
|
|
138
|
+
return (
|
|
139
|
+
`${t("mcpFolderTrustedByDashboard", undefined, "This folder is trusted by the dashboard")} — ${label} ${source.entry}. ${scope} ` +
|
|
140
|
+
t("mcpFolderTrustedNotChecked", undefined, "Running pi mcp list here, outside the dashboard, still reports its servers as not loaded.")
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
80
144
|
function UntrustedNotice(): React.ReactElement {
|
|
81
145
|
const t = useT();
|
|
146
|
+
const [, navigate] = useLocation();
|
|
82
147
|
return (
|
|
83
148
|
<div
|
|
84
149
|
data-testid="mcp-folder-untrusted"
|
|
@@ -89,7 +154,15 @@ function UntrustedNotice(): React.ReactElement {
|
|
|
89
154
|
"mcpFolderUntrusted",
|
|
90
155
|
undefined,
|
|
91
156
|
"pi does not trust this project yet: folder servers stay inactive until the project is trusted. Headless sessions the dashboard starts in this folder trust it per run. Editing <cwd>/.pi/mcp.json stays allowed.",
|
|
92
|
-
)}
|
|
157
|
+
)}{" "}
|
|
158
|
+
<button
|
|
159
|
+
type="button"
|
|
160
|
+
data-testid="mcp-folder-untrusted-access-link"
|
|
161
|
+
onClick={() => navigate("/settings/access")}
|
|
162
|
+
className="underline text-[var(--accent-text)]"
|
|
163
|
+
>
|
|
164
|
+
{t("mcpFolderOpenAccess", undefined, "Settings → Access")}
|
|
165
|
+
</button>
|
|
93
166
|
</div>
|
|
94
167
|
);
|
|
95
168
|
}
|
|
@@ -104,7 +177,9 @@ interface EditingState {
|
|
|
104
177
|
|
|
105
178
|
interface UndoState {
|
|
106
179
|
name: string;
|
|
180
|
+
/** The exact prior entry: an override (restored via the override route) or a whole entry. */
|
|
107
181
|
removed: Record<string, unknown>;
|
|
182
|
+
message: string;
|
|
108
183
|
}
|
|
109
184
|
|
|
110
185
|
interface ChoiceState {
|
|
@@ -112,12 +187,6 @@ interface ChoiceState {
|
|
|
112
187
|
omitted: string[];
|
|
113
188
|
}
|
|
114
189
|
|
|
115
|
-
interface OmittedNoteState {
|
|
116
|
-
key: string;
|
|
117
|
-
name: string;
|
|
118
|
-
omitted: string[];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
190
|
/** The editor pre-fill for a row: the folder's own entry, or the override copy. */
|
|
122
191
|
function prefillFor(server: { name: string; provenance: Provenance; entry: Record<string, unknown> } | null): EditingState {
|
|
123
192
|
if (server === null) return { name: "", entry: {} };
|
|
@@ -131,7 +200,7 @@ interface FolderActions {
|
|
|
131
200
|
editing: EditingState | null;
|
|
132
201
|
undo: UndoState | null;
|
|
133
202
|
choice: ChoiceState | null;
|
|
134
|
-
|
|
203
|
+
projectPanel: string | null;
|
|
135
204
|
actionError: string | null;
|
|
136
205
|
scope: Scope;
|
|
137
206
|
open: (name: string, provenance: Provenance) => void;
|
|
@@ -141,8 +210,12 @@ interface FolderActions {
|
|
|
141
210
|
undoRemove: () => void;
|
|
142
211
|
resolveChoiceRemove: () => void;
|
|
143
212
|
resolveChoiceReenter: () => void;
|
|
213
|
+
resolveChoiceConvert: () => void;
|
|
144
214
|
onNeedsChoice: (row: RowRef, omitted: string[]) => void;
|
|
145
|
-
|
|
215
|
+
openProjectSettings: (name: string) => void;
|
|
216
|
+
closeProjectSettings: () => void;
|
|
217
|
+
reset: (name: string) => void;
|
|
218
|
+
convertLegacy: (name: string) => void;
|
|
146
219
|
refreshed: () => void;
|
|
147
220
|
}
|
|
148
221
|
|
|
@@ -152,10 +225,11 @@ function useFolderActions(
|
|
|
152
225
|
view: EffectiveView | null,
|
|
153
226
|
reload: () => void,
|
|
154
227
|
): FolderActions {
|
|
228
|
+
const t = useT();
|
|
155
229
|
const [editing, setEditing] = useState<EditingState | null>(null);
|
|
156
230
|
const [undo, setUndo] = useState<UndoState | null>(null);
|
|
157
231
|
const [choice, setChoice] = useState<ChoiceState | null>(null);
|
|
158
|
-
const [
|
|
232
|
+
const [projectPanel, setProjectPanel] = useState<string | null>(null);
|
|
159
233
|
const [actionError, setActionError] = useState<string | null>(null);
|
|
160
234
|
const scope = useMemo<Scope>(() => ({ kind: "project", cwd }), [cwd]);
|
|
161
235
|
const refreshed = (): void => {
|
|
@@ -163,13 +237,17 @@ function useFolderActions(
|
|
|
163
237
|
reload();
|
|
164
238
|
};
|
|
165
239
|
|
|
166
|
-
async function removeOverride(name: string): Promise<void> {
|
|
240
|
+
async function removeOverride(name: string, message?: string): Promise<void> {
|
|
167
241
|
setActionError(null);
|
|
168
242
|
try {
|
|
169
243
|
const res = await removeServer(name, scopeToWire(scope));
|
|
170
244
|
setEditing(null);
|
|
171
245
|
setChoice(null);
|
|
172
|
-
setUndo({
|
|
246
|
+
setUndo({
|
|
247
|
+
name,
|
|
248
|
+
removed: res.removed ?? {},
|
|
249
|
+
message: message ?? t("mcpFolderOverrideRemoved", { name }, `Removed folder override for ${name}.`),
|
|
250
|
+
});
|
|
173
251
|
refreshed();
|
|
174
252
|
} catch (e) {
|
|
175
253
|
setActionError(e instanceof ApiError ? e.message : String(e));
|
|
@@ -179,7 +257,13 @@ function useFolderActions(
|
|
|
179
257
|
async function undoRemove(): Promise<void> {
|
|
180
258
|
if (!undo) return;
|
|
181
259
|
try {
|
|
182
|
-
|
|
260
|
+
// An override (no command/url/type) is restored through the override route
|
|
261
|
+
// with its absent keys as `null`; a whole entry goes through the generic PUT.
|
|
262
|
+
if (isProjectOverride(undo.removed)) {
|
|
263
|
+
await setProjectOverride(undo.name, overrideRestorePatch(undo.removed), scopeToWire(scope));
|
|
264
|
+
} else {
|
|
265
|
+
await saveServer(undo.name, { ...scopeToWire(scope), entry: undo.removed });
|
|
266
|
+
}
|
|
183
267
|
setUndo(null);
|
|
184
268
|
refreshed();
|
|
185
269
|
} catch (e) {
|
|
@@ -187,11 +271,28 @@ function useFolderActions(
|
|
|
187
271
|
}
|
|
188
272
|
}
|
|
189
273
|
|
|
274
|
+
async function convertLegacy(name: string): Promise<void> {
|
|
275
|
+
setActionError(null);
|
|
276
|
+
try {
|
|
277
|
+
const res = await convertToOverride(name, scopeToWire(scope));
|
|
278
|
+
setChoice(null);
|
|
279
|
+
// Undo re-PUTs the original copy (a full entry), which replaces the converted override.
|
|
280
|
+
setUndo({
|
|
281
|
+
name,
|
|
282
|
+
removed: res.previous,
|
|
283
|
+
message: t("mcpFolderConverted", { name }, `Converted ${name} to a project override.`),
|
|
284
|
+
});
|
|
285
|
+
refreshed();
|
|
286
|
+
} catch (e) {
|
|
287
|
+
setActionError(e instanceof ApiError ? e.message : String(e));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
190
291
|
return {
|
|
191
292
|
editing,
|
|
192
293
|
undo,
|
|
193
294
|
choice,
|
|
194
|
-
|
|
295
|
+
projectPanel,
|
|
195
296
|
actionError,
|
|
196
297
|
scope,
|
|
197
298
|
open: (name, provenance) => {
|
|
@@ -217,13 +318,20 @@ function useFolderActions(
|
|
|
217
318
|
setChoice(null);
|
|
218
319
|
setEditing(prefillFor(server));
|
|
219
320
|
},
|
|
321
|
+
resolveChoiceConvert: () => {
|
|
322
|
+
if (choice) void convertLegacy(choice.row.name);
|
|
323
|
+
},
|
|
220
324
|
onNeedsChoice: (row, omitted) => setChoice({ row, omitted }),
|
|
221
|
-
|
|
325
|
+
openProjectSettings: (name) => setProjectPanel(name),
|
|
326
|
+
closeProjectSettings: () => setProjectPanel(null),
|
|
327
|
+
reset: (name) =>
|
|
328
|
+
void removeOverride(name, t("mcpFolderResetDone", { name }, `Reset ${name} to Pi global.`)),
|
|
329
|
+
convertLegacy: (name) => void convertLegacy(name),
|
|
222
330
|
refreshed,
|
|
223
331
|
};
|
|
224
332
|
}
|
|
225
333
|
|
|
226
|
-
function UndoToast({
|
|
334
|
+
function UndoToast({ message, onUndo }: { message: string; onUndo: () => void }): React.ReactElement {
|
|
227
335
|
const t = useT();
|
|
228
336
|
return (
|
|
229
337
|
<div
|
|
@@ -231,7 +339,7 @@ function UndoToast({ name, onUndo }: { name: string; onUndo: () => void }): Reac
|
|
|
231
339
|
role="status"
|
|
232
340
|
className="flex items-center gap-2 text-[11px] px-2 py-1.5 rounded border border-[var(--border-secondary)] text-[var(--text-secondary)]"
|
|
233
341
|
>
|
|
234
|
-
<span>{
|
|
342
|
+
<span>{message}</span>
|
|
235
343
|
<button
|
|
236
344
|
type="button"
|
|
237
345
|
onClick={onUndo}
|
|
@@ -250,11 +358,14 @@ function NeedsChoicePanel({
|
|
|
250
358
|
omitted,
|
|
251
359
|
onRemove,
|
|
252
360
|
onReenter,
|
|
361
|
+
onConvert,
|
|
253
362
|
}: {
|
|
254
363
|
name: string;
|
|
255
364
|
omitted: string[];
|
|
256
365
|
onRemove: () => void;
|
|
257
366
|
onReenter: () => void;
|
|
367
|
+
/** Present only for a legacy copy of the global entry. */
|
|
368
|
+
onConvert?: () => void;
|
|
258
369
|
}): React.ReactElement {
|
|
259
370
|
const t = useT();
|
|
260
371
|
return (
|
|
@@ -287,6 +398,16 @@ function NeedsChoicePanel({
|
|
|
287
398
|
>
|
|
288
399
|
{t("mcpChoiceReenter", undefined, "Re-enter omitted values")}
|
|
289
400
|
</button>
|
|
401
|
+
{onConvert && (
|
|
402
|
+
<button
|
|
403
|
+
type="button"
|
|
404
|
+
onClick={onConvert}
|
|
405
|
+
data-testid="mcp-choice-convert"
|
|
406
|
+
className="px-2 py-1 min-h-11 min-w-11 sm:min-h-0 sm:min-w-0 rounded border border-[var(--accent-primary,#60a5fa)] text-[var(--accent-primary,#60a5fa)]"
|
|
407
|
+
>
|
|
408
|
+
{t("mcpChoiceConvert", undefined, "Convert to project override")}
|
|
409
|
+
</button>
|
|
410
|
+
)}
|
|
290
411
|
</div>
|
|
291
412
|
</div>
|
|
292
413
|
);
|
|
@@ -301,12 +422,25 @@ function FolderSummary({ view }: { view: EffectiveView }): React.ReactElement {
|
|
|
301
422
|
{t(
|
|
302
423
|
"mcpFolderSummary",
|
|
303
424
|
{ count: overrides },
|
|
304
|
-
`A folder entry replaces the global entry of the same name as a whole · ${overrides}
|
|
425
|
+
`A folder entry with a command or url replaces the global entry of the same name as a whole · ${overrides} replacement(s)`,
|
|
305
426
|
)}
|
|
306
427
|
</p>
|
|
307
428
|
);
|
|
308
429
|
}
|
|
309
430
|
|
|
431
|
+
/** The global row the settings panel is open on, and whether the pending choice is a legacy copy. */
|
|
432
|
+
function pageDerivations(
|
|
433
|
+
servers: EffectiveServerView[],
|
|
434
|
+
panelName: string | null,
|
|
435
|
+
choiceName: string | null,
|
|
436
|
+
): { panelServer: EffectiveServerView | null; legacyChoice: boolean } {
|
|
437
|
+
const panelServer =
|
|
438
|
+
panelName === null ? null : (servers.find((s) => s.name === panelName && s.provenance === "pi-global") ?? null);
|
|
439
|
+
const legacyChoice =
|
|
440
|
+
choiceName !== null && servers.some((s) => s.name === choiceName && s.provenance === "pi-folder" && s.legacyCopy === true);
|
|
441
|
+
return { panelServer, legacyChoice };
|
|
442
|
+
}
|
|
443
|
+
|
|
310
444
|
function FolderMcpPageBody({ cwd }: { cwd: string }): React.ReactElement {
|
|
311
445
|
const t = useT();
|
|
312
446
|
const { view, loading, error, reload } = useEffectiveConfig(cwd);
|
|
@@ -336,10 +470,11 @@ function FolderMcpPageBody({ cwd }: { cwd: string }): React.ReactElement {
|
|
|
336
470
|
}
|
|
337
471
|
|
|
338
472
|
const servers = view?.servers ?? [];
|
|
473
|
+
const { panelServer, legacyChoice } = pageDerivations(servers, actions.projectPanel, actions.choice?.row.name ?? null);
|
|
339
474
|
|
|
340
475
|
return (
|
|
341
476
|
<div className="space-y-2">
|
|
342
|
-
{view
|
|
477
|
+
<TrustNotices view={view} />
|
|
343
478
|
{actions.actionError && (
|
|
344
479
|
<p
|
|
345
480
|
data-testid="mcp-folder-action-error"
|
|
@@ -349,19 +484,6 @@ function FolderMcpPageBody({ cwd }: { cwd: string }): React.ReactElement {
|
|
|
349
484
|
{actions.actionError}
|
|
350
485
|
</p>
|
|
351
486
|
)}
|
|
352
|
-
{actions.omittedNote && (
|
|
353
|
-
<p
|
|
354
|
-
data-testid={`mcp-folder-omitted-${actions.omittedNote.key}`}
|
|
355
|
-
role="status"
|
|
356
|
-
className="text-[11px] text-[var(--text-secondary)] m-0"
|
|
357
|
-
>
|
|
358
|
-
{t(
|
|
359
|
-
"mcpFolderOmitted",
|
|
360
|
-
{ name: actions.omittedNote.name, omitted: actions.omittedNote.omitted.join(", ") },
|
|
361
|
-
`The folder copy of ${actions.omittedNote.name} omits: ${actions.omittedNote.omitted.join(", ")}. Re-enter them via Edit.`,
|
|
362
|
-
)}
|
|
363
|
-
</p>
|
|
364
|
-
)}
|
|
365
487
|
|
|
366
488
|
<ServerList
|
|
367
489
|
servers={servers}
|
|
@@ -372,9 +494,13 @@ function FolderMcpPageBody({ cwd }: { cwd: string }): React.ReactElement {
|
|
|
372
494
|
onAdd={actions.openAdd}
|
|
373
495
|
onChanged={actions.refreshed}
|
|
374
496
|
onNeedsChoice={actions.onNeedsChoice}
|
|
375
|
-
onOmitted={actions.onOmitted}
|
|
376
497
|
onRemoveOverride={actions.removeOverride}
|
|
377
498
|
chipsRemovable={!narrow}
|
|
499
|
+
onProjectSettings={actions.openProjectSettings}
|
|
500
|
+
onReset={actions.reset}
|
|
501
|
+
onConvertLegacy={actions.convertLegacy}
|
|
502
|
+
untrusted={view?.trusted === false}
|
|
503
|
+
narrow={narrow}
|
|
378
504
|
/>
|
|
379
505
|
|
|
380
506
|
{actions.choice && (
|
|
@@ -383,10 +509,22 @@ function FolderMcpPageBody({ cwd }: { cwd: string }): React.ReactElement {
|
|
|
383
509
|
omitted={actions.choice.omitted}
|
|
384
510
|
onRemove={actions.resolveChoiceRemove}
|
|
385
511
|
onReenter={actions.resolveChoiceReenter}
|
|
512
|
+
{...(legacyChoice ? { onConvert: actions.resolveChoiceConvert } : {})}
|
|
386
513
|
/>
|
|
387
514
|
)}
|
|
388
515
|
|
|
389
|
-
{actions.undo && <UndoToast
|
|
516
|
+
{actions.undo && <UndoToast message={actions.undo.message} onUndo={actions.undoRemove} />}
|
|
517
|
+
|
|
518
|
+
{panelServer && (
|
|
519
|
+
<ProjectSettingsPanel
|
|
520
|
+
key={panelServer.name}
|
|
521
|
+
server={panelServer}
|
|
522
|
+
scope={actions.scope as Extract<Scope, { kind: "project" }>}
|
|
523
|
+
narrow={narrow}
|
|
524
|
+
onClose={actions.closeProjectSettings}
|
|
525
|
+
onSaved={actions.refreshed}
|
|
526
|
+
/>
|
|
527
|
+
)}
|
|
390
528
|
|
|
391
529
|
{actions.editing && (
|
|
392
530
|
<ServerEditor
|
|
@@ -184,7 +184,8 @@ export function FolderMcpSection({
|
|
|
184
184
|
|
|
185
185
|
const notAllowed = error instanceof ApiError && error.isNotAllowed;
|
|
186
186
|
const otherError = error && !notAllowed ? (error as Error) : null;
|
|
187
|
-
|
|
187
|
+
// An orphaned / invalid override row is a pi message, not a server: pi loads nothing for it.
|
|
188
|
+
const servers = (view?.servers ?? []).filter((s) => s.overrideIssue === undefined);
|
|
188
189
|
const { accent, body } = pillContent(t, {
|
|
189
190
|
parseErrorPath: view?.layers.find((l) => !l.ok)?.path,
|
|
190
191
|
otherError,
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
*
|
|
9
9
|
* See change: migrate-mcp-to-pi-builtin.
|
|
10
10
|
*/
|
|
11
|
-
import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
11
|
+
import { SettingsNotice, useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
12
12
|
import type React from "react";
|
|
13
13
|
import { useState } from "react";
|
|
14
14
|
import { ApiError } from "./api.js";
|
|
15
15
|
import { useEffectiveConfig, useLiveState } from "./hooks.js";
|
|
16
16
|
import { ServerEditor } from "./ServerEditor.js";
|
|
17
17
|
import { ServerList } from "./ServerList.js";
|
|
18
|
+
import { BTN, BTN_PRIMARY } from "./settings-ui.js";
|
|
18
19
|
|
|
19
20
|
export function McpSettingsClaim(): React.ReactElement {
|
|
20
21
|
return <McpSettings />;
|
|
@@ -59,57 +60,73 @@ export function McpSettings(): React.ReactElement {
|
|
|
59
60
|
refresh();
|
|
60
61
|
};
|
|
61
62
|
|
|
63
|
+
const servers = view?.servers ?? [];
|
|
64
|
+
const layers = view?.layers ?? [];
|
|
65
|
+
// Empty state = loaded, no servers, no broken file, no error: the empty block owns the one primary Add.
|
|
66
|
+
const isEmpty = !loading && !error && servers.length === 0 && layers.every((l) => l.ok);
|
|
67
|
+
const refreshButton = (
|
|
68
|
+
<button
|
|
69
|
+
type="button"
|
|
70
|
+
onClick={refreshAll}
|
|
71
|
+
data-testid="mcp-refresh"
|
|
72
|
+
title={t("mcpRefreshTitle", undefined, "Re-read the config files and pi's live state")}
|
|
73
|
+
className={BTN}
|
|
74
|
+
>
|
|
75
|
+
{t("mcpRefresh", undefined, "Refresh")}
|
|
76
|
+
</button>
|
|
77
|
+
);
|
|
78
|
+
|
|
62
79
|
return (
|
|
63
80
|
<section data-testid="mcp-settings" className="space-y-2">
|
|
64
81
|
<div className="flex items-center gap-2 flex-wrap">
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
>
|
|
83
|
-
{t("mcpAddServer", undefined, "Add server")}
|
|
84
|
-
</button>
|
|
82
|
+
{isEmpty ? (
|
|
83
|
+
<span className="ml-auto">{refreshButton}</span>
|
|
84
|
+
) : (
|
|
85
|
+
<>
|
|
86
|
+
<h4 className="m-0 text-xs font-semibold text-[var(--text-secondary)]">
|
|
87
|
+
{loading && !view
|
|
88
|
+
? t("mcpServersHeadingBare", undefined, "Servers")
|
|
89
|
+
: t("mcpServersHeading", { count: servers.length }, `Servers · ${servers.length}`)}
|
|
90
|
+
</h4>
|
|
91
|
+
<span className="ml-auto flex items-center gap-2">
|
|
92
|
+
{refreshButton}
|
|
93
|
+
<button type="button" onClick={() => setEditing("")} data-testid="mcp-add-server" className={BTN_PRIMARY}>
|
|
94
|
+
{t("mcpAddServer", undefined, "Add server")}
|
|
95
|
+
</button>
|
|
96
|
+
</span>
|
|
97
|
+
</>
|
|
98
|
+
)}
|
|
85
99
|
</div>
|
|
86
100
|
|
|
87
101
|
{notAllowed && (
|
|
88
|
-
<
|
|
102
|
+
<SettingsNotice tone="info" role="alert" testId="mcp-not-allowed">
|
|
89
103
|
{t("mcpNotAllowed", undefined, "This folder is not tracked by the dashboard.")}
|
|
90
|
-
</
|
|
104
|
+
</SettingsNotice>
|
|
91
105
|
)}
|
|
92
106
|
|
|
93
107
|
{otherError && (
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
108
|
+
<SettingsNotice
|
|
109
|
+
tone="error"
|
|
110
|
+
testId="mcp-error"
|
|
111
|
+
onRetry={refreshAll}
|
|
112
|
+
details={(otherError as Error).message}
|
|
98
113
|
>
|
|
99
|
-
{t("mcpLoadError",
|
|
100
|
-
</
|
|
114
|
+
{t("mcpLoadError", undefined, "Could not load the MCP configuration.")}
|
|
115
|
+
</SettingsNotice>
|
|
101
116
|
)}
|
|
102
117
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
{!error && (
|
|
119
|
+
<ServerList
|
|
120
|
+
servers={servers}
|
|
121
|
+
layers={layers}
|
|
122
|
+
loading={loading}
|
|
123
|
+
live={live}
|
|
124
|
+
liveLoading={liveLoading}
|
|
125
|
+
onOpen={setEditing}
|
|
126
|
+
onAdd={() => setEditing("")}
|
|
127
|
+
onChanged={refreshAll}
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
113
130
|
|
|
114
131
|
<EditorForEditing
|
|
115
132
|
editing={editing}
|