/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { Box, Text } from 'ink'; import type { RadioSelectItem } from './shared/RadioButtonSelect.js'; import { RadioButtonSelect } from './shared/RadioButtonSelect.js'; import { useKeypress } from '../hooks/useKeypress.js'; import { theme } from '../semantic-colors.js'; export type LoopDetectionConfirmationResult = { userSelection: 'disable' | 'keep'; }; interface LoopDetectionConfirmationProps { onComplete: (result: LoopDetectionConfirmationResult) => void; } export function LoopDetectionConfirmation({ onComplete, }: LoopDetectionConfirmationProps) { useKeypress( (key) => { if (key.name === 'escape') { onComplete({ userSelection: 'keep', }); } }, { isActive: true }, ); const OPTIONS: Array> = [ { label: 'Keep loop detection enabled (esc)', value: { userSelection: 'keep', }, key: 'Keep loop detection enabled (esc)', }, { label: 'Disable loop detection for this session', value: { userSelection: 'disable', }, key: 'Disable loop detection for this session', }, ]; return ( ? A potential loop was detected {' '} This can happen due to repetitive tool calls or other model behavior. Do you want to keep loop detection enabled or disable it for this session? Note: To disable loop detection checks for all future sessions, set "model.skipLoopDetection" to true in your settings.json. ); }