MCPcopy Create free account
hub / github.com/Noumena-Network/code / onSelectRestoreOption

Function onSelectRestoreOption

src/components/MessageSelector.tsx:178–247  ·  view source on GitHub ↗
(option: RestoreOption)

Source from the content-addressed store, hash-verified

176 setDiffStatsForRestore(diffStats);
177 }
178 async function onSelectRestoreOption(option: RestoreOption) {
179 logEvent('ncode_message_selector_restore_option_selected', {
180 option: option as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
181 });
182 if (!messageToRestore) {
183 setError('Message not found.');
184 return;
185 }
186 if (option === 'nevermind') {
187 if (preselectedMessage) onClose();else setMessageToRestore(undefined);
188 return;
189 }
190 if (isSummarizeOption(option)) {
191 onPreRestore();
192 setIsRestoring(true);
193 setRestoringOption(option);
194 setError(undefined);
195 try {
196 const direction = option === 'summarize_up_to' ? 'up_to' : 'from';
197 const feedback = (direction === 'up_to' ? summarizeUpToFeedback : summarizeFromFeedback).trim() || undefined;
198 await onSummarize(messageToRestore, feedback, direction);
199 setIsRestoring(false);
200 setRestoringOption(null);
201 setMessageToRestore(undefined);
202 onClose();
203 } catch (error_1) {
204 logError(error_1 as Error);
205 setIsRestoring(false);
206 setRestoringOption(null);
207 setMessageToRestore(undefined);
208 setError(`Failed to summarize:\n${error_1}`);
209 }
210 return;
211 }
212 onPreRestore();
213 setIsRestoring(true);
214 setError(undefined);
215 let codeError: Error | null = null;
216 let conversationError: Error | null = null;
217 if (option === 'code' || option === 'both') {
218 try {
219 await onRestoreCode(messageToRestore);
220 } catch (error_2) {
221 codeError = error_2 as Error;
222 logError(codeError);
223 }
224 }
225 if (option === 'conversation' || option === 'both') {
226 try {
227 await onRestoreMessage(messageToRestore);
228 } catch (error_3) {
229 conversationError = error_3 as Error;
230 logError(conversationError);
231 }
232 }
233 setIsRestoring(false);
234 setMessageToRestore(undefined);
235

Callers 1

MessageSelectorFunction · 0.85

Calls 3

isSummarizeOptionFunction · 0.85
logEventFunction · 0.70
logErrorFunction · 0.50

Tested by

no test coverage detected