[chat] clone comment threads when cloning project with ranges (#32852)

* [project-history] add best effort flush when cloning project

* [web] update labels in clone project modal for admins

* [project-history] do not shadow history flush failure

* [web] fix accessible label for 'Add comment' button

* [chat] clone comment threads when cloning project with ranges

GitOrigin-RevId: ef30204c8a94b3d6204d56dcca2f62a46319996b
This commit is contained in:
Jakob Ackermann
2026-04-17 08:07:03 +00:00
committed by Copybot
parent 933c0c2943
commit 6117feef1b
9 changed files with 177 additions and 73 deletions
@@ -249,6 +249,21 @@ async function generateThreadData(projectId, threads) {
)
}
/**
* @param {string} sourceProjectId
* @param {string} targetProjectId
* @return {Promise<void>}
*/
async function cloneCommentThreads(sourceProjectId, targetProjectId) {
await fetchNothing(
chatApiUrl(`/project/${sourceProjectId}/clone-comment-threads`),
{
method: 'POST',
json: { targetProjectId },
}
)
}
/**
* @param {any} path
*/
@@ -296,5 +311,6 @@ export default {
getResolvedThreadIds,
duplicateCommentThreads,
generateThreadData,
cloneCommentThreads,
},
}
@@ -22,6 +22,7 @@ import _ from 'lodash'
import TagsHandler from '../Tags/TagsHandler.mjs'
import ClsiCacheManager from '../Compile/ClsiCacheManager.mjs'
import Modules from '../../infrastructure/Modules.mjs'
import ChatApiHandler from '../Chat/ChatApiHandler.mjs'
const TAG_COLOR_RED = '#f04343'
const DEBUG_TAG_NAME = 'Debug'
@@ -191,6 +192,12 @@ async function duplicate(
newProject._id
)
}
if (opts.cloneRanges) {
await ChatApiHandler.promises.cloneCommentThreads(
originalProject._id.toString(),
newProject._id.toString()
)
}
} catch (err) {
// Clean up broken clone on error.
// Make sure we delete the new failed project, not the original one!
@@ -263,6 +263,7 @@ const ReviewTooltipMenuContent = memo<{ onAddComment: () => void }>(
<button
className="review-tooltip-menu-button review-tooltip-add-comment-button"
onClick={handleAddCommentClick}
aria-label={t('add_comment')}
>
<MaterialIcon type="chat" />
{t('add_comment')}