()
| 500 | } |
| 501 | }; |
| 502 | const resetProject = (): void => { |
| 503 | if (!runtime.current || phase === 'preparing' || phase === 'removing') { release(); return; } |
| 504 | const retainedRuntime = runtime.current; |
| 505 | const settled = operationSettled.current; |
| 506 | if (autoRun.current) autoRun.current.cancelled = true; |
| 507 | if (manualRequest.current) manualRequest.current.cancelled = true; |
| 508 | autoRun.current = undefined; manualRequest.current = undefined; |
| 509 | lastAttempt.current = undefined; activeTurn.current = undefined; |
| 510 | setQuestionQueued(false); setExplanation(undefined); setError(undefined); |
| 511 | const ticket = ++epoch.current; |
| 512 | pending.current = !!settled; stopRequested.current = !!settled; setStopping(!!settled); |
| 513 | if (!settled) { setPhase('ready'); return; } |
| 514 | // Retain downloaded weights across projects, but drain the old worker request |
| 515 | // before making the new project's context eligible for inference. |
| 516 | setPhase('counting'); retainedRuntime.stop(); |
| 517 | void settled.then(() => { |
| 518 | if (epoch.current !== ticket || runtime.current !== retainedRuntime) return; |
| 519 | pending.current = false; stopRequested.current = false; setStopping(false); setPhase('ready'); |
| 520 | }); |
| 521 | }; |
| 522 | const handoverOf = (current: BrowserChatRuntime, modelId: string): AgentHandover => ({ runtime: current, modelId, |
| 523 | ...operationSettled.current ? { settled: operationSettled.current } : {}, ...loading.current ? { ready: loading.current.ready, progress: loading.current.progress } : {} }); |
| 524 | /** Gives the model to the dock of the next project (K24). What this dock was doing stops, |
no test coverage detected