MCPcopy Index your code
hub / github.com/winfunc/opcode / loadSessionHistory

Function loadSessionHistory

src/components/ClaudeCodeSession.tsx:295–338  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

293 }, [messages]);
294
295 const loadSessionHistory = async () => {
296 if (!session) return;
297
298 try {
299 setIsLoading(true);
300 setError(null);
301
302 const history = await api.loadSessionHistory(session.id, session.project_id);
303
304 // Save session data for restoration
305 if (history && history.length > 0) {
306 SessionPersistenceService.saveSession(
307 session.id,
308 session.project_id,
309 session.project_path,
310 history.length
311 );
312 }
313
314 // Convert history to messages format
315 const loadedMessages: ClaudeStreamMessage[] = history.map(entry => ({
316 ...entry,
317 type: entry.type || "assistant"
318 }));
319
320 setMessages(loadedMessages);
321 setRawJsonlOutput(history.map(h => JSON.stringify(h)));
322
323 // After loading history, we're continuing a conversation
324 setIsFirstPrompt(false);
325
326 // Scroll to bottom after loading history
327 setTimeout(() => {
328 if (loadedMessages.length > 0) {
329 rowVirtualizer.scrollToIndex(loadedMessages.length - 1, { align: 'end', behavior: 'auto' });
330 }
331 }, 100);
332 } catch (err) {
333 console.error("Failed to load session history:", err);
334 setError("Failed to load session history");
335 } finally {
336 setIsLoading(false);
337 }
338 };
339
340 const checkForActiveSession = async () => {
341 // If we have a session prop, check if it's still active

Callers 2

initializeSessionFunction · 0.70
handleCheckpointSelectFunction · 0.70

Calls 1

saveSessionMethod · 0.80

Tested by

no test coverage detected