Skip to content

Commit 618f3d2

Browse files
committed
improve checkpoint warning 18n and validation logic
1 parent 89b6284 commit 618f3d2

File tree

21 files changed

+72
-61
lines changed

21 files changed

+72
-61
lines changed

src/core/checkpoints/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ import { getApiMetrics } from "../../shared/getApiMetrics"
1515
import { DIFF_VIEW_URI_SCHEME } from "../../integrations/editor/DiffViewProvider"
1616

1717
import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../../services/checkpoints"
18+
import { time } from "node:console"
1819

1920
const WARNING_THRESHOLD_MS = 5000
20-
const waitWarn = t("common:errors.wait_checkpoint_long_time")
21-
const failWarn = t("common:errors.init_checkpoint_fail_long_time")
21+
const WAIT_LONG_TIME_I18_KEY = "common:errors.wait_checkpoint_long_time"
22+
const INIT_FAIL_LONG_TIME_I18_KEY = "common:errors.init_checkpoint_fail_long_time"
2223

2324
function sendCheckpointInitWarn(task: Task, checkpointWarning: string) {
2425
task.providerRef.deref()?.postMessageToWebview({
@@ -88,7 +89,10 @@ export async function getCheckpointService(task: Task, { interval = 250 }: { int
8889
// Show warning if we're past the threshold and haven't shown it yet
8990
if (!warningShown && elapsed >= WARNING_THRESHOLD_MS) {
9091
warningShown = true
91-
sendCheckpointInitWarn(task, waitWarn)
92+
sendCheckpointInitWarn(
93+
task,
94+
t(WAIT_LONG_TIME_I18_KEY, { timeout: WARNING_THRESHOLD_MS / 1000 }),
95+
)
9296
}
9397

9498
console.log(
@@ -99,7 +103,7 @@ export async function getCheckpointService(task: Task, { interval = 250 }: { int
99103
{ interval, timeout: checkpointTimeoutMs },
100104
)
101105
if (!task?.checkpointService) {
102-
sendCheckpointInitWarn(task, failWarn)
106+
sendCheckpointInitWarn(task, t(INIT_FAIL_LONG_TIME_I18_KEY, { timeout: task.checkpointTimeout }))
103107
task.enableCheckpoints = false
104108
return undefined
105109
} else {
@@ -122,7 +126,7 @@ export async function getCheckpointService(task: Task, { interval = 250 }: { int
122126
return service
123127
} catch (err) {
124128
if (err.name === "TimeoutError" && task.enableCheckpoints) {
125-
sendCheckpointInitWarn(task, failWarn)
129+
sendCheckpointInitWarn(task, t(INIT_FAIL_LONG_TIME_I18_KEY, { timeout: task.checkpointTimeout }))
126130
}
127131
log(`[Task#getCheckpointService] ${err.message}`)
128132
task.enableCheckpoints = false
@@ -166,6 +170,7 @@ async function checkGitInstallation(
166170

167171
service.on("checkpoint", ({ fromHash: from, toHash: to, suppressMessage }) => {
168172
try {
173+
sendCheckpointInitWarn(task, "")
169174
// Always update the current checkpoint hash in the webview, including the suppress flag
170175
provider?.postMessageToWebview({
171176
type: "currentCheckpointUpdated",

src/core/task/Task.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import {
3636
isResumableAsk,
3737
QueuedMessage,
3838
DEFAULT_CHECKPOINT_TIMEOUT_SECONDS,
39+
MAX_CHECKPOINT_TIMEOUT_SECONDS,
40+
MIN_CHECKPOINT_TIMEOUT_SECONDS,
3941
} from "@roo-code/types"
4042
import { TelemetryService } from "@roo-code/telemetry"
4143
import { CloudService, BridgeOrchestrator } from "@roo-code/cloud"
@@ -326,6 +328,20 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
326328
throw new Error("Either historyItem or task/images must be provided")
327329
}
328330

331+
if (
332+
!checkpointTimeout ||
333+
checkpointTimeout > MAX_CHECKPOINT_TIMEOUT_SECONDS ||
334+
checkpointTimeout < MIN_CHECKPOINT_TIMEOUT_SECONDS
335+
) {
336+
throw new Error(
337+
"checkpointTimeout must be between " +
338+
MIN_CHECKPOINT_TIMEOUT_SECONDS +
339+
" and " +
340+
MAX_CHECKPOINT_TIMEOUT_SECONDS +
341+
" seconds",
342+
)
343+
}
344+
329345
this.taskId = historyItem ? historyItem.id : crypto.randomUUID()
330346
this.rootTaskId = historyItem ? historyItem.rootTaskId : rootTask?.taskId
331347
this.parentTaskId = historyItem ? historyItem.parentTaskId : parentTask?.taskId

src/i18n/locales/ca/common.json

Lines changed: 2 additions & 2 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: 2 additions & 2 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"checkpoint_failed": "Failed to restore checkpoint.",
3131
"git_not_installed": "Git is required for the checkpoints feature. Please install Git to enable checkpoints.",
3232
"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.",
33-
"wait_checkpoint_long_time": "Checkpoint initialization is taking longer than expected. This may indicate a large repository or slow Git operations.",
34-
"init_checkpoint_fail_long_time": "Checkpoint initialization failed after taking a long time. Checkpoints have been disabled for this task. You can disable checkpoints entirely or increase the timeout in settings.",
33+
"wait_checkpoint_long_time": "Waited {{timeout}} seconds for checkpoint initialization. If you don't need the checkpoint feature, please turn it off in the settings.",
34+
"init_checkpoint_fail_long_time": "Checkpoint initialization has taken more than {{timeout}} seconds. Checkpoint function is disabled for this task. You can disable checkpoint or extend the waiting time in settings.",
3535
"no_workspace": "Please open a project folder first",
3636
"update_support_prompt": "Failed to update support prompt",
3737
"reset_support_prompt": "Failed to reset support prompt",

src/i18n/locales/es/common.json

Lines changed: 2 additions & 2 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: 2 additions & 2 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: 2 additions & 2 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: 2 additions & 2 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: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)