feat: add Duplicate Topic feature#14788
Open
LWWZH wants to merge 1 commit into
Open
Conversation
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:
Users could only copy topic content to clipboard (as image, markdown, or plain text) or export it to external formats. There was no way to create a full copy of a topic including all its conversation history within the app.
After this PR:
Right-clicking any topic in the topic list now shows a "Duplicate Topic" option. Selecting it creates a complete clone of the topic — including all messages, blocks, files, and the topic prompt — with the name suffixed by
" (Copy)". The duplicated topic is immediately activated so the user can continue the conversation.Fixes #14773
Why we need it and why it was done in this way
This feature was requested by AI novel creators who frequently need to branch stories within the same world view / background / premise. Without duplication, they had to manually save content or copy-paste, which is cumbersome for long conversations.
The implementation reuses the existing
cloneMessagesToNewTopicThunk(already used for topic branching) to deep-clone all messages and blocks with remapped IDs. This avoids duplicating logic and ensures file references are handled correctly.Tradeoffs:
dataApiService.postis not rolled back on local clone failure. This matches the existingremoveTopicpattern in the codebase.Alternatives considered:
Breaking changes
None.
Special notes for your reviewer
useDispatch→useAppDispatchinTopics.tsxfor better type safety.en-us,zh-cn, andzh-tw.Checklist
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note