import React from 'react' import { Box, Newline, Text, useInput } from 'ink' import { getTheme } from '@utils/theme' import { Select } from './CustomSelect/select' import { render } from 'ink' import { writeFileSync } from 'fs' import { ConfigParseError } from '@utils/errors' import { useExitOnCtrlCD } from '@hooks/useExitOnCtrlCD' interface InvalidConfigHandlerProps { error: ConfigParseError } interface InvalidConfigDialogProps { filePath: string errorDescription: string onExit: () => void onReset: () => void } /** * Dialog shown when the Kode config file contains invalid JSON */ function InvalidConfigDialog({ filePath, errorDescription, onExit, onReset, }: InvalidConfigDialogProps): React.ReactNode { const theme = getTheme() // Handle escape key useInput((_, key) => { if (key.escape) { onExit() } }) const exitState = useExitOnCtrlCD(() => process.exit(0)) // Handler for Select onChange const handleSelect = (value: string) => { if (value === 'exit') { onExit() } else { onReset() } } return ( <> Configuration Error The configuration file at {filePath} contains invalid JSON. {errorDescription} Choose an option: