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

Function handleImport

extensions/cli/src/slashCommands.ts:190–255  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

188}
189
190function handleImport(args: string[]): SlashCommandResult {
191 const filePath = args.join(" ").trim();
192 if (!filePath) {
193 return {
194 exit: false,
195 output: chalk.yellow(
196 "Please provide a file path. Usage: /import <file-path>",
197 ),
198 };
199 }
200
201 if (!fs.existsSync(filePath)) {
202 return {
203 exit: false,
204 output: chalk.red(`File not found: ${filePath}`),
205 };
206 }
207
208 try {
209 const fileContent = fs.readFileSync(filePath, "utf-8");
210 const exportedData: unknown = JSON.parse(fileContent);
211
212 if (!isValidExportedSession(exportedData)) {
213 return {
214 exit: false,
215 output: chalk.red(
216 "Invalid session file: expected a valid Continue exported session (version 1).",
217 ),
218 };
219 }
220
221 let session = exportedData.session;
222
223 const existing = historyManager.load(session.sessionId);
224 const sessionExists = existing.history.length > 0;
225
226 if (sessionExists) {
227 const originalId = session.sessionId;
228 session = {
229 ...session,
230 sessionId: uuidv4(),
231 };
232 historyManager.save(session);
233 return {
234 exit: false,
235 output: chalk.green(
236 `Session imported with new ID: ${session.sessionId}\n` +
237 chalk.gray(`(original ID: ${originalId} already existed)`),
238 ),
239 };
240 }
241
242 historyManager.save(session);
243 return {
244 exit: false,
245 output: chalk.green(
246 `Session imported: ${session.sessionId} (${session.title})`,
247 ),

Callers

nothing calls this directly

Calls 3

isValidExportedSessionFunction · 0.85
saveMethod · 0.65
loadMethod · 0.45

Tested by

no test coverage detected