MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / Shell

Function Shell

console/src/platform/shell/Shell.tsx:62–363  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60}
61
62const 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],

Callers

nothing calls this directly

Calls 15

useShellVirtualizedListFunction · 0.90
useCancelQueryFunction · 0.90
clearListItemHeightsFunction · 0.90
previousPromptFunction · 0.90
nextPromptFunction · 0.90
exhaustiveGuardFunction · 0.90
useShellWebsocketFunction · 0.85
splitQueryStringFunction · 0.85
sendFunction · 0.85
shouldNavigatePreviousFunction · 0.85
shouldNavigateNextFunction · 0.85

Tested by

no test coverage detected