[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
@@ -3,6 +3,7 @@ import * as MessageManager from './MessageManager.js'
import * as MessageFormatter from './MessageFormatter.js'
import * as ThreadManager from '../Threads/ThreadManager.js'
import { ObjectId } from '../../mongodb.js'
import { promiseMapWithLimit } from '@overleaf/promise-utils'
const DEFAULT_MESSAGE_LIMIT = 50
const MAX_MESSAGE_LENGTH = 10 * 1024 // 10kb, about 1,500 words
@@ -114,6 +115,10 @@ export async function generateThreadData(context) {
return await callMessageHttpController(context, _generateThreadData)
}
export async function cloneCommentThreads(context) {
return await callMessageHttpController(context, _cloneCommentThreads)
}
export async function getStatus(context) {
const message = 'chat is alive'
context.res.status(200).setBody(message)
@@ -436,3 +441,16 @@ async function _duplicateCommentThreads(req, res) {
}
res.json({ newThreads: result })
}
async function _cloneCommentThreads(req, res) {
const { projectId: sourceProjectId } = req.params
const { targetProjectId } = req.body
const rooms = await ThreadManager.cloneThreads(
sourceProjectId,
targetProjectId
)
await promiseMapWithLimit(10, rooms, async ({ from, to }) => {
await MessageManager.duplicateRoomToOtherRoom(from, to)
})
res.status(204)
}