From 34b5dc7f289dc9af0a87d3a795e681d2415da3c9 Mon Sep 17 00:00:00 2001 From: shrutip90 Date: Fri, 8 Aug 2025 11:02:27 -0700 Subject: Add FolderTrustDialog that shows on launch and enables folderTrust setting (#5815) --- .../cli/src/ui/components/FolderTrustDialog.tsx | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 packages/cli/src/ui/components/FolderTrustDialog.tsx (limited to 'packages/cli/src/ui/components/FolderTrustDialog.tsx') diff --git a/packages/cli/src/ui/components/FolderTrustDialog.tsx b/packages/cli/src/ui/components/FolderTrustDialog.tsx new file mode 100644 index 00000000..1918998c --- /dev/null +++ b/packages/cli/src/ui/components/FolderTrustDialog.tsx @@ -0,0 +1,70 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { Box, Text, useInput } from 'ink'; +import React from 'react'; +import { Colors } from '../colors.js'; +import { + RadioButtonSelect, + RadioSelectItem, +} from './shared/RadioButtonSelect.js'; + +export enum FolderTrustChoice { + TRUST_FOLDER = 'trust_folder', + TRUST_PARENT = 'trust_parent', + DO_NOT_TRUST = 'do_not_trust', +} + +interface FolderTrustDialogProps { + onSelect: (choice: FolderTrustChoice) => void; +} + +export const FolderTrustDialog: React.FC = ({ + onSelect, +}) => { + useInput((_, key) => { + if (key.escape) { + onSelect(FolderTrustChoice.DO_NOT_TRUST); + } + }); + + const options: Array> = [ + { + label: 'Trust folder', + value: FolderTrustChoice.TRUST_FOLDER, + }, + { + label: 'Trust parent folder', + value: FolderTrustChoice.TRUST_PARENT, + }, + { + label: "Don't trust (esc)", + value: FolderTrustChoice.DO_NOT_TRUST, + }, + ]; + + return ( + + + Do you trust this folder? + + Trusting a folder allows Gemini to execute commands it suggests. This + is a security feature to prevent accidental execution in untrusted + directories. + + + + + + ); +}; -- cgit v1.2.3