(props: Props)
| 124 | type Props = RegularProps | ReadOnlyProps; |
| 125 | |
| 126 | export default function ControlledCodeCell(props: Props) { |
| 127 | const { readOnly, cell } = props; |
| 128 | const channel = !readOnly ? props.channel : null; |
| 129 | |
| 130 | const { theme, codeTheme } = useTheme(); |
| 131 | |
| 132 | const [filenameError, _setFilenameError] = useState<string | null>(null); |
| 133 | const [showStdio, setShowStdio] = useState(false); |
| 134 | const [cellMode, setCellMode] = useState<CellModeType>('off'); |
| 135 | const [generationType, setGenerationType] = useState<'edit' | 'fix'>('edit'); |
| 136 | const [prompt, setPrompt] = useState(''); |
| 137 | const [newSource, setNewSource] = useState(''); |
| 138 | const [fullscreen, setFullscreen] = useState(false); |
| 139 | const { aiEnabled } = useSettings(); |
| 140 | |
| 141 | const [isModalOpen, setIsModalOpen] = useState(false); |
| 142 | const [modalContent, setModalContent] = useState(''); |
| 143 | |
| 144 | useHotkeys( |
| 145 | 'mod+enter', |
| 146 | () => { |
| 147 | if (!prompt) return; |
| 148 | if (cellMode !== 'prompting') return; |
| 149 | if (!aiEnabled) return; |
| 150 | generate(); |
| 151 | }, |
| 152 | { enableOnFormTags: ['textarea'] }, |
| 153 | ); |
| 154 | |
| 155 | useHotkeys( |
| 156 | 'escape', |
| 157 | () => { |
| 158 | if (cellMode === 'prompting') { |
| 159 | setCellMode('off'); |
| 160 | setPrompt(''); |
| 161 | } |
| 162 | }, |
| 163 | |
| 164 | { enableOnFormTags: ['textarea'] }, |
| 165 | ); |
| 166 | |
| 167 | const { |
| 168 | updateCell: updateCellOnClient, |
| 169 | clearOutput, |
| 170 | getTsServerDiagnostics, |
| 171 | getTsServerSuggestions, |
| 172 | } = useCells(); |
| 173 | |
| 174 | function setFilenameError(error: string | null) { |
| 175 | _setFilenameError(error); |
| 176 | setTimeout(() => _setFilenameError(null), 3000); |
| 177 | } |
| 178 | |
| 179 | useEffect(() => { |
| 180 | if (!channel) { |
| 181 | return; |
| 182 | } |
| 183 |
nothing calls this directly
no test coverage detected