(setAppState: SetAppState)
| 800 | } |
| 801 | |
| 802 | export function abortSpeculation(setAppState: SetAppState): void { |
| 803 | setAppState(prev => { |
| 804 | if (prev.speculation.status !== 'active') return prev |
| 805 | |
| 806 | const { |
| 807 | id, |
| 808 | abort, |
| 809 | startTime, |
| 810 | boundary, |
| 811 | suggestionLength, |
| 812 | messagesRef, |
| 813 | isPipelined, |
| 814 | } = prev.speculation |
| 815 | |
| 816 | logForDebugging(`[Speculation] Aborting ${id}`) |
| 817 | |
| 818 | logSpeculation( |
| 819 | id, |
| 820 | 'aborted', |
| 821 | startTime, |
| 822 | suggestionLength, |
| 823 | messagesRef.current, |
| 824 | boundary, |
| 825 | { abort_reason: 'user_typed', is_pipelined: isPipelined }, |
| 826 | ) |
| 827 | |
| 828 | abort() |
| 829 | safeRemoveOverlay(getOverlayPath(id)) |
| 830 | |
| 831 | return { ...prev, speculation: IDLE_SPECULATION_STATE } |
| 832 | }) |
| 833 | } |
| 834 | |
| 835 | export async function handleSpeculationAccept( |
| 836 | speculationState: ActiveSpeculationState, |
no test coverage detected