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

Method saveSession

src/services/sessionPersistence.ts:24–47  ·  view source on GitHub ↗

* Save session data for later restoration

(sessionId: string, projectId: string, projectPath: string, messageCount?: number, scrollPosition?: number)

Source from the content-addressed store, hash-verified

22 * Save session data for later restoration
23 */
24 static saveSession(sessionId: string, projectId: string, projectPath: string, messageCount?: number, scrollPosition?: number): void {
25 try {
26 const sessionData: SessionRestoreData = {
27 sessionId,
28 projectId,
29 projectPath,
30 lastMessageCount: messageCount,
31 scrollPosition,
32 timestamp: Date.now()
33 };
34
35 // Save individual session data
36 localStorage.setItem(`${STORAGE_KEY_PREFIX}${sessionId}`, JSON.stringify(sessionData));
37
38 // Update session index
39 const index = this.getSessionIndex();
40 if (!index.includes(sessionId)) {
41 index.push(sessionId);
42 localStorage.setItem(SESSION_INDEX_KEY, JSON.stringify(index));
43 }
44 } catch (error) {
45 console.error('Failed to save session data:', error);
46 }
47 }
48
49 /**
50 * Load session data for restoration

Callers 2

loadSessionHistoryFunction · 0.80
handleSendPromptFunction · 0.80

Calls 1

getSessionIndexMethod · 0.95

Tested by

no test coverage detected