Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion extensions/cli/src/ui/components/ToolPermissionSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,6 +64,13 @@ export const ToolPermissionSelector: React.FC<ToolPermissionSelectorProps> = ({
}) => {
const permissionOptions = getPermissionOptions();
const [selectedIndex, setSelectedIndex] = useState(0);
const [hasShownDangerousCommandWarningOnce] = useState(() => {
const prev = hasShownDangerousCommandWarning;
hasShownDangerousCommandWarning = true;
return prev;
});
const showDynamicWarning =
hasDynamicEvaluation && !hasShownDangerousCommandWarningOnce;

useInput((input, key) => {
if (key.return) {
Expand Down Expand Up @@ -125,7 +135,7 @@ export const ToolPermissionSelector: React.FC<ToolPermissionSelectorProps> = ({

<Box marginTop={1} flexDirection="column">
<Text color="dim">Would you like to continue?</Text>
{hasDynamicEvaluation && (
{showDynamicWarning && (
<Box marginTop={1}>
<Text color="yellow" dimColor>
Note: Dangerous commands will be blocked regardless of your
Expand Down
Loading