@blackbelt-technology/pi-dashboard-mcp-client-plugin 0.9.0 → 0.11.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/README.md +1 -1
- package/package.json +9 -4
- package/src/client/FolderMcpPage.tsx +207 -45
- package/src/client/FolderMcpSection.tsx +5 -4
- package/src/client/McpSettings.tsx +56 -39
- package/src/client/ProjectSettings.tsx +217 -0
- package/src/client/ServerEditor.tsx +2 -2
- package/src/client/ServerList.tsx +431 -170
- package/src/client/api.ts +52 -2
- package/src/client/folder-view.ts +30 -8
- package/src/client/hooks.ts +40 -5
- package/src/client/index.tsx +0 -2
- package/src/client/schema.ts +1 -1
- package/src/client/settings-ui.ts +19 -0
- package/src/core/index.ts +8 -66
- package/src/server/index.ts +26 -4
- package/src/server/pi-runner.ts +1 -1
- package/src/server/routes.ts +238 -50
- package/schema/mcp-config.schema.json +0 -54
- package/src/core/config-io.ts +0 -70
- package/src/core/config-writer.ts +0 -407
- package/src/core/effective-view.ts +0 -197
- package/src/core/layers.ts +0 -61
- package/src/core/live-state.ts +0 -134
- package/src/core/path-utils.ts +0 -29
- package/src/core/pi-rules.ts +0 -220
- package/src/core/schema-validation.ts +0 -52
- package/src/core/service.ts +0 -96
- package/src/core/types.ts +0 -200
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ view. Uses pi's BUILT-IN MCP (pi ≥ 1.0.0); no `pi-mcp-adapter`.
|
|
|
11
11
|
|---|---|
|
|
12
12
|
| `.` / `./client` | Settings claim + sidebar/worktree folder MCP section + `/folder/:cwd/mcp` page |
|
|
13
13
|
| `./server` | `registerPlugin` — provides `mcp-client.config`, mounts the REST surface |
|
|
14
|
-
| `./core` |
|
|
14
|
+
| `./core` | DEPRECATED re-export of `@blackbelt-technology/pi-dashboard-mcp-core` (the host-free logic now lives there; kept for one minor) |
|
|
15
15
|
|
|
16
16
|
## Two layers
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackbelt-technology/pi-dashboard-mcp-client-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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
|
+
"keywords": [
|
|
6
|
+
"pi-dashboard-plugin"
|
|
7
|
+
],
|
|
5
8
|
"license": "MIT",
|
|
6
9
|
"publishConfig": {
|
|
7
10
|
"access": "public"
|
|
@@ -32,7 +35,6 @@
|
|
|
32
35
|
},
|
|
33
36
|
"files": [
|
|
34
37
|
"src/",
|
|
35
|
-
"schema/",
|
|
36
38
|
"!**/AGENTS.md",
|
|
37
39
|
"!**/*.AGENTS.md",
|
|
38
40
|
"!**/__tests__",
|
|
@@ -46,8 +48,9 @@
|
|
|
46
48
|
"wouter": ">=3.0.0"
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
|
-
"@blackbelt-technology/dashboard-plugin-runtime": "^0.
|
|
50
|
-
"@blackbelt-technology/pi-dashboard-
|
|
51
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.11.0",
|
|
52
|
+
"@blackbelt-technology/pi-dashboard-mcp-core": "^0.11.0",
|
|
53
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.11.0",
|
|
51
54
|
"@mdi/js": "^7.4.47",
|
|
52
55
|
"@mdi/react": "^1.6.1",
|
|
53
56
|
"ajv": "^8.17.1"
|
|
@@ -72,6 +75,7 @@
|
|
|
72
75
|
{
|
|
73
76
|
"slot": "settings-section",
|
|
74
77
|
"component": "McpSettingsClaim",
|
|
78
|
+
"module": "./src/client/McpSettings.tsx",
|
|
75
79
|
"tab": "general"
|
|
76
80
|
},
|
|
77
81
|
{
|
|
@@ -85,6 +89,7 @@
|
|
|
85
89
|
{
|
|
86
90
|
"slot": "shell-overlay-route",
|
|
87
91
|
"component": "FolderMcpPage",
|
|
92
|
+
"module": "./src/client/FolderMcpPage.tsx",
|
|
88
93
|
"path": "/folder/:encodedCwd/mcp",
|
|
89
94
|
"depth": 2,
|
|
90
95
|
"parentPath": "/folder/:encodedCwd"
|
|
@@ -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";
|
|
23
|
+
import { isProjectOverride } from "@blackbelt-technology/pi-dashboard-mcp-core/pi-rules.js";
|
|
24
|
+
import type { EffectiveServerView, EffectiveView, Provenance, Scope } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
20
25
|
import type React from "react";
|
|
21
26
|
import { useMemo, useState } from "react";
|
|
22
|
-
import
|
|
23
|
-
import { ApiError, removeServer, saveServer, scopeToWire } from "./api.js";
|
|
24
|
-
import { folderOverrideDraftOf, isFolderOwned } from "./folder-view.js";
|
|
27
|
+
import { useLocation } from "wouter";
|
|
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,91 @@ 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
|
+
yolo: "YOLO",
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A live entry's lifetime phrase from the host ("until dashboard restarts",
|
|
98
|
+
* "YOLO until <ISO>", "YOLO while the server runs"), worded for the banner.
|
|
99
|
+
* YOLO's ISO instant renders as the viewer's local time; the "YOLO" prefix is
|
|
100
|
+
* dropped because the sentence already names YOLO.
|
|
101
|
+
*/
|
|
102
|
+
function lifetimePhrase(lifetime: string): string {
|
|
103
|
+
if (lifetime === "until dashboard restarts") return "until the dashboard restarts";
|
|
104
|
+
const yoloUntil = /^YOLO until (.+)$/.exec(lifetime);
|
|
105
|
+
if (yoloUntil) {
|
|
106
|
+
const at = new Date(yoloUntil[1]);
|
|
107
|
+
return Number.isNaN(at.getTime())
|
|
108
|
+
? lifetime
|
|
109
|
+
: `until ${at.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`;
|
|
110
|
+
}
|
|
111
|
+
const yoloOther = /^YOLO (.+)$/.exec(lifetime);
|
|
112
|
+
return yoloOther ? yoloOther[1] : lifetime;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Who trusts this folder, per the host's decision order: pi's trust store (naming
|
|
117
|
+
* the recorded path), the dashboard (naming source + folder, and the scope), or —
|
|
118
|
+
* rendered by `UntrustedNotice` — neither. Reports the FOLDER's decision, not a
|
|
119
|
+
* session's command-line override. See change: mirror-dashboard-trust-to-pi.
|
|
120
|
+
*/
|
|
121
|
+
function TrustBanner({ view }: { view: EffectiveView }): React.ReactElement | null {
|
|
122
|
+
const t = useT();
|
|
123
|
+
const source = view.trustSource;
|
|
124
|
+
if (view.trusted !== true || !source) return null;
|
|
125
|
+
return (
|
|
126
|
+
<div
|
|
127
|
+
data-testid={source.kind === "dashboard" ? "mcp-folder-trusted-dashboard" : "mcp-folder-trusted-pi"}
|
|
128
|
+
role="status"
|
|
129
|
+
className="text-[11px] px-2 py-1.5 rounded border border-[var(--border-secondary)] text-[var(--text-secondary)]"
|
|
130
|
+
>
|
|
131
|
+
{trustText(source, view.trustCoverInteractive === true, t)}
|
|
132
|
+
</div>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** The folder's trust notice: "who trusts it", or the untrusted notice when nobody does. */
|
|
137
|
+
function TrustNotices({ view }: { view: EffectiveView | null }): React.ReactElement | null {
|
|
138
|
+
if (!view) return null;
|
|
139
|
+
return view.trusted === false ? <UntrustedNotice /> : <TrustBanner view={view} />;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function trustText(
|
|
143
|
+
source: NonNullable<EffectiveView["trustSource"]>,
|
|
144
|
+
coverInteractive: boolean,
|
|
145
|
+
t: (key: string, params: undefined, fallback: string) => string,
|
|
146
|
+
): string {
|
|
147
|
+
if (source.kind === "recorded") return `${t("mcpFolderTrustedByPi", undefined, "pi trusts this folder through")} ${source.path}.`;
|
|
148
|
+
if (source.kind === "implicit") {
|
|
149
|
+
return t("mcpFolderTrustedImplicit", undefined, "pi trusts this folder: it has no project resources that need trust.");
|
|
150
|
+
}
|
|
151
|
+
if (source.kind === "default") {
|
|
152
|
+
return t("mcpFolderTrustedDefault", undefined, "pi trusts this folder through its defaultProjectTrust setting.");
|
|
153
|
+
}
|
|
154
|
+
const label = SOURCE_LABEL[source.sourceKind] ?? source.sourceKind;
|
|
155
|
+
const scope = coverInteractive
|
|
156
|
+
? t("mcpFolderTrustedScopeAll", undefined, "This applies to every pi session on this machine.")
|
|
157
|
+
: t("mcpFolderTrustedScopeDashboard", undefined, "This applies to dashboard sessions, not terminal pi.");
|
|
158
|
+
// A live (server-lifetime) entry names its source and how long it lasts.
|
|
159
|
+
const through = source.lifetime
|
|
160
|
+
? `${t("mcpFolderTrustedThrough", undefined, "through")} ${label} ${t("mcpFolderTrustedFor", undefined, "for")} ${source.entry} ${lifetimePhrase(source.lifetime)}`
|
|
161
|
+
: `${label} ${source.entry}`;
|
|
162
|
+
return (
|
|
163
|
+
`${t("mcpFolderTrustedByDashboard", undefined, "This folder is trusted by the dashboard")} ${source.lifetime ? "" : "— "}${through}. ${scope} ` +
|
|
164
|
+
t("mcpFolderTrustedNotChecked", undefined, "Running pi mcp list here, outside the dashboard, still reports its servers as not loaded.")
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
80
168
|
function UntrustedNotice(): React.ReactElement {
|
|
81
169
|
const t = useT();
|
|
170
|
+
const [, navigate] = useLocation();
|
|
82
171
|
return (
|
|
83
172
|
<div
|
|
84
173
|
data-testid="mcp-folder-untrusted"
|
|
@@ -89,7 +178,15 @@ function UntrustedNotice(): React.ReactElement {
|
|
|
89
178
|
"mcpFolderUntrusted",
|
|
90
179
|
undefined,
|
|
91
180
|
"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
|
-
)}
|
|
181
|
+
)}{" "}
|
|
182
|
+
<button
|
|
183
|
+
type="button"
|
|
184
|
+
data-testid="mcp-folder-untrusted-access-link"
|
|
185
|
+
onClick={() => navigate("/settings/access")}
|
|
186
|
+
className="underline text-[var(--accent-text)]"
|
|
187
|
+
>
|
|
188
|
+
{t("mcpFolderOpenAccess", undefined, "Settings → Access")}
|
|
189
|
+
</button>
|
|
93
190
|
</div>
|
|
94
191
|
);
|
|
95
192
|
}
|
|
@@ -104,7 +201,9 @@ interface EditingState {
|
|
|
104
201
|
|
|
105
202
|
interface UndoState {
|
|
106
203
|
name: string;
|
|
204
|
+
/** The exact prior entry: an override (restored via the override route) or a whole entry. */
|
|
107
205
|
removed: Record<string, unknown>;
|
|
206
|
+
message: string;
|
|
108
207
|
}
|
|
109
208
|
|
|
110
209
|
interface ChoiceState {
|
|
@@ -112,12 +211,6 @@ interface ChoiceState {
|
|
|
112
211
|
omitted: string[];
|
|
113
212
|
}
|
|
114
213
|
|
|
115
|
-
interface OmittedNoteState {
|
|
116
|
-
key: string;
|
|
117
|
-
name: string;
|
|
118
|
-
omitted: string[];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
214
|
/** The editor pre-fill for a row: the folder's own entry, or the override copy. */
|
|
122
215
|
function prefillFor(server: { name: string; provenance: Provenance; entry: Record<string, unknown> } | null): EditingState {
|
|
123
216
|
if (server === null) return { name: "", entry: {} };
|
|
@@ -131,7 +224,7 @@ interface FolderActions {
|
|
|
131
224
|
editing: EditingState | null;
|
|
132
225
|
undo: UndoState | null;
|
|
133
226
|
choice: ChoiceState | null;
|
|
134
|
-
|
|
227
|
+
projectPanel: string | null;
|
|
135
228
|
actionError: string | null;
|
|
136
229
|
scope: Scope;
|
|
137
230
|
open: (name: string, provenance: Provenance) => void;
|
|
@@ -141,8 +234,12 @@ interface FolderActions {
|
|
|
141
234
|
undoRemove: () => void;
|
|
142
235
|
resolveChoiceRemove: () => void;
|
|
143
236
|
resolveChoiceReenter: () => void;
|
|
237
|
+
resolveChoiceConvert: () => void;
|
|
144
238
|
onNeedsChoice: (row: RowRef, omitted: string[]) => void;
|
|
145
|
-
|
|
239
|
+
openProjectSettings: (name: string) => void;
|
|
240
|
+
closeProjectSettings: () => void;
|
|
241
|
+
reset: (name: string) => void;
|
|
242
|
+
convertLegacy: (name: string) => void;
|
|
146
243
|
refreshed: () => void;
|
|
147
244
|
}
|
|
148
245
|
|
|
@@ -152,10 +249,11 @@ function useFolderActions(
|
|
|
152
249
|
view: EffectiveView | null,
|
|
153
250
|
reload: () => void,
|
|
154
251
|
): FolderActions {
|
|
252
|
+
const t = useT();
|
|
155
253
|
const [editing, setEditing] = useState<EditingState | null>(null);
|
|
156
254
|
const [undo, setUndo] = useState<UndoState | null>(null);
|
|
157
255
|
const [choice, setChoice] = useState<ChoiceState | null>(null);
|
|
158
|
-
const [
|
|
256
|
+
const [projectPanel, setProjectPanel] = useState<string | null>(null);
|
|
159
257
|
const [actionError, setActionError] = useState<string | null>(null);
|
|
160
258
|
const scope = useMemo<Scope>(() => ({ kind: "project", cwd }), [cwd]);
|
|
161
259
|
const refreshed = (): void => {
|
|
@@ -163,13 +261,17 @@ function useFolderActions(
|
|
|
163
261
|
reload();
|
|
164
262
|
};
|
|
165
263
|
|
|
166
|
-
async function removeOverride(name: string): Promise<void> {
|
|
264
|
+
async function removeOverride(name: string, message?: string): Promise<void> {
|
|
167
265
|
setActionError(null);
|
|
168
266
|
try {
|
|
169
267
|
const res = await removeServer(name, scopeToWire(scope));
|
|
170
268
|
setEditing(null);
|
|
171
269
|
setChoice(null);
|
|
172
|
-
setUndo({
|
|
270
|
+
setUndo({
|
|
271
|
+
name,
|
|
272
|
+
removed: res.removed ?? {},
|
|
273
|
+
message: message ?? t("mcpFolderOverrideRemoved", { name }, `Removed folder override for ${name}.`),
|
|
274
|
+
});
|
|
173
275
|
refreshed();
|
|
174
276
|
} catch (e) {
|
|
175
277
|
setActionError(e instanceof ApiError ? e.message : String(e));
|
|
@@ -179,7 +281,13 @@ function useFolderActions(
|
|
|
179
281
|
async function undoRemove(): Promise<void> {
|
|
180
282
|
if (!undo) return;
|
|
181
283
|
try {
|
|
182
|
-
|
|
284
|
+
// An override (no command/url/type) is restored through the override route
|
|
285
|
+
// with its absent keys as `null`; a whole entry goes through the generic PUT.
|
|
286
|
+
if (isProjectOverride(undo.removed)) {
|
|
287
|
+
await setProjectOverride(undo.name, overrideRestorePatch(undo.removed), scopeToWire(scope));
|
|
288
|
+
} else {
|
|
289
|
+
await saveServer(undo.name, { ...scopeToWire(scope), entry: undo.removed });
|
|
290
|
+
}
|
|
183
291
|
setUndo(null);
|
|
184
292
|
refreshed();
|
|
185
293
|
} catch (e) {
|
|
@@ -187,11 +295,28 @@ function useFolderActions(
|
|
|
187
295
|
}
|
|
188
296
|
}
|
|
189
297
|
|
|
298
|
+
async function convertLegacy(name: string): Promise<void> {
|
|
299
|
+
setActionError(null);
|
|
300
|
+
try {
|
|
301
|
+
const res = await convertToOverride(name, scopeToWire(scope));
|
|
302
|
+
setChoice(null);
|
|
303
|
+
// Undo re-PUTs the original copy (a full entry), which replaces the converted override.
|
|
304
|
+
setUndo({
|
|
305
|
+
name,
|
|
306
|
+
removed: res.previous,
|
|
307
|
+
message: t("mcpFolderConverted", { name }, `Converted ${name} to a project override.`),
|
|
308
|
+
});
|
|
309
|
+
refreshed();
|
|
310
|
+
} catch (e) {
|
|
311
|
+
setActionError(e instanceof ApiError ? e.message : String(e));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
190
315
|
return {
|
|
191
316
|
editing,
|
|
192
317
|
undo,
|
|
193
318
|
choice,
|
|
194
|
-
|
|
319
|
+
projectPanel,
|
|
195
320
|
actionError,
|
|
196
321
|
scope,
|
|
197
322
|
open: (name, provenance) => {
|
|
@@ -217,13 +342,20 @@ function useFolderActions(
|
|
|
217
342
|
setChoice(null);
|
|
218
343
|
setEditing(prefillFor(server));
|
|
219
344
|
},
|
|
345
|
+
resolveChoiceConvert: () => {
|
|
346
|
+
if (choice) void convertLegacy(choice.row.name);
|
|
347
|
+
},
|
|
220
348
|
onNeedsChoice: (row, omitted) => setChoice({ row, omitted }),
|
|
221
|
-
|
|
349
|
+
openProjectSettings: (name) => setProjectPanel(name),
|
|
350
|
+
closeProjectSettings: () => setProjectPanel(null),
|
|
351
|
+
reset: (name) =>
|
|
352
|
+
void removeOverride(name, t("mcpFolderResetDone", { name }, `Reset ${name} to Pi global.`)),
|
|
353
|
+
convertLegacy: (name) => void convertLegacy(name),
|
|
222
354
|
refreshed,
|
|
223
355
|
};
|
|
224
356
|
}
|
|
225
357
|
|
|
226
|
-
function UndoToast({
|
|
358
|
+
function UndoToast({ message, onUndo }: { message: string; onUndo: () => void }): React.ReactElement {
|
|
227
359
|
const t = useT();
|
|
228
360
|
return (
|
|
229
361
|
<div
|
|
@@ -231,7 +363,7 @@ function UndoToast({ name, onUndo }: { name: string; onUndo: () => void }): Reac
|
|
|
231
363
|
role="status"
|
|
232
364
|
className="flex items-center gap-2 text-[11px] px-2 py-1.5 rounded border border-[var(--border-secondary)] text-[var(--text-secondary)]"
|
|
233
365
|
>
|
|
234
|
-
<span>{
|
|
366
|
+
<span>{message}</span>
|
|
235
367
|
<button
|
|
236
368
|
type="button"
|
|
237
369
|
onClick={onUndo}
|
|
@@ -250,11 +382,14 @@ function NeedsChoicePanel({
|
|
|
250
382
|
omitted,
|
|
251
383
|
onRemove,
|
|
252
384
|
onReenter,
|
|
385
|
+
onConvert,
|
|
253
386
|
}: {
|
|
254
387
|
name: string;
|
|
255
388
|
omitted: string[];
|
|
256
389
|
onRemove: () => void;
|
|
257
390
|
onReenter: () => void;
|
|
391
|
+
/** Present only for a legacy copy of the global entry. */
|
|
392
|
+
onConvert?: () => void;
|
|
258
393
|
}): React.ReactElement {
|
|
259
394
|
const t = useT();
|
|
260
395
|
return (
|
|
@@ -287,6 +422,16 @@ function NeedsChoicePanel({
|
|
|
287
422
|
>
|
|
288
423
|
{t("mcpChoiceReenter", undefined, "Re-enter omitted values")}
|
|
289
424
|
</button>
|
|
425
|
+
{onConvert && (
|
|
426
|
+
<button
|
|
427
|
+
type="button"
|
|
428
|
+
onClick={onConvert}
|
|
429
|
+
data-testid="mcp-choice-convert"
|
|
430
|
+
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)]"
|
|
431
|
+
>
|
|
432
|
+
{t("mcpChoiceConvert", undefined, "Convert to project override")}
|
|
433
|
+
</button>
|
|
434
|
+
)}
|
|
290
435
|
</div>
|
|
291
436
|
</div>
|
|
292
437
|
);
|
|
@@ -301,12 +446,25 @@ function FolderSummary({ view }: { view: EffectiveView }): React.ReactElement {
|
|
|
301
446
|
{t(
|
|
302
447
|
"mcpFolderSummary",
|
|
303
448
|
{ count: overrides },
|
|
304
|
-
`A folder entry replaces the global entry of the same name as a whole · ${overrides}
|
|
449
|
+
`A folder entry with a command or url replaces the global entry of the same name as a whole · ${overrides} replacement(s)`,
|
|
305
450
|
)}
|
|
306
451
|
</p>
|
|
307
452
|
);
|
|
308
453
|
}
|
|
309
454
|
|
|
455
|
+
/** The global row the settings panel is open on, and whether the pending choice is a legacy copy. */
|
|
456
|
+
function pageDerivations(
|
|
457
|
+
servers: EffectiveServerView[],
|
|
458
|
+
panelName: string | null,
|
|
459
|
+
choiceName: string | null,
|
|
460
|
+
): { panelServer: EffectiveServerView | null; legacyChoice: boolean } {
|
|
461
|
+
const panelServer =
|
|
462
|
+
panelName === null ? null : (servers.find((s) => s.name === panelName && s.provenance === "pi-global") ?? null);
|
|
463
|
+
const legacyChoice =
|
|
464
|
+
choiceName !== null && servers.some((s) => s.name === choiceName && s.provenance === "pi-folder" && s.legacyCopy === true);
|
|
465
|
+
return { panelServer, legacyChoice };
|
|
466
|
+
}
|
|
467
|
+
|
|
310
468
|
function FolderMcpPageBody({ cwd }: { cwd: string }): React.ReactElement {
|
|
311
469
|
const t = useT();
|
|
312
470
|
const { view, loading, error, reload } = useEffectiveConfig(cwd);
|
|
@@ -336,10 +494,11 @@ function FolderMcpPageBody({ cwd }: { cwd: string }): React.ReactElement {
|
|
|
336
494
|
}
|
|
337
495
|
|
|
338
496
|
const servers = view?.servers ?? [];
|
|
497
|
+
const { panelServer, legacyChoice } = pageDerivations(servers, actions.projectPanel, actions.choice?.row.name ?? null);
|
|
339
498
|
|
|
340
499
|
return (
|
|
341
500
|
<div className="space-y-2">
|
|
342
|
-
{view
|
|
501
|
+
<TrustNotices view={view} />
|
|
343
502
|
{actions.actionError && (
|
|
344
503
|
<p
|
|
345
504
|
data-testid="mcp-folder-action-error"
|
|
@@ -349,19 +508,6 @@ function FolderMcpPageBody({ cwd }: { cwd: string }): React.ReactElement {
|
|
|
349
508
|
{actions.actionError}
|
|
350
509
|
</p>
|
|
351
510
|
)}
|
|
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
511
|
|
|
366
512
|
<ServerList
|
|
367
513
|
servers={servers}
|
|
@@ -372,9 +518,13 @@ function FolderMcpPageBody({ cwd }: { cwd: string }): React.ReactElement {
|
|
|
372
518
|
onAdd={actions.openAdd}
|
|
373
519
|
onChanged={actions.refreshed}
|
|
374
520
|
onNeedsChoice={actions.onNeedsChoice}
|
|
375
|
-
onOmitted={actions.onOmitted}
|
|
376
521
|
onRemoveOverride={actions.removeOverride}
|
|
377
522
|
chipsRemovable={!narrow}
|
|
523
|
+
onProjectSettings={actions.openProjectSettings}
|
|
524
|
+
onReset={actions.reset}
|
|
525
|
+
onConvertLegacy={actions.convertLegacy}
|
|
526
|
+
untrusted={view?.trusted === false}
|
|
527
|
+
narrow={narrow}
|
|
378
528
|
/>
|
|
379
529
|
|
|
380
530
|
{actions.choice && (
|
|
@@ -383,10 +533,22 @@ function FolderMcpPageBody({ cwd }: { cwd: string }): React.ReactElement {
|
|
|
383
533
|
omitted={actions.choice.omitted}
|
|
384
534
|
onRemove={actions.resolveChoiceRemove}
|
|
385
535
|
onReenter={actions.resolveChoiceReenter}
|
|
536
|
+
{...(legacyChoice ? { onConvert: actions.resolveChoiceConvert } : {})}
|
|
386
537
|
/>
|
|
387
538
|
)}
|
|
388
539
|
|
|
389
|
-
{actions.undo && <UndoToast
|
|
540
|
+
{actions.undo && <UndoToast message={actions.undo.message} onUndo={actions.undoRemove} />}
|
|
541
|
+
|
|
542
|
+
{panelServer && (
|
|
543
|
+
<ProjectSettingsPanel
|
|
544
|
+
key={panelServer.name}
|
|
545
|
+
server={panelServer}
|
|
546
|
+
scope={actions.scope as Extract<Scope, { kind: "project" }>}
|
|
547
|
+
narrow={narrow}
|
|
548
|
+
onClose={actions.closeProjectSettings}
|
|
549
|
+
onSaved={actions.refreshed}
|
|
550
|
+
/>
|
|
551
|
+
)}
|
|
390
552
|
|
|
391
553
|
{actions.editing && (
|
|
392
554
|
<ServerEditor
|
|
@@ -49,7 +49,7 @@ function ErrorMarker({ name }: { name: string }): React.ReactElement {
|
|
|
49
49
|
data-testid="mcp-folder-pill-error"
|
|
50
50
|
role="img"
|
|
51
51
|
aria-label={name}
|
|
52
|
-
className="text-red-
|
|
52
|
+
className="text-[var(--accent-red-text)] flex-none"
|
|
53
53
|
>
|
|
54
54
|
⚠
|
|
55
55
|
</span>
|
|
@@ -130,7 +130,7 @@ function pillContent(t: Translate, state: PillState): PillContent {
|
|
|
130
130
|
body: (
|
|
131
131
|
<span
|
|
132
132
|
data-testid="mcp-folder-pill-loading"
|
|
133
|
-
className="inline-block h-[15px] w-16 rounded bg-[var(--bg-tertiary
|
|
133
|
+
className="inline-block h-[15px] w-16 rounded bg-[var(--bg-tertiary)] animate-pulse"
|
|
134
134
|
/>
|
|
135
135
|
),
|
|
136
136
|
};
|
|
@@ -160,7 +160,7 @@ function pillContent(t: Translate, state: PillState): PillContent {
|
|
|
160
160
|
{state.off > 0 && (
|
|
161
161
|
<>
|
|
162
162
|
<span className="text-[var(--text-tertiary)]">·</span>
|
|
163
|
-
<span data-testid="mcp-folder-pill-off" className="text-
|
|
163
|
+
<span data-testid="mcp-folder-pill-off" className="text-[var(--accent-orange-text)]">
|
|
164
164
|
{t("mcpFolderOffCount", { count: state.off }, `${state.off} off`)}
|
|
165
165
|
</span>
|
|
166
166
|
</>
|
|
@@ -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}
|