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

Function listSessions

extensions/cli/src/session.ts:451–500  ·  view source on GitHub ↗
(
  limit: number = 100,
)

Source from the content-addressed store, hash-verified

449 * List all available sessions with metadata (both local and remote)
450 */
451export async function listSessions(
452 limit: number = 100,
453): Promise<ExtendedSessionMetadata[]> {
454 try {
455 // Get local sessions
456 const localSessions = historyManager.list({ limit });
457
458 // Add first user message preview to each local session
459 const localSessionsWithPreview: ExtendedSessionMetadata[] = [];
460
461 for (const sessionMeta of localSessions) {
462 const sessionFilePath = path.join(
463 getSessionDir(),
464 `${sessionMeta.sessionId}.json`,
465 );
466
467 if (fs.existsSync(sessionFilePath)) {
468 const metadata = getSessionMetadataWithPreview(sessionFilePath);
469 if (metadata) {
470 localSessionsWithPreview.push({
471 ...metadata,
472 isRemote: false,
473 });
474 }
475 } else {
476 // Fall back to basic metadata if file doesn't exist
477 localSessionsWithPreview.push({
478 ...sessionMeta,
479 isRemote: false,
480 });
481 }
482 }
483
484 // Get remote sessions
485 const remoteSessions = await getRemoteSessions();
486
487 // Combine and sort by date (most recent first)
488 const allSessions = [...localSessionsWithPreview, ...remoteSessions]
489 .sort(
490 (a, b) =>
491 new Date(b.dateCreated).getTime() - new Date(a.dateCreated).getTime(),
492 )
493 .slice(0, limit);
494
495 return allSessions;
496 } catch (error) {
497 logger.error("Error listing sessions:", error);
498 return [];
499 }
500}
501
502/**
503 * Load session by ID

Callers 2

listSessionsCommandFunction · 0.85
loadSessionsFunction · 0.85

Calls 7

getSessionDirFunction · 0.85
getRemoteSessionsFunction · 0.85
sortMethod · 0.80
errorMethod · 0.80
listMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected