Skip to content

Commit 2e79364

Browse files
committed
feat: add clickable settings links to checkpoint timeout warnings
- Use flag-based approach instead of passing i18n keys around - Backend sends warning type enum (WAIT_TIMEOUT/INIT_TIMEOUT) + timeout value - Frontend CheckpointWarning maps type to appropriate i18n key - Add checkpoint error translations to webview-ui locale files only - Remove duplicate translations from backend locale files - Trans component handles translation and link interpolation - Move periods inside settingsLink tags for proper spacing TEMPORARY: Warning always shows for testing (will be reverted) This provides a clean architecture where: - Backend: Sends simple flag + timeout (no i18n dependency) - Frontend: Handles all i18n logic with Trans component - No duplication: Translations only in frontend where they're used Addresses PR #8019 review feedback.
1 parent 62143f9 commit 2e79364

40 files changed

+110
-63
lines changed

src/core/checkpoints/index.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ import { DIFF_VIEW_URI_SCHEME } from "../../integrations/editor/DiffViewProvider
1717
import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../../services/checkpoints"
1818

1919
const WARNING_THRESHOLD_MS = 5000
20-
const WAIT_LONG_TIME_I18_KEY = "common:errors.wait_checkpoint_long_time"
21-
const INIT_FAIL_LONG_TIME_I18_KEY = "common:errors.init_checkpoint_fail_long_time"
2220

23-
function sendCheckpointInitWarn(task: Task, checkpointWarning: string) {
21+
function sendCheckpointInitWarn(task: Task, type?: "WAIT_TIMEOUT" | "INIT_TIMEOUT", timeout?: number) {
2422
task.providerRef.deref()?.postMessageToWebview({
2523
type: "checkpointInitWarning",
26-
checkpointWarning,
24+
checkpointWarning: type && timeout ? { type, timeout } : undefined,
2725
})
2826
}
2927

@@ -88,10 +86,7 @@ export async function getCheckpointService(task: Task, { interval = 250 }: { int
8886
// Show warning if we're past the threshold and haven't shown it yet
8987
if (!warningShown && elapsed >= WARNING_THRESHOLD_MS) {
9088
warningShown = true
91-
sendCheckpointInitWarn(
92-
task,
93-
t(WAIT_LONG_TIME_I18_KEY, { timeout: WARNING_THRESHOLD_MS / 1000 }),
94-
)
89+
sendCheckpointInitWarn(task, "WAIT_TIMEOUT", WARNING_THRESHOLD_MS / 1000)
9590
}
9691

9792
console.log(
@@ -102,11 +97,11 @@ export async function getCheckpointService(task: Task, { interval = 250 }: { int
10297
{ interval, timeout: checkpointTimeoutMs },
10398
)
10499
if (!task?.checkpointService) {
105-
sendCheckpointInitWarn(task, t(INIT_FAIL_LONG_TIME_I18_KEY, { timeout: task.checkpointTimeout }))
100+
sendCheckpointInitWarn(task, "INIT_TIMEOUT", task.checkpointTimeout)
106101
task.enableCheckpoints = false
107102
return undefined
108103
} else {
109-
sendCheckpointInitWarn(task, "")
104+
sendCheckpointInitWarn(task)
110105
}
111106
return task.checkpointService
112107
}
@@ -120,12 +115,12 @@ export async function getCheckpointService(task: Task, { interval = 250 }: { int
120115
await checkGitInstallation(task, service, log, provider)
121116
task.checkpointService = service
122117
if (task.enableCheckpoints) {
123-
sendCheckpointInitWarn(task, "")
118+
sendCheckpointInitWarn(task)
124119
}
125120
return service
126121
} catch (err) {
127122
if (err.name === "TimeoutError" && task.enableCheckpoints) {
128-
sendCheckpointInitWarn(task, t(INIT_FAIL_LONG_TIME_I18_KEY, { timeout: task.checkpointTimeout }))
123+
sendCheckpointInitWarn(task, "INIT_TIMEOUT", task.checkpointTimeout)
129124
}
130125
log(`[Task#getCheckpointService] ${err.message}`)
131126
task.enableCheckpoints = false
@@ -169,7 +164,7 @@ async function checkGitInstallation(
169164

170165
service.on("checkpoint", ({ fromHash: from, toHash: to, suppressMessage }) => {
171166
try {
172-
sendCheckpointInitWarn(task, "")
167+
sendCheckpointInitWarn(task)
173168
// Always update the current checkpoint hash in the webview, including the suppress flag
174169
provider?.postMessageToWebview({
175170
type: "currentCheckpointUpdated",

src/i18n/locales/ca/common.json

Lines changed: 0 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: 0 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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
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": "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.",
3533
"no_workspace": "Please open a project folder first",
3634
"update_support_prompt": "Failed to update support prompt",
3735
"reset_support_prompt": "Failed to reset support prompt",

src/i18n/locales/es/common.json

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

src/i18n/locales/ja/common.json

Lines changed: 0 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)