Changesets · Branches · Tags · Compare
| Changeset | 480243bc3999144ed9d879aead4fdb15c80244f7f2021ecca76ca043f6d482ce |
|---|---|
| Author | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-23 19:23 +05:30 |
| Committer | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-23 19:23 +05:30 |
| Parents | 578c9023eefa |
1 file changed
modified extensions/cli/src/ui/components/ToolPermissionSelector.tsx +12 −2
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import { Box, Text, useInput } from "ink"; |
| 2 | -import React, { useState } from "react"; | |
| 2 | +import React, { useEffect, useState } from "react"; | |
| 3 | 3 | |
| 4 | 4 | import { ToolCallTitle } from "src/tools/ToolCallTitle.js"; |
| 5 | 5 | |
| @@ -8,6 +8,9 @@ | ||
| 8 | 8 | |
| 9 | 9 | import { ToolPreview } from "./ToolPreview.js"; |
| 10 | 10 | |
| 11 | +// show dangerous commmand warning only once per CLI process | |
| 12 | +let hasShownDangerousCommandWarning = false; | |
| 13 | + | |
| 11 | 14 | interface PermissionOption { |
| 12 | 15 | id: string; |
| 13 | 16 | name: string; |
| @@ -61,6 +64,13 @@ | ||
| 61 | 64 | }) => { |
| 62 | 65 | const permissionOptions = getPermissionOptions(); |
| 63 | 66 | const [selectedIndex, setSelectedIndex] = useState(0); |
| 67 | + const showDynamicWarning = | |
| 68 | + hasDynamicEvaluation && !hasShownDangerousCommandWarning; | |
| 69 | + useEffect(() => { | |
| 70 | + if (showDynamicWarning) { | |
| 71 | + hasShownDangerousCommandWarning = true; | |
| 72 | + } | |
| 73 | + }, [showDynamicWarning]); | |
| 64 | 74 | |
| 65 | 75 | useInput((input, key) => { |
| 66 | 76 | if (key.return) { |
| @@ -125,7 +135,7 @@ | ||
| 125 | 135 | |
| 126 | 136 | <Box marginTop={1} flexDirection="column"> |
| 127 | 137 | <Text color="dim">Would you like to continue?</Text> |
| 128 | - {hasDynamicEvaluation && ( | |
| 138 | + {showDynamicWarning && ( | |
| 129 | 139 | <Box marginTop={1}> |
| 130 | 140 | <Text color="yellow" dimColor> |
| 131 | 141 | Note: Dangerous commands will be blocked regardless of your |