Files
gemini-cli/packages/cli/src/ui/components/ApprovalModeIndicator.tsx
T

65 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-05-17 21:25:28 -07:00
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type React from 'react';
2025-05-17 21:25:28 -07:00
import { Box, Text } from 'ink';
2025-09-10 10:57:07 -07:00
import { theme } from '../semantic-colors.js';
import { ApprovalMode } from '@google/gemini-cli-core';
2025-05-17 21:25:28 -07:00
interface ApprovalModeIndicatorProps {
approvalMode: ApprovalMode;
isPlanEnabled?: boolean;
}
export const ApprovalModeIndicator: React.FC<ApprovalModeIndicatorProps> = ({
approvalMode,
isPlanEnabled,
}) => {
let textColor = '';
let textContent = '';
let subText = '';
switch (approvalMode) {
case ApprovalMode.AUTO_EDIT:
textColor = theme.status.warning;
textContent = 'auto-edit';
subText = 'shift + tab to enter default mode';
break;
case ApprovalMode.PLAN:
textColor = theme.status.success;
textContent = 'plan';
subText = 'shift + tab to enter auto-edit mode';
break;
case ApprovalMode.YOLO:
2025-09-10 10:57:07 -07:00
textColor = theme.status.error;
textContent = 'YOLO';
subText = 'shift + tab to enter auto-edit mode';
break;
case ApprovalMode.DEFAULT:
default:
textColor = theme.text.accent;
textContent = '';
subText = isPlanEnabled
? 'shift + tab to enter plan mode'
: 'shift + tab to enter auto-edit mode';
break;
}
return (
<Box>
<Text color={textColor}>
{textContent ? textContent : null}
{subText ? (
<Text color={theme.text.secondary}>
{textContent ? ' ' : ''}
{subText}
</Text>
) : null}
</Text>
</Box>
);
};