Skip to content

fix(core): copy imported sessions on ID collision - #48336

Closed
OpeOginni wants to merge 2 commits into
anomalyco:devfrom
OpeOginni:import-id-collision
Closed

OpeOginni wants to merge 2 commits into
anomalyco:devfrom
OpeOginni:import-id-collision

Conversation

@OpeOginni

@OpeOginni OpeOginni commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  • Imports a separate copy when the exported session ID already exists.
  • Gives the copy fresh session and message IDs so database records do not collide; preserves message content and tool-call IDs.
  • Preserves exported IDs when the session ID is available.
  • Prints the new session ID and the reason it changed in the CLI.

How did you verify your code works?

  • Core session tests: 43 passed.
  • One focused collision test covers fresh IDs, another destination directory, preserved message content, and continuing the copy without changing the original.
  • CLI import/export tests: 6 passed, including the new-ID output.
  • Core and CLI typechecks, formatting, and diff checks passed.
  • Pre-push typechecks passed across all 35 tasks using Bun 1.4.2.

Screenshots / recordings

  • CLI output example: Imported session: ses_NEW (new ID because ses_ORIGINAL already exists).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli: V2 session import fails when the session ID already exists

1 participant