Skip to content

Commit 0d49afd

Browse files
committed
refactor: use existing writeDelayMs instead of diagnosticsDelayMs
- Remove diagnosticsDelayMs setting in favor of existing writeDelayMs - Add min(0) validation for writeDelayMs in global settings schema - Add error handling around delay function calls in DiffViewProvider - Create DEFAULT_WRITE_DELAY_MS constant (1000ms) to replace repeated defaults - Update all tool files to pass writeDelayMs instead of diagnosticsDelayMs - Remove diagnosticsDelayMs from webview message handlers and types - Update test files to use writeDelayMs instead of diagnosticsDelayMs This refactoring consolidates diagnostic delay functionality to use the existing writeDelayMs setting as requested in PR feedback.
1 parent e1a105d commit 0d49afd

File tree

15 files changed

+86
-37
lines changed

15 files changed

+86
-37
lines changed

packages/types/src/global-settings.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const globalSettingsSchema = z.object({
3737
alwaysAllowWrite: z.boolean().optional(),
3838
alwaysAllowWriteOutsideWorkspace: z.boolean().optional(),
3939
alwaysAllowWriteProtected: z.boolean().optional(),
40-
writeDelayMs: z.number().optional(),
40+
writeDelayMs: z.number().min(0).optional(),
4141
alwaysAllowBrowser: z.boolean().optional(),
4242
alwaysApproveResubmit: z.boolean().optional(),
4343
requestDelaySeconds: z.number().optional(),
@@ -86,7 +86,6 @@ export const globalSettingsSchema = z.object({
8686
terminalZdotdir: z.boolean().optional(),
8787
terminalCompressProgressBar: z.boolean().optional(),
8888

89-
diagnosticsDelayMs: z.number().optional(),
9089
diagnosticsEnabled: z.boolean().optional(),
9190

9291
rateLimitSeconds: z.number().optional(),
@@ -227,7 +226,6 @@ export const EVALS_SETTINGS: RooCodeSettings = {
227226
terminalCompressProgressBar: true,
228227
terminalShellIntegrationDisabled: true,
229228

230-
diagnosticsDelayMs: 2000,
231229
diagnosticsEnabled: true,
232230

233231
diffEnabled: true,

src/core/tools/__tests__/insertContentTool.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe("insertContentTool", () => {
7575
deref: vi.fn().mockReturnValue({
7676
getState: vi.fn().mockResolvedValue({
7777
diagnosticsEnabled: true,
78-
diagnosticsDelayMs: 2000,
78+
writeDelayMs: 1000,
7979
}),
8080
}),
8181
},

src/core/tools/__tests__/writeToFileTool.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe("writeToFileTool", () => {
136136
deref: vi.fn().mockReturnValue({
137137
getState: vi.fn().mockResolvedValue({
138138
diagnosticsEnabled: true,
139-
diagnosticsDelayMs: 2000,
139+
writeDelayMs: 1000,
140140
}),
141141
}),
142142
}

src/core/tools/applyDiffTool.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from "path"
22
import fs from "fs/promises"
33

44
import { TelemetryService } from "@roo-code/telemetry"
5+
import { DEFAULT_WRITE_DELAY_MS } from "../../shared/constants"
56

67
import { ClineSayTool } from "../../shared/ExtensionMessage"
78
import { getReadablePath } from "../../utils/path"
@@ -173,8 +174,8 @@ export async function applyDiffToolLegacy(
173174
const provider = cline.providerRef.deref()
174175
const state = await provider?.getState()
175176
const diagnosticsEnabled = state?.diagnosticsEnabled ?? true
176-
const diagnosticsDelayMs = state?.diagnosticsDelayMs ?? 2000
177-
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, diagnosticsDelayMs)
177+
const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS
178+
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
178179

179180
// Track file edit operation
180181
if (relPath) {

src/core/tools/insertContentTool.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ClineSayTool } from "../../shared/ExtensionMessage"
1010
import { RecordSource } from "../context-tracking/FileContextTrackerTypes"
1111
import { fileExistsAtPath } from "../../utils/fs"
1212
import { insertGroups } from "../diff/insert-groups"
13+
import { DEFAULT_WRITE_DELAY_MS } from "../../shared/constants"
1314

1415
export async function insertContentTool(
1516
cline: Task,
@@ -158,8 +159,8 @@ export async function insertContentTool(
158159
const provider = cline.providerRef.deref()
159160
const state = await provider?.getState()
160161
const diagnosticsEnabled = state?.diagnosticsEnabled ?? true
161-
const diagnosticsDelayMs = state?.diagnosticsDelayMs ?? 2000
162-
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, diagnosticsDelayMs)
162+
const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS
163+
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
163164

164165
// Track file edit operation
165166
if (relPath) {

src/core/tools/multiApplyDiffTool.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from "path"
22
import fs from "fs/promises"
33

44
import { TelemetryService } from "@roo-code/telemetry"
5+
import { DEFAULT_WRITE_DELAY_MS } from "../../shared/constants"
56

67
import { ClineSayTool } from "../../shared/ExtensionMessage"
78
import { getReadablePath } from "../../utils/path"
@@ -556,8 +557,8 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""}
556557
const provider = cline.providerRef.deref()
557558
const state = await provider?.getState()
558559
const diagnosticsEnabled = state?.diagnosticsEnabled ?? true
559-
const diagnosticsDelayMs = state?.diagnosticsDelayMs ?? 2000
560-
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, diagnosticsDelayMs)
560+
const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS
561+
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
561562

562563
// Track file edit operation
563564
await cline.fileContextTracker.trackFileContext(relPath, "roo_edited" as RecordSource)

src/core/tools/searchAndReplaceTool.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ClineSayTool } from "../../shared/ExtensionMessage"
1111
import { getReadablePath } from "../../utils/path"
1212
import { fileExistsAtPath } from "../../utils/fs"
1313
import { RecordSource } from "../context-tracking/FileContextTrackerTypes"
14+
import { DEFAULT_WRITE_DELAY_MS } from "../../shared/constants"
1415

1516
/**
1617
* Tool for performing search and replace operations on files
@@ -230,8 +231,8 @@ export async function searchAndReplaceTool(
230231
const provider = cline.providerRef.deref()
231232
const state = await provider?.getState()
232233
const diagnosticsEnabled = state?.diagnosticsEnabled ?? true
233-
const diagnosticsDelayMs = state?.diagnosticsDelayMs ?? 2000
234-
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, diagnosticsDelayMs)
234+
const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS
235+
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
235236

236237
// Track file edit operation
237238
if (relPath) {

src/core/tools/writeToFileTool.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { getReadablePath } from "../../utils/path"
1313
import { isPathOutsideWorkspace } from "../../utils/pathUtils"
1414
import { detectCodeOmission } from "../../integrations/editor/detect-omission"
1515
import { unescapeHtmlEntities } from "../../utils/text-normalization"
16+
import { DEFAULT_WRITE_DELAY_MS } from "../../shared/constants"
1617

1718
export async function writeToFileTool(
1819
cline: Task,
@@ -216,8 +217,8 @@ export async function writeToFileTool(
216217
const provider = cline.providerRef.deref()
217218
const state = await provider?.getState()
218219
const diagnosticsEnabled = state?.diagnosticsEnabled ?? true
219-
const diagnosticsDelayMs = state?.diagnosticsDelayMs ?? 2000
220-
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, diagnosticsDelayMs)
220+
const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS
221+
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
221222

222223
// Track file edit operation
223224
if (relPath) {

src/core/webview/ClineProvider.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { ExtensionMessage, MarketplaceInstalledMetadata } from "../../shared/Ext
4242
import { Mode, defaultModeSlug } from "../../shared/modes"
4343
import { experimentDefault, experiments, EXPERIMENT_IDS } from "../../shared/experiments"
4444
import { formatLanguage } from "../../shared/language"
45+
import { DEFAULT_WRITE_DELAY_MS } from "../../shared/constants"
4546
import { Terminal } from "../../integrations/terminal/Terminal"
4647
import { downloadTask } from "../../integrations/misc/export-markdown"
4748
import { getTheme } from "../../integrations/theme/getTheme"
@@ -1436,7 +1437,6 @@ export class ClineProvider
14361437
profileThresholds,
14371438
alwaysAllowFollowupQuestions,
14381439
followupAutoApproveTimeoutMs,
1439-
diagnosticsDelayMs,
14401440
diagnosticsEnabled,
14411441
} = await this.getState()
14421442

@@ -1491,7 +1491,7 @@ export class ClineProvider
14911491
remoteBrowserHost,
14921492
remoteBrowserEnabled: remoteBrowserEnabled ?? false,
14931493
cachedChromeHostUrl: cachedChromeHostUrl,
1494-
writeDelayMs: writeDelayMs ?? 1000,
1494+
writeDelayMs: writeDelayMs ?? DEFAULT_WRITE_DELAY_MS,
14951495
terminalOutputLineLimit: terminalOutputLineLimit ?? 500,
14961496
terminalShellIntegrationTimeout: terminalShellIntegrationTimeout ?? Terminal.defaultShellIntegrationTimeout,
14971497
terminalShellIntegrationDisabled: terminalShellIntegrationDisabled ?? false,
@@ -1557,7 +1557,6 @@ export class ClineProvider
15571557
hasOpenedModeSelector: this.getGlobalState("hasOpenedModeSelector") ?? false,
15581558
alwaysAllowFollowupQuestions: alwaysAllowFollowupQuestions ?? false,
15591559
followupAutoApproveTimeoutMs: followupAutoApproveTimeoutMs ?? 60000,
1560-
diagnosticsDelayMs: diagnosticsDelayMs ?? 2000,
15611560
diagnosticsEnabled: diagnosticsEnabled ?? true,
15621561
}
15631562
}
@@ -1642,7 +1641,6 @@ export class ClineProvider
16421641
alwaysAllowFollowupQuestions: stateValues.alwaysAllowFollowupQuestions ?? false,
16431642
alwaysAllowUpdateTodoList: stateValues.alwaysAllowUpdateTodoList ?? false,
16441643
followupAutoApproveTimeoutMs: stateValues.followupAutoApproveTimeoutMs ?? 60000,
1645-
diagnosticsDelayMs: stateValues.diagnosticsDelayMs ?? 2000,
16461644
diagnosticsEnabled: stateValues.diagnosticsEnabled ?? true,
16471645
allowedMaxRequests: stateValues.allowedMaxRequests,
16481646
autoCondenseContext: stateValues.autoCondenseContext ?? true,
@@ -1662,7 +1660,7 @@ export class ClineProvider
16621660
remoteBrowserEnabled: stateValues.remoteBrowserEnabled ?? false,
16631661
cachedChromeHostUrl: stateValues.cachedChromeHostUrl as string | undefined,
16641662
fuzzyMatchThreshold: stateValues.fuzzyMatchThreshold ?? 1.0,
1665-
writeDelayMs: stateValues.writeDelayMs ?? 1000,
1663+
writeDelayMs: stateValues.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS,
16661664
terminalOutputLineLimit: stateValues.terminalOutputLineLimit ?? 500,
16671665
terminalShellIntegrationTimeout:
16681666
stateValues.terminalShellIntegrationTimeout ?? Terminal.defaultShellIntegrationTimeout,

src/core/webview/__tests__/ClineProvider.spec.ts

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { setTtsEnabled } from "../../../utils/tts"
1414
import { ContextProxy } from "../../config/ContextProxy"
1515
import { Task, TaskOptions } from "../../task/Task"
1616
import { safeWriteJson } from "../../../utils/safeWriteJson"
17+
import { DEFAULT_WRITE_DELAY_MS } from "../../../shared/constants"
1718

1819
import { ClineProvider } from "../ClineProvider"
1920

@@ -500,24 +501,30 @@ describe("ClineProvider", () => {
500501
alwaysAllowReadOnly: false,
501502
alwaysAllowReadOnlyOutsideWorkspace: false,
502503
alwaysAllowWrite: false,
503-
codebaseIndexConfig: {
504-
codebaseIndexEnabled: true,
505-
codebaseIndexQdrantUrl: "",
506-
codebaseIndexEmbedderProvider: "openai",
507-
codebaseIndexEmbedderBaseUrl: "",
508-
codebaseIndexEmbedderModelId: "",
509-
},
510504
alwaysAllowWriteOutsideWorkspace: false,
505+
alwaysAllowWriteProtected: false,
511506
alwaysAllowExecute: false,
512507
alwaysAllowBrowser: false,
513508
alwaysAllowMcp: false,
509+
alwaysAllowModeSwitch: false,
510+
alwaysAllowSubtasks: false,
511+
alwaysAllowUpdateTodoList: false,
512+
allowedCommands: [],
513+
deniedCommands: [],
514+
allowedMaxRequests: 100,
514515
uriScheme: "vscode",
515516
soundEnabled: false,
517+
soundVolume: 0.5,
516518
ttsEnabled: false,
519+
ttsSpeed: 1.0,
517520
diffEnabled: false,
518521
enableCheckpoints: false,
519522
writeDelayMs: 1000,
520523
browserViewportSize: "900x600",
524+
browserToolEnabled: true,
525+
remoteBrowserEnabled: false,
526+
remoteBrowserHost: "",
527+
screenshotQuality: 0.8,
521528
fuzzyMatchThreshold: 1.0,
522529
mcpEnabled: true,
523530
enableMcpServerCreation: false,
@@ -527,11 +534,23 @@ describe("ClineProvider", () => {
527534
experiments: experimentDefault,
528535
maxOpenTabsContext: 20,
529536
maxWorkspaceFiles: 200,
530-
browserToolEnabled: true,
537+
maxReadFileLine: 500,
538+
maxConcurrentFileReads: 10,
539+
terminalOutputLineLimit: 1000,
540+
terminalShellIntegrationTimeout: 5000,
541+
terminalShellIntegrationDisabled: false,
542+
terminalCommandDelay: 100,
543+
terminalPowershellCounter: 0,
544+
terminalZshClearEolMark: false,
545+
terminalZshOhMy: false,
546+
terminalZshP10k: false,
547+
terminalZdotdir: "",
548+
terminalCompressProgressBar: false,
549+
diagnosticsEnabled: true,
550+
language: "en",
531551
telemetrySetting: "unset",
532552
showRooIgnoredFiles: true,
533553
renderContext: "sidebar",
534-
maxReadFileLine: 500,
535554
cloudUserInfo: null,
536555
organizationAllowList: ORGANIZATION_ALLOW_ALL,
537556
autoCondenseContext: true,
@@ -540,6 +559,26 @@ describe("ClineProvider", () => {
540559
sharingEnabled: false,
541560
profileThresholds: {},
542561
hasOpenedModeSelector: false,
562+
// Add missing required properties
563+
currentApiConfigName: "test-config",
564+
listApiConfigMeta: [],
565+
pinnedApiConfigs: [],
566+
autoApprovalEnabled: false,
567+
alwaysApproveResubmit: false,
568+
customModePrompts: {},
569+
customSupportPrompts: {},
570+
modeApiConfigs: {},
571+
enhancementApiConfigId: "",
572+
condensingApiConfigId: "",
573+
customCondensingPrompt: "",
574+
codebaseIndexConfig: {
575+
codebaseIndexEnabled: true,
576+
codebaseIndexQdrantUrl: "",
577+
codebaseIndexEmbedderProvider: "openai",
578+
codebaseIndexEmbedderBaseUrl: "",
579+
codebaseIndexEmbedderModelId: "",
580+
},
581+
codebaseIndexModels: {},
543582
}
544583

545584
const message: ExtensionMessage = {

0 commit comments

Comments
 (0)