From 6e5ab9c6a29cd8585cf8229641485515debd1cb0 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 23 Sep 2025 19:23:15 +0530 Subject: [PATCH 1/3] feat(cli): show dangerous command once per session --- .../src/ui/components/ToolPermissionSelector.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/extensions/cli/src/ui/components/ToolPermissionSelector.tsx b/extensions/cli/src/ui/components/ToolPermissionSelector.tsx index f47ac23ec..0247cfdb5 100644 --- a/extensions/cli/src/ui/components/ToolPermissionSelector.tsx +++ b/extensions/cli/src/ui/components/ToolPermissionSelector.tsx @@ -1,5 +1,5 @@ import { Box, Text, useInput } from "ink"; -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { ToolCallTitle } from "src/tools/ToolCallTitle.js"; @@ -8,6 +8,9 @@ import { defaultBoxStyles } from "../styles.js"; import { ToolPreview } from "./ToolPreview.js"; +// show dangerous commmand warning only once per CLI process +let hasShownDangerousCommandWarning = false; + interface PermissionOption { id: string; name: string; @@ -61,6 +64,13 @@ export const ToolPermissionSelector: React.FC = ({ }) => { const permissionOptions = getPermissionOptions(); const [selectedIndex, setSelectedIndex] = useState(0); + const showDynamicWarning = + hasDynamicEvaluation && !hasShownDangerousCommandWarning; + useEffect(() => { + if (showDynamicWarning) { + hasShownDangerousCommandWarning = true; + } + }, [showDynamicWarning]); useInput((input, key) => { if (key.return) { @@ -125,7 +135,7 @@ export const ToolPermissionSelector: React.FC = ({ Would you like to continue? - {hasDynamicEvaluation && ( + {showDynamicWarning && ( Note: Dangerous commands will be blocked regardless of your From 2874c3a0db0396309b595704a4222ca0f18d9ee3 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Wed, 24 Sep 2025 19:01:41 +0530 Subject: [PATCH 2/3] store in state --- .../src/ui/components/ToolPermissionSelector.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/cli/src/ui/components/ToolPermissionSelector.tsx b/extensions/cli/src/ui/components/ToolPermissionSelector.tsx index 0247cfdb5..fcc081799 100644 --- a/extensions/cli/src/ui/components/ToolPermissionSelector.tsx +++ b/extensions/cli/src/ui/components/ToolPermissionSelector.tsx @@ -1,5 +1,5 @@ import { Box, Text, useInput } from "ink"; -import React, { useEffect, useState } from "react"; +import React, { useState } from "react"; import { ToolCallTitle } from "src/tools/ToolCallTitle.js"; @@ -64,13 +64,13 @@ export const ToolPermissionSelector: React.FC = ({ }) => { const permissionOptions = getPermissionOptions(); const [selectedIndex, setSelectedIndex] = useState(0); + const [hasShownDangerousCommandWarningOnce] = useState(() => { + const prev = hasShownDangerousCommandWarning; + hasShownDangerousCommandWarning = true; + return prev; + }); const showDynamicWarning = - hasDynamicEvaluation && !hasShownDangerousCommandWarning; - useEffect(() => { - if (showDynamicWarning) { - hasShownDangerousCommandWarning = true; - } - }, [showDynamicWarning]); + hasDynamicEvaluation && !hasShownDangerousCommandWarningOnce; useInput((input, key) => { if (key.return) { From d66d700c7316661d2774f6d2e2fb59cfb498887a Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 25 Sep 2025 09:54:06 +0530 Subject: [PATCH 3/3] refactor and rename variable --- .../cli/src/ui/components/ToolPermissionSelector.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/extensions/cli/src/ui/components/ToolPermissionSelector.tsx b/extensions/cli/src/ui/components/ToolPermissionSelector.tsx index fcc081799..bd58f9045 100644 --- a/extensions/cli/src/ui/components/ToolPermissionSelector.tsx +++ b/extensions/cli/src/ui/components/ToolPermissionSelector.tsx @@ -64,13 +64,12 @@ export const ToolPermissionSelector: React.FC = ({ }) => { const permissionOptions = getPermissionOptions(); const [selectedIndex, setSelectedIndex] = useState(0); - const [hasShownDangerousCommandWarningOnce] = useState(() => { - const prev = hasShownDangerousCommandWarning; - hasShownDangerousCommandWarning = true; - return prev; - }); + const [initialHasShownDangerousCommand] = useState( + hasShownDangerousCommandWarning, + ); + hasShownDangerousCommandWarning = false; const showDynamicWarning = - hasDynamicEvaluation && !hasShownDangerousCommandWarningOnce; + hasDynamicEvaluation && !initialHasShownDangerousCommand; useInput((input, key) => { if (key.return) {