import React from 'react'; import { Box, Text } from '@anthropic/ink'; import { useDebouncedDigitInput } from './useDebouncedDigitInput.js'; import type { FeedbackSurveyResponse } from './utils.js'; type Props = { onSelect: (option: FeedbackSurveyResponse) => void; inputValue: string; setInputValue: (value: string) => void; message?: string; }; const RESPONSE_INPUTS = ['0', '1', '2', '3'] as const; type ResponseInput = (typeof RESPONSE_INPUTS)[number]; const inputToResponse: Record = { '0': 'dismissed', '1': 'bad', '2': 'fine', '3': 'good', } as const; export const isValidResponseInput = (input: string): input is ResponseInput => (RESPONSE_INPUTS as readonly string[]).includes(input); const DEFAULT_MESSAGE = 'How is Claude doing this session? (optional)'; export function FeedbackSurveyView({ onSelect, inputValue, setInputValue, message = DEFAULT_MESSAGE, }: Props): React.ReactNode { useDebouncedDigitInput({ inputValue, setInputValue, isValidDigit: isValidResponseInput, onDigit: digit => onSelect(inputToResponse[digit]), }); return ( {message} 1: Bad 2: Fine 3: Good 0: Dismiss ); }