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

Function listSessionsCommand

extensions/cli/src/commands/ls.ts:29–111  ·  view source on GitHub ↗
(
  options: ListSessionsOptions = {},
)

Source from the content-addressed store, hash-verified

27 * List recent chat sessions and allow selection
28 */
29export async function listSessionsCommand(
30 options: ListSessionsOptions = {},
31): Promise<void> {
32 // Handle JSON format output first
33 if (options.format === "json") {
34 const sessions = await listSessions();
35 console.log(
36 JSON.stringify(
37 {
38 sessions: sessions.map((session) => ({
39 id: session.sessionId,
40 timestamp: session.dateCreated,
41 workspaceDirectory: session.workspaceDirectory,
42 title: session.title,
43 firstUserMessage: session.firstUserMessage,
44 isRemote: session.isRemote,
45 remoteId: session.remoteId,
46 })),
47 },
48 null,
49 2,
50 ),
51 );
52 return;
53 }
54
55 // For TUI mode, fetch more sessions than we might display so the UI can choose based on screen height
56 const sessions = await listSessions();
57
58 // Handle empty sessions case
59 if (sessions.length === 0) {
60 console.log(
61 "No previous sessions found. Start a new conversation with: cn",
62 );
63 return;
64 }
65
66 // Start TUI selector
67 return new Promise<void>((resolve, reject) => {
68 const handleSelect = async (sessionId: string) => {
69 try {
70 app.unmount();
71
72 // Handle local session
73 const sessionHistory = loadSessionById(sessionId);
74 if (!sessionHistory) {
75 logger.error(`Session ${sessionId} could not be loaded.`);
76 resolve();
77 return;
78 }
79
80 logger.info(`Loading session: ${sessionId}`);
81
82 // Set the session ID so that when chat() runs, it will load this session
83 setSessionId(sessionId);
84
85 // Start chat with resume flag to load the selected session
86 await chat(undefined, {

Callers 2

index.tsFile · 0.85
ls.test.tsFile · 0.85

Calls 2

listSessionsFunction · 0.85
logMethod · 0.65

Tested by

no test coverage detected