()
| 196 | setSubmitError(''); setStep('confirm'); |
| 197 | }; |
| 198 | const start = async (): Promise<void> => { |
| 199 | const projectName = name.trim(); |
| 200 | if (submitPending.current || !selectedPath || !validName(projectName) || duplicate || listStatus !== 'ready' || jobRef.current?.status === 'indexing') return; |
| 201 | const path = selectedPath; |
| 202 | submitPending.current = true; setSubmitting(true); setSubmitError(''); |
| 203 | try { |
| 204 | const projects = await source.listProjects(); |
| 205 | if (!alive.current) return; |
| 206 | setEntries(projects); setListStatus('ready'); |
| 207 | if (projects.some(entry => samePath(entry.root_path, path) || entry.name.toLowerCase() === projectName.toLowerCase())) return; |
| 208 | const started = await source.startIndex(path, projectName); |
| 209 | if (!alive.current) return; |
| 210 | const valid = Number.isInteger(started.slot) && started.slot >= 0 && samePath(started.path, path); |
| 211 | const tracked: TrackedIndex = { id: ++nextJob.current, name: projectName, path, slot: started.slot, |
| 212 | status: valid ? 'indexing' : 'error', phase: valid ? 'running' : 'lost', message: valid |
| 213 | ? 'Indexing source and relationships…' : 'The server accepted the request without a matching job identifier. Completion is unconfirmed.' }; |
| 214 | updateJob(tracked); setStep('progress'); |
| 215 | if (valid) void pollRef.current(); |
| 216 | } catch { |
| 217 | if (alive.current) setSubmitError('The index request was not confirmed. Check the server in System before trying again.'); |
| 218 | } finally { submitPending.current = false; if (alive.current) setSubmitting(false); } |
| 219 | }; |
| 220 | const another = (): void => { |
| 221 | if (jobRef.current?.status === 'indexing' || pollPending.current) return; |
| 222 | clearTimeout(timer.current); updateJob(undefined); setStep('browse'); setSubmitError(''); |
no test coverage detected