()
| 60 | } |
| 61 | |
| 62 | const Shell = () => { |
| 63 | const [shellState, setShellState] = useAtom(shellStateAtom); |
| 64 | |
| 65 | const { |
| 66 | send, |
| 67 | commitToHistory, |
| 68 | isSocketError, |
| 69 | isSocketAvailable, |
| 70 | cacheCommand, |
| 71 | on, |
| 72 | off, |
| 73 | } = useShellWebsocket(); |
| 74 | |
| 75 | const { scrollToBottom, setShouldAutoScroll } = useShellVirtualizedList(); |
| 76 | |
| 77 | const { mutate: cancelQueryMutation } = useCancelQuery(); |
| 78 | |
| 79 | const getView = useGetView(); |
| 80 | const viewDispatch = useViewDispatch(); |
| 81 | |
| 82 | const { track } = useSegment(); |
| 83 | |
| 84 | const cancelQuery = () => { |
| 85 | const { connectionId } = shellState; |
| 86 | if (!connectionId) { |
| 87 | return; |
| 88 | } |
| 89 | cancelQueryMutation({ connectionId }); |
| 90 | }; |
| 91 | |
| 92 | const clearHistory = useAtomCallback( |
| 93 | React.useCallback( |
| 94 | (_get, set) => |
| 95 | set(historyIdsAtom, (currentHistoryIds) => { |
| 96 | currentHistoryIds.forEach((historyId) => |
| 97 | set(historyItemAtom(historyId), RESET), |
| 98 | ); |
| 99 | clearListItemHeights(); |
| 100 | return []; |
| 101 | }), |
| 102 | [], |
| 103 | ), |
| 104 | ); |
| 105 | |
| 106 | const previousPrompt = useAtomCallback(previousPromptJotaiCallback); |
| 107 | const nextPrompt = useAtomCallback(nextPromptJotaiCallback); |
| 108 | const setPrompt = useAtomCallback(setPromptValue); |
| 109 | const dispatchReplacePrompt = useCallback( |
| 110 | (value: string) => { |
| 111 | const view = getView(); |
| 112 | if (!view) return; |
| 113 | const updateEvent: TransactionSpec = { |
| 114 | changes: { from: 0, to: view.state.doc.length, insert: value }, |
| 115 | selection: { anchor: value.length }, |
| 116 | }; |
| 117 | viewDispatch(updateEvent); |
| 118 | }, |
| 119 | [getView, viewDispatch], |
nothing calls this directly
no test coverage detected