Skip to content

feat(cli): export and import sessions#11075

Open
uinstinct wants to merge 2 commits intocontinuedev:mainfrom
uinstinct:cli-import-export
Open

feat(cli): export and import sessions#11075
uinstinct wants to merge 2 commits intocontinuedev:mainfrom
uinstinct:cli-import-export

Conversation

@uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Mar 5, 2026

Description

Add the ability to export a selected session and import it by path of the file.

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Continue Tasks: 🔄 7 running — View all


Summary by cubic

Add CLI support to export a session to JSON and import a session from a file path. Adds new slash commands and a TUI export selector to make moving sessions easy.

  • New Features
    • Added /export to pick a session and save it as JSON in the current directory (continue-session-.json), including version and exportedAt.
    • Added /import with helpful errors for missing/invalid paths.
    • On import, if the sessionId already exists, a new UUID is generated and the session is saved without overwriting.
    • Integrated with the TUI: new Export selector screen, command routing, and system messages on success/failure.

Written for commit 026a449. Summary will update on new commits.

@uinstinct uinstinct requested a review from a team as a code owner March 5, 2026 13:38
@uinstinct uinstinct requested review from Patrick-Erichsen and removed request for a team March 5, 2026 13:38
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 5, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="extensions/cli/src/slashCommands.ts">

<violation number="1" location="extensions/cli/src/slashCommands.ts:199">
P2: `/import` only uses `args[0]`, so file paths containing spaces are truncated and reported as missing.</violation>

<violation number="2" location="extensions/cli/src/slashCommands.ts:218">
P2: Import command lacks runtime validation of exported session format/version before persistence, allowing incompatible or malformed session data to be saved.</violation>

<violation number="3" location="extensions/cli/src/slashCommands.ts:222">
P1: Import collision detection only checks 1000 sessions, so duplicate IDs outside that window can be missed and existing sessions overwritten.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


let session = exportedData.session;

const existingSessions = historyManager.list({ limit: 1000 });
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Import collision detection only checks 1000 sessions, so duplicate IDs outside that window can be missed and existing sessions overwritten.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/slashCommands.ts, line 222:

<comment>Import collision detection only checks 1000 sessions, so duplicate IDs outside that window can be missed and existing sessions overwritten.</comment>

<file context>
@@ -173,6 +178,83 @@ function handleJobs() {
+
+    let session = exportedData.session;
+
+    const existingSessions = historyManager.list({ limit: 1000 });
+    const sessionExists = existingSessions.some(
+      (s) => s.sessionId === session.sessionId,
</file context>
Suggested change
const existingSessions = historyManager.list({ limit: 1000 });
const existingSessions = historyManager.list({});
Fix with Cubic

function handleImport(args: string[]): SlashCommandResult {
posthogService.capture("useSlashCommand", { name: "import" });

const filePath = args[0];
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: /import only uses args[0], so file paths containing spaces are truncated and reported as missing.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/slashCommands.ts, line 199:

<comment>`/import` only uses `args[0]`, so file paths containing spaces are truncated and reported as missing.</comment>

<file context>
@@ -173,6 +178,83 @@ function handleJobs() {
+function handleImport(args: string[]): SlashCommandResult {
+  posthogService.capture("useSlashCommand", { name: "import" });
+
+  const filePath = args[0];
+  if (!filePath) {
+    return {
</file context>
Suggested change
const filePath = args[0];
const filePath = args.join(" ").trim().replace(/^['\"]|['\"]$/g, "");
Fix with Cubic


try {
const fileContent = fs.readFileSync(filePath, "utf-8");
const exportedData: ExportedSession = JSON.parse(fileContent);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Import command lacks runtime validation of exported session format/version before persistence, allowing incompatible or malformed session data to be saved.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/slashCommands.ts, line 218:

<comment>Import command lacks runtime validation of exported session format/version before persistence, allowing incompatible or malformed session data to be saved.</comment>

<file context>
@@ -173,6 +178,83 @@ function handleJobs() {
+
+  try {
+    const fileContent = fs.readFileSync(filePath, "utf-8");
+    const exportedData: ExportedSession = JSON.parse(fileContent);
+
+    let session = exportedData.session;
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant