Skip to content

feat: add Claude (Anthropic) conversation import support#16164

Draft
Pleasurecruise wants to merge 1 commit into
mainfrom
feat/anthropic-history
Draft

feat: add Claude (Anthropic) conversation import support#16164
Pleasurecruise wants to merge 1 commit into
mainfrom
feat/anthropic-history

Conversation

@Pleasurecruise

Copy link
Copy Markdown
Collaborator

What this PR does

Before this PR:
Cherry Studio could import ChatGPT exports but had no way to import Claude/Anthropic conversation history, so users running both apps had no migration path.

After this PR:

  • Adds AnthropicImporter, which parses Claude's official conversations.json export into Cherry Studio topics/messages/blocks. It handles text, thinking, tool_use, and tool_result content blocks (tool calls/results become unified Tool blocks, reasoning becomes Thinking blocks), so messages aren't silently dropped.
  • Registers it in the importer registry and widens ImportResult.blocks to MessageBlock[] so thinking/tool blocks are preserved alongside main text.
  • Adds AnthropicImportPopup, mirroring the (already-migrated) ImportPopup: @cherrystudio/ui Dialog + Spinner feedback, errors captured and logged.
  • Wires a Claude entry into ImportMenuSettings (Settings → Data → Import).
  • Adds import.claude.* i18n strings for en, zh-CN, and zh-TW.
  • Adds unit tests for the importer.

This PR re-opens / supersedes #13691, which accumulated too many merge conflicts to rebase cleanly after the v2 refactor. The feature is re-implemented from scratch on top of the current main (post-refactor services/import layout, @cherrystudio/ui dialog primitives, MessageBlock-typed import result), and the code-review feedback from #13691 is folded in here.

Fixes #

Why we need it and why it was done in this way

Many users run Claude and Cherry Studio side by side, and migrating conversation history is a common request. The implementation follows the existing ChatgptImporter conventions to keep the import pipeline consistent:

  • Parser and UI are decoupledAnthropicImporter only transforms data; AnthropicImportPopup only handles interaction.
  • Lightweight, additive — only the top-level conversations.json structure is validated (and mapping is used to distinguish it from the ChatGPT format), so minor future export changes don't break the whole import.

The following tradeoffs were made:

  • Model metadata is a hard-coded Claude default. Anthropic's export contains no per-message model field (chat_messages only expose uuid/text/content/sender/timestamps/attachments/files), so assistant messages are tagged with a default Claude model purely so the Claude logo renders — mirroring how ChatgptImporter hard-codes gpt-5. This limitation is documented in the code.
  • No real per-message progress bar. Parsing is synchronous and effectively instant, so the UI shows a spinner rather than a fake/percentage progress bar.
  • Rides the existing (v1) import path. Like ChatgptImporter, it persists via the current import service. No new v2 data-layer surface was added.

The following alternatives were considered:

Links to places where the discussion took place: supersedes #13691 (carries over its review thread).

Breaking changes

None. This change is purely additive — no existing data models, schemas, or stores are modified.

Special notes for your reviewer

  1. This supersedes feat: add Claude (Anthropic) conversation import support #13691 — that PR can be closed in favor of this one.
  2. Code-review items from feat: add Claude (Anthropic) conversation import support #13691 addressed here: error context is now logged in the popup catch, the fake progress bar is replaced by a spinner, the importer covers thinking/tool_use/tool_result blocks (no silent message loss), AnthropicContentBlock.text is optional, and the missing-model limitation is documented at the default. Unit tests were added.
  3. Please sanity-check the content-block coverage in AnthropicImporter against the current Claude export format.

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

  • Branch: This PR targets the correct branch — main for active development, v1 for v1 maintenance fixes
  • PR: The PR description is expressive enough and will help future contributors
  • Code: Write code that humans can understand and Keep it simple
  • Refactor: You have left the code cleaner than you found it (Boy Scout Rule)
  • Upgrade: Impact of this change on upgrade flows was considered and addressed if required
  • Documentation: A user-guide update was considered and is present (link) or not required. Check this only when the PR introduces or changes a user-facing feature or behavior.
  • Self-review: I have reviewed my own code (e.g., via /gh-pr-review, gh pr diff, or GitHub UI) before requesting review from others

Release note

Added Claude (Anthropic) conversation import: in Settings → Data → Import, select a conversations.json file exported from Claude to import your chat history (text, reasoning, and tool calls). Available in English, Simplified Chinese, and Traditional Chinese.

Port the AnthropicImporter feature from PR #13691, rebased onto the
current main and adapted to the post-refactor structure (services/import
relocation, @cherrystudio/ui dialog primitives, MessageBlock-typed import
result).

- Add AnthropicImporter parsing Claude's conversations.json export into
  topics/messages/blocks, handling text, thinking, tool_use and
  tool_result content blocks.
- Register it in the importer registry and widen ImportResult.blocks to
  MessageBlock[] so thinking/tool blocks are preserved.
- Add AnthropicImportPopup mirroring the migrated ImportPopup
  (Spinner-based feedback, error captured and logged).
- Wire a Claude entry into ImportMenuSettings.
- Add import.claude i18n strings for en/zh-CN/zh-TW.
- Add unit tests for the importer.

Addresses the code review on #13691: error context is logged, the fake
progress bar is replaced by a spinner, and the lack of a model field in
Anthropic exports is documented at the hard-coded default.

Signed-off-by: Pleasurecruise <3196812536@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant