mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
remove some extra code
This commit is contained in:
parent
0bd49d7e54
commit
85268aaec7
2 changed files with 13 additions and 57 deletions
|
|
@ -176,21 +176,6 @@ describe("Checkpoint functionality", () => {
|
||||||
expect(mockTask.enableCheckpoints).toBe(true)
|
expect(mockTask.enableCheckpoints).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should prevent duplicate checkpoint operations for the same task", async () => {
|
|
||||||
// Start two checkpoint saves simultaneously
|
|
||||||
const promise1 = checkpointSave(mockTask)
|
|
||||||
const promise2 = checkpointSave(mockTask)
|
|
||||||
|
|
||||||
// Wait for both promises
|
|
||||||
const [result1, result2] = await Promise.all([promise1, promise2])
|
|
||||||
|
|
||||||
// Both should return the same result
|
|
||||||
expect(result1).toEqual(result2)
|
|
||||||
|
|
||||||
// saveCheckpoint should only be called once due to deduplication
|
|
||||||
expect(mockCheckpointService.saveCheckpoint).toHaveBeenCalledTimes(1)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("should handle errors gracefully and disable checkpoints", async () => {
|
it("should handle errors gracefully and disable checkpoints", async () => {
|
||||||
mockCheckpointService.saveCheckpoint.mockRejectedValue(new Error("Save failed"))
|
mockCheckpointService.saveCheckpoint.mockRejectedValue(new Error("Save failed"))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@ import { DIFF_VIEW_URI_SCHEME } from "../../integrations/editor/DiffViewProvider
|
||||||
|
|
||||||
import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../../services/checkpoints"
|
import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../../services/checkpoints"
|
||||||
|
|
||||||
// Map to store pending checkpoint operations by taskId to prevent race conditions
|
|
||||||
const pendingCheckpointOperations = new Map<string, Promise<any>>()
|
|
||||||
|
|
||||||
export function getCheckpointService(cline: Task) {
|
export function getCheckpointService(cline: Task) {
|
||||||
if (!cline.enableCheckpoints) {
|
if (!cline.enableCheckpoints) {
|
||||||
return undefined
|
return undefined
|
||||||
|
|
@ -195,17 +192,6 @@ async function getInitializedCheckpointService(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkpointSave(cline: Task, force = false) {
|
export async function checkpointSave(cline: Task, force = false) {
|
||||||
const taskId = cline.taskId
|
|
||||||
|
|
||||||
// Check if there's already a pending checkpoint operation for this task
|
|
||||||
const existingOperation = pendingCheckpointOperations.get(taskId)
|
|
||||||
if (existingOperation) {
|
|
||||||
// Return the existing Promise to prevent duplicate operations
|
|
||||||
return existingOperation
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new checkpoint operation Promise
|
|
||||||
const checkpointOperation = (async () => {
|
|
||||||
try {
|
try {
|
||||||
// Use getInitializedCheckpointService to wait for initialization
|
// Use getInitializedCheckpointService to wait for initialization
|
||||||
const service = await getInitializedCheckpointService(cline)
|
const service = await getInitializedCheckpointService(cline)
|
||||||
|
|
@ -223,21 +209,6 @@ export async function checkpointSave(cline: Task, force = false) {
|
||||||
cline.enableCheckpoints = false
|
cline.enableCheckpoints = false
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
})()
|
|
||||||
|
|
||||||
// Store the operation in the Map
|
|
||||||
pendingCheckpointOperations.set(taskId, checkpointOperation)
|
|
||||||
|
|
||||||
// Clean up the Map entry after the operation completes (success or failure)
|
|
||||||
checkpointOperation
|
|
||||||
.finally(() => {
|
|
||||||
pendingCheckpointOperations.delete(taskId)
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
// Error already handled above, this catch prevents unhandled rejection
|
|
||||||
})
|
|
||||||
|
|
||||||
return checkpointOperation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CheckpointRestoreOptions = {
|
export type CheckpointRestoreOptions = {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue