@shellui/core 0.8.1 → 0.8.3

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.
Files changed (27) hide show
  1. package/README.md +1 -1
  2. package/package.json +29 -29
  3. package/schemas/shellui.config.schema.json +4 -0
  4. package/src/components/contentIframeSandbox.spec.ts +51 -8
  5. package/src/components/contentIframeSandbox.ts +60 -19
  6. package/src/features/auth/appBackend/childFrames.ts +3 -8
  7. package/src/features/auth/appBackend/identity.ts +1 -3
  8. package/src/features/auth/appBackend/silentSignIn.ts +1 -2
  9. package/src/features/auth/appBackend/tokenExchange.ts +1 -2
  10. package/src/features/auth/shellAccountRequests.ts +1 -2
  11. package/src/features/config/types.ts +12 -11
  12. package/src/features/layouts/floating/FloatingSidebar.tsx +1 -2
  13. package/src/features/legal/legalDocuments.ts +1 -4
  14. package/src/features/mcp/mcpAgentActivityPresentation.ts +1 -2
  15. package/src/features/mcp/mcpAgentsConnect.spec.ts +62 -0
  16. package/src/features/mcp/mcpAgentsConnect.ts +49 -0
  17. package/src/features/mcp/personalAgentsApi.ts +1 -6
  18. package/src/features/security/trustedFrames.spec.ts +44 -0
  19. package/src/features/security/trustedFrames.ts +35 -0
  20. package/src/features/settings/SettingsProvider.spec.tsx +167 -0
  21. package/src/features/settings/SettingsProvider.tsx +17 -0
  22. package/src/features/settings/components/McpAgents.spec.tsx +31 -2
  23. package/src/features/settings/components/McpAgents.tsx +11 -3
  24. package/src/features/settings/components/McpPendingApprovals.tsx +147 -136
  25. package/src/features/sonner/SonnerContext.tsx +1 -6
  26. package/src/features/storage/uploads/handleTrackedUpload.spec.ts +1 -2
  27. package/src/routes/utils/navigationRouteAccess.ts +1 -4
@@ -1,6 +1,7 @@
1
1
  import type { ShellUIConfig } from '../config/types';
2
2
  import urls from '../../constants/urls';
3
3
  import { isAdminFrame } from '../admin/utils';
4
+ import { isShellOwnedPath } from '../layouts/floating/isShellOwnedPath';
4
5
  import { flattenNavigationItems, isFrameForAppUrl } from '../layouts/utils';
5
6
 
6
7
  function currentShellOrigin(): string | null {
@@ -116,6 +117,40 @@ export function isShellSettingsFrameMessage(
116
117
  return isShellSettingsFrameSrc(frameSrc, shellOrigin, settingsPath);
117
118
  }
118
119
 
120
+ /** Same-origin shell page (settings, cookie preferences, login, admin, legal, demos). */
121
+ export function isShellOwnedFrameSrc(frameSrc: string, shellOrigin: string): boolean {
122
+ try {
123
+ const url = new URL(frameSrc, shellOrigin);
124
+ return url.origin === shellOrigin && isShellOwnedPath(url.pathname);
125
+ } catch {
126
+ return false;
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Whether a message came from the shell window itself or directly from a shell
132
+ * page. Companion frames are rejected, including ones opted in for an access
133
+ * token. Messages relayed through a nested frame (more than one hop) are rejected.
134
+ */
135
+ export function isShellOwnedFrameMessage(
136
+ from: string[] | undefined,
137
+ frameRegistry: FrameRegistryLike,
138
+ shellOrigin: string,
139
+ ): boolean {
140
+ const hops = (from ?? []).filter(Boolean);
141
+ if (hops.length === 0) {
142
+ return true;
143
+ }
144
+ if (hops.length !== 1) {
145
+ return false;
146
+ }
147
+ const frameSrc = resolveRegisteredFrameSrc(hops, frameRegistry);
148
+ if (!frameSrc) {
149
+ return false;
150
+ }
151
+ return isShellOwnedFrameSrc(frameSrc, shellOrigin);
152
+ }
153
+
119
154
  export type StorageTrustDenial = { message: string; status: 403 };
120
155
 
121
156
  /**
@@ -0,0 +1,167 @@
1
+ // @vitest-environment happy-dom
2
+ import { act } from 'react';
3
+ import { createRoot, type Root } from 'react-dom/client';
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
+ import { shellui, type ShellUIMessage } from '@shellui/sdk';
6
+ import { SettingsProvider } from './SettingsProvider';
7
+ import { useSettings } from './SettingsContext';
8
+
9
+ vi.mock('../config/useConfig', () => ({
10
+ useConfig: () => ({ config: { navigation: [] }, isLoading: false }),
11
+ }));
12
+
13
+ vi.mock('../auth/hooks/useAuth', () => ({
14
+ useAuth: () => ({
15
+ user: null,
16
+ session: null,
17
+ syncUserPreferences: vi.fn(async () => undefined),
18
+ loadUserPreferences: vi.fn(async () => null),
19
+ logout: vi.fn(async () => undefined),
20
+ }),
21
+ }));
22
+
23
+ function OllamaProbe() {
24
+ const { settings } = useSettings();
25
+ return <output>{settings.ai?.ollamaBaseUrl ?? ''}</output>;
26
+ }
27
+
28
+ /** In-memory storage. Node 25's global localStorage has no clear(). */
29
+ function memoryStorage(): Storage {
30
+ const data = new Map<string, string>();
31
+ return {
32
+ getItem: (key: string) => data.get(key) ?? null,
33
+ setItem: (key: string, value: string) => {
34
+ data.set(key, value);
35
+ },
36
+ removeItem: (key: string) => {
37
+ data.delete(key);
38
+ },
39
+ clear: () => {
40
+ data.clear();
41
+ },
42
+ key: (index: number) => [...data.keys()][index] ?? null,
43
+ get length() {
44
+ return data.size;
45
+ },
46
+ };
47
+ }
48
+
49
+ describe('SettingsProvider settings messages', () => {
50
+ let container: HTMLDivElement;
51
+ let root: Root | undefined;
52
+ let listeners: Map<string, (message: ShellUIMessage) => void>;
53
+ let warn: ReturnType<typeof vi.spyOn>;
54
+
55
+ beforeEach(() => {
56
+ vi.stubGlobal('localStorage', memoryStorage());
57
+ listeners = new Map();
58
+ vi.spyOn(shellui, 'addMessageListener').mockImplementation((type, cb) => {
59
+ listeners.set(type, cb);
60
+ return () => {
61
+ if (listeners.get(type) === cb) listeners.delete(type);
62
+ };
63
+ });
64
+ warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
65
+ container = document.createElement('div');
66
+ document.body.appendChild(container);
67
+ root = createRoot(container);
68
+ });
69
+
70
+ afterEach(() => {
71
+ if (root) act(() => root.unmount());
72
+ container?.remove();
73
+ vi.restoreAllMocks();
74
+ vi.unstubAllGlobals();
75
+ });
76
+
77
+ async function renderProvider() {
78
+ await act(async () => {
79
+ root.render(
80
+ <SettingsProvider>
81
+ <OllamaProbe />
82
+ </SettingsProvider>,
83
+ );
84
+ });
85
+ }
86
+
87
+ function frames(entries: Array<[string, string]>) {
88
+ vi.spyOn(shellui.frameRegistry, 'getAllIframes').mockReturnValue(
89
+ entries.map(([uuid, src]) => [uuid, { src } as HTMLIFrameElement]),
90
+ );
91
+ }
92
+
93
+ function deliver(
94
+ type: 'SHELLUI_SETTINGS' | 'SHELLUI_SETTINGS_UPDATED',
95
+ from: string[],
96
+ url: string,
97
+ ) {
98
+ const listener = listeners.get(type);
99
+ expect(listener).toBeTypeOf('function');
100
+ act(() => {
101
+ listener?.({
102
+ type,
103
+ from,
104
+ payload: { settings: { ai: { ollamaBaseUrl: url } } },
105
+ } as ShellUIMessage);
106
+ });
107
+ }
108
+
109
+ function shownUrl(): string {
110
+ return container.querySelector('output')?.textContent ?? '';
111
+ }
112
+
113
+ it('rejects a settings update from a registered companion', async () => {
114
+ const origin = window.location.origin;
115
+ frames([
116
+ ['companion', 'http://127.0.0.1:5175/'],
117
+ ['same-origin-app', `${origin}/app/`],
118
+ ]);
119
+ await renderProvider();
120
+
121
+ deliver('SHELLUI_SETTINGS_UPDATED', ['companion'], 'http://evil.example:11434');
122
+ expect(shownUrl()).toBe('');
123
+ expect(localStorage.getItem('shellui:settings')).toBeNull();
124
+ expect(warn).toHaveBeenCalled();
125
+
126
+ deliver('SHELLUI_SETTINGS', ['same-origin-app'], 'http://evil.example:11435');
127
+ expect(shownUrl()).toBe('');
128
+ expect(localStorage.getItem('shellui:settings')).toBeNull();
129
+ });
130
+
131
+ it('rejects a companion that is allowed to receive an access token', async () => {
132
+ frames([['trusted-companion', 'http://127.0.0.1:5175/company']]);
133
+ await renderProvider();
134
+ deliver('SHELLUI_SETTINGS_UPDATED', ['trusted-companion'], 'http://evil.example:11434');
135
+ expect(shownUrl()).toBe('');
136
+ expect(warn).toHaveBeenCalled();
137
+ });
138
+
139
+ it('applies a settings update from a shell page', async () => {
140
+ const origin = window.location.origin;
141
+ frames([
142
+ ['settings', `${origin}/__settings/ai`],
143
+ ['cookies', `${origin}/__cookie-preferences`],
144
+ ]);
145
+ await renderProvider();
146
+
147
+ deliver('SHELLUI_SETTINGS_UPDATED', ['settings'], 'http://127.0.0.1:11434');
148
+ expect(shownUrl()).toBe('http://127.0.0.1:11434');
149
+ expect(localStorage.getItem('shellui:settings')).toContain('http://127.0.0.1:11434');
150
+
151
+ deliver('SHELLUI_SETTINGS_UPDATED', ['cookies'], 'http://127.0.0.1:11435');
152
+ expect(shownUrl()).toBe('http://127.0.0.1:11435');
153
+ });
154
+
155
+ it('rejects a settings update relayed through another frame', async () => {
156
+ const origin = window.location.origin;
157
+ frames([['settings', `${origin}/__settings/ai`]]);
158
+ await renderProvider();
159
+ deliver(
160
+ 'SHELLUI_SETTINGS_UPDATED',
161
+ ['settings', 'nested-companion'],
162
+ 'http://evil.example:11434',
163
+ );
164
+ expect(shownUrl()).toBe('');
165
+ expect(warn).toHaveBeenCalled();
166
+ });
167
+ });
@@ -62,6 +62,7 @@ import {
62
62
  } from './utils';
63
63
  import { unregisterServiceWorker } from '../../service-worker/register';
64
64
  import { refreshFrameAccessTokenIfNeeded } from '../auth/utils/frameSessionRefresher';
65
+ import { isShellOwnedFrameMessage } from '../security/trustedFrames';
65
66
 
66
67
  const logger = getLogger('shellcore');
67
68
 
@@ -520,9 +521,24 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
520
521
  return;
521
522
  }
522
523
 
524
+ const settingsMessageFromShell = (message: ShellUIMessage): boolean => {
525
+ const from = (message.from ?? []).filter(Boolean);
526
+ if (isShellOwnedFrameMessage(from, shellui.frameRegistry, window.location.origin)) {
527
+ return true;
528
+ }
529
+ // Visible without the shellcore debug namespace. Do not log the payload.
530
+ // eslint-disable-next-line no-console
531
+ console.warn('Shellui rejected a settings message from a companion frame.', {
532
+ type: message.type,
533
+ from,
534
+ });
535
+ return false;
536
+ };
537
+
523
538
  const cleanup = shellui.addMessageListener(
524
539
  'SHELLUI_SETTINGS_UPDATED',
525
540
  (message: ShellUIMessage) => {
541
+ if (!settingsMessageFromShell(message)) return;
526
542
  const payload = message.payload as { settings: Settings };
527
543
  const newSettings = payload.settings;
528
544
  if (newSettings) {
@@ -624,6 +640,7 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
624
640
  'SHELLUI_SETTINGS',
625
641
  (data: ShellUIMessage) => {
626
642
  const message = data as ShellUIMessage;
643
+ if (!settingsMessageFromShell(message)) return;
627
644
  const payload = message.payload as { settings: Settings };
628
645
  const newSettings = payload.settings;
629
646
  if (newSettings) {
@@ -15,6 +15,8 @@ import { McpAgents } from './McpAgents';
15
15
  const page = vi.hoisted(() => ({
16
16
  language: 'en',
17
17
  aiUrl: 'https://ai.example/' as string | null,
18
+ mcpUrl: null as string | null,
19
+ companyId: '42',
18
20
  visibility: 'visible',
19
21
  }));
20
22
 
@@ -42,8 +44,15 @@ vi.mock('../../config/useConfig', () => ({
42
44
  useConfig: () => ({
43
45
  config: {
44
46
  title: 'Acme',
45
- backend: { type: 'shellui', url: 'https://id.example', companyId: '42' },
46
- ...(page.aiUrl ? { aiService: { url: page.aiUrl } } : {}),
47
+ backend: { type: 'shellui', url: 'https://id.example', companyId: page.companyId },
48
+ ...(page.aiUrl
49
+ ? {
50
+ aiService: {
51
+ url: page.aiUrl,
52
+ ...(page.mcpUrl ? { mcpUrl: page.mcpUrl } : {}),
53
+ },
54
+ }
55
+ : {}),
47
56
  },
48
57
  }),
49
58
  }));
@@ -145,6 +154,8 @@ let root: Root;
145
154
  beforeEach(() => {
146
155
  page.language = 'en';
147
156
  page.aiUrl = 'https://ai.example/';
157
+ page.mcpUrl = null;
158
+ page.companyId = '42';
148
159
  page.visibility = 'visible';
149
160
  Object.defineProperty(document, 'visibilityState', {
150
161
  configurable: true,
@@ -243,6 +254,24 @@ describe('McpAgents connect prompt', () => {
243
254
  expect(container.querySelector('pre')).toBeNull();
244
255
  expect(buttonByText('Copy prompt')).toBeUndefined();
245
256
  });
257
+
258
+ it('shows the global account MCP URL when aiService.mcpUrl is set, even with a company id', async () => {
259
+ const globalUrl = 'https://global.example/mcp';
260
+ page.companyId = '1';
261
+ page.mcpUrl = globalUrl;
262
+ await renderPage();
263
+
264
+ expect(container.textContent).toContain(globalUrl);
265
+ expect(container.textContent).not.toContain('https://ai.example/c/1/mcp');
266
+ const prompt = container.querySelector('pre')?.textContent ?? '';
267
+ expect(prompt).toBe(buildAgentPrompt(globalUrl, 'en'));
268
+
269
+ await act(async () => {
270
+ buttonByText('Copy URL')?.click();
271
+ await Promise.resolve();
272
+ });
273
+ expect(writeText).toHaveBeenCalledWith(globalUrl);
274
+ });
246
275
  });
247
276
 
248
277
  describe('McpAgents static secret', () => {
@@ -7,7 +7,7 @@ import { useAuth } from '../../auth/hooks/useAuth';
7
7
  import {
8
8
  agentIncludesSaasScope,
9
9
  buildAgentPrompt,
10
- buildCompanyMcpUrl,
10
+ resolveSettingsMcpUrl,
11
11
  MCP_PERSONAL_AGENT_MAX_LIFETIME_DAYS,
12
12
  defaultPersonalAgentExpiresAt,
13
13
  formatAgentExpiry,
@@ -76,9 +76,17 @@ export const McpAgents = () => {
76
76
  return u || null;
77
77
  }, [status?.globalMcpUrl]);
78
78
 
79
+ const configuredGlobalMcpUrl = config?.aiService?.mcpUrl ?? null;
79
80
  const companyMcpUrl = useMemo(
80
- () => buildCompanyMcpUrl(aiServiceUrl, companyId, status?.mcpUrl),
81
- [aiServiceUrl, companyId, status?.mcpUrl],
81
+ () =>
82
+ resolveSettingsMcpUrl({
83
+ aiServiceUrl,
84
+ companyId,
85
+ configuredGlobalMcpUrl,
86
+ statusMcpUrl: status?.mcpUrl,
87
+ statusGlobalMcpUrl: status?.globalMcpUrl,
88
+ }),
89
+ [aiServiceUrl, companyId, configuredGlobalMcpUrl, status?.globalMcpUrl, status?.mcpUrl],
82
90
  );
83
91
  const absoluteMcpUrl = useMemo(
84
92
  () => (companyMcpUrl && isAbsoluteHttpUrl(companyMcpUrl) ? companyMcpUrl : null),
@@ -20,149 +20,160 @@ type Props = {
20
20
  onRefresh: () => Promise<void>;
21
21
  };
22
22
 
23
- export const McpPendingApprovals = forwardRef<HTMLElement, Props>(function McpPendingApprovals(
24
- { backendUrl, accessToken, companyId, enabled, companyName, approvals, pendingCount, onRefresh },
25
- ref,
26
- ) {
27
- const { t } = useTranslation('settings');
23
+ export const McpPendingApprovals = forwardRef<HTMLElement, Props>(
24
+ (
25
+ {
26
+ backendUrl,
27
+ accessToken,
28
+ companyId,
29
+ enabled,
30
+ companyName,
31
+ approvals,
32
+ pendingCount,
33
+ onRefresh,
34
+ },
35
+ ref,
36
+ ) => {
37
+ const { t } = useTranslation('settings');
28
38
 
29
- const [decidingId, setDecidingId] = useState<string | null>(null);
39
+ const [decidingId, setDecidingId] = useState<string | null>(null);
30
40
 
31
- const runDecide = useCallback(
32
- async (approval: McpPendingToolApproval, decision: 'approve' | 'deny') => {
33
- setDecidingId(approval.id);
34
- try {
35
- await decideMcpToolApproval(backendUrl, accessToken, companyId, approval.id, decision);
36
- shellui.toast({
37
- type: 'success',
38
- title:
39
- decision === 'approve'
40
- ? t('mcpAgents.pendingApprovals.toast.approvedTitle')
41
- : t('mcpAgents.pendingApprovals.toast.deniedTitle'),
42
- description: t('mcpAgents.pendingApprovals.toast.description', {
43
- toolName: approval.toolName,
44
- }),
45
- });
46
- await onRefresh();
47
- } catch {
48
- shellui.toast({
49
- type: 'error',
50
- title: t('mcpAgents.pendingApprovals.toast.errorTitle'),
51
- });
52
- } finally {
53
- setDecidingId(null);
54
- }
55
- },
56
- [accessToken, backendUrl, companyId, onRefresh, t],
57
- );
41
+ const runDecide = useCallback(
42
+ async (approval: McpPendingToolApproval, decision: 'approve' | 'deny') => {
43
+ setDecidingId(approval.id);
44
+ try {
45
+ await decideMcpToolApproval(backendUrl, accessToken, companyId, approval.id, decision);
46
+ shellui.toast({
47
+ type: 'success',
48
+ title:
49
+ decision === 'approve'
50
+ ? t('mcpAgents.pendingApprovals.toast.approvedTitle')
51
+ : t('mcpAgents.pendingApprovals.toast.deniedTitle'),
52
+ description: t('mcpAgents.pendingApprovals.toast.description', {
53
+ toolName: approval.toolName,
54
+ }),
55
+ });
56
+ await onRefresh();
57
+ } catch {
58
+ shellui.toast({
59
+ type: 'error',
60
+ title: t('mcpAgents.pendingApprovals.toast.errorTitle'),
61
+ });
62
+ } finally {
63
+ setDecidingId(null);
64
+ }
65
+ },
66
+ [accessToken, backendUrl, companyId, onRefresh, t],
67
+ );
58
68
 
59
- const handleApprove = useCallback(
60
- (approval: McpPendingToolApproval) => {
61
- if (approval.isDestructive) {
62
- shellui.dialog({
63
- title: t('mcpAgents.pendingApprovals.confirmApprove.title', {
64
- toolName: approval.toolName,
65
- }),
66
- description: t('mcpAgents.pendingApprovals.confirmApprove.description', {
67
- companyName,
68
- }),
69
- mode: 'okCancel',
70
- size: 'sm',
71
- okLabel: t('mcpAgents.pendingApprovals.confirmApprove.confirm'),
72
- cancelLabel: t('mcpAgents.pendingApprovals.confirmApprove.cancel'),
73
- onOk: async () => {
74
- await runDecide(approval, 'approve');
75
- },
76
- onCancel: () => {},
77
- });
78
- return;
79
- }
80
- void runDecide(approval, 'approve');
81
- },
82
- [companyName, runDecide, t],
83
- );
69
+ const handleApprove = useCallback(
70
+ (approval: McpPendingToolApproval) => {
71
+ if (approval.isDestructive) {
72
+ shellui.dialog({
73
+ title: t('mcpAgents.pendingApprovals.confirmApprove.title', {
74
+ toolName: approval.toolName,
75
+ }),
76
+ description: t('mcpAgents.pendingApprovals.confirmApprove.description', {
77
+ companyName,
78
+ }),
79
+ mode: 'okCancel',
80
+ size: 'sm',
81
+ okLabel: t('mcpAgents.pendingApprovals.confirmApprove.confirm'),
82
+ cancelLabel: t('mcpAgents.pendingApprovals.confirmApprove.cancel'),
83
+ onOk: async () => {
84
+ await runDecide(approval, 'approve');
85
+ },
86
+ onCancel: () => {},
87
+ });
88
+ return;
89
+ }
90
+ void runDecide(approval, 'approve');
91
+ },
92
+ [companyName, runDecide, t],
93
+ );
84
94
 
85
- if (!enabled || pendingCount <= 0 || approvals.length === 0) {
86
- return null;
87
- }
95
+ if (!enabled || pendingCount <= 0 || approvals.length === 0) {
96
+ return null;
97
+ }
88
98
 
89
- const countLabel = String(pendingCount);
99
+ const countLabel = String(pendingCount);
90
100
 
91
- return (
92
- <section
93
- ref={ref}
94
- className="space-y-4 scroll-mt-8"
95
- >
96
- <div className="flex flex-wrap items-center gap-2">
97
- <h2
98
- className="text-sm font-medium leading-none"
99
- style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
100
- >
101
- {t('mcpAgents.pendingApprovals.title')}
102
- </h2>
103
- <Badge
104
- variant="muted"
105
- className="font-normal tabular-nums"
106
- >
107
- {countLabel}
108
- </Badge>
109
- </div>
110
- <ul className="space-y-3">
111
- {approvals.map((approval) => {
112
- const expiresInMinutes = mcpApprovalExpiresInMinutes(approval.expiresAt);
113
- const busy = decidingId === approval.id;
114
- return (
115
- <li
116
- key={approval.id}
117
- className="rounded-lg border bg-card p-4"
118
- >
119
- <div className="flex flex-wrap items-start justify-between gap-3">
120
- <div className="min-w-0 space-y-1">
121
- <p className="text-sm font-medium font-mono">{approval.toolName}</p>
122
- <p className="text-sm text-muted-foreground">
123
- {t('mcpAgents.pendingApprovals.meta', {
124
- agentName: approval.agentName,
125
- expiresInMinutes,
126
- })}
127
- </p>
128
- {approval.shortActionSummary ? (
129
- <p className="text-sm text-muted-foreground">{approval.shortActionSummary}</p>
130
- ) : null}
131
- {approval.isDestructive ? (
132
- <Badge
133
- variant="muted"
134
- className="mt-1 font-normal"
101
+ return (
102
+ <section
103
+ ref={ref}
104
+ className="space-y-4 scroll-mt-8"
105
+ >
106
+ <div className="flex flex-wrap items-center gap-2">
107
+ <h2
108
+ className="text-sm font-medium leading-none"
109
+ style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
110
+ >
111
+ {t('mcpAgents.pendingApprovals.title')}
112
+ </h2>
113
+ <Badge
114
+ variant="muted"
115
+ className="font-normal tabular-nums"
116
+ >
117
+ {countLabel}
118
+ </Badge>
119
+ </div>
120
+ <ul className="space-y-3">
121
+ {approvals.map((approval) => {
122
+ const expiresInMinutes = mcpApprovalExpiresInMinutes(approval.expiresAt);
123
+ const busy = decidingId === approval.id;
124
+ return (
125
+ <li
126
+ key={approval.id}
127
+ className="rounded-lg border bg-card p-4"
128
+ >
129
+ <div className="flex flex-wrap items-start justify-between gap-3">
130
+ <div className="min-w-0 space-y-1">
131
+ <p className="text-sm font-medium font-mono">{approval.toolName}</p>
132
+ <p className="text-sm text-muted-foreground">
133
+ {t('mcpAgents.pendingApprovals.meta', {
134
+ agentName: approval.agentName,
135
+ expiresInMinutes,
136
+ })}
137
+ </p>
138
+ {approval.shortActionSummary ? (
139
+ <p className="text-sm text-muted-foreground">{approval.shortActionSummary}</p>
140
+ ) : null}
141
+ {approval.isDestructive ? (
142
+ <Badge
143
+ variant="muted"
144
+ className="mt-1 font-normal"
145
+ >
146
+ {t('mcpAgents.pendingApprovals.destructiveBadge')}
147
+ </Badge>
148
+ ) : null}
149
+ </div>
150
+ <div className="flex shrink-0 flex-wrap gap-2">
151
+ <Button
152
+ type="button"
153
+ size="sm"
154
+ disabled={busy}
155
+ onClick={() => handleApprove(approval)}
135
156
  >
136
- {t('mcpAgents.pendingApprovals.destructiveBadge')}
137
- </Badge>
138
- ) : null}
139
- </div>
140
- <div className="flex shrink-0 flex-wrap gap-2">
141
- <Button
142
- type="button"
143
- size="sm"
144
- disabled={busy}
145
- onClick={() => handleApprove(approval)}
146
- >
147
- {t('mcpAgents.pendingApprovals.approve')}
148
- </Button>
149
- <Button
150
- type="button"
151
- variant="outline"
152
- size="sm"
153
- disabled={busy}
154
- onClick={() => void runDecide(approval, 'deny')}
155
- >
156
- {t('mcpAgents.pendingApprovals.deny')}
157
- </Button>
157
+ {t('mcpAgents.pendingApprovals.approve')}
158
+ </Button>
159
+ <Button
160
+ type="button"
161
+ variant="outline"
162
+ size="sm"
163
+ disabled={busy}
164
+ onClick={() => void runDecide(approval, 'deny')}
165
+ >
166
+ {t('mcpAgents.pendingApprovals.deny')}
167
+ </Button>
168
+ </div>
158
169
  </div>
159
- </div>
160
- </li>
161
- );
162
- })}
163
- </ul>
164
- </section>
165
- );
166
- });
170
+ </li>
171
+ );
172
+ })}
173
+ </ul>
174
+ </section>
175
+ );
176
+ },
177
+ );
167
178
 
168
179
  McpPendingApprovals.displayName = 'McpPendingApprovals';
@@ -9,12 +9,7 @@ interface ToastOptions {
9
9
  type?: 'default' | 'success' | 'error' | 'warning' | 'info' | 'loading';
10
10
  duration?: number;
11
11
  position?:
12
- | 'top-left'
13
- | 'top-center'
14
- | 'top-right'
15
- | 'bottom-left'
16
- | 'bottom-center'
17
- | 'bottom-right';
12
+ 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
18
13
  action?: {
19
14
  label: string;
20
15
  onClick: () => void;
@@ -10,8 +10,7 @@ class MockXHR {
10
10
  responseText = '';
11
11
  upload: {
12
12
  onprogress:
13
- | ((event: { lengthComputable: boolean; loaded: number; total: number }) => void)
14
- | null;
13
+ ((event: { lengthComputable: boolean; loaded: number; total: number }) => void) | null;
15
14
  } = {
16
15
  onprogress: null,
17
16
  };