MCPcopy Index your code
hub / github.com/continuedev/continue / loadSession

Function loadSession

extensions/cli/src/session.ts:301–332  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

299 * Load session from current terminal's session file
300 */
301export function loadSession(): Session | null {
302 try {
303 // For resume, we need to find the most recent session
304 const sessionDir = getSessionDir();
305 if (!fs.existsSync(sessionDir)) {
306 return null;
307 }
308
309 const files = fs
310 .readdirSync(sessionDir)
311 .filter((f) => f.endsWith(".json") && f !== "sessions.json")
312 .map((f) => ({
313 name: f,
314 path: path.join(sessionDir, f),
315 mtime: fs.statSync(path.join(sessionDir, f)).mtime,
316 }))
317 .sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
318
319 if (files.length === 0) {
320 return null;
321 }
322
323 // Load the most recent session
324 const session: Session = JSON.parse(fs.readFileSync(files[0].path, "utf8"));
325 // Set this as the current session for future saves
326 SessionManager.getInstance().setSession(session);
327 return session;
328 } catch (error) {
329 logger.error("Error loading session:", error);
330 return null;
331 }
332}
333
334/**
335 * Create a new session

Callers 9

handleTabClickFunction · 0.90
HistoryTableRowFunction · 0.90
initialLoadConfigFunction · 0.90
useCompactConversationFunction · 0.90
session.test.tsFile · 0.85
initializeChatHistoryFunction · 0.85
initChatHistoryFunction · 0.85
useChatFunction · 0.85

Calls 5

getSessionDirFunction · 0.85
sortMethod · 0.80
setSessionMethod · 0.80
errorMethod · 0.80
getInstanceMethod · 0.45

Tested by

no test coverage detected