Skip to content

Commit 485b551

Browse files
daniel-lxsbrunobergherellipsis-dev[bot]NaccOll
authored
Improve checkpoint menu translations for PR RooCodeInc#7841 (RooCodeInc#8796)
Co-authored-by: Bruno Bergher <[email protected]> Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: NaccOll <[email protected]>
1 parent ab9a485 commit 485b551

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+326
-57
lines changed

src/core/checkpoints/__tests__/checkpoint.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ describe("Checkpoint functionality", () => {
304304
]
305305
})
306306

307-
it("should show diff for full mode", async () => {
307+
it("should show diff for to-current mode", async () => {
308308
const mockChanges = [
309309
{
310310
paths: { absolute: "/test/file.ts", relative: "file.ts" },
@@ -316,7 +316,7 @@ describe("Checkpoint functionality", () => {
316316
await checkpointDiff(mockTask, {
317317
ts: 4,
318318
commitHash: "commit2",
319-
mode: "full",
319+
mode: "to-current",
320320
})
321321

322322
expect(mockCheckpointService.getDiff).toHaveBeenCalledWith({
@@ -325,7 +325,7 @@ describe("Checkpoint functionality", () => {
325325
})
326326
expect(vscode.commands.executeCommand).toHaveBeenCalledWith(
327327
"vscode.changes",
328-
"Changes since task started",
328+
"errors.checkpoint_diff_to_current",
329329
expect.any(Array),
330330
)
331331
})
@@ -350,7 +350,7 @@ describe("Checkpoint functionality", () => {
350350
})
351351
expect(vscode.commands.executeCommand).toHaveBeenCalledWith(
352352
"vscode.changes",
353-
"Changes compare with next checkpoint",
353+
"errors.checkpoint_diff_with_next",
354354
expect.any(Array),
355355
)
356356
})
@@ -382,10 +382,10 @@ describe("Checkpoint functionality", () => {
382382
await checkpointDiff(mockTask, {
383383
ts: 4,
384384
commitHash: "commit2",
385-
mode: "full",
385+
mode: "to-current",
386386
})
387387

388-
expect(vscode.window.showInformationMessage).toHaveBeenCalledWith("No changes found.")
388+
expect(vscode.window.showInformationMessage).toHaveBeenCalledWith("errors.checkpoint_no_changes")
389389
expect(vscode.commands.executeCommand).not.toHaveBeenCalled()
390390
})
391391

@@ -395,7 +395,7 @@ describe("Checkpoint functionality", () => {
395395
await checkpointDiff(mockTask, {
396396
ts: 4,
397397
commitHash: "commit2",
398-
mode: "full",
398+
mode: "to-current",
399399
})
400400

401401
expect(mockTask.enableCheckpoints).toBe(false)

src/core/checkpoints/index.ts

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,16 @@ export async function checkpointRestore(
302302
}
303303

304304
export type CheckpointDiffOptions = {
305-
ts: number
305+
ts?: number
306306
previousCommitHash?: string
307307
commitHash: string
308-
mode: "full" | "checkpoint"
308+
/**
309+
* from-init: Compare from the first checkpoint to the selected checkpoint.
310+
* checkpoint: Compare the selected checkpoint to the next checkpoint.
311+
* to-current: Compare the selected checkpoint to the current workspace.
312+
* full: Compare from the first checkpoint to the current workspace.
313+
*/
314+
mode: "from-init" | "checkpoint" | "to-current" | "full"
309315
}
310316

311317
export async function checkpointDiff(task: Task, { ts, previousCommitHash, commitHash, mode }: CheckpointDiffOptions) {
@@ -317,30 +323,57 @@ export async function checkpointDiff(task: Task, { ts, previousCommitHash, commi
317323

318324
TelemetryService.instance.captureCheckpointDiffed(task.taskId)
319325

320-
let prevHash = commitHash
321-
let nextHash: string | undefined = undefined
326+
let fromHash: string | undefined
327+
let toHash: string | undefined
328+
let title: string
322329

323-
if (mode !== "full") {
324-
const checkpoints = task.clineMessages.filter(({ say }) => say === "checkpoint_saved").map(({ text }) => text!)
325-
const idx = checkpoints.indexOf(commitHash)
326-
if (idx !== -1 && idx < checkpoints.length - 1) {
327-
nextHash = checkpoints[idx + 1]
328-
} else {
329-
nextHash = undefined
330-
}
330+
const checkpoints = task.clineMessages.filter(({ say }) => say === "checkpoint_saved").map(({ text }) => text!)
331+
332+
if (["from-init", "full"].includes(mode) && checkpoints.length < 1) {
333+
vscode.window.showInformationMessage(t("common:errors.checkpoint_no_first"))
334+
return
335+
}
336+
337+
const idx = checkpoints.indexOf(commitHash)
338+
switch (mode) {
339+
case "checkpoint":
340+
fromHash = commitHash
341+
toHash = idx !== -1 && idx < checkpoints.length - 1 ? checkpoints[idx + 1] : undefined
342+
title = t("common:errors.checkpoint_diff_with_next")
343+
break
344+
case "from-init":
345+
fromHash = checkpoints[0]
346+
toHash = commitHash
347+
title = t("common:errors.checkpoint_diff_since_first")
348+
break
349+
case "to-current":
350+
fromHash = commitHash
351+
toHash = undefined
352+
title = t("common:errors.checkpoint_diff_to_current")
353+
break
354+
case "full":
355+
fromHash = checkpoints[0]
356+
toHash = undefined
357+
title = t("common:errors.checkpoint_diff_since_first")
358+
break
359+
}
360+
361+
if (!fromHash) {
362+
vscode.window.showInformationMessage(t("common:errors.checkpoint_no_previous"))
363+
return
331364
}
332365

333366
try {
334-
const changes = await service.getDiff({ from: prevHash, to: nextHash })
367+
const changes = await service.getDiff({ from: fromHash, to: toHash })
335368

336369
if (!changes?.length) {
337-
vscode.window.showInformationMessage("No changes found.")
370+
vscode.window.showInformationMessage(t("common:errors.checkpoint_no_changes"))
338371
return
339372
}
340373

341374
await vscode.commands.executeCommand(
342375
"vscode.changes",
343-
mode === "full" ? "Changes since task started" : "Changes compare with next checkpoint",
376+
title,
344377
changes.map((change) => [
345378
vscode.Uri.file(change.paths.absolute),
346379
vscode.Uri.parse(`${DIFF_VIEW_URI_SCHEME}:${change.paths.relative}`).with({

src/i18n/locales/ca/common.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/de/common.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/en/common.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
"checkpoint_timeout": "Timed out when attempting to restore checkpoint.",
3030
"checkpoint_failed": "Failed to restore checkpoint.",
3131
"git_not_installed": "Git is required for the checkpoints feature. Please install Git to enable checkpoints.",
32+
"checkpoint_no_first": "No first checkpoint to compare.",
33+
"checkpoint_no_previous": "No previous checkpoint to compare.",
34+
"checkpoint_no_changes": "No changes found.",
35+
"checkpoint_diff_with_next": "Changes compared with next checkpoint",
36+
"checkpoint_diff_since_first": "Changes since first checkpoint",
37+
"checkpoint_diff_to_current": "Changes to current workspace",
3238
"nested_git_repos_warning": "Checkpoints are disabled because a nested git repository was detected at: {{path}}. To use checkpoints, please remove or relocate this nested git repository.",
3339
"no_workspace": "Please open a project folder first",
3440
"update_support_prompt": "Failed to update support prompt",

src/i18n/locales/es/common.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/fr/common.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/hi/common.json

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/id/common.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/it/common.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)