Download projects/gemini-cli/packages/cli/src/ui/components/ShellConfirmationDialog.tsx from LevelUp2x/adaptai: direct link, hf CLI and curl.
- Browser
- Download file 2.66 kB
-
https://huggingface.co/datasets/LevelUp2x/adaptai/resolve/2147bc06c2ccf123b96f98eace2e6bf6486e7f0e/projects/gemini-cli/packages/cli/src/ui/components/ShellConfirmationDialog.tsx
- Command line
-
hf download hf://datasets/LevelUp2x/adaptai@2147bc06c2ccf123b96f98eace2e6bf6486e7f0e/projects/gemini-cli/packages/cli/src/ui/components/ShellConfirmationDialog.tsx
-
curl -L -o ShellConfirmationDialog.tsx https://huggingface.co/datasets/LevelUp2x/adaptai/resolve/2147bc06c2ccf123b96f98eace2e6bf6486e7f0e/projects/gemini-cli/packages/cli/src/ui/components/ShellConfirmationDialog.tsx
2.66 kB
| /** | |
| * @license | |
| * Copyright 2025 Google LLC | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| import { ToolConfirmationOutcome } from '@google/gemini-cli-core'; | |
| import { Box, Text } from 'ink'; | |
| import type React from 'react'; | |
| import { Colors } from '../colors.js'; | |
| import { RenderInline } from '../utils/InlineMarkdownRenderer.js'; | |
| import type { RadioSelectItem } from './shared/RadioButtonSelect.js'; | |
| import { RadioButtonSelect } from './shared/RadioButtonSelect.js'; | |
| import { useKeypress } from '../hooks/useKeypress.js'; | |
| export interface ShellConfirmationRequest { | |
| commands: string[]; | |
| onConfirm: ( | |
| outcome: ToolConfirmationOutcome, | |
| approvedCommands?: string[], | |
| ) => void; | |
| } | |
| export interface ShellConfirmationDialogProps { | |
| request: ShellConfirmationRequest; | |
| } | |
| export const ShellConfirmationDialog: React.FC< | |
| ShellConfirmationDialogProps | |
| > = ({ request }) => { | |
| const { commands, onConfirm } = request; | |
| useKeypress( | |
| (key) => { | |
| if (key.name === 'escape') { | |
| onConfirm(ToolConfirmationOutcome.Cancel); | |
| } | |
| }, | |
| { isActive: true }, | |
| ); | |
| const handleSelect = (item: ToolConfirmationOutcome) => { | |
| if (item === ToolConfirmationOutcome.Cancel) { | |
| onConfirm(item); | |
| } else { | |
| // For both ProceedOnce and ProceedAlways, we approve all the | |
| // commands that were requested. | |
| onConfirm(item, commands); | |
| } | |
| }; | |
| const options: Array<RadioSelectItem<ToolConfirmationOutcome>> = [ | |
| { | |
| label: 'Yes, allow once', | |
| value: ToolConfirmationOutcome.ProceedOnce, | |
| }, | |
| { | |
| label: 'Yes, allow always for this session', | |
| value: ToolConfirmationOutcome.ProceedAlways, | |
| }, | |
| { | |
| label: 'No (esc)', | |
| value: ToolConfirmationOutcome.Cancel, | |
| }, | |
| ]; | |
| return ( | |
| <Box | |
| flexDirection="column" | |
| borderStyle="round" | |
| borderColor={Colors.AccentYellow} | |
| padding={1} | |
| width="100%" | |
| marginLeft={1} | |
| > | |
| <Box flexDirection="column" marginBottom={1}> | |
| <Text bold>Shell Command Execution</Text> | |
| <Text>A custom command wants to run the following shell commands:</Text> | |
| <Box | |
| flexDirection="column" | |
| borderStyle="round" | |
| borderColor={Colors.Gray} | |
| paddingX={1} | |
| marginTop={1} | |
| > | |
| {commands.map((cmd) => ( | |
| <Text key={cmd} color={Colors.AccentCyan}> | |
| <RenderInline text={cmd} /> | |
| </Text> | |
| ))} | |
| </Box> | |
| </Box> | |
| <Box marginBottom={1}> | |
| <Text>Do you want to proceed?</Text> | |
| </Box> | |
| <RadioButtonSelect items={options} onSelect={handleSelect} isFocused /> | |
| </Box> | |
| ); | |
| }; | |