feat: add Claude (Anthropic) conversation import support#16164
Draft
Pleasurecruise wants to merge 1 commit into
Draft
feat: add Claude (Anthropic) conversation import support#16164Pleasurecruise wants to merge 1 commit into
Pleasurecruise wants to merge 1 commit into
Conversation
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>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
AnthropicImporter, which parses Claude's officialconversations.jsonexport into Cherry Studio topics/messages/blocks. It handlestext,thinking,tool_use, andtool_resultcontent blocks (tool calls/results become unified Tool blocks, reasoning becomes Thinking blocks), so messages aren't silently dropped.ImportResult.blockstoMessageBlock[]so thinking/tool blocks are preserved alongside main text.AnthropicImportPopup, mirroring the (already-migrated)ImportPopup:@cherrystudio/uiDialog+Spinnerfeedback, errors captured and logged.ImportMenuSettings(Settings → Data → Import).import.claude.*i18n strings foren,zh-CN, andzh-TW.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-refactorservices/importlayout,@cherrystudio/uidialog 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
ChatgptImporterconventions to keep the import pipeline consistent:AnthropicImporteronly transforms data;AnthropicImportPopuponly handles interaction.conversations.jsonstructure is validated (andmappingis used to distinguish it from the ChatGPT format), so minor future export changes don't break the whole import.The following tradeoffs were made:
modelfield (chat_messagesonly exposeuuid/text/content/sender/timestamps/attachments/files), so assistant messages are tagged with a default Claude model purely so the Claude logo renders — mirroring howChatgptImporterhard-codesgpt-5. This limitation is documented in the code.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
catch, the fake progress bar is replaced by a spinner, the importer coversthinking/tool_use/tool_resultblocks (no silent message loss),AnthropicContentBlock.textis optional, and the missing-model limitation is documented at the default. Unit tests were added.AnthropicImporteragainst 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.
mainfor active development,v1for v1 maintenance fixes/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note