@steerable/agent-shell-web 0.14.1 → 0.14.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.
@@ -1,5 +1,5 @@
1
- import { useEffect, useRef } from 'react';
2
- import { LuFlag, LuShieldAlert, LuTriangleAlert } from 'react-icons/lu';
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { LuChevronDown, LuFlag, LuShieldAlert, LuTriangleAlert } from 'react-icons/lu';
3
3
  import {
4
4
  type ApprovalDecisionKind,
5
5
  type ApprovalPromptRequest,
@@ -9,9 +9,11 @@ import { t } from '@/i18n';
9
9
  /**
10
10
  * ApprovalPromptMenu — W4-1 & Phase 9 `outward` approval UI.
11
11
  *
12
- * Supports the 7-variant approval algebra for standard/egress/sandbox prompts,
13
- * and enforces single-invocation confirmation for `checkpoint === 'outward'`
14
- * (hiding session/always options and placing initial keyboard focus on Reject).
12
+ * Supports the 7-variant approval algebra for standard/egress/sandbox prompts
13
+ * with a converged primary action bar + overflow scope menu, structured code
14
+ * and command previews, honest sandbox boundary messaging, keyboard shortcuts,
15
+ * and single-invocation confirmation for `checkpoint === 'outward'` (hiding
16
+ * session/always options and placing initial keyboard focus on Reject).
15
17
  */
16
18
 
17
19
  const MODE_LABEL: Record<string, string> = {
@@ -21,78 +23,197 @@ const MODE_LABEL: Record<string, string> = {
21
23
  other: 'Other',
22
24
  };
23
25
 
24
- function summarizeArguments(args: Record<string, unknown>): string {
25
- for (const key of ['url', 'command', 'cmd', 'path', 'file', 'target', 'query', 'content']) {
26
- const v = args[key];
27
- if (typeof v === 'string' && v.length > 0) {
28
- return v.length > 300 ? `${v.slice(0, 300)}…` : v;
26
+ /** Tools wrapped by `SandboxedToolExecutor` when the workspace sandbox is active. */
27
+ const SANDBOXED_SHELL_TOOLS = new Set(['bash', 'shell', 'local_exec_shell']);
28
+ const SNIPPET_TOOLS = new Set(['local_run_snippet', 'run_code']);
29
+
30
+ type ArgumentPreview =
31
+ | {
32
+ kind: 'snippet';
33
+ language: string;
34
+ packages: string[];
35
+ cwd: string;
36
+ code: string;
29
37
  }
30
- }
31
- const json = JSON.stringify(args);
32
- return json.length > 300 ? `${json.slice(0, 300)}…` : json;
38
+ | {
39
+ kind: 'command';
40
+ command: string;
41
+ cwd: string;
42
+ }
43
+ | {
44
+ kind: 'file';
45
+ path: string;
46
+ body: string;
47
+ }
48
+ | {
49
+ kind: 'text';
50
+ text: string;
51
+ };
52
+
53
+ function truncateText(value: string, maxChars: number): string {
54
+ return value.length > maxChars ? `${value.slice(0, maxChars)}…` : value;
33
55
  }
34
56
 
35
- interface DecisionButton {
36
- kind: ApprovalDecisionKind;
37
- label: string;
38
- tone: 'allow' | 'deny' | 'abort';
57
+ function formatSnippetLanguage(raw: unknown): string {
58
+ if (typeof raw !== 'string') return '';
59
+ const trimmed = raw.trim();
60
+ const lower = trimmed.toLowerCase();
61
+ if (lower === 'python' || lower === 'py') return 'Python';
62
+ if (lower === 'node' || lower === 'javascript' || lower === 'js') return 'Node.js';
63
+ return trimmed;
39
64
  }
40
65
 
41
- function categoryName(label: string): string {
42
- return t(label);
66
+ function extractStringList(raw: unknown): string[] {
67
+ if (!Array.isArray(raw)) return [];
68
+ return raw
69
+ .filter((item): item is string => typeof item === 'string')
70
+ .map((item) => item.trim())
71
+ .filter((item) => item.length > 0);
43
72
  }
44
73
 
45
- function allowButtons(request: ApprovalPromptRequest): DecisionButton[] {
46
- const category = request.category !== request.toolName && request.categoryLabel
47
- ? categoryName(request.categoryLabel)
48
- : undefined;
49
- return [
50
- { kind: 'allow_once', label: 'Allow once', tone: 'allow' },
51
- {
52
- kind: 'allow_for_session',
53
- label: category ? t('Allow {category} for this chat', { category }) : 'Allow for this chat',
54
- tone: 'allow',
55
- },
56
- {
57
- kind: 'allow_always',
58
- label: category ? t('Always allow {category}', { category }) : 'Always allow',
59
- tone: 'allow',
60
- },
61
- ];
74
+ function buildArgumentPreview(
75
+ toolName: string,
76
+ args: Record<string, unknown>,
77
+ ): ArgumentPreview {
78
+ const cwd = typeof args.cwd === 'string' && args.cwd.trim() ? args.cwd.trim() : '';
79
+
80
+ if (
81
+ SNIPPET_TOOLS.has(toolName) ||
82
+ (typeof args.code === 'string' && args.code.length > 0)
83
+ ) {
84
+ const packages = [
85
+ ...extractStringList(args.pipPackages),
86
+ ...extractStringList(args.npmPackages),
87
+ ];
88
+ return {
89
+ kind: 'snippet',
90
+ language: formatSnippetLanguage(args.language),
91
+ packages,
92
+ cwd,
93
+ code: truncateText(typeof args.code === 'string' ? args.code : '', 2000),
94
+ };
95
+ }
96
+
97
+ const command =
98
+ typeof args.command === 'string' && args.command.length > 0
99
+ ? args.command
100
+ : typeof args.cmd === 'string' && args.cmd.length > 0
101
+ ? args.cmd
102
+ : '';
103
+ if (command) {
104
+ return {
105
+ kind: 'command',
106
+ command: truncateText(command, 600),
107
+ cwd,
108
+ };
109
+ }
110
+
111
+ const filePath =
112
+ typeof args.path === 'string' && args.path.length > 0
113
+ ? args.path
114
+ : typeof args.file_path === 'string' && args.file_path.length > 0
115
+ ? args.file_path
116
+ : typeof args.file === 'string' && args.file.length > 0
117
+ ? args.file
118
+ : '';
119
+ if (filePath) {
120
+ const rawBody =
121
+ typeof args.content === 'string' && args.content.length > 0
122
+ ? args.content
123
+ : typeof args.new_string === 'string' && args.new_string.length > 0
124
+ ? args.new_string
125
+ : '';
126
+ return {
127
+ kind: 'file',
128
+ path: truncateText(filePath, 300),
129
+ body: rawBody ? truncateText(rawBody, 600) : '',
130
+ };
131
+ }
132
+
133
+ for (const key of ['url', 'target', 'query', 'content']) {
134
+ const v = args[key];
135
+ if (typeof v === 'string' && v.length > 0) {
136
+ return { kind: 'text', text: truncateText(v, 400) };
137
+ }
138
+ }
139
+
140
+ if (Object.keys(args).length === 0) {
141
+ return { kind: 'text', text: '' };
142
+ }
143
+ return {
144
+ kind: 'text',
145
+ text: truncateText(JSON.stringify(args, null, 2), 600),
146
+ };
62
147
  }
63
148
 
64
- const DENY_BUTTONS: DecisionButton[] = [
65
- { kind: 'deny_once', label: 'Deny once', tone: 'deny' },
66
- { kind: 'deny_for_session', label: 'Deny for this chat', tone: 'deny' },
67
- { kind: 'deny_always', label: 'Always deny', tone: 'deny' },
68
- ];
149
+ function ArgumentPreviewBox({ preview }: { preview: ArgumentPreview }) {
150
+ switch (preview.kind) {
151
+ case 'snippet':
152
+ return (
153
+ <div className="overflow-hidden rounded-agent-md border border-agent-border/70 bg-agent-muted/40">
154
+ {(preview.language || preview.packages.length > 0 || preview.cwd) && (
155
+ <div className="flex flex-wrap items-center gap-1.5 border-b border-agent-border/60 bg-agent-muted/60 px-2.5 py-1 text-[11px]">
156
+ {preview.language && (
157
+ <span className="font-medium text-agent-foreground">{preview.language}</span>
158
+ )}
159
+ {preview.packages.length > 0 && (
160
+ <span
161
+ className="rounded border border-amber-500/30 bg-amber-500/15 px-1.5 py-0.5 font-mono text-[11px] font-medium text-amber-900 dark:text-amber-200"
162
+ data-testid="approval-snippet-packages"
163
+ >
164
+ {t('Install packages: {packages}', {
165
+ packages: preview.packages.join(', '),
166
+ })}
167
+ </span>
168
+ )}
169
+ {preview.cwd && (
170
+ <span className="font-mono text-agent-muted-foreground">cwd: {preview.cwd}</span>
171
+ )}
172
+ </div>
173
+ )}
174
+ <pre className="whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs leading-relaxed text-agent-foreground">
175
+ {preview.code}
176
+ </pre>
177
+ </div>
178
+ );
179
+ case 'command':
180
+ return (
181
+ <div className="overflow-hidden rounded-agent-md border border-agent-border/70 bg-agent-muted/40">
182
+ <pre className="whitespace-pre-wrap break-all px-3 py-2 font-mono text-xs leading-relaxed text-agent-foreground">
183
+ <span className="select-none text-agent-muted-foreground">$ </span>
184
+ <span>{preview.command}</span>
185
+ </pre>
186
+ {preview.cwd && (
187
+ <div className="border-t border-agent-border/60 px-3 py-1 font-mono text-[11px] text-agent-muted-foreground">
188
+ cwd: {preview.cwd}
189
+ </div>
190
+ )}
191
+ </div>
192
+ );
193
+ case 'file':
194
+ return (
195
+ <div className="overflow-hidden rounded-agent-md border border-agent-border/70 bg-agent-muted/40">
196
+ <div className="break-all px-3 py-1.5 font-mono text-xs text-agent-foreground">
197
+ {preview.path}
198
+ </div>
199
+ {preview.body && (
200
+ <pre className="whitespace-pre-wrap break-words border-t border-agent-border/60 px-3 py-2 font-mono text-[11px] leading-relaxed text-agent-muted-foreground">
201
+ {preview.body}
202
+ </pre>
203
+ )}
204
+ </div>
205
+ );
206
+ case 'text':
207
+ return preview.text ? (
208
+ <pre className="whitespace-pre-wrap break-words rounded-agent-md border border-agent-border/70 bg-agent-muted/40 px-3 py-2 font-mono text-xs leading-relaxed text-agent-foreground">
209
+ {preview.text}
210
+ </pre>
211
+ ) : null;
212
+ }
213
+ }
69
214
 
70
- function DecisionRow({
71
- buttons,
72
- onPick,
73
- }: {
74
- buttons: DecisionButton[];
75
- onPick: (kind: ApprovalDecisionKind) => void;
76
- }) {
77
- return (
78
- <div className="flex flex-wrap gap-2">
79
- {buttons.map((b) => (
80
- <button
81
- key={b.kind}
82
- type="button"
83
- data-testid={`approval-${b.kind}`}
84
- onClick={() => onPick(b.kind)}
85
- className={
86
- b.tone === 'allow'
87
- ? 'rounded-agent-md bg-agent-foreground px-3 py-1.5 text-xs font-medium text-agent-canvas transition hover:opacity-90'
88
- : 'rounded-agent-md border border-agent-border px-3 py-1.5 text-xs font-medium text-agent-foreground transition hover:bg-agent-muted'
89
- }
90
- >
91
- {t(b.label)}
92
- </button>
93
- ))}
94
- </div>
95
- );
215
+ function categoryName(label: string): string {
216
+ return t(label);
96
217
  }
97
218
 
98
219
  export function ApprovalPromptMenu({
@@ -105,26 +226,81 @@ export function ApprovalPromptMenu({
105
226
  onDecide: (kind: ApprovalDecisionKind) => void;
106
227
  }) {
107
228
  const isOutward = current.checkpoint === 'outward';
229
+ const destructive = current.mode === 'destructive';
230
+ const isEgress = current.category === 'network_egress';
231
+ const isSandboxEscalation = current.category === 'sandbox_escalation';
232
+ const isBrowser = current.category === 'browser';
233
+ const isSnippet = SNIPPET_TOOLS.has(current.toolName);
234
+ const isSandboxedShell = SANDBOXED_SHELL_TOOLS.has(current.toolName);
235
+ const sandboxOff = current.sandboxEnforced === false;
236
+
237
+ const [moreOpen, setMoreOpen] = useState(false);
238
+ const allowOnceRef = useRef<HTMLButtonElement | null>(null);
239
+ const denyOnceRef = useRef<HTMLButtonElement | null>(null);
108
240
  const outwardRejectRef = useRef<HTMLButtonElement | null>(null);
241
+ const moreWrapRef = useRef<HTMLDivElement | null>(null);
242
+ const moreButtonRef = useRef<HTMLButtonElement | null>(null);
243
+
244
+ useEffect(() => {
245
+ setMoreOpen(false);
246
+ if (isOutward) {
247
+ outwardRejectRef.current?.focus();
248
+ } else if (isEgress) {
249
+ denyOnceRef.current?.focus();
250
+ } else {
251
+ allowOnceRef.current?.focus();
252
+ }
253
+ }, [isOutward, isEgress, current.requestId]);
254
+
255
+ useEffect(() => {
256
+ if (!moreOpen) return;
257
+ const onPointerDown = (event: MouseEvent) => {
258
+ if (moreWrapRef.current && !moreWrapRef.current.contains(event.target as Node)) {
259
+ setMoreOpen(false);
260
+ }
261
+ };
262
+ document.addEventListener('mousedown', onPointerDown);
263
+ return () => document.removeEventListener('mousedown', onPointerDown);
264
+ }, [moreOpen]);
109
265
 
110
266
  useEffect(() => {
111
- if (!isOutward) return;
112
- outwardRejectRef.current?.focus();
113
267
  const onWindowKeyDown = (e: KeyboardEvent) => {
268
+ if (e.defaultPrevented || e.isComposing || e.keyCode === 229) return;
269
+ if (e.metaKey || e.ctrlKey || e.altKey) return;
270
+ const target = e.target instanceof Element ? e.target : null;
271
+ if (
272
+ target?.closest(
273
+ 'input, textarea, select, [contenteditable="true"], [contenteditable=""]',
274
+ )
275
+ ) {
276
+ return;
277
+ }
114
278
  if (e.key === 'Escape') {
115
279
  e.preventDefault();
280
+ if (moreOpen) {
281
+ setMoreOpen(false);
282
+ moreButtonRef.current?.focus();
283
+ return;
284
+ }
116
285
  onDecide('deny_once');
286
+ return;
287
+ }
288
+ if (
289
+ e.key === 'Enter' &&
290
+ !isOutward &&
291
+ !isEgress &&
292
+ !moreOpen &&
293
+ !e.repeat &&
294
+ !target?.closest('button, a[href], [role="button"], [role="menuitem"]')
295
+ ) {
296
+ e.preventDefault();
297
+ onDecide('allow_once');
117
298
  }
118
299
  };
119
300
  window.addEventListener('keydown', onWindowKeyDown);
120
301
  return () => window.removeEventListener('keydown', onWindowKeyDown);
121
- }, [isOutward, current.requestId, onDecide]);
302
+ }, [isOutward, isEgress, moreOpen, current.requestId, onDecide]);
122
303
 
123
- const destructive = current.mode === 'destructive';
124
- const isEgress = current.category === 'network_egress';
125
- const isSandboxEscalation = current.category === 'sandbox_escalation';
126
- const isBrowser = current.category === 'browser';
127
- const sandboxOff = current.sandboxEnforced === false;
128
304
  const outsideWorkspace =
129
305
  current.outsideWorkspace === true &&
130
306
  !isOutward &&
@@ -138,19 +314,25 @@ export function ApprovalPromptMenu({
138
314
  const egressPort =
139
315
  typeof current.arguments.port === 'number' ? current.arguments.port : null;
140
316
 
317
+ const preview = buildArgumentPreview(current.toolName, current.arguments);
318
+ const sharedCategory =
319
+ current.category !== current.toolName && current.categoryLabel
320
+ ? categoryName(current.categoryLabel)
321
+ : undefined;
322
+ const sessionAllowLabel = sharedCategory
323
+ ? t('Allow {category} for this chat', { category: sharedCategory })
324
+ : t('Allow for this chat');
325
+ const alwaysAllowLabel = sharedCategory
326
+ ? t('Always allow {category}', { category: sharedCategory })
327
+ : t('Always allow');
328
+
141
329
  return (
142
330
  <div
143
- className="overflow-hidden rounded-agent-lg border border-agent-border bg-agent-canvas text-xs text-agent-foreground shadow-xl"
331
+ className="rounded-agent-lg border border-agent-border bg-agent-canvas text-xs text-agent-foreground shadow-xl"
144
332
  data-testid="approval-composer"
145
- onKeyDown={(e) => {
146
- if (isOutward && e.key === 'Escape') {
147
- e.preventDefault();
148
- onDecide('deny_once');
149
- }
150
- }}
151
333
  >
152
334
  <div
153
- className={`flex items-center gap-2 border-b px-3 py-2 ${
335
+ className={`flex items-center gap-2 rounded-t-agent-lg border-b px-3 py-2 ${
154
336
  isOutward
155
337
  ? 'border-rose-500/30 bg-rose-500/10'
156
338
  : 'border-agent-border'
@@ -207,11 +389,15 @@ export function ApprovalPromptMenu({
207
389
  {t('Agent requests to run')}
208
390
  <span className="mx-1 font-mono">{current.toolName}</span>
209
391
  <span className="text-agent-muted-foreground">
210
- {current.categoryLabel
211
- ? t('({category})', { category: categoryName(current.categoryLabel) })
212
- : t('({mode} action)', {
213
- mode: MODE_LABEL[current.mode] ? t(MODE_LABEL[current.mode]) : current.mode,
214
- })}
392
+ {isSnippet
393
+ ? t('({category})', { category: t('Run snippet') })
394
+ : current.categoryLabel
395
+ ? t('({category})', { category: categoryName(current.categoryLabel) })
396
+ : t('({mode} action)', {
397
+ mode: MODE_LABEL[current.mode]
398
+ ? t(MODE_LABEL[current.mode])
399
+ : current.mode,
400
+ })}
215
401
  </span>
216
402
  </>
217
403
  )}
@@ -225,9 +411,7 @@ export function ApprovalPromptMenu({
225
411
  </div>
226
412
 
227
413
  <div className="max-h-48 overflow-auto px-3 py-2">
228
- <pre className="whitespace-pre-wrap break-all rounded-agent-md bg-agent-muted/50 px-3 py-2 font-mono text-xs text-agent-foreground">
229
- {summarizeArguments(current.arguments)}
230
- </pre>
414
+ <ArgumentPreviewBox preview={preview} />
231
415
  {isOutward ? (
232
416
  <p className="mt-2 text-[11px] leading-relaxed text-agent-muted-foreground">
233
417
  {t(
@@ -272,6 +456,17 @@ export function ApprovalPromptMenu({
272
456
  'The command runs in the sandbox. Its working directory is outside the project, so writes there are blocked. Add that directory as a project source folder when a write is required.',
273
457
  )}
274
458
  </p>
459
+ ) : isSnippet ? (
460
+ <p className="mt-2 text-[11px] leading-relaxed text-agent-muted-foreground">
461
+ {preview.kind === 'snippet' && preview.packages.length > 0
462
+ ? t(
463
+ 'Runs with the local interpreter outside the command sandbox and installs {packages} before running.',
464
+ { packages: preview.packages.join(', ') },
465
+ )
466
+ : t(
467
+ 'Runs with the local interpreter outside the command sandbox. Review the code before allowing.',
468
+ )}
469
+ </p>
275
470
  ) : (
276
471
  <>
277
472
  {current.category !== current.toolName && (
@@ -282,7 +477,7 @@ export function ApprovalPromptMenu({
282
477
  )}
283
478
  </p>
284
479
  )}
285
- {!sandboxOff && (
480
+ {isSandboxedShell && !sandboxOff && (
286
481
  <p className="mt-2 text-[11px] leading-relaxed text-agent-muted-foreground">
287
482
  {t(
288
483
  'Runs in the workspace sandbox. Writes outside it are blocked. To write outside, switch the sandbox to "Full access" and try again.',
@@ -294,7 +489,7 @@ export function ApprovalPromptMenu({
294
489
  </div>
295
490
 
296
491
  {isOutward ? (
297
- <div className="flex flex-wrap items-center justify-between gap-2 border-t border-agent-border px-3 py-2">
492
+ <div className="flex flex-wrap items-center justify-between gap-2 rounded-b-agent-lg border-t border-agent-border px-3 py-2">
298
493
  <div className="flex flex-wrap items-center gap-2">
299
494
  <button
300
495
  ref={outwardRejectRef}
@@ -324,38 +519,145 @@ export function ApprovalPromptMenu({
324
519
  </button>
325
520
  </div>
326
521
  ) : (
327
- <div className="space-y-2 border-t border-agent-border px-3 py-2">
328
- <DecisionRow
329
- buttons={
330
- isEgress
331
- ? allowButtons(current).filter((b) => b.kind !== 'allow_always')
332
- : allowButtons(current)
333
- }
334
- onPick={onDecide}
335
- />
336
- <div className="flex items-center justify-between gap-2">
337
- <DecisionRow
338
- buttons={
339
- isEgress
340
- ? DENY_BUTTONS.filter((b) => b.kind !== 'deny_always')
341
- : DENY_BUTTONS
342
- }
343
- onPick={onDecide}
344
- />
345
- <button
346
- type="button"
347
- onClick={() => onDecide('abort')}
348
- className="shrink-0 rounded-agent-md bg-agent-destructive px-3 py-1.5 text-xs font-medium text-white transition hover:opacity-90"
349
- data-testid="approval-abort"
350
- >
351
- {t('Abort this turn')}
352
- </button>
522
+ <div className="space-y-1.5 rounded-b-agent-lg border-t border-agent-border px-3 py-2">
523
+ <div className="flex flex-wrap items-center justify-between gap-2">
524
+ <div className="flex flex-wrap items-center gap-2">
525
+ <button
526
+ ref={allowOnceRef}
527
+ type="button"
528
+ data-testid="approval-allow_once"
529
+ onClick={() => onDecide('allow_once')}
530
+ className="rounded-agent-md bg-agent-foreground px-3 py-1.5 text-xs font-medium text-agent-canvas transition hover:opacity-90"
531
+ >
532
+ {t('Allow once')}
533
+ </button>
534
+
535
+ <div
536
+ ref={moreWrapRef}
537
+ className="relative inline-flex rounded-agent-md border border-agent-border bg-agent-canvas"
538
+ >
539
+ <button
540
+ type="button"
541
+ data-testid="approval-allow_for_session"
542
+ onClick={() => onDecide('allow_for_session')}
543
+ className="rounded-l-agent-md px-3 py-1.5 text-xs font-medium text-agent-foreground transition hover:bg-agent-muted"
544
+ >
545
+ {sessionAllowLabel}
546
+ </button>
547
+ <button
548
+ ref={moreButtonRef}
549
+ type="button"
550
+ data-testid="approval-more-options"
551
+ aria-label={t('More approval options')}
552
+ aria-haspopup="menu"
553
+ aria-expanded={moreOpen}
554
+ onClick={() => setMoreOpen((prev) => !prev)}
555
+ className="inline-flex items-center justify-center rounded-r-agent-md border-l border-agent-border px-1.5 py-1.5 text-agent-muted-foreground transition hover:bg-agent-muted hover:text-agent-foreground"
556
+ >
557
+ <LuChevronDown className="h-3.5 w-3.5" aria-hidden="true" />
558
+ </button>
559
+
560
+ {moreOpen && (
561
+ <div
562
+ role="menu"
563
+ aria-label={t('More approval options')}
564
+ className="absolute bottom-full left-0 z-30 mb-1.5 w-64 overflow-hidden rounded-agent-md border border-agent-border bg-agent-canvas py-1 shadow-lg"
565
+ >
566
+ {!isEgress && (
567
+ <>
568
+ <button
569
+ type="button"
570
+ role="menuitem"
571
+ data-testid="approval-allow_always"
572
+ onClick={() => {
573
+ setMoreOpen(false);
574
+ onDecide('allow_always');
575
+ }}
576
+ className="flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition hover:bg-agent-muted"
577
+ >
578
+ <span className="text-xs font-medium text-agent-foreground">
579
+ {alwaysAllowLabel}
580
+ </span>
581
+ <span className="text-[11px] leading-snug text-agent-muted-foreground">
582
+ {t('Saved on this computer and applies to every chat')}
583
+ </span>
584
+ </button>
585
+ <div className="my-1 border-t border-agent-border" role="separator" />
586
+ </>
587
+ )}
588
+ <button
589
+ type="button"
590
+ role="menuitem"
591
+ data-testid="approval-deny_for_session"
592
+ onClick={() => {
593
+ setMoreOpen(false);
594
+ onDecide('deny_for_session');
595
+ }}
596
+ className="flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition hover:bg-agent-muted"
597
+ >
598
+ <span className="text-xs font-medium text-agent-foreground">
599
+ {t('Deny for this chat')}
600
+ </span>
601
+ <span className="text-[11px] leading-snug text-agent-muted-foreground">
602
+ {t('Automatically deny in this chat')}
603
+ </span>
604
+ </button>
605
+ {!isEgress && (
606
+ <button
607
+ type="button"
608
+ role="menuitem"
609
+ data-testid="approval-deny_always"
610
+ onClick={() => {
611
+ setMoreOpen(false);
612
+ onDecide('deny_always');
613
+ }}
614
+ className="flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition hover:bg-rose-500/10"
615
+ >
616
+ <span className="text-xs font-medium text-agent-destructive">
617
+ {t('Always deny')}
618
+ </span>
619
+ <span className="text-[11px] leading-snug text-agent-muted-foreground">
620
+ {t('Block on this computer across every chat')}
621
+ </span>
622
+ </button>
623
+ )}
624
+ </div>
625
+ )}
626
+ </div>
627
+
628
+ <button
629
+ ref={denyOnceRef}
630
+ type="button"
631
+ data-testid="approval-deny_once"
632
+ onClick={() => onDecide('deny_once')}
633
+ className="rounded-agent-md border border-agent-border px-3 py-1.5 text-xs font-medium text-agent-foreground transition hover:bg-agent-muted"
634
+ >
635
+ {t('Deny once')}
636
+ </button>
637
+ </div>
638
+
639
+ <div className="flex items-center gap-2">
640
+ <span className="hidden text-[11px] text-agent-muted-foreground sm:inline">
641
+ {isEgress ? t('Esc to deny') : t('Enter to allow · Esc to deny')}
642
+ </span>
643
+ <button
644
+ type="button"
645
+ onClick={() => onDecide('abort')}
646
+ className="shrink-0 rounded-agent-md px-2.5 py-1.5 text-xs font-medium text-agent-muted-foreground transition hover:bg-rose-500/10 hover:text-agent-destructive"
647
+ data-testid="approval-abort"
648
+ >
649
+ {t('Abort this turn')}
650
+ </button>
651
+ </div>
353
652
  </div>
354
- <p className="text-[11px] leading-relaxed text-agent-muted-foreground">
355
- {isEgress
356
- ? t('With no action for about 3 minutes, the request is denied and that network access fails.')
357
- : t('"This chat" applies only to this chat. "Always" is saved on this computer and applies to every chat.')}
358
- </p>
653
+
654
+ {isEgress && (
655
+ <p className="text-[11px] leading-relaxed text-agent-muted-foreground">
656
+ {t(
657
+ 'With no action for about 3 minutes, the request is denied and that network access fails.',
658
+ )}
659
+ </p>
660
+ )}
359
661
  </div>
360
662
  )}
361
663
  </div>