@shellui/core 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -1
- package/package.json +2 -2
- package/schemas/shellui.config.schema.json +45 -2
- package/src/app.tsx +2 -0
- package/src/features/auth/AuthProvider.tsx +212 -97
- package/src/features/auth/appBackend/configSchema.spec.ts +1 -0
- package/src/features/auth/appBackend/frameAuth.ts +5 -0
- package/src/features/auth/backends/shellui.spec.ts +110 -0
- package/src/features/auth/backends/shellui.ts +47 -20
- package/src/features/auth/backends/types.ts +5 -0
- package/src/features/auth/hooks/useAuth.tsx +6 -1
- package/src/features/auth/types.ts +5 -0
- package/src/features/auth/utils/bffAuthClient.spec.ts +313 -0
- package/src/features/auth/utils/bffAuthClient.ts +171 -49
- package/src/features/auth/utils/buildSessionFromParams.ts +5 -2
- package/src/features/auth/utils/buildSessionFromTokenPayload.spec.ts +12 -0
- package/src/features/auth/utils/buildSessionFromTokenPayload.ts +3 -1
- package/src/features/auth/utils/canRestoreStoredSession.spec.ts +140 -4
- package/src/features/auth/utils/canRestoreStoredSession.ts +47 -0
- package/src/features/auth/utils/cliCallback.ts +5 -0
- package/src/features/auth/utils/identityBrowserLogout.spec.ts +185 -0
- package/src/features/auth/utils/identityBrowserLogout.ts +174 -0
- package/src/features/auth/utils/index.ts +21 -3
- package/src/features/auth/utils/isBffAuthEnabled.ts +10 -2
- package/src/features/auth/utils/normalizeAuthSettings.spec.ts +9 -0
- package/src/features/auth/utils/normalizeAuthSettings.ts +3 -1
- package/src/features/auth/utils/pkce.spec.ts +29 -1
- package/src/features/auth/utils/pkce.ts +106 -2
- package/src/features/config/types.ts +37 -5
- package/src/features/mcp/mcpActivityErrorCodeI18n.spec.ts +32 -0
- package/src/features/mcp/mcpActivityErrorCodeI18n.ts +30 -0
- package/src/features/mcp/mcpAgentActivityMerge.spec.ts +91 -0
- package/src/features/mcp/mcpAgentActivityMerge.ts +53 -0
- package/src/features/mcp/mcpAgentActivityPresentation.spec.ts +129 -0
- package/src/features/mcp/mcpAgentActivityPresentation.ts +201 -0
- package/src/features/mcp/mcpAgentsConnect.spec.ts +215 -0
- package/src/features/mcp/mcpAgentsConnect.ts +189 -0
- package/src/features/mcp/mcpToolActivityRegistry.spec.ts +9 -0
- package/src/features/mcp/mcpToolActivityRegistry.ts +20 -0
- package/src/features/mcp/mcpToolApprovalsApi.spec.ts +113 -0
- package/src/features/mcp/mcpToolApprovalsApi.ts +162 -0
- package/src/features/mcp/personalAgentsApi.spec.ts +661 -0
- package/src/features/mcp/personalAgentsApi.ts +697 -0
- package/src/features/settings/SettingsIcons.tsx +28 -0
- package/src/features/settings/SettingsRoutes.tsx +8 -0
- package/src/features/settings/SettingsView.tsx +90 -26
- package/src/features/settings/components/McpAgentActivitySection.spec.tsx +255 -0
- package/src/features/settings/components/McpAgentActivitySection.tsx +481 -0
- package/src/features/settings/components/McpAgents.spec.tsx +336 -0
- package/src/features/settings/components/McpAgents.tsx +654 -0
- package/src/features/settings/components/McpPendingApprovals.spec.tsx +201 -0
- package/src/features/settings/components/McpPendingApprovals.tsx +168 -0
- package/src/features/settings/components/McpPersonalStatusPrefetch.tsx +21 -0
- package/src/features/settings/hooks/useMcpPendingToolApprovals.ts +69 -0
- package/src/features/settings/hooks/useMcpPersonalStatus.ts +83 -0
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +44 -1
- package/src/features/settings/utils/buildSettingsForPropagation.ts +30 -1
- package/src/features/settings/utils/isMcpAgentsSettingsEligible.spec.ts +25 -0
- package/src/features/settings/utils/isMcpAgentsSettingsEligible.ts +14 -0
- package/src/features/settings/utils/loadMcpPersonalStatus.spec.ts +76 -0
- package/src/features/settings/utils/loadMcpPersonalStatus.ts +84 -0
- package/src/features/settings/utils/mcpPersonalStatusCache.spec.ts +77 -0
- package/src/features/settings/utils/mcpPersonalStatusCache.ts +95 -0
- package/src/features/settings/utils/shouldShowMcpAgentsSettings.spec.ts +66 -0
- package/src/features/settings/utils/shouldShowMcpAgentsSettings.ts +16 -0
- package/src/features/storage/StorageBridge.paths.spec.ts +286 -0
- package/src/features/storage/StorageBridge.tsx +25 -5
- package/src/features/storage/resolveStorageBridgeTarget.spec.ts +51 -0
- package/src/features/storage/resolveStorageBridgeTarget.ts +24 -0
- package/src/i18n/translations/en/settings.json +201 -0
- package/src/i18n/translations/fr/settings.json +201 -0
- package/src/index.ts +1 -0
- package/src/service-worker/sw.ts +4 -2
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Badge } from '../../../components/ui/badge';
|
|
4
|
+
import { Button } from '../../../components/ui/button';
|
|
5
|
+
import { MCP_ACTIVITY_ERROR_CODE_I18N_KEYS } from '../../mcp/mcpActivityErrorCodeI18n';
|
|
6
|
+
import { mergeMcpAgentActivity } from '../../mcp/mcpAgentActivityMerge';
|
|
7
|
+
import {
|
|
8
|
+
activityApprovalOutcomeFallback,
|
|
9
|
+
activityApprovalOutcomeLabelKey,
|
|
10
|
+
activityErrorMessageForDisplay,
|
|
11
|
+
activityWrapperToolForDisplay,
|
|
12
|
+
buildActivityPrimarySummary,
|
|
13
|
+
formatActivityDurationMs,
|
|
14
|
+
formatActivityWhen,
|
|
15
|
+
inferActivityAccessKind,
|
|
16
|
+
parseActivityOutcomeFromFields,
|
|
17
|
+
resolveActivityPendingLink,
|
|
18
|
+
type ActivityPendingLink,
|
|
19
|
+
} from '../../mcp/mcpAgentActivityPresentation';
|
|
20
|
+
import {
|
|
21
|
+
fetchMcpPersonalAgentActivity,
|
|
22
|
+
fetchMcpPersonalAgentCallLogs,
|
|
23
|
+
mcpCallLogPageHasMore,
|
|
24
|
+
MCP_PERSONAL_CALL_LOG_PAGE_SIZE,
|
|
25
|
+
type McpAgentActivityRow,
|
|
26
|
+
type McpAgentSummary,
|
|
27
|
+
} from '../../mcp/personalAgentsApi';
|
|
28
|
+
import type { McpPendingToolApproval } from '../../mcp/mcpToolApprovalsApi';
|
|
29
|
+
|
|
30
|
+
type Props = {
|
|
31
|
+
backendUrl: string;
|
|
32
|
+
/** Normalized ai-service base URL from `aiService.url`. Null when unset. */
|
|
33
|
+
aiServiceUrl: string | null;
|
|
34
|
+
accessToken: string;
|
|
35
|
+
companyId: string;
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
agent: McpAgentSummary;
|
|
38
|
+
pendingApprovals: McpPendingToolApproval[];
|
|
39
|
+
onJumpToApprovals: () => void;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type CallLogsError = 'initial' | 'page' | null;
|
|
43
|
+
|
|
44
|
+
export const McpAgentActivitySection = ({
|
|
45
|
+
backendUrl,
|
|
46
|
+
aiServiceUrl,
|
|
47
|
+
accessToken,
|
|
48
|
+
companyId,
|
|
49
|
+
enabled,
|
|
50
|
+
agent,
|
|
51
|
+
pendingApprovals,
|
|
52
|
+
onJumpToApprovals,
|
|
53
|
+
}: Props) => {
|
|
54
|
+
const { t, i18n } = useTranslation('settings');
|
|
55
|
+
const locale = i18n.language || 'en';
|
|
56
|
+
const [open, setOpen] = useState(false);
|
|
57
|
+
const [identityRows, setIdentityRows] = useState<McpAgentActivityRow[]>([]);
|
|
58
|
+
const [callRows, setCallRows] = useState<McpAgentActivityRow[]>([]);
|
|
59
|
+
const [nextOffset, setNextOffset] = useState(0);
|
|
60
|
+
const [hasMore, setHasMore] = useState(false);
|
|
61
|
+
const [loading, setLoading] = useState(false);
|
|
62
|
+
const [loadingMore, setLoadingMore] = useState(false);
|
|
63
|
+
const [identityError, setIdentityError] = useState(false);
|
|
64
|
+
const [callLogsError, setCallLogsError] = useState<CallLogsError>(null);
|
|
65
|
+
const requestSeq = useRef(0);
|
|
66
|
+
|
|
67
|
+
const pendingToolNames = useMemo(
|
|
68
|
+
() => new Set(pendingApprovals.map((item) => item.toolName)),
|
|
69
|
+
[pendingApprovals],
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const rows = useMemo(
|
|
73
|
+
() =>
|
|
74
|
+
mergeMcpAgentActivity(identityRows, callRows, {
|
|
75
|
+
callLogsComplete: !hasMore && callLogsError !== 'page',
|
|
76
|
+
}),
|
|
77
|
+
[callLogsError, callRows, hasMore, identityRows],
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const load = useCallback(async () => {
|
|
81
|
+
const request = ++requestSeq.current;
|
|
82
|
+
if (!enabled || !backendUrl || !accessToken) {
|
|
83
|
+
setIdentityRows([]);
|
|
84
|
+
setCallRows([]);
|
|
85
|
+
setHasMore(false);
|
|
86
|
+
setNextOffset(0);
|
|
87
|
+
setIdentityError(false);
|
|
88
|
+
setCallLogsError(null);
|
|
89
|
+
setLoading(false);
|
|
90
|
+
setLoadingMore(false);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
setLoading(true);
|
|
94
|
+
setLoadingMore(false);
|
|
95
|
+
setIdentityError(false);
|
|
96
|
+
setCallLogsError(null);
|
|
97
|
+
setHasMore(false);
|
|
98
|
+
|
|
99
|
+
const consentPromise = fetchMcpPersonalAgentActivity(
|
|
100
|
+
backendUrl,
|
|
101
|
+
accessToken,
|
|
102
|
+
companyId,
|
|
103
|
+
agent.id,
|
|
104
|
+
).catch(() => {
|
|
105
|
+
if (request === requestSeq.current) setIdentityError(true);
|
|
106
|
+
return [] as McpAgentActivityRow[];
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const callsPromise = (async () => {
|
|
110
|
+
if (!aiServiceUrl) {
|
|
111
|
+
if (request === requestSeq.current) setCallLogsError('initial');
|
|
112
|
+
return { callLogs: [] as McpAgentActivityRow[], hasMoreCalls: false, offset: 0 };
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const page = await fetchMcpPersonalAgentCallLogs(aiServiceUrl, accessToken, agent.id, {
|
|
116
|
+
limit: MCP_PERSONAL_CALL_LOG_PAGE_SIZE,
|
|
117
|
+
offset: 0,
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
callLogs: page.callLogs,
|
|
121
|
+
hasMoreCalls: mcpCallLogPageHasMore(page),
|
|
122
|
+
offset: page.offset + page.limit,
|
|
123
|
+
};
|
|
124
|
+
} catch {
|
|
125
|
+
if (request === requestSeq.current) setCallLogsError('initial');
|
|
126
|
+
return { callLogs: [] as McpAgentActivityRow[], hasMoreCalls: false, offset: 0 };
|
|
127
|
+
}
|
|
128
|
+
})();
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
const [consent, calls] = await Promise.all([consentPromise, callsPromise]);
|
|
132
|
+
if (request !== requestSeq.current) return;
|
|
133
|
+
setIdentityRows(consent);
|
|
134
|
+
setCallRows(calls.callLogs);
|
|
135
|
+
setNextOffset(calls.offset);
|
|
136
|
+
setHasMore(calls.hasMoreCalls);
|
|
137
|
+
} finally {
|
|
138
|
+
if (request === requestSeq.current) setLoading(false);
|
|
139
|
+
}
|
|
140
|
+
}, [accessToken, agent.id, aiServiceUrl, backendUrl, companyId, enabled]);
|
|
141
|
+
|
|
142
|
+
const loadMore = useCallback(async () => {
|
|
143
|
+
if (!enabled || !aiServiceUrl || !accessToken || loadingMore || !hasMore) return;
|
|
144
|
+
const request = requestSeq.current;
|
|
145
|
+
setLoadingMore(true);
|
|
146
|
+
setCallLogsError(null);
|
|
147
|
+
try {
|
|
148
|
+
const page = await fetchMcpPersonalAgentCallLogs(aiServiceUrl, accessToken, agent.id, {
|
|
149
|
+
limit: MCP_PERSONAL_CALL_LOG_PAGE_SIZE,
|
|
150
|
+
offset: nextOffset,
|
|
151
|
+
});
|
|
152
|
+
if (request !== requestSeq.current) return;
|
|
153
|
+
setCallRows((current) => [...current, ...page.callLogs]);
|
|
154
|
+
setNextOffset(page.offset + page.limit);
|
|
155
|
+
setHasMore(mcpCallLogPageHasMore(page));
|
|
156
|
+
} catch {
|
|
157
|
+
if (request === requestSeq.current) setCallLogsError('page');
|
|
158
|
+
} finally {
|
|
159
|
+
if (request === requestSeq.current) setLoadingMore(false);
|
|
160
|
+
}
|
|
161
|
+
}, [accessToken, agent.id, aiServiceUrl, enabled, hasMore, loadingMore, nextOffset]);
|
|
162
|
+
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
if (!open) return;
|
|
165
|
+
void load();
|
|
166
|
+
}, [open, load]);
|
|
167
|
+
|
|
168
|
+
const outcomeLabel = useCallback(
|
|
169
|
+
(kind: ReturnType<typeof parseActivityOutcomeFromFields>) => {
|
|
170
|
+
switch (kind) {
|
|
171
|
+
case 'allowed':
|
|
172
|
+
return t('mcpAgents.activity.outcome.allowed');
|
|
173
|
+
case 'denied':
|
|
174
|
+
return t('mcpAgents.activity.outcome.denied');
|
|
175
|
+
case 'failed':
|
|
176
|
+
return t('mcpAgents.activity.outcome.failed');
|
|
177
|
+
case 'pending_approval':
|
|
178
|
+
return t('mcpAgents.activity.outcome.pendingApproval');
|
|
179
|
+
case 'session_used':
|
|
180
|
+
return t('mcpAgents.activity.outcome.sessionUsed');
|
|
181
|
+
default:
|
|
182
|
+
return t('mcpAgents.activity.outcome.unknown');
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
[t],
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const accessLabel = useCallback(
|
|
189
|
+
(row: McpAgentActivityRow) => {
|
|
190
|
+
const kind = inferActivityAccessKind(row);
|
|
191
|
+
switch (kind) {
|
|
192
|
+
case 'read':
|
|
193
|
+
return t('mcpAgents.activity.access.read');
|
|
194
|
+
case 'write':
|
|
195
|
+
return t('mcpAgents.activity.access.write');
|
|
196
|
+
case 'destructive':
|
|
197
|
+
return t('mcpAgents.activity.access.destructive');
|
|
198
|
+
default:
|
|
199
|
+
return t('mcpAgents.activity.access.unknown');
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
[t],
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const linkButtonLabel = useCallback(
|
|
206
|
+
(link: ActivityPendingLink) => {
|
|
207
|
+
if (link.type === 'id') {
|
|
208
|
+
return t('mcpAgents.activity.link.openApprovalById');
|
|
209
|
+
}
|
|
210
|
+
return t('mcpAgents.activity.link.openApprovalsSection');
|
|
211
|
+
},
|
|
212
|
+
[t],
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const errorCodeLabel = useCallback(
|
|
216
|
+
(code: McpAgentActivityRow['errorCode']) => {
|
|
217
|
+
if (!code) return null;
|
|
218
|
+
return t(MCP_ACTIVITY_ERROR_CODE_I18N_KEYS[code]);
|
|
219
|
+
},
|
|
220
|
+
[t],
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
const summaryFor = useCallback(
|
|
224
|
+
(row: McpAgentActivityRow) => {
|
|
225
|
+
const tool = row.tool.trim();
|
|
226
|
+
const titled = row.operationTitle?.trim();
|
|
227
|
+
if (!titled || titled === tool) {
|
|
228
|
+
if (tool.toLowerCase() === 'oauth.authorize.approved') {
|
|
229
|
+
return t('mcpAgents.activity.consentOauth');
|
|
230
|
+
}
|
|
231
|
+
if (tool.toLowerCase() === 'oauth.device.approved') {
|
|
232
|
+
return t('mcpAgents.activity.consentDevice');
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return buildActivityPrimarySummary(row, {
|
|
236
|
+
toolUnknown: t('mcpAgents.activity.toolUnknown'),
|
|
237
|
+
operationSuffix: t('mcpAgents.activity.operationSuffix'),
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
[t],
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
const showFatalError = identityError && callLogsError === 'initial' && rows.length === 0;
|
|
244
|
+
const showCallLogsWarning = callLogsError !== null && !showFatalError;
|
|
245
|
+
const showConsentWarning = identityError && !showFatalError;
|
|
246
|
+
const showEmpty = rows.length === 0 && !showCallLogsWarning && !showConsentWarning;
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<div className="mt-4 border-t pt-4 space-y-3">
|
|
250
|
+
<div className="flex flex-wrap items-center justify-between gap-2">
|
|
251
|
+
<h3
|
|
252
|
+
className="text-xs font-medium uppercase tracking-wide text-muted-foreground"
|
|
253
|
+
style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
|
|
254
|
+
>
|
|
255
|
+
{t('mcpAgents.activity.title')}
|
|
256
|
+
</h3>
|
|
257
|
+
<Button
|
|
258
|
+
type="button"
|
|
259
|
+
variant="ghost"
|
|
260
|
+
size="sm"
|
|
261
|
+
className="h-8 px-2"
|
|
262
|
+
onClick={() => setOpen((value) => !value)}
|
|
263
|
+
aria-expanded={open}
|
|
264
|
+
>
|
|
265
|
+
{open ? t('mcpAgents.activity.hide') : t('mcpAgents.activity.show')}
|
|
266
|
+
</Button>
|
|
267
|
+
</div>
|
|
268
|
+
{open ? (
|
|
269
|
+
<div className="space-y-3">
|
|
270
|
+
{loading ? (
|
|
271
|
+
<p className="text-sm text-muted-foreground">{t('mcpAgents.activity.loading')}</p>
|
|
272
|
+
) : showFatalError ? (
|
|
273
|
+
<div className="space-y-2">
|
|
274
|
+
<p className="text-sm text-muted-foreground">{t('mcpAgents.activity.error')}</p>
|
|
275
|
+
<Button
|
|
276
|
+
type="button"
|
|
277
|
+
variant="outline"
|
|
278
|
+
size="sm"
|
|
279
|
+
onClick={() => void load()}
|
|
280
|
+
>
|
|
281
|
+
{t('mcpAgents.activity.retry')}
|
|
282
|
+
</Button>
|
|
283
|
+
</div>
|
|
284
|
+
) : (
|
|
285
|
+
<>
|
|
286
|
+
{showCallLogsWarning || showConsentWarning ? (
|
|
287
|
+
<div className="space-y-2">
|
|
288
|
+
{showCallLogsWarning ? (
|
|
289
|
+
<p className="text-sm text-muted-foreground">
|
|
290
|
+
{callLogsError === 'page'
|
|
291
|
+
? t('mcpAgents.activity.callLogsPageUnavailable')
|
|
292
|
+
: t('mcpAgents.activity.callLogsUnavailable')}
|
|
293
|
+
</p>
|
|
294
|
+
) : null}
|
|
295
|
+
{showConsentWarning ? (
|
|
296
|
+
<p className="text-sm text-muted-foreground">
|
|
297
|
+
{t('mcpAgents.activity.consentUnavailable')}
|
|
298
|
+
</p>
|
|
299
|
+
) : null}
|
|
300
|
+
{callLogsError !== 'page' || showConsentWarning ? (
|
|
301
|
+
<Button
|
|
302
|
+
type="button"
|
|
303
|
+
variant="outline"
|
|
304
|
+
size="sm"
|
|
305
|
+
onClick={() => void load()}
|
|
306
|
+
>
|
|
307
|
+
{t('mcpAgents.activity.retry')}
|
|
308
|
+
</Button>
|
|
309
|
+
) : null}
|
|
310
|
+
</div>
|
|
311
|
+
) : null}
|
|
312
|
+
{showEmpty ? (
|
|
313
|
+
<p className="text-sm text-muted-foreground">{t('mcpAgents.activity.empty')}</p>
|
|
314
|
+
) : rows.length > 0 ? (
|
|
315
|
+
<ul className="space-y-2">
|
|
316
|
+
{rows.map((row, index) => {
|
|
317
|
+
const summary = summaryFor(row);
|
|
318
|
+
const outcome = parseActivityOutcomeFromFields(row.result, row.outcome);
|
|
319
|
+
const resultDetail =
|
|
320
|
+
outcome === 'unknown'
|
|
321
|
+
? t('mcpAgents.activity.detail.resultUnknown')
|
|
322
|
+
: outcomeLabel(outcome);
|
|
323
|
+
const errorDetailLabel = errorCodeLabel(row.errorCode);
|
|
324
|
+
const errorMessage =
|
|
325
|
+
outcome === 'failed'
|
|
326
|
+
? activityErrorMessageForDisplay(row.errorMessage)
|
|
327
|
+
: null;
|
|
328
|
+
const wrapper = activityWrapperToolForDisplay(row.wrapperTool);
|
|
329
|
+
const approvalKey = activityApprovalOutcomeLabelKey(row.approvalOutcome);
|
|
330
|
+
const approvalLabel = approvalKey
|
|
331
|
+
? t(approvalKey)
|
|
332
|
+
: activityApprovalOutcomeFallback(row.approvalOutcome);
|
|
333
|
+
const duration = formatActivityDurationMs(row.durationMs, locale);
|
|
334
|
+
const when = formatActivityWhen(row.timestamp, locale);
|
|
335
|
+
const access = accessLabel(row);
|
|
336
|
+
const link = resolveActivityPendingLink(row, pendingToolNames);
|
|
337
|
+
const showDestructiveBadge = row.accessKind === 'destructive';
|
|
338
|
+
|
|
339
|
+
return (
|
|
340
|
+
<li
|
|
341
|
+
key={`${row.timestamp}-${row.tool}-${index}`}
|
|
342
|
+
className="rounded-md border bg-muted/20 px-3 py-2 space-y-2"
|
|
343
|
+
>
|
|
344
|
+
<p className="text-sm">{summary}</p>
|
|
345
|
+
{wrapper ? (
|
|
346
|
+
<p className="text-xs text-muted-foreground">
|
|
347
|
+
{t('mcpAgents.activity.detail.viaWrapper', { wrapper })}
|
|
348
|
+
</p>
|
|
349
|
+
) : null}
|
|
350
|
+
<div className="flex flex-wrap gap-1.5">
|
|
351
|
+
<Badge
|
|
352
|
+
variant="secondary"
|
|
353
|
+
className="font-normal text-xs"
|
|
354
|
+
>
|
|
355
|
+
{outcomeLabel(outcome)}
|
|
356
|
+
</Badge>
|
|
357
|
+
<Badge
|
|
358
|
+
variant="outline"
|
|
359
|
+
className="font-normal text-xs"
|
|
360
|
+
>
|
|
361
|
+
{access}
|
|
362
|
+
</Badge>
|
|
363
|
+
{showDestructiveBadge ? (
|
|
364
|
+
<Badge
|
|
365
|
+
variant="muted"
|
|
366
|
+
className="font-normal text-xs"
|
|
367
|
+
>
|
|
368
|
+
{t('mcpAgents.activity.destructiveBadge')}
|
|
369
|
+
</Badge>
|
|
370
|
+
) : null}
|
|
371
|
+
</div>
|
|
372
|
+
<dl className="grid grid-cols-1 gap-1 text-xs text-muted-foreground sm:grid-cols-2">
|
|
373
|
+
<div>
|
|
374
|
+
<dt className="inline font-medium text-foreground/80">
|
|
375
|
+
{t('mcpAgents.activity.detail.when')}:{' '}
|
|
376
|
+
</dt>
|
|
377
|
+
<dd className="inline">{when}</dd>
|
|
378
|
+
</div>
|
|
379
|
+
{duration ? (
|
|
380
|
+
<div>
|
|
381
|
+
<dt className="inline font-medium text-foreground/80">
|
|
382
|
+
{t('mcpAgents.activity.detail.duration')}:{' '}
|
|
383
|
+
</dt>
|
|
384
|
+
<dd className="inline">{duration}</dd>
|
|
385
|
+
</div>
|
|
386
|
+
) : (
|
|
387
|
+
<div>
|
|
388
|
+
<dt className="inline font-medium text-foreground/80">
|
|
389
|
+
{t('mcpAgents.activity.detail.duration')}:{' '}
|
|
390
|
+
</dt>
|
|
391
|
+
<dd className="inline">
|
|
392
|
+
{t('mcpAgents.activity.detail.notProvided')}
|
|
393
|
+
</dd>
|
|
394
|
+
</div>
|
|
395
|
+
)}
|
|
396
|
+
<div>
|
|
397
|
+
<dt className="inline font-medium text-foreground/80">
|
|
398
|
+
{t('mcpAgents.activity.detail.actor')}:{' '}
|
|
399
|
+
</dt>
|
|
400
|
+
<dd className="inline">
|
|
401
|
+
{row.actorLabel?.trim() ||
|
|
402
|
+
t('mcpAgents.activity.detail.actorUnknown')}
|
|
403
|
+
</dd>
|
|
404
|
+
</div>
|
|
405
|
+
<div>
|
|
406
|
+
<dt className="inline font-medium text-foreground/80">
|
|
407
|
+
{t('mcpAgents.activity.detail.agent')}:{' '}
|
|
408
|
+
</dt>
|
|
409
|
+
<dd className="inline">{row.agentName?.trim() || agent.name}</dd>
|
|
410
|
+
</div>
|
|
411
|
+
<div className="sm:col-span-2">
|
|
412
|
+
<dt className="inline font-medium text-foreground/80">
|
|
413
|
+
{t('mcpAgents.activity.detail.result')}:{' '}
|
|
414
|
+
</dt>
|
|
415
|
+
<dd className="inline">{resultDetail}</dd>
|
|
416
|
+
</div>
|
|
417
|
+
{errorDetailLabel ? (
|
|
418
|
+
<div className="sm:col-span-2">
|
|
419
|
+
<dt className="inline font-medium text-foreground/80">
|
|
420
|
+
{t('mcpAgents.activity.detail.error')}:{' '}
|
|
421
|
+
</dt>
|
|
422
|
+
<dd className="inline">{errorDetailLabel}</dd>
|
|
423
|
+
</div>
|
|
424
|
+
) : null}
|
|
425
|
+
{errorMessage ? (
|
|
426
|
+
<div className="sm:col-span-2">
|
|
427
|
+
<dt className="inline font-medium text-foreground/80">
|
|
428
|
+
{t('mcpAgents.activity.detail.errorMessage')}:{' '}
|
|
429
|
+
</dt>
|
|
430
|
+
<dd className="inline">{errorMessage}</dd>
|
|
431
|
+
</div>
|
|
432
|
+
) : outcome === 'failed' && !errorDetailLabel ? (
|
|
433
|
+
<div className="sm:col-span-2 text-muted-foreground">
|
|
434
|
+
{t('mcpAgents.activity.detail.errorUnavailable')}
|
|
435
|
+
</div>
|
|
436
|
+
) : null}
|
|
437
|
+
{approvalLabel ? (
|
|
438
|
+
<div className="sm:col-span-2">
|
|
439
|
+
<dt className="inline font-medium text-foreground/80">
|
|
440
|
+
{t('mcpAgents.activity.detail.approvalOutcome')}:{' '}
|
|
441
|
+
</dt>
|
|
442
|
+
<dd className="inline">{approvalLabel}</dd>
|
|
443
|
+
</div>
|
|
444
|
+
) : null}
|
|
445
|
+
</dl>
|
|
446
|
+
{link && outcome === 'pending_approval' ? (
|
|
447
|
+
<Button
|
|
448
|
+
type="button"
|
|
449
|
+
variant="link"
|
|
450
|
+
size="sm"
|
|
451
|
+
className="h-auto p-0 text-xs"
|
|
452
|
+
onClick={onJumpToApprovals}
|
|
453
|
+
>
|
|
454
|
+
{linkButtonLabel(link)}
|
|
455
|
+
</Button>
|
|
456
|
+
) : null}
|
|
457
|
+
</li>
|
|
458
|
+
);
|
|
459
|
+
})}
|
|
460
|
+
</ul>
|
|
461
|
+
) : null}
|
|
462
|
+
{hasMore ? (
|
|
463
|
+
<Button
|
|
464
|
+
type="button"
|
|
465
|
+
variant="outline"
|
|
466
|
+
size="sm"
|
|
467
|
+
disabled={loadingMore}
|
|
468
|
+
onClick={() => void loadMore()}
|
|
469
|
+
>
|
|
470
|
+
{loadingMore
|
|
471
|
+
? t('mcpAgents.activity.loadingMore')
|
|
472
|
+
: t('mcpAgents.activity.loadMore')}
|
|
473
|
+
</Button>
|
|
474
|
+
) : null}
|
|
475
|
+
</>
|
|
476
|
+
)}
|
|
477
|
+
</div>
|
|
478
|
+
) : null}
|
|
479
|
+
</div>
|
|
480
|
+
);
|
|
481
|
+
};
|