[history-ot] rename remaining history-v1-ot references to history-ot (#25428)

* [history-ot] rename remaining history-v1-ot references to history-ot

* [web] rename History-v1 OT -> History OT in admin panel

* [web] rename OT Migration -> History OT Migration in admin panel

GitOrigin-RevId: 103ce816d5320d6379d51009cdc08b8a71aa48e6
This commit is contained in:
Jakob Ackermann
2025-05-20 08:06:46 +00:00
committed by Copybot
parent f56645ecfe
commit 1e6b13f9d5
16 changed files with 37 additions and 39 deletions
@@ -176,7 +176,7 @@ const DocumentManager = {
}
// Circular dependencies. Import at runtime.
const HistoryV1OTUpdateManager = require('./HistoryV1OTUpdateManager')
const HistoryOTUpdateManager = require('./HistoryOTUpdateManager')
const UpdateManager = require('./UpdateManager')
const {
@@ -246,7 +246,7 @@ const DocumentManager = {
// removed from redis.
if (op.length > 0) {
if (type === 'history-ot') {
await HistoryV1OTUpdateManager.applyUpdate(projectId, docId, update)
await HistoryOTUpdateManager.applyUpdate(projectId, docId, update)
} else {
await UpdateManager.promises.applyUpdate(projectId, docId, update)
}
@@ -16,12 +16,12 @@ const RealTimeRedisManager = require('./RealTimeRedisManager')
/**
* @typedef {import("./types").Update} Update
* @typedef {import("./types").HistoryV1OTEditOperationUpdate} HistoryV1OTEditOperationUpdate
* @typedef {import("./types").HistoryOTEditOperationUpdate} HistoryOTEditOperationUpdate
*/
/**
* @param {Update} update
* @return {update is HistoryV1OTEditOperationUpdate}
* @return {update is HistoryOTEditOperationUpdate}
*/
function isHistoryOTEditOperationUpdate(update) {
return (
@@ -39,7 +39,7 @@ function isHistoryOTEditOperationUpdate(update) {
*
* @param {string} projectId
* @param {string} docId
* @param {HistoryV1OTEditOperationUpdate} update
* @param {HistoryOTEditOperationUpdate} update
* @param {Profiler} profiler
*/
async function tryApplyUpdate(projectId, docId, update, profiler) {
@@ -131,7 +131,7 @@ async function tryApplyUpdate(projectId, docId, update, profiler) {
*
* @param {string} projectId
* @param {string} docId
* @param {HistoryV1OTEditOperationUpdate} update
* @param {HistoryOTEditOperationUpdate} update
*/
async function applyUpdate(projectId, docId, update) {
const profiler = new Profiler('applyUpdate', {
@@ -37,7 +37,7 @@ function getDoc(req, res, next) {
if (lines == null || version == null) {
return next(new Errors.NotFoundError('document not found'))
}
if (!Array.isArray(lines) && req.query.historyV1OTSupport !== 'true') {
if (!Array.isArray(lines) && req.query.historyOTSupport !== 'true') {
const file = StringFileData.fromRaw(lines)
// TODO(24596): tc support for history-ot
lines = file.getLines()
@@ -91,7 +91,7 @@ function peekDoc(req, res, next) {
if (lines == null || version == null) {
return next(new Errors.NotFoundError('document not found'))
}
if (!Array.isArray(lines) && req.query.historyV1OTSupport !== 'true') {
if (!Array.isArray(lines) && req.query.historyOTSupport !== 'true') {
const file = StringFileData.fromRaw(lines)
// TODO(24596): tc support for history-ot
lines = file.getLines()
@@ -15,7 +15,7 @@ const RangesManager = require('./RangesManager')
const SnapshotManager = require('./SnapshotManager')
const Profiler = require('./Profiler')
const { isInsert, isDelete, getDocLength, computeDocHash } = require('./Utils')
const HistoryV1OTUpdateManager = require('./HistoryV1OTUpdateManager')
const HistoryOTUpdateManager = require('./HistoryOTUpdateManager')
/**
* @import { Ranges, Update, HistoryUpdate } from "./types"
@@ -81,8 +81,8 @@ const UpdateManager = {
profile.log('getPendingUpdatesForDoc')
for (const update of updates) {
if (HistoryV1OTUpdateManager.isHistoryOTEditOperationUpdate(update)) {
await HistoryV1OTUpdateManager.applyUpdate(projectId, docId, update)
if (HistoryOTUpdateManager.isHistoryOTEditOperationUpdate(update)) {
await HistoryOTUpdateManager.applyUpdate(projectId, docId, update)
} else {
await UpdateManager.applyUpdate(projectId, docId, update)
}
+1 -1
View File
@@ -23,7 +23,7 @@ export type Update = {
projectHistoryId?: string
}
export type HistoryV1OTEditOperationUpdate = Omit<Update, 'op'> & {
export type HistoryOTEditOperationUpdate = Omit<Update, 'op'> & {
op: RawEditOperation[]
meta: Update['meta'] & { source: string }
}
@@ -31,7 +31,7 @@ describe('Applying updates to a doc', function () {
op: [this.op],
v: this.version,
}
this.historyV1OTUpdate = {
this.historyOTUpdate = {
doc: this.doc_id,
op: [{ textOperation: [4, 'one and a half\n', 9] }],
v: this.version,
@@ -301,7 +301,7 @@ describe('Applying updates to a doc', function () {
DocUpdaterClient.sendUpdate(
this.project_id,
this.doc_id,
this.historyV1OTUpdate,
this.historyOTUpdate,
error => {
if (error != null) {
throw error
@@ -352,7 +352,7 @@ describe('Applying updates to a doc', function () {
if (error != null) {
throw error
}
JSON.parse(updates[0]).op.should.deep.equal(this.historyV1OTUpdate.op)
JSON.parse(updates[0]).op.should.deep.equal(this.historyOTUpdate.op)
JSON.parse(updates[0]).meta.pathname.should.equal('/a/b/c.tex')
done()
@@ -395,7 +395,7 @@ describe('Applying updates to a doc', function () {
describe('when sending another update', function () {
beforeEach(function (done) {
this.timeout(10000)
this.second_update = Object.assign({}, this.historyV1OTUpdate)
this.second_update = Object.assign({}, this.historyOTUpdate)
this.second_update.op = [
{
textOperation: [4, 'one and a half\n', 24],
@@ -664,7 +664,7 @@ describe('Applying updates to a doc', function () {
DocUpdaterClient.sendUpdate(
this.project_id,
this.doc_id,
this.historyV1OTUpdate,
this.historyOTUpdate,
error => {
if (error != null) {
throw error
@@ -694,7 +694,7 @@ describe('Applying updates to a doc', function () {
-1,
(error, updates) => {
if (error) return done(error)
JSON.parse(updates[0]).op.should.deep.equal(this.historyV1OTUpdate.op)
JSON.parse(updates[0]).op.should.deep.equal(this.historyOTUpdate.op)
JSON.parse(updates[0]).meta.pathname.should.equal('/a/b/c.tex')
done()
}
@@ -979,7 +979,7 @@ describe('Applying updates to a doc', function () {
DocUpdaterClient.sendUpdate(
this.project_id,
this.doc_id,
this.historyV1OTUpdate,
this.historyOTUpdate,
error => {
if (error != null) {
throw error
@@ -201,7 +201,7 @@ describe('Setting a document', function () {
numberOfReceivedUpdates = 0
this.project_id = DocUpdaterClient.randomId()
this.doc_id = DocUpdaterClient.randomId()
this.historyV1OTUpdate = {
this.historyOTUpdate = {
doc: this.doc_id,
op: [{ textOperation: [4, 'one and a half\n', 9] }],
v: this.version,
@@ -219,7 +219,7 @@ describe('Setting a document', function () {
DocUpdaterClient.sendUpdate(
this.project_id,
this.doc_id,
this.historyV1OTUpdate,
this.historyOTUpdate,
error => {
if (error) {
throw error
@@ -49,7 +49,7 @@ describe('DocumentManager', function () {
applyUpdate: sinon.stub().resolves(),
},
}
this.HistoryV1OTUpdateManager = {
this.HistoryOTUpdateManager = {
applyUpdate: sinon.stub().resolves(),
}
this.RangesManager = {
@@ -69,7 +69,7 @@ describe('DocumentManager', function () {
'./Metrics': this.Metrics,
'./DiffCodec': this.DiffCodec,
'./UpdateManager': this.UpdateManager,
'./HistoryV1OTUpdateManager': this.HistoryV1OTUpdateManager,
'./HistoryOTUpdateManager': this.HistoryOTUpdateManager,
'./RangesManager': this.RangesManager,
'./Errors': Errors,
'@overleaf/settings': this.Settings,
@@ -231,11 +231,9 @@ function _concatTwoUpdates(firstUpdate, secondUpdate) {
return [firstUpdate, secondUpdate]
}
const firstUpdateIsHistoryV1OT = EditOperationBuilder.isValid(firstUpdate.op)
const secondUpdateIsHistoryV1OT = EditOperationBuilder.isValid(
secondUpdate.op
)
if (firstUpdateIsHistoryV1OT !== secondUpdateIsHistoryV1OT) {
const firstUpdateIsHistoryOT = EditOperationBuilder.isValid(firstUpdate.op)
const secondUpdateIsHistoryOT = EditOperationBuilder.isValid(secondUpdate.op)
if (firstUpdateIsHistoryOT !== secondUpdateIsHistoryOT) {
// cannot merge mix of sharejs-text-op and history-ot, should not happen.
return [firstUpdate, secondUpdate]
}
@@ -286,7 +284,7 @@ function _concatTwoUpdates(firstUpdate, secondUpdate) {
return [firstUpdate, secondUpdate]
}
if (firstUpdateIsHistoryV1OT && secondUpdateIsHistoryV1OT) {
if (firstUpdateIsHistoryOT && secondUpdateIsHistoryOT) {
const op1 = EditOperationBuilder.fromJSON(firstUpdate.op)
const op2 = EditOperationBuilder.fromJSON(secondUpdate.op)
if (!op1.canBeComposedWith(op2)) return [firstUpdate, secondUpdate]
@@ -7,7 +7,7 @@ import * as OperationsCompressor from './OperationsCompressor.js'
import { isInsert, isRetain, isDelete, isComment } from './Utils.js'
/**
* @import { AddDocUpdate, AddFileUpdate, DeleteCommentUpdate, HistoryV1OTEditOperationUpdate, Op, RawScanOp } from './types'
* @import { AddDocUpdate, AddFileUpdate, DeleteCommentUpdate, HistoryOTEditOperationUpdate, Op, RawScanOp } from './types'
* @import { RenameUpdate, TextUpdate, TrackingDirective, TrackingProps } from './types'
* @import { SetCommentStateUpdate, SetFileMetadataOperation, Update, UpdateWithBlob } from './types'
*/
@@ -206,7 +206,7 @@ export function isTextUpdate(update) {
/**
* @param {Update} update
* @returns {update is HistoryV1OTEditOperationUpdate}
* @returns {update is HistoryOTEditOperationUpdate}
*/
export function isHistoryOTEditOperationUpdate(update) {
return (
+1 -1
View File
@@ -44,7 +44,7 @@ export type TextUpdate = {
}
}
export type HistoryV1OTEditOperationUpdate = {
export type HistoryOTEditOperationUpdate = {
doc: string
op: RawEditOperation[]
v: number
@@ -19,7 +19,7 @@ const Keys = settings.redis.documentupdater.key_schema
const DocumentUpdaterManager = {
getDocument(projectId, docId, fromVersion, callback) {
const timer = new metrics.Timer('get-document')
const url = `${settings.apis.documentupdater.url}/project/${projectId}/doc/${docId}?fromVersion=${fromVersion}&historyV1OTSupport=true`
const url = `${settings.apis.documentupdater.url}/project/${projectId}/doc/${docId}?fromVersion=${fromVersion}&historyOTSupport=true`
logger.debug(
{ projectId, docId, fromVersion },
'getting doc from document updater'
@@ -309,11 +309,11 @@ module.exports = WebsocketController = {
const encodeForWebsockets = text =>
unescape(encodeURIComponent(text))
metrics.inc('client_supports_history_v1_ot', 1, {
status: options.supportsHistoryV1OT ? 'success' : 'failure',
status: options.supportsHistoryOT ? 'success' : 'failure',
})
let escapedLines
if (type === 'history-ot') {
if (!options.supportsHistoryV1OT) {
if (!options.supportsHistoryOT) {
RoomManager.leaveDoc(client, docId)
// TODO(24596): ask the user to reload the editor page (via out-of-sync modal when there are pending ops).
return callback(
@@ -641,7 +641,7 @@ describe('joinDoc', function () {
this.client.emit(
'joinDoc',
this.doc_id,
{ supportsHistoryV1OT: true },
{ supportsHistoryOT: true },
(error, ...rest) => {
;[...this.returnedArgs] = Array.from(rest)
cb(error)
@@ -79,7 +79,7 @@ describe('DocumentUpdaterManager', function () {
})
it('should get the document from the document updater', function () {
const url = `${this.settings.apis.documentupdater.url}/project/${this.project_id}/doc/${this.doc_id}?fromVersion=${this.fromVersion}&historyV1OTSupport=true`
const url = `${this.settings.apis.documentupdater.url}/project/${this.project_id}/doc/${this.doc_id}?fromVersion=${this.fromVersion}&historyOTSupport=true`
return this.request.get.calledWith(url).should.equal(true)
})
@@ -451,7 +451,7 @@ export class DocumentContainer extends EventEmitter {
{
encodeRanges: true,
age: this.doc.getTimeSinceLastServerActivity(),
supportsHistoryV1OT: true,
supportsHistoryOT: true,
},
(
error,
@@ -487,7 +487,7 @@ export class DocumentContainer extends EventEmitter {
this.doc_id,
{
encodeRanges: true,
supportsHistoryV1OT: true,
supportsHistoryOT: true,
},
(
error,