@blackbelt-technology/pi-dashboard-chat-gateway-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 -4
- package/src/client/ChatGatewaySettings.tsx +504 -0
- package/src/client/index.tsx +7 -381
- package/src/client/team-controls-panel.tsx +168 -133
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackbelt-technology/pi-dashboard-chat-gateway-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Inbound chat control plane — drive dashboard pi sessions from a chat platform (Discord shipped). Extensible adapter layer; no bridge or server protocol change.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
{
|
|
56
56
|
"slot": "settings-section",
|
|
57
57
|
"component": "ChatGatewaySettings",
|
|
58
|
+
"module": "./src/client/ChatGatewaySettings.tsx",
|
|
58
59
|
"config": {
|
|
59
60
|
"tab": "general"
|
|
60
61
|
}
|
|
@@ -67,9 +68,9 @@
|
|
|
67
68
|
"react-dom": ">=18.0.0"
|
|
68
69
|
},
|
|
69
70
|
"dependencies": {
|
|
70
|
-
"@blackbelt-technology/dashboard-plugin-runtime": "^0.
|
|
71
|
-
"@blackbelt-technology/pi-dashboard-mcp-server-plugin": "^0.
|
|
72
|
-
"@blackbelt-technology/pi-dashboard-shared": "^0.
|
|
71
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.10.0",
|
|
72
|
+
"@blackbelt-technology/pi-dashboard-mcp-server-plugin": "^0.10.0",
|
|
73
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.10.0",
|
|
73
74
|
"discord.js": "^14.27.0"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chat-gateway — dashboard plugin client entry (settings-section, task 10.1).
|
|
3
|
+
*
|
|
4
|
+
* Edits the gateway config through the canonical partial-write lane
|
|
5
|
+
* (`plugin_config_write` → `POST /api/config/plugins/chat-gateway`), which
|
|
6
|
+
* shallow-merges. The page buffers its edits into the host Save bar (draft
|
|
7
|
+
* source `plugin:chat-gateway`, no Save button of its own) and commits ONLY the
|
|
8
|
+
* keys the operator edited, so a key it does not own is never overwritten by a
|
|
9
|
+
* stale snapshot.
|
|
10
|
+
*
|
|
11
|
+
* The bot TOKEN is write-only: the draft holds just a "replace token" string,
|
|
12
|
+
* cleared after a commit / Discard / reset, never sent blank, never echoed from
|
|
13
|
+
* the server, and scrubbed out of every error text and "Copy details" payload.
|
|
14
|
+
*
|
|
15
|
+
* The bindings table is read-only and fetched from the plugin's own
|
|
16
|
+
* `/api/chat-gateway/bindings` route (registered only when configured).
|
|
17
|
+
*
|
|
18
|
+
* See change: add-chat-gateway, retro-ux-plugin-settings-wave-2.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
SelectField,
|
|
23
|
+
SettingsGroup,
|
|
24
|
+
SettingsNotice,
|
|
25
|
+
SettingsStatusPill,
|
|
26
|
+
SettingsTable,
|
|
27
|
+
TextAreaField,
|
|
28
|
+
TextField,
|
|
29
|
+
ToggleField,
|
|
30
|
+
useSettingsDraftSource,
|
|
31
|
+
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
32
|
+
import { usePluginConfig, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
33
|
+
import type { SlotProps } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/slot-props.js";
|
|
34
|
+
import type React from "react";
|
|
35
|
+
import { useEffect, useState } from "react";
|
|
36
|
+
import type { Binding, ChatGatewayConfig } from "../shared/types.js";
|
|
37
|
+
import { TeamControlsPanel } from "./team-controls-panel.js";
|
|
38
|
+
|
|
39
|
+
interface BindingsResponse {
|
|
40
|
+
bindings: Binding[];
|
|
41
|
+
status: { running: boolean; boundChannels: number; pendingSpawns: number };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Editable form values, kept as the strings the operator types. */
|
|
45
|
+
interface Draft {
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
threadPerConversation: boolean;
|
|
48
|
+
mirrorDashboardSessions: boolean;
|
|
49
|
+
allowedRoots: string;
|
|
50
|
+
defaultCwd: string;
|
|
51
|
+
fixedMap: string;
|
|
52
|
+
allowlist: string;
|
|
53
|
+
admins: string;
|
|
54
|
+
groupChannels: string;
|
|
55
|
+
steerPrefix: string;
|
|
56
|
+
sessionVisibility: "hidden" | "shown";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const INVALID_FIELDS = "Fix the invalid fields before saving.";
|
|
60
|
+
const SAVE_FAILED = "Couldn't save these settings. Your changes are still here.";
|
|
61
|
+
|
|
62
|
+
function parseList(value: string): string[] {
|
|
63
|
+
return value
|
|
64
|
+
.split(/[\n,]/)
|
|
65
|
+
.map((s) => s.trim())
|
|
66
|
+
.filter((s) => s.length > 0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function parseLines(value: string): string[] {
|
|
70
|
+
return value
|
|
71
|
+
.split("\n")
|
|
72
|
+
.map((s) => s.trim())
|
|
73
|
+
.filter((s) => s.length > 0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function formatFixedMap(map: Record<string, string>): string {
|
|
77
|
+
return Object.entries(map)
|
|
78
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
79
|
+
.join("\n");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Split one `channelKey=cwd` line on its first `=`; `null` when malformed. */
|
|
83
|
+
function splitMapLine(line: string): [string, string] | null {
|
|
84
|
+
const trimmed = line.trim();
|
|
85
|
+
const eq = trimmed.indexOf("=");
|
|
86
|
+
if (eq <= 0) return null;
|
|
87
|
+
const key = trimmed.slice(0, eq).trim();
|
|
88
|
+
const cwd = trimmed.slice(eq + 1).trim();
|
|
89
|
+
return key.length > 0 && cwd.length > 0 ? [key, cwd] : null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** `channelKey=cwd` per line; the first `=` splits (cwd paths may contain none). */
|
|
93
|
+
function parseFixedMap(value: string): Record<string, string> {
|
|
94
|
+
const out: Record<string, string> = {};
|
|
95
|
+
for (const line of value.split("\n")) {
|
|
96
|
+
const pair = splitMapLine(line);
|
|
97
|
+
if (pair) out[pair[0]] = pair[1];
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** 1-based numbers of the non-blank lines that are not `channelKey=folder`. */
|
|
103
|
+
function badMapLines(value: string): number[] {
|
|
104
|
+
const bad: number[] = [];
|
|
105
|
+
value.split("\n").forEach((line, i) => {
|
|
106
|
+
if (line.trim().length > 0 && !splitMapLine(line)) bad.push(i + 1);
|
|
107
|
+
});
|
|
108
|
+
return bad;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function mapLineError(bad: number[]): string | null {
|
|
112
|
+
if (bad.length === 0) return null;
|
|
113
|
+
return bad.length === 1
|
|
114
|
+
? `Line ${bad[0]} is not in the form channelKey=folder, so it would be dropped.`
|
|
115
|
+
: `Lines ${bad.join(", ")} are not in the form channelKey=folder, so they would be dropped.`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Remove every spelling of a secret (raw, trimmed, JSON-escaped, URL-encoded)
|
|
120
|
+
* from text that may be shown or copied. A server error can echo the request.
|
|
121
|
+
*/
|
|
122
|
+
function scrubSecret(text: string, secret: string): string {
|
|
123
|
+
const spellings = new Set<string>();
|
|
124
|
+
for (const s of [secret, secret.trim()]) {
|
|
125
|
+
if (s.length === 0) continue;
|
|
126
|
+
spellings.add(s);
|
|
127
|
+
spellings.add(JSON.stringify(s).slice(1, -1));
|
|
128
|
+
spellings.add(encodeURIComponent(s));
|
|
129
|
+
}
|
|
130
|
+
let out = text;
|
|
131
|
+
for (const s of [...spellings].sort((a, b) => b.length - a.length)) out = out.split(s).join("[token hidden]");
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The saved config as editable form values (defaults mirror the server's). */
|
|
136
|
+
function savedDraft(config: ChatGatewayConfig | undefined): Draft {
|
|
137
|
+
return {
|
|
138
|
+
enabled: config?.enabled ?? true,
|
|
139
|
+
threadPerConversation: config?.threadPerConversation ?? true,
|
|
140
|
+
mirrorDashboardSessions: config?.mirrorDashboardSessions ?? false,
|
|
141
|
+
allowedRoots: (config?.allowedRoots ?? []).join("\n"),
|
|
142
|
+
defaultCwd: config?.defaultCwd ?? "",
|
|
143
|
+
fixedMap: formatFixedMap(config?.fixedMap ?? {}),
|
|
144
|
+
allowlist: (config?.allowlist ?? []).join(", "),
|
|
145
|
+
admins: (config?.admins ?? []).join(", "),
|
|
146
|
+
groupChannels: (config?.groupChannels ?? []).join(", "),
|
|
147
|
+
steerPrefix: config?.steerPrefix ?? "!",
|
|
148
|
+
sessionVisibility: config?.sessionVisibility ?? "hidden",
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Header pill: Not set up (no gateway route yet) · Paused · Running · Not running. */
|
|
153
|
+
function GatewayStatus({ bindings, enabled }: { bindings: BindingsResponse | null; enabled: boolean }): React.ReactElement {
|
|
154
|
+
if (!bindings) {
|
|
155
|
+
return (
|
|
156
|
+
<SettingsStatusPill tone="neutral" status="not-set-up" testId="chat-gateway-status">
|
|
157
|
+
Not set up · add a bot token
|
|
158
|
+
</SettingsStatusPill>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
if (!enabled) {
|
|
162
|
+
return (
|
|
163
|
+
<SettingsStatusPill tone="neutral" icon={null} status="paused" testId="chat-gateway-status">
|
|
164
|
+
Paused
|
|
165
|
+
</SettingsStatusPill>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
return bindings.status.running ? (
|
|
169
|
+
<SettingsStatusPill tone="success" status="running" testId="chat-gateway-status">
|
|
170
|
+
Running
|
|
171
|
+
</SettingsStatusPill>
|
|
172
|
+
) : (
|
|
173
|
+
<SettingsStatusPill tone="warning" status="not-running" testId="chat-gateway-status">
|
|
174
|
+
Not running
|
|
175
|
+
</SettingsStatusPill>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const WIRE: { [K in keyof Draft]: (v: Draft[K]) => unknown } = {
|
|
180
|
+
enabled: (v) => v,
|
|
181
|
+
threadPerConversation: (v) => v,
|
|
182
|
+
mirrorDashboardSessions: (v) => v,
|
|
183
|
+
allowedRoots: parseLines,
|
|
184
|
+
defaultCwd: (v) => v,
|
|
185
|
+
fixedMap: parseFixedMap,
|
|
186
|
+
allowlist: parseList,
|
|
187
|
+
admins: parseList,
|
|
188
|
+
groupChannels: parseList,
|
|
189
|
+
steerPrefix: (v) => v,
|
|
190
|
+
sessionVisibility: (v) => v,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export function ChatGatewaySettings(_props: SlotProps<"settings-section">): React.ReactElement {
|
|
194
|
+
const config = usePluginConfig<ChatGatewayConfig>();
|
|
195
|
+
const send = usePluginSend();
|
|
196
|
+
|
|
197
|
+
// Values this page saved successfully, shown as "saved" until the next
|
|
198
|
+
// `plugin_config_update` replaces them — so a save never flashes the old
|
|
199
|
+
// values back while the broadcast is in flight (or lost).
|
|
200
|
+
const [landed, setLanded] = useState<Partial<Draft>>({});
|
|
201
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: reset on every config broadcast.
|
|
202
|
+
useEffect(() => setLanded({}), [config]);
|
|
203
|
+
const saved: Draft = { ...savedDraft(config), ...landed };
|
|
204
|
+
|
|
205
|
+
// Only the EDITED keys live in `draft`; every other field shows the saved
|
|
206
|
+
// value, so a clean page adopts a `plugin_config_update` broadcast and a dirty
|
|
207
|
+
// page keeps its edited keys while the rest adopt it.
|
|
208
|
+
const [draft, setDraft] = useState<Partial<Draft>>({});
|
|
209
|
+
// Write-only secret: the typed replacement only, never seeded from the server.
|
|
210
|
+
const [token, setToken] = useState("");
|
|
211
|
+
const [busy, setBusy] = useState(false);
|
|
212
|
+
const [notice, setNotice] = useState<{ details: string } | null>(null);
|
|
213
|
+
const [bindings, setBindings] = useState<BindingsResponse | null>(null);
|
|
214
|
+
const [refreshKey, setRefreshKey] = useState(0);
|
|
215
|
+
|
|
216
|
+
// Drop draft keys the stored config now matches (our own save landing, or
|
|
217
|
+
// another writer saving the same value), so a later broadcast never turns a
|
|
218
|
+
// stale draft key into a ghost edit. Keyed on `config`: `saved` is derived.
|
|
219
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: `saved` derives from `config` + `landed`.
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
setDraft((d) => {
|
|
222
|
+
const stale = (Object.keys(d) as Array<keyof Draft>).filter((k) => d[k] === saved[k]);
|
|
223
|
+
if (stale.length === 0) return d;
|
|
224
|
+
const next = { ...d };
|
|
225
|
+
for (const k of stale) delete next[k];
|
|
226
|
+
return next;
|
|
227
|
+
});
|
|
228
|
+
}, [config, landed]);
|
|
229
|
+
|
|
230
|
+
const value: Draft = { ...saved, ...draft };
|
|
231
|
+
const editedKeys = (Object.keys(draft) as Array<keyof Draft>).filter((k) => draft[k] !== saved[k]);
|
|
232
|
+
const tokenTyped = token.trim().length > 0;
|
|
233
|
+
const isDirty = editedKeys.length > 0 || tokenTyped;
|
|
234
|
+
|
|
235
|
+
const mapError = mapLineError(badMapLines(value.fixedMap));
|
|
236
|
+
const noAllowedFolders = parseLines(value.allowedRoots).length === 0;
|
|
237
|
+
|
|
238
|
+
function edit<K extends keyof Draft>(key: K) {
|
|
239
|
+
return (v: Draft[K]) => {
|
|
240
|
+
setNotice(null);
|
|
241
|
+
setDraft((d) => {
|
|
242
|
+
const next = { ...d };
|
|
243
|
+
if (v === saved[key]) delete next[key];
|
|
244
|
+
else next[key] = v;
|
|
245
|
+
return next;
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// `refreshKey` re-reads the bindings after a successful commit.
|
|
251
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: refetch trigger only.
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
let cancelled = false;
|
|
254
|
+
void (async () => {
|
|
255
|
+
try {
|
|
256
|
+
const res = await fetch("/api/chat-gateway/bindings");
|
|
257
|
+
if (!res.ok) return;
|
|
258
|
+
const body = (await res.json()) as BindingsResponse;
|
|
259
|
+
if (!cancelled) setBindings(body);
|
|
260
|
+
} catch {
|
|
261
|
+
/* unavailable until configured — leave the table hidden */
|
|
262
|
+
}
|
|
263
|
+
})();
|
|
264
|
+
return () => {
|
|
265
|
+
cancelled = true;
|
|
266
|
+
};
|
|
267
|
+
}, [refreshKey]);
|
|
268
|
+
|
|
269
|
+
async function commit(): Promise<void> {
|
|
270
|
+
if (mapError) throw new Error(INVALID_FIELDS);
|
|
271
|
+
const partial: Record<string, unknown> = {};
|
|
272
|
+
for (const key of editedKeys) partial[key] = (WIRE[key] as (v: unknown) => unknown)(value[key]);
|
|
273
|
+
// A blank token means "keep the stored secret" — never send it, so a save
|
|
274
|
+
// cannot erase the token by omission-through-the-form.
|
|
275
|
+
if (tokenTyped) partial.token = token.trim();
|
|
276
|
+
if (Object.keys(partial).length === 0) return;
|
|
277
|
+
setBusy(true);
|
|
278
|
+
try {
|
|
279
|
+
await send({ type: "plugin_config_write", id: "chat-gateway", config: partial });
|
|
280
|
+
} catch (err) {
|
|
281
|
+
const raw = err instanceof Error ? err.message : String(err);
|
|
282
|
+
setNotice({ details: scrubSecret(raw, token) });
|
|
283
|
+
// The host shows this message: a sentence, never the raw server text.
|
|
284
|
+
throw new Error(SAVE_FAILED);
|
|
285
|
+
} finally {
|
|
286
|
+
setBusy(false);
|
|
287
|
+
}
|
|
288
|
+
// Keep what was typed while the save was in flight: clear the token only if
|
|
289
|
+
// it is still the one sent, and leave edited keys to the prune effect above,
|
|
290
|
+
// which drops each once the stored config matches it (no revert-to-old flash).
|
|
291
|
+
const sentToken = partial.token;
|
|
292
|
+
setToken((t) => (t.trim() === sentToken ? "" : t));
|
|
293
|
+
const sent: Partial<Draft> = {};
|
|
294
|
+
for (const key of editedKeys) (sent as Record<string, unknown>)[key] = value[key];
|
|
295
|
+
setLanded((l) => ({ ...l, ...sent }));
|
|
296
|
+
setNotice(null);
|
|
297
|
+
setRefreshKey((k) => k + 1);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function reset(): void {
|
|
301
|
+
setToken("");
|
|
302
|
+
setDraft({});
|
|
303
|
+
setNotice(null);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
useSettingsDraftSource({ id: "plugin:chat-gateway", isDirty, commit, reset });
|
|
307
|
+
|
|
308
|
+
const configured = bindings !== null;
|
|
309
|
+
return (
|
|
310
|
+
<div className="space-y-3" data-testid="chat-gateway-settings">
|
|
311
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
312
|
+
<GatewayStatus bindings={bindings} enabled={saved.enabled} />
|
|
313
|
+
</div>
|
|
314
|
+
<p className="text-xs text-[var(--text-secondary)]">Drive dashboard sessions from Discord.</p>
|
|
315
|
+
|
|
316
|
+
{notice && (
|
|
317
|
+
<SettingsNotice
|
|
318
|
+
tone="error"
|
|
319
|
+
testId="chat-gateway-notice"
|
|
320
|
+
onRetry={() => void commit().catch(() => {})}
|
|
321
|
+
retrying={busy}
|
|
322
|
+
details={notice.details}
|
|
323
|
+
>
|
|
324
|
+
{SAVE_FAILED}
|
|
325
|
+
</SettingsNotice>
|
|
326
|
+
)}
|
|
327
|
+
|
|
328
|
+
<SettingsGroup title="Discord connection" testId="chat-gateway-group-connection">
|
|
329
|
+
<ToggleField
|
|
330
|
+
label="Answer Discord messages"
|
|
331
|
+
hint="Turn off to pause the gateway without losing its settings."
|
|
332
|
+
value={value.enabled}
|
|
333
|
+
onChange={edit("enabled")}
|
|
334
|
+
testIds={{ control: "chat-gateway-enabled" }}
|
|
335
|
+
/>
|
|
336
|
+
<TextField
|
|
337
|
+
label="Bot token"
|
|
338
|
+
type="password"
|
|
339
|
+
autoComplete="off"
|
|
340
|
+
hint={
|
|
341
|
+
configured
|
|
342
|
+
? "A token is saved. Paste a new one to replace it."
|
|
343
|
+
: "Create a bot in the Discord developer portal and paste its token. Without it the gateway does nothing."
|
|
344
|
+
}
|
|
345
|
+
placeholder={configured ? "•••••••• saved" : "Paste bot token"}
|
|
346
|
+
value={token}
|
|
347
|
+
onChange={(v) => {
|
|
348
|
+
setNotice(null);
|
|
349
|
+
setToken(v);
|
|
350
|
+
}}
|
|
351
|
+
testIds={{ control: "chat-gateway-token" }}
|
|
352
|
+
/>
|
|
353
|
+
</SettingsGroup>
|
|
354
|
+
|
|
355
|
+
<SettingsGroup title="Where sessions run" testId="chat-gateway-group-where">
|
|
356
|
+
{noAllowedFolders && (
|
|
357
|
+
<SettingsNotice tone="warning" testId="chat-gateway-allowed-roots-warning">
|
|
358
|
+
No allowed folders yet, so no session can start. Add at least one folder.
|
|
359
|
+
</SettingsNotice>
|
|
360
|
+
)}
|
|
361
|
+
<TextAreaField
|
|
362
|
+
label="Allowed folders"
|
|
363
|
+
hint="One folder per line. Every new session's folder must be inside one of these. Required."
|
|
364
|
+
placeholder="/Users/you/Projects"
|
|
365
|
+
rows={3}
|
|
366
|
+
mono
|
|
367
|
+
value={value.allowedRoots}
|
|
368
|
+
onChange={edit("allowedRoots")}
|
|
369
|
+
testIds={{ control: "chat-gateway-allowed-roots" }}
|
|
370
|
+
/>
|
|
371
|
+
<TextField
|
|
372
|
+
label="Default folder"
|
|
373
|
+
hint="Used when a channel has no folder below. Must be inside an allowed folder."
|
|
374
|
+
placeholder="/Users/you/Projects/app"
|
|
375
|
+
mono
|
|
376
|
+
value={value.defaultCwd}
|
|
377
|
+
onChange={edit("defaultCwd")}
|
|
378
|
+
testIds={{ control: "chat-gateway-default-cwd" }}
|
|
379
|
+
/>
|
|
380
|
+
<TextAreaField
|
|
381
|
+
label="Channel folders"
|
|
382
|
+
hint={
|
|
383
|
+
<>
|
|
384
|
+
One <code>channelKey=folder</code> per line. Pins a channel to a folder.
|
|
385
|
+
</>
|
|
386
|
+
}
|
|
387
|
+
placeholder="discord:123456789:-=/repos/proj"
|
|
388
|
+
rows={3}
|
|
389
|
+
mono
|
|
390
|
+
value={value.fixedMap}
|
|
391
|
+
onChange={edit("fixedMap")}
|
|
392
|
+
error={mapError}
|
|
393
|
+
testIds={{ control: "chat-gateway-fixed-map", error: "chat-gateway-fixed-map-error" }}
|
|
394
|
+
/>
|
|
395
|
+
</SettingsGroup>
|
|
396
|
+
|
|
397
|
+
<SettingsGroup title="Who can use it" defaultOpen={false} testId="chat-gateway-group-access">
|
|
398
|
+
<TextField
|
|
399
|
+
label="Allowed users"
|
|
400
|
+
hint="Discord user ids, comma-separated. They can talk to sessions in direct messages."
|
|
401
|
+
placeholder="123456789012345678"
|
|
402
|
+
mono
|
|
403
|
+
value={value.allowlist}
|
|
404
|
+
onChange={edit("allowlist")}
|
|
405
|
+
testIds={{ control: "chat-gateway-allowlist" }}
|
|
406
|
+
/>
|
|
407
|
+
<TextField
|
|
408
|
+
label="Admins"
|
|
409
|
+
hint="Can also bind channels to sessions."
|
|
410
|
+
mono
|
|
411
|
+
value={value.admins}
|
|
412
|
+
onChange={edit("admins")}
|
|
413
|
+
testIds={{ control: "chat-gateway-admins" }}
|
|
414
|
+
/>
|
|
415
|
+
<TextField
|
|
416
|
+
label="Group channels"
|
|
417
|
+
hint="Channel ids where the bot answers everyone, not only allowed users."
|
|
418
|
+
mono
|
|
419
|
+
value={value.groupChannels}
|
|
420
|
+
onChange={edit("groupChannels")}
|
|
421
|
+
testIds={{ control: "chat-gateway-group-channels" }}
|
|
422
|
+
/>
|
|
423
|
+
</SettingsGroup>
|
|
424
|
+
|
|
425
|
+
<SettingsGroup title="Behaviour" defaultOpen={false} testId="chat-gateway-group-behaviour">
|
|
426
|
+
<ToggleField
|
|
427
|
+
label="New thread per conversation"
|
|
428
|
+
hint="A new channel message starts a new thread and a new session."
|
|
429
|
+
value={value.threadPerConversation}
|
|
430
|
+
onChange={edit("threadPerConversation")}
|
|
431
|
+
testIds={{ control: "chat-gateway-thread-per-conversation" }}
|
|
432
|
+
/>
|
|
433
|
+
<ToggleField
|
|
434
|
+
label="Mirror dashboard sessions"
|
|
435
|
+
hint="Every dashboard session gets its own Discord thread and sends its activity there."
|
|
436
|
+
value={value.mirrorDashboardSessions}
|
|
437
|
+
onChange={edit("mirrorDashboardSessions")}
|
|
438
|
+
testIds={{ control: "chat-gateway-mirror-dashboard-sessions" }}
|
|
439
|
+
/>
|
|
440
|
+
<TextField
|
|
441
|
+
label="Steer prefix"
|
|
442
|
+
hint="Start a message with this to interrupt a running turn."
|
|
443
|
+
mono
|
|
444
|
+
value={value.steerPrefix}
|
|
445
|
+
onChange={edit("steerPrefix")}
|
|
446
|
+
testIds={{ control: "chat-gateway-steer-prefix" }}
|
|
447
|
+
/>
|
|
448
|
+
<SelectField
|
|
449
|
+
label="Chat sessions on the board"
|
|
450
|
+
hint="Hidden sessions appear when “Show hidden” is on."
|
|
451
|
+
value={value.sessionVisibility}
|
|
452
|
+
options={[
|
|
453
|
+
{ value: "hidden", label: "Hidden" },
|
|
454
|
+
{ value: "shown", label: "Shown" },
|
|
455
|
+
]}
|
|
456
|
+
onChange={(v) => edit("sessionVisibility")(v as Draft["sessionVisibility"])}
|
|
457
|
+
testIds={{ control: "chat-gateway-session-visibility" }}
|
|
458
|
+
/>
|
|
459
|
+
</SettingsGroup>
|
|
460
|
+
|
|
461
|
+
<SettingsNotice tone="info" testId="chat-gateway-pairing-hint">
|
|
462
|
+
Pairing: a direct message from an unknown user is accepted only when it contains the current pairing
|
|
463
|
+
code. The code is printed in the server log when the gateway starts.
|
|
464
|
+
</SettingsNotice>
|
|
465
|
+
|
|
466
|
+
<SettingsGroup
|
|
467
|
+
title="Bound channels"
|
|
468
|
+
meta={bindings && bindings.bindings.length > 0 ? String(bindings.bindings.length) : undefined}
|
|
469
|
+
testId="chat-gateway-group-bindings"
|
|
470
|
+
>
|
|
471
|
+
{bindings && bindings.bindings.length > 0 ? (
|
|
472
|
+
<SettingsTable
|
|
473
|
+
testId="chat-gateway-bindings"
|
|
474
|
+
caption="Bound channels"
|
|
475
|
+
columns={["Channel", "Session", "Folder", "Source"]}
|
|
476
|
+
rows={bindings.bindings.map((b) => ({
|
|
477
|
+
key: `${b.platform}:${b.channelId}:${b.threadId ?? "-"}`,
|
|
478
|
+
cells: [
|
|
479
|
+
<span key="c" className="break-all">
|
|
480
|
+
{b.channelId}
|
|
481
|
+
</span>,
|
|
482
|
+
<span key="s" className="break-all">
|
|
483
|
+
{b.sessionId}
|
|
484
|
+
</span>,
|
|
485
|
+
<code key="f" className="break-all">
|
|
486
|
+
{b.cwd}
|
|
487
|
+
</code>,
|
|
488
|
+
b.source,
|
|
489
|
+
],
|
|
490
|
+
}))}
|
|
491
|
+
/>
|
|
492
|
+
) : (
|
|
493
|
+
<p data-testid="chat-gateway-bindings-empty" className="text-xs text-[var(--text-secondary)]">
|
|
494
|
+
{bindings
|
|
495
|
+
? "No channels are bound yet. They appear here once the gateway is running."
|
|
496
|
+
: "Bound channels appear here once the gateway is set up and running."}
|
|
497
|
+
</p>
|
|
498
|
+
)}
|
|
499
|
+
</SettingsGroup>
|
|
500
|
+
|
|
501
|
+
<TeamControlsPanel />
|
|
502
|
+
</div>
|
|
503
|
+
);
|
|
504
|
+
}
|
package/src/client/index.tsx
CHANGED
|
@@ -1,385 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* chat-gateway
|
|
2
|
+
* chat-gateway · CLIENT entry (intentionally empty).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The only claim — the `ChatGatewaySettings` settings-section — loads lazily
|
|
5
|
+
* from `./ChatGatewaySettings.tsx` via the manifest `module` field. Do NOT
|
|
6
|
+
* re-export it here: the registry generator rejects a main entry that also
|
|
7
|
+
* exports a lazy component.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* `/api/chat-gateway/bindings` route (registered only when configured).
|
|
11
|
-
*
|
|
12
|
-
* See change: add-chat-gateway.
|
|
9
|
+
* See change: lazy-plugin-claim-modules.
|
|
13
10
|
*/
|
|
14
|
-
|
|
15
|
-
import { usePluginConfig, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
16
|
-
import type { SlotProps } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/slot-props.js";
|
|
17
|
-
import type React from "react";
|
|
18
|
-
import { useEffect, useRef, useState } from "react";
|
|
19
|
-
import type { Binding, ChatGatewayConfig } from "../shared/types.js";
|
|
20
|
-
import { TeamControlsPanel } from "./team-controls-panel.js";
|
|
21
|
-
|
|
22
|
-
interface BindingsResponse {
|
|
23
|
-
bindings: Binding[];
|
|
24
|
-
status: { running: boolean; boundChannels: number; pendingSpawns: number };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function parseList(value: string): string[] {
|
|
28
|
-
return value
|
|
29
|
-
.split(/[\n,]/)
|
|
30
|
-
.map((s) => s.trim())
|
|
31
|
-
.filter((s) => s.length > 0);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function parseLines(value: string): string[] {
|
|
35
|
-
return value
|
|
36
|
-
.split("\n")
|
|
37
|
-
.map((s) => s.trim())
|
|
38
|
-
.filter((s) => s.length > 0);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function formatFixedMap(map: Record<string, string>): string {
|
|
42
|
-
return Object.entries(map)
|
|
43
|
-
.map(([k, v]) => `${k}=${v}`)
|
|
44
|
-
.join("\n");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** `channelKey=cwd` per line; the first `=` splits (cwd paths may contain none). */
|
|
48
|
-
function parseFixedMap(value: string): Record<string, string> {
|
|
49
|
-
const out: Record<string, string> = {};
|
|
50
|
-
for (const line of value.split("\n")) {
|
|
51
|
-
const trimmed = line.trim();
|
|
52
|
-
if (trimmed.length === 0) continue;
|
|
53
|
-
const eq = trimmed.indexOf("=");
|
|
54
|
-
if (eq <= 0) continue;
|
|
55
|
-
const key = trimmed.slice(0, eq).trim();
|
|
56
|
-
const cwd = trimmed.slice(eq + 1).trim();
|
|
57
|
-
if (key.length > 0 && cwd.length > 0) out[key] = cwd;
|
|
58
|
-
}
|
|
59
|
-
return out;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function ChatGatewaySettings(_props: SlotProps<"settings-section">): React.ReactElement {
|
|
63
|
-
const config = usePluginConfig<ChatGatewayConfig>();
|
|
64
|
-
const send = usePluginSend();
|
|
65
|
-
|
|
66
|
-
const [enabled, setEnabled] = useState(config?.enabled ?? true);
|
|
67
|
-
const [threadPerConversation, setThreadPerConversation] = useState(
|
|
68
|
-
config?.threadPerConversation ?? true,
|
|
69
|
-
);
|
|
70
|
-
const [mirrorDashboardSessions, setMirrorDashboardSessions] = useState(
|
|
71
|
-
config?.mirrorDashboardSessions ?? false,
|
|
72
|
-
);
|
|
73
|
-
const [token, setToken] = useState("");
|
|
74
|
-
const [allowedRoots, setAllowedRoots] = useState("");
|
|
75
|
-
const [defaultCwd, setDefaultCwd] = useState("");
|
|
76
|
-
const [fixedMap, setFixedMap] = useState("");
|
|
77
|
-
const [allowlist, setAllowlist] = useState("");
|
|
78
|
-
const [admins, setAdmins] = useState("");
|
|
79
|
-
const [groupChannels, setGroupChannels] = useState("");
|
|
80
|
-
const [steerPrefix, setSteerPrefix] = useState(config?.steerPrefix ?? "!");
|
|
81
|
-
const [sessionVisibility, setSessionVisibility] = useState<"hidden" | "shown">(
|
|
82
|
-
config?.sessionVisibility ?? "hidden",
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const [busy, setBusy] = useState(false);
|
|
86
|
-
const [notice, setNotice] = useState<{ kind: "ok" | "error"; text: string } | null>(null);
|
|
87
|
-
const [bindings, setBindings] = useState<BindingsResponse | null>(null);
|
|
88
|
-
|
|
89
|
-
// Once the user edits a field, stop mirroring late-hydrating config for THAT
|
|
90
|
-
// field only, so their typing is never clobbered while the other fields still
|
|
91
|
-
// fill in. A successful save clears the set and re-mirrors everything. A
|
|
92
|
-
// single global flag would leave untouched fields at their defaults and the
|
|
93
|
-
// next save would erase the hydrated values.
|
|
94
|
-
const dirtyFields = useRef<Set<string>>(new Set());
|
|
95
|
-
|
|
96
|
-
const saved = {
|
|
97
|
-
enabled: config?.enabled ?? true,
|
|
98
|
-
threadPerConversation: config?.threadPerConversation ?? true,
|
|
99
|
-
mirrorDashboardSessions: config?.mirrorDashboardSessions ?? false,
|
|
100
|
-
allowedRoots: (config?.allowedRoots ?? []).join("\n"),
|
|
101
|
-
defaultCwd: config?.defaultCwd ?? "",
|
|
102
|
-
fixedMap: formatFixedMap(config?.fixedMap ?? {}),
|
|
103
|
-
allowlist: (config?.allowlist ?? []).join(", "),
|
|
104
|
-
admins: (config?.admins ?? []).join(", "),
|
|
105
|
-
groupChannels: (config?.groupChannels ?? []).join(", "),
|
|
106
|
-
steerPrefix: config?.steerPrefix ?? "!",
|
|
107
|
-
sessionVisibility: config?.sessionVisibility ?? "hidden",
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const savedKey = JSON.stringify(saved);
|
|
111
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: mirror on the serialized snapshot only.
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
const d = dirtyFields.current;
|
|
114
|
-
if (!d.has("enabled")) setEnabled(saved.enabled);
|
|
115
|
-
if (!d.has("threadPerConversation")) setThreadPerConversation(saved.threadPerConversation);
|
|
116
|
-
if (!d.has("mirrorDashboardSessions")) setMirrorDashboardSessions(saved.mirrorDashboardSessions);
|
|
117
|
-
if (!d.has("allowedRoots")) setAllowedRoots(saved.allowedRoots);
|
|
118
|
-
if (!d.has("defaultCwd")) setDefaultCwd(saved.defaultCwd);
|
|
119
|
-
if (!d.has("fixedMap")) setFixedMap(saved.fixedMap);
|
|
120
|
-
if (!d.has("allowlist")) setAllowlist(saved.allowlist);
|
|
121
|
-
if (!d.has("admins")) setAdmins(saved.admins);
|
|
122
|
-
if (!d.has("groupChannels")) setGroupChannels(saved.groupChannels);
|
|
123
|
-
if (!d.has("steerPrefix")) setSteerPrefix(saved.steerPrefix);
|
|
124
|
-
if (!d.has("sessionVisibility")) setSessionVisibility(saved.sessionVisibility);
|
|
125
|
-
}, [savedKey]);
|
|
126
|
-
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
let cancelled = false;
|
|
129
|
-
void (async () => {
|
|
130
|
-
try {
|
|
131
|
-
const res = await fetch("/api/chat-gateway/bindings");
|
|
132
|
-
if (!res.ok) return;
|
|
133
|
-
const body = (await res.json()) as BindingsResponse;
|
|
134
|
-
if (!cancelled) setBindings(body);
|
|
135
|
-
} catch {
|
|
136
|
-
/* unavailable until configured — leave the table hidden */
|
|
137
|
-
}
|
|
138
|
-
})();
|
|
139
|
-
return () => {
|
|
140
|
-
cancelled = true;
|
|
141
|
-
};
|
|
142
|
-
}, [notice]);
|
|
143
|
-
|
|
144
|
-
function markDirty<T>(field: string, setter: (v: T) => void) {
|
|
145
|
-
return (value: T) => {
|
|
146
|
-
dirtyFields.current.add(field);
|
|
147
|
-
setter(value);
|
|
148
|
-
setNotice(null);
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async function save(): Promise<void> {
|
|
153
|
-
setBusy(true);
|
|
154
|
-
setNotice(null);
|
|
155
|
-
try {
|
|
156
|
-
const partial: Record<string, unknown> = {
|
|
157
|
-
enabled,
|
|
158
|
-
threadPerConversation,
|
|
159
|
-
mirrorDashboardSessions,
|
|
160
|
-
allowedRoots: parseLines(allowedRoots),
|
|
161
|
-
defaultCwd,
|
|
162
|
-
fixedMap: parseFixedMap(fixedMap),
|
|
163
|
-
allowlist: parseList(allowlist),
|
|
164
|
-
admins: parseList(admins),
|
|
165
|
-
groupChannels: parseList(groupChannels),
|
|
166
|
-
steerPrefix,
|
|
167
|
-
sessionVisibility,
|
|
168
|
-
};
|
|
169
|
-
// A blank token means "keep the stored secret" — never send it, so a
|
|
170
|
-
// save cannot erase the token by omission-through-the-form.
|
|
171
|
-
if (token.trim().length > 0) partial.token = token.trim();
|
|
172
|
-
await send({ type: "plugin_config_write", id: "chat-gateway", config: partial });
|
|
173
|
-
setToken("");
|
|
174
|
-
dirtyFields.current.clear();
|
|
175
|
-
setNotice({ kind: "ok", text: "Saved." });
|
|
176
|
-
} catch (err) {
|
|
177
|
-
setNotice({ kind: "error", text: err instanceof Error ? err.message : String(err) });
|
|
178
|
-
} finally {
|
|
179
|
-
setBusy(false);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const field = "w-full px-2 py-1 rounded border border-[var(--border-secondary)] bg-[var(--bg-primary)] text-xs";
|
|
184
|
-
const label = "block text-[11px] text-[var(--text-secondary)] mb-0.5";
|
|
185
|
-
|
|
186
|
-
return (
|
|
187
|
-
<div className="space-y-3" data-testid="chat-gateway-settings">
|
|
188
|
-
<p className="text-xs text-[var(--text-secondary)]">
|
|
189
|
-
Drive dashboard pi sessions from Discord. Inert until a bot token is set; every
|
|
190
|
-
new session's cwd must be inside <code>allowedRoots</code>.
|
|
191
|
-
</p>
|
|
192
|
-
|
|
193
|
-
<label className="flex items-center gap-2 text-xs text-[var(--text-secondary)]">
|
|
194
|
-
<input
|
|
195
|
-
type="checkbox"
|
|
196
|
-
data-testid="chat-gateway-enabled"
|
|
197
|
-
checked={enabled}
|
|
198
|
-
onChange={(e) => markDirty("enabled", setEnabled)(e.target.checked)}
|
|
199
|
-
/>
|
|
200
|
-
Enabled
|
|
201
|
-
</label>
|
|
202
|
-
|
|
203
|
-
<label className="flex items-center gap-2 text-xs text-[var(--text-secondary)]">
|
|
204
|
-
<input
|
|
205
|
-
type="checkbox"
|
|
206
|
-
data-testid="chat-gateway-thread-per-conversation"
|
|
207
|
-
checked={threadPerConversation}
|
|
208
|
-
onChange={(e) => markDirty("threadPerConversation", setThreadPerConversation)(e.target.checked)}
|
|
209
|
-
/>
|
|
210
|
-
One thread per conversation (new channel message → new thread + session)
|
|
211
|
-
</label>
|
|
212
|
-
|
|
213
|
-
<label className="flex items-center gap-2 text-xs text-[var(--text-secondary)]">
|
|
214
|
-
<input
|
|
215
|
-
type="checkbox"
|
|
216
|
-
data-testid="chat-gateway-mirror-dashboard-sessions"
|
|
217
|
-
checked={mirrorDashboardSessions}
|
|
218
|
-
onChange={(e) => markDirty("mirrorDashboardSessions", setMirrorDashboardSessions)(e.target.checked)}
|
|
219
|
-
/>
|
|
220
|
-
Show dashboard sessions on Discord (one thread each; sends their activity to Discord)
|
|
221
|
-
</label>
|
|
222
|
-
|
|
223
|
-
<div>
|
|
224
|
-
<span className={label}>Discord bot token</span>
|
|
225
|
-
<input
|
|
226
|
-
type="password"
|
|
227
|
-
autoComplete="off"
|
|
228
|
-
data-testid="chat-gateway-token"
|
|
229
|
-
value={token}
|
|
230
|
-
placeholder="Leave blank to keep the current token"
|
|
231
|
-
onChange={(e) => markDirty("token", setToken)(e.target.value)}
|
|
232
|
-
className={field}
|
|
233
|
-
/>
|
|
234
|
-
</div>
|
|
235
|
-
|
|
236
|
-
<div>
|
|
237
|
-
<span className={label}>allowedRoots (one path per line — mandatory)</span>
|
|
238
|
-
<textarea
|
|
239
|
-
data-testid="chat-gateway-allowed-roots"
|
|
240
|
-
value={allowedRoots}
|
|
241
|
-
rows={3}
|
|
242
|
-
onChange={(e) => markDirty("allowedRoots", setAllowedRoots)(e.target.value)}
|
|
243
|
-
className={field}
|
|
244
|
-
/>
|
|
245
|
-
</div>
|
|
246
|
-
|
|
247
|
-
<div>
|
|
248
|
-
<span className={label}>Default cwd (still gated by allowedRoots)</span>
|
|
249
|
-
<input
|
|
250
|
-
data-testid="chat-gateway-default-cwd"
|
|
251
|
-
value={defaultCwd}
|
|
252
|
-
onChange={(e) => markDirty("defaultCwd", setDefaultCwd)(e.target.value)}
|
|
253
|
-
className={field}
|
|
254
|
-
/>
|
|
255
|
-
</div>
|
|
256
|
-
|
|
257
|
-
<div>
|
|
258
|
-
<span className={label}>Fixed map — one <code>channelKey=cwd</code> per line</span>
|
|
259
|
-
<textarea
|
|
260
|
-
data-testid="chat-gateway-fixed-map"
|
|
261
|
-
value={fixedMap}
|
|
262
|
-
rows={3}
|
|
263
|
-
placeholder="discord:123456789:-=/repos/proj"
|
|
264
|
-
onChange={(e) => markDirty("fixedMap", setFixedMap)(e.target.value)}
|
|
265
|
-
className={field}
|
|
266
|
-
/>
|
|
267
|
-
</div>
|
|
268
|
-
|
|
269
|
-
<div className="grid grid-cols-1 gap-2 sm:grid-cols-3">
|
|
270
|
-
<div>
|
|
271
|
-
<span className={label}>Allowlist (L1 users)</span>
|
|
272
|
-
<input
|
|
273
|
-
data-testid="chat-gateway-allowlist"
|
|
274
|
-
value={allowlist}
|
|
275
|
-
onChange={(e) => markDirty("allowlist", setAllowlist)(e.target.value)}
|
|
276
|
-
className={field}
|
|
277
|
-
/>
|
|
278
|
-
</div>
|
|
279
|
-
<div>
|
|
280
|
-
<span className={label}>Admins (L2 bind)</span>
|
|
281
|
-
<input
|
|
282
|
-
data-testid="chat-gateway-admins"
|
|
283
|
-
value={admins}
|
|
284
|
-
onChange={(e) => markDirty("admins", setAdmins)(e.target.value)}
|
|
285
|
-
className={field}
|
|
286
|
-
/>
|
|
287
|
-
</div>
|
|
288
|
-
<div>
|
|
289
|
-
<span className={label}>Group channels (L4 opt-in)</span>
|
|
290
|
-
<input
|
|
291
|
-
data-testid="chat-gateway-group-channels"
|
|
292
|
-
value={groupChannels}
|
|
293
|
-
onChange={(e) => markDirty("groupChannels", setGroupChannels)(e.target.value)}
|
|
294
|
-
className={field}
|
|
295
|
-
/>
|
|
296
|
-
</div>
|
|
297
|
-
</div>
|
|
298
|
-
|
|
299
|
-
<div>
|
|
300
|
-
<span className={label}>Steer prefix (mid-turn override)</span>
|
|
301
|
-
<input
|
|
302
|
-
data-testid="chat-gateway-steer-prefix"
|
|
303
|
-
value={steerPrefix}
|
|
304
|
-
onChange={(e) => markDirty("steerPrefix", setSteerPrefix)(e.target.value)}
|
|
305
|
-
className={`${field} max-w-[8rem]`}
|
|
306
|
-
/>
|
|
307
|
-
</div>
|
|
308
|
-
|
|
309
|
-
<label className="block">
|
|
310
|
-
<span className={label}>Chat sessions on the board</span>
|
|
311
|
-
<select
|
|
312
|
-
data-testid="chat-gateway-session-visibility"
|
|
313
|
-
value={sessionVisibility}
|
|
314
|
-
onChange={(e) =>
|
|
315
|
-
markDirty("sessionVisibility", setSessionVisibility)(e.target.value as "hidden" | "shown")
|
|
316
|
-
}
|
|
317
|
-
className={`${field} max-w-[16rem]`}
|
|
318
|
-
>
|
|
319
|
-
<option value="hidden">Hidden (show with "show hidden")</option>
|
|
320
|
-
<option value="shown">Shown</option>
|
|
321
|
-
</select>
|
|
322
|
-
</label>
|
|
323
|
-
|
|
324
|
-
<div className="flex items-center gap-2">
|
|
325
|
-
<button
|
|
326
|
-
type="button"
|
|
327
|
-
data-testid="chat-gateway-save"
|
|
328
|
-
disabled={busy}
|
|
329
|
-
onClick={() => void save()}
|
|
330
|
-
className="px-2 py-1 rounded border border-[var(--border-secondary)] text-xs hover:bg-[var(--bg-secondary)] disabled:opacity-50"
|
|
331
|
-
>
|
|
332
|
-
Save
|
|
333
|
-
</button>
|
|
334
|
-
{notice && (
|
|
335
|
-
<span
|
|
336
|
-
data-testid="chat-gateway-notice"
|
|
337
|
-
className={`text-[11px] ${notice.kind === "ok" ? "text-[var(--text-secondary)]" : "text-[var(--danger-text,var(--text-secondary))]"}`}
|
|
338
|
-
>
|
|
339
|
-
{notice.text}
|
|
340
|
-
</span>
|
|
341
|
-
)}
|
|
342
|
-
</div>
|
|
343
|
-
|
|
344
|
-
<div>
|
|
345
|
-
<span className={label}>Pairing (L1)</span>
|
|
346
|
-
<span data-testid="chat-gateway-pairing-hint" className="text-[11px] text-[var(--text-tertiary)]">
|
|
347
|
-
A DM from an unknown user is paired only when it matches the current pairing code.
|
|
348
|
-
The code is printed to the server log at gateway startup (never returned over the API).
|
|
349
|
-
</span>
|
|
350
|
-
</div>
|
|
351
|
-
|
|
352
|
-
<div>
|
|
353
|
-
<span className={label}>Bindings</span>
|
|
354
|
-
{bindings && bindings.bindings.length > 0 ? (
|
|
355
|
-
<table data-testid="chat-gateway-bindings" className="w-full text-[11px]">
|
|
356
|
-
<thead>
|
|
357
|
-
<tr className="text-[var(--text-tertiary)] text-left">
|
|
358
|
-
<th className="font-normal">channel</th>
|
|
359
|
-
<th className="font-normal">session</th>
|
|
360
|
-
<th className="font-normal">cwd</th>
|
|
361
|
-
<th className="font-normal">source</th>
|
|
362
|
-
</tr>
|
|
363
|
-
</thead>
|
|
364
|
-
<tbody>
|
|
365
|
-
{bindings.bindings.map((b) => (
|
|
366
|
-
<tr key={`${b.platform}:${b.channelId}:${b.threadId ?? "-"}`}>
|
|
367
|
-
<td className="truncate max-w-[8rem]">{b.channelId}</td>
|
|
368
|
-
<td className="truncate max-w-[8rem]">{b.sessionId}</td>
|
|
369
|
-
<td className="truncate max-w-[12rem]">{b.cwd}</td>
|
|
370
|
-
<td>{b.source}</td>
|
|
371
|
-
</tr>
|
|
372
|
-
))}
|
|
373
|
-
</tbody>
|
|
374
|
-
</table>
|
|
375
|
-
) : (
|
|
376
|
-
<span data-testid="chat-gateway-bindings-empty" className="text-[11px] text-[var(--text-tertiary)]">
|
|
377
|
-
{bindings ? "No bound channels." : "Bindings appear once the gateway is configured and running."}
|
|
378
|
-
</span>
|
|
379
|
-
)}
|
|
380
|
-
</div>
|
|
381
|
-
|
|
382
|
-
<TeamControlsPanel />
|
|
383
|
-
</div>
|
|
384
|
-
);
|
|
385
|
-
}
|
|
11
|
+
export {};
|
|
@@ -11,8 +11,21 @@
|
|
|
11
11
|
* `plugin_config_write` because only that lane can await the platform before
|
|
12
12
|
* reporting success — see `shared/types.ts`.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* Presentation runs on the shared settings kit (status pills, items, facts,
|
|
15
|
+
* table, notices): raw codes (`problem`, `configError`, a refusal `reason`)
|
|
16
|
+
* never render — a sentence shows and the raw text is only copyable through
|
|
17
|
+
* "Copy details".
|
|
18
|
+
*
|
|
19
|
+
* See change: add-chat-gateway-team-controls, retro-ux-plugin-settings-wave-2.
|
|
15
20
|
*/
|
|
21
|
+
import {
|
|
22
|
+
SettingsFacts,
|
|
23
|
+
SettingsGroup,
|
|
24
|
+
SettingsItem,
|
|
25
|
+
SettingsNotice,
|
|
26
|
+
SettingsStatusPill,
|
|
27
|
+
SettingsTable,
|
|
28
|
+
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
16
29
|
import { usePluginConfig, usePluginMessage, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
17
30
|
import type React from "react";
|
|
18
31
|
import { useCallback, useEffect, useState } from "react";
|
|
@@ -29,6 +42,18 @@ function formatWhen(at: number): string {
|
|
|
29
42
|
return new Date(at).toLocaleString();
|
|
30
43
|
}
|
|
31
44
|
|
|
45
|
+
const MIRROR_LABEL: Record<TeamSurfaceView["bindings"][number]["mirrorLevel"], string> = {
|
|
46
|
+
"names-only": "Mirror: names only",
|
|
47
|
+
"names-and-diffs": "Mirror: names and diffs",
|
|
48
|
+
"full-transcript": "Mirror: full transcript",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const SMALL_BUTTON =
|
|
52
|
+
"focus-ring inline-flex min-h-[32px] items-center gap-1 rounded-md border border-[var(--border-secondary)] bg-[var(--bg-tertiary)] px-2 text-[12px] font-semibold text-[var(--text-primary)] hover:bg-[var(--bg-hover)]";
|
|
53
|
+
|
|
54
|
+
const SUBHEAD = "text-xs font-semibold text-[var(--text-primary)]";
|
|
55
|
+
const MUTED = "text-[12px] text-[var(--text-secondary)]";
|
|
56
|
+
|
|
32
57
|
/**
|
|
33
58
|
* The delegation disclosure for one role mapping.
|
|
34
59
|
*
|
|
@@ -41,7 +66,7 @@ function Delegation({ role }: { role: SurfaceRoleMapping }): React.ReactElement
|
|
|
41
66
|
return (
|
|
42
67
|
<span
|
|
43
68
|
data-testid={`delegation-unavailable-${role.roleId}`}
|
|
44
|
-
className="text-[var(--
|
|
69
|
+
className="text-[var(--severity-error-fg)]"
|
|
45
70
|
>
|
|
46
71
|
Cannot list who can assign this — missing permission: {role.assigners.missingPermission}
|
|
47
72
|
</span>
|
|
@@ -49,7 +74,7 @@ function Delegation({ role }: { role: SurfaceRoleMapping }): React.ReactElement
|
|
|
49
74
|
}
|
|
50
75
|
if (role.assigners.members.length === 0) {
|
|
51
76
|
return (
|
|
52
|
-
<span data-testid={`delegation-none-${role.roleId}`} className="text-[var(--text-
|
|
77
|
+
<span data-testid={`delegation-none-${role.roleId}`} className="text-[var(--text-secondary)]">
|
|
53
78
|
Nobody can assign this role.
|
|
54
79
|
</span>
|
|
55
80
|
);
|
|
@@ -63,52 +88,49 @@ function Delegation({ role }: { role: SurfaceRoleMapping }): React.ReactElement
|
|
|
63
88
|
}
|
|
64
89
|
|
|
65
90
|
function Binding({ binding }: { binding: TeamSurfaceView["bindings"][number] }): React.ReactElement {
|
|
91
|
+
const id = binding.workspaceId;
|
|
66
92
|
return (
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
93
|
+
<SettingsItem
|
|
94
|
+
testId={`team-binding-${id}`}
|
|
95
|
+
title={<span data-testid={`team-binding-name-${id}`}>{binding.workspaceName ?? "(workspace missing)"}</span>}
|
|
96
|
+
subtitle={
|
|
97
|
+
binding.channelId ? (
|
|
98
|
+
<>
|
|
99
|
+
channel <code>{binding.channelId}</code>
|
|
100
|
+
</>
|
|
101
|
+
) : (
|
|
102
|
+
"No channel provisioned."
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
status={
|
|
106
|
+
<>
|
|
107
|
+
<SettingsStatusPill tone="neutral" icon={null}>
|
|
108
|
+
Level: {binding.ceiling}
|
|
109
|
+
</SettingsStatusPill>
|
|
110
|
+
<SettingsStatusPill tone="neutral" icon={null}>
|
|
111
|
+
{MIRROR_LABEL[binding.mirrorLevel]}
|
|
112
|
+
</SettingsStatusPill>
|
|
113
|
+
</>
|
|
114
|
+
}
|
|
70
115
|
>
|
|
71
|
-
<div className="flex items-baseline justify-between gap-2">
|
|
72
|
-
<span className="text-xs font-medium" data-testid={`team-binding-name-${binding.workspaceId}`}>
|
|
73
|
-
{binding.workspaceName ?? "(workspace missing)"}
|
|
74
|
-
</span>
|
|
75
|
-
<span className="text-[11px] text-[var(--text-tertiary)]">
|
|
76
|
-
ceiling {binding.ceiling} · mirror {binding.mirrorLevel}
|
|
77
|
-
</span>
|
|
78
|
-
</div>
|
|
79
|
-
|
|
80
116
|
{!binding.bound && (
|
|
81
|
-
<
|
|
82
|
-
data-testid={`team-binding-unbound-${binding.workspaceId}`}
|
|
83
|
-
className="text-[11px] text-[var(--danger-text,var(--text-secondary))]"
|
|
84
|
-
>
|
|
117
|
+
<SettingsNotice tone="warning" testId={`team-binding-unbound-${id}`}>
|
|
85
118
|
This workspace no longer exists. The binding is retained but inert; its channel is kept.
|
|
86
|
-
</
|
|
119
|
+
</SettingsNotice>
|
|
87
120
|
)}
|
|
88
121
|
|
|
89
122
|
{binding.problem && (
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
>
|
|
94
|
-
Provisioning problem: {binding.problem}
|
|
95
|
-
</p>
|
|
96
|
-
)}
|
|
97
|
-
|
|
98
|
-
{binding.channelId ? (
|
|
99
|
-
<p className="text-[11px] text-[var(--text-tertiary)]">
|
|
100
|
-
channel <code>{binding.channelId}</code>
|
|
101
|
-
</p>
|
|
102
|
-
) : (
|
|
103
|
-
<p className="text-[11px] text-[var(--text-tertiary)]">No channel provisioned.</p>
|
|
123
|
+
<SettingsNotice tone="error" testId={`team-binding-problem-${id}`} details={binding.problem}>
|
|
124
|
+
This binding could not be set up, so it stays inactive.
|
|
125
|
+
</SettingsNotice>
|
|
104
126
|
)}
|
|
105
127
|
|
|
106
128
|
<div>
|
|
107
|
-
<
|
|
129
|
+
<p className={SUBHEAD}>Principals</p>
|
|
108
130
|
{binding.principals.length === 0 ? (
|
|
109
|
-
<
|
|
131
|
+
<p className={MUTED}>None mapped.</p>
|
|
110
132
|
) : (
|
|
111
|
-
<ul data-testid={`team-principals-${
|
|
133
|
+
<ul data-testid={`team-principals-${id}`} className="text-[12px]">
|
|
112
134
|
{binding.principals.map((p) => (
|
|
113
135
|
<li key={p.id}>
|
|
114
136
|
<code>{p.id}</code> — {p.tier}
|
|
@@ -119,11 +141,11 @@ function Binding({ binding }: { binding: TeamSurfaceView["bindings"][number] }):
|
|
|
119
141
|
</div>
|
|
120
142
|
|
|
121
143
|
<div>
|
|
122
|
-
<
|
|
144
|
+
<p className={SUBHEAD}>Roles</p>
|
|
123
145
|
{binding.roles.length === 0 ? (
|
|
124
|
-
<
|
|
146
|
+
<p className={MUTED}>None mapped.</p>
|
|
125
147
|
) : (
|
|
126
|
-
<ul data-testid={`team-roles-${
|
|
148
|
+
<ul data-testid={`team-roles-${id}`} className="space-y-0.5 text-[12px]">
|
|
127
149
|
{binding.roles.map((role) => (
|
|
128
150
|
<li key={role.roleId}>
|
|
129
151
|
<code>{role.roleId}</code> — {role.tier}: <Delegation role={role} />
|
|
@@ -134,24 +156,21 @@ function Binding({ binding }: { binding: TeamSurfaceView["bindings"][number] }):
|
|
|
134
156
|
</div>
|
|
135
157
|
|
|
136
158
|
<div>
|
|
137
|
-
<
|
|
138
|
-
<ul data-testid={`team-folders-${
|
|
159
|
+
<p className={SUBHEAD}>Folders</p>
|
|
160
|
+
<ul data-testid={`team-folders-${id}`} className="text-[12px]">
|
|
139
161
|
{binding.folders.map((f) => (
|
|
140
|
-
<li key={f.path} data-inert={f.inert ? "true" : "false"}>
|
|
162
|
+
<li key={f.path} data-inert={f.inert ? "true" : "false"} className="flex flex-wrap items-center gap-1">
|
|
141
163
|
<code>{f.path}</code>
|
|
142
164
|
{f.inert && (
|
|
143
|
-
<
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
>
|
|
147
|
-
inert — outside allowedRoots
|
|
148
|
-
</span>
|
|
165
|
+
<SettingsStatusPill tone="warning" testId={`team-folder-inert-${id}-${f.path}`}>
|
|
166
|
+
Not used · outside the allowed folders
|
|
167
|
+
</SettingsStatusPill>
|
|
149
168
|
)}
|
|
150
169
|
</li>
|
|
151
170
|
))}
|
|
152
171
|
</ul>
|
|
153
172
|
</div>
|
|
154
|
-
</
|
|
173
|
+
</SettingsItem>
|
|
155
174
|
);
|
|
156
175
|
}
|
|
157
176
|
|
|
@@ -159,7 +178,8 @@ export function TeamControlsPanel(): React.ReactElement {
|
|
|
159
178
|
const config = usePluginConfig<ChatGatewayConfig>();
|
|
160
179
|
const send = usePluginSend();
|
|
161
180
|
const [surface, setSurface] = useState<TeamSurfaceView | null>(null);
|
|
162
|
-
|
|
181
|
+
// `reason` is the raw refusal code: kept only for "Copy details".
|
|
182
|
+
const [writeNotice, setWriteNotice] = useState<{ ok: true } | { ok: false; reason: string } | null>(null);
|
|
163
183
|
|
|
164
184
|
// The surface answer and the write result both arrive on their own types.
|
|
165
185
|
usePluginMessage<{ surface?: TeamSurfaceView }>(TEAM_SURFACE_MESSAGE, (msg) => {
|
|
@@ -169,8 +189,8 @@ export function TeamControlsPanel(): React.ReactElement {
|
|
|
169
189
|
TEAM_CONFIG_MESSAGE,
|
|
170
190
|
(msg) => {
|
|
171
191
|
if (msg?.surface) setSurface(msg.surface);
|
|
172
|
-
if (msg?.ok === true) setWriteNotice(
|
|
173
|
-
else if (msg?.reason) setWriteNotice(
|
|
192
|
+
if (msg?.ok === true) setWriteNotice({ ok: true });
|
|
193
|
+
else if (msg?.reason) setWriteNotice({ ok: false, reason: msg.reason });
|
|
174
194
|
},
|
|
175
195
|
);
|
|
176
196
|
|
|
@@ -190,98 +210,113 @@ export function TeamControlsPanel(): React.ReactElement {
|
|
|
190
210
|
|
|
191
211
|
if (!surface) {
|
|
192
212
|
return (
|
|
193
|
-
<div data-testid="team-controls-panel" className="text-
|
|
213
|
+
<div data-testid="team-controls-panel" className="text-xs text-[var(--text-secondary)]">
|
|
194
214
|
Loading team controls…
|
|
195
215
|
</div>
|
|
196
216
|
);
|
|
197
217
|
}
|
|
198
218
|
|
|
199
219
|
return (
|
|
200
|
-
<div data-testid="team-controls-panel"
|
|
201
|
-
<
|
|
202
|
-
<
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
{writeNotice && (
|
|
224
|
-
<span data-testid="team-write-notice" className="text-[11px] text-[var(--text-tertiary)]">
|
|
225
|
-
{writeNotice}
|
|
226
|
-
</span>
|
|
227
|
-
)}
|
|
228
|
-
</div>
|
|
220
|
+
<div data-testid="team-controls-panel">
|
|
221
|
+
<SettingsGroup title="Team controls" testId="team-controls-group">
|
|
222
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
223
|
+
{surface.disarmed ? (
|
|
224
|
+
<SettingsStatusPill tone="error" status="disarmed" testId="team-disarm-state">
|
|
225
|
+
Disarmed · action requests are refused
|
|
226
|
+
</SettingsStatusPill>
|
|
227
|
+
) : (
|
|
228
|
+
<SettingsStatusPill tone="success" status="armed" testId="team-disarm-state">
|
|
229
|
+
Armed
|
|
230
|
+
</SettingsStatusPill>
|
|
231
|
+
)}
|
|
232
|
+
{surface.disarmed && (
|
|
233
|
+
<button type="button" data-testid="team-rearm" onClick={rearm} className={SMALL_BUTTON}>
|
|
234
|
+
Re-arm
|
|
235
|
+
</button>
|
|
236
|
+
)}
|
|
237
|
+
{writeNotice?.ok === true && (
|
|
238
|
+
<span data-testid="team-write-notice" className={MUTED}>
|
|
239
|
+
Saved.
|
|
240
|
+
</span>
|
|
241
|
+
)}
|
|
242
|
+
</div>
|
|
229
243
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
Configuration rejected — the layer is running FAIL-CLOSED: {surface.configError}
|
|
236
|
-
</p>
|
|
237
|
-
)}
|
|
244
|
+
{writeNotice?.ok === false && (
|
|
245
|
+
<SettingsNotice tone="warning" testId="team-write-notice" details={writeNotice.reason}>
|
|
246
|
+
Couldn't apply that change. Nothing was changed.
|
|
247
|
+
</SettingsNotice>
|
|
248
|
+
)}
|
|
238
249
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
250
|
+
{surface.configError && (
|
|
251
|
+
<SettingsNotice tone="error" testId="team-config-error" details={surface.configError}>
|
|
252
|
+
The team-controls configuration was rejected, so the layer is running FAIL-CLOSED and refuses every
|
|
253
|
+
action.
|
|
254
|
+
</SettingsNotice>
|
|
255
|
+
)}
|
|
243
256
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
257
|
+
<SettingsFacts
|
|
258
|
+
rows={[
|
|
259
|
+
["Highest level", surface.ceiling],
|
|
260
|
+
...(surface.allowedRoots.length > 0
|
|
261
|
+
? [
|
|
262
|
+
[
|
|
263
|
+
"Allowed folders",
|
|
264
|
+
surface.allowedRoots.map((r) => (
|
|
265
|
+
<code key={r} className="mr-2 break-all">
|
|
266
|
+
{r}
|
|
267
|
+
</code>
|
|
268
|
+
)),
|
|
269
|
+
] as const,
|
|
270
|
+
]
|
|
271
|
+
: []),
|
|
272
|
+
]}
|
|
273
|
+
/>
|
|
251
274
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
{surface.log.length === 0 ? (
|
|
257
|
-
<span data-testid="team-log-empty" className="text-[11px] text-[var(--text-tertiary)]">
|
|
258
|
-
No activity recorded.
|
|
259
|
-
</span>
|
|
275
|
+
{surface.bindings.length === 0 ? (
|
|
276
|
+
<p data-testid="team-bindings-empty" className={MUTED}>
|
|
277
|
+
No workspace bindings configured.
|
|
278
|
+
</p>
|
|
260
279
|
) : (
|
|
261
|
-
<
|
|
262
|
-
<thead>
|
|
263
|
-
<tr className="text-[var(--text-tertiary)] text-left">
|
|
264
|
-
<th className="font-normal">when</th>
|
|
265
|
-
<th className="font-normal">principal</th>
|
|
266
|
-
<th className="font-normal">verb</th>
|
|
267
|
-
<th className="font-normal">outcome</th>
|
|
268
|
-
<th className="font-normal">reason</th>
|
|
269
|
-
</tr>
|
|
270
|
-
</thead>
|
|
271
|
-
<tbody>
|
|
272
|
-
{surface.log.map((e, i) => (
|
|
273
|
-
<tr key={`${e.at}-${i}`} data-testid="team-log-row">
|
|
274
|
-
<td>{formatWhen(e.at)}</td>
|
|
275
|
-
<td className="truncate max-w-[8rem]">{e.principal}</td>
|
|
276
|
-
<td>{e.verb}</td>
|
|
277
|
-
<td>{e.outcome}</td>
|
|
278
|
-
<td className="truncate max-w-[12rem]">{e.reason ?? ""}</td>
|
|
279
|
-
</tr>
|
|
280
|
-
))}
|
|
281
|
-
</tbody>
|
|
282
|
-
</table>
|
|
280
|
+
surface.bindings.map((b) => <Binding key={b.workspaceId} binding={b} />)
|
|
283
281
|
)}
|
|
284
|
-
|
|
282
|
+
|
|
283
|
+
<div className="space-y-1">
|
|
284
|
+
<p className={SUBHEAD}>Command log</p>
|
|
285
|
+
<p className={MUTED}>Newest first. The dashboard is the only place it is readable.</p>
|
|
286
|
+
{surface.log.length === 0 ? (
|
|
287
|
+
<p data-testid="team-log-empty" className={MUTED}>
|
|
288
|
+
No activity recorded.
|
|
289
|
+
</p>
|
|
290
|
+
) : (
|
|
291
|
+
<SettingsTable
|
|
292
|
+
testId="team-log"
|
|
293
|
+
caption="Command log"
|
|
294
|
+
columns={["When", "Who", "Command", "Result", "Reason"]}
|
|
295
|
+
rows={surface.log.map((e, i) => ({
|
|
296
|
+
key: `${e.at}-${i}`,
|
|
297
|
+
testId: "team-log-row",
|
|
298
|
+
cells: [
|
|
299
|
+
formatWhen(e.at),
|
|
300
|
+
<span key="p" className="break-all">
|
|
301
|
+
{e.principal}
|
|
302
|
+
</span>,
|
|
303
|
+
e.verb,
|
|
304
|
+
e.outcome === "permitted" ? (
|
|
305
|
+
<SettingsStatusPill key="o" tone="success" status={e.outcome}>
|
|
306
|
+
Done
|
|
307
|
+
</SettingsStatusPill>
|
|
308
|
+
) : (
|
|
309
|
+
<SettingsStatusPill key="o" tone="error" status={e.outcome}>
|
|
310
|
+
Refused
|
|
311
|
+
</SettingsStatusPill>
|
|
312
|
+
),
|
|
313
|
+
e.reason ?? "",
|
|
314
|
+
],
|
|
315
|
+
}))}
|
|
316
|
+
/>
|
|
317
|
+
)}
|
|
318
|
+
</div>
|
|
319
|
+
</SettingsGroup>
|
|
285
320
|
</div>
|
|
286
321
|
);
|
|
287
322
|
}
|