Skip to content

perf(write-path): remove artificial write delays by default (part of #1375) - #31

Closed
easonLiangWorldedtech wants to merge 1 commit into
mainfrom
fix/write-delay-default
Closed

perf(write-path): remove artificial write delays by default (part of #1375)#31
easonLiangWorldedtech wants to merge 1 commit into
mainfrom
fix/write-delay-default

Conversation

@easonLiangWorldedtech

Copy link
Copy Markdown
Owner

Summary

Speed follow-through on epic Zoo-Code-Org#1375: removes the two artificial latency sources on the agent file-write path.

Changes

  1. DEFAULT_WRITE_DELAY_MS: 1000 → 0 (packages/types/src/global-settings.ts)
    Every write (write_to_file, edit_file, edit, search_replace, apply_patch, apply_diff, and the DiffViewProvider save paths) waited a full second after saving, before reporting diagnostics. With the default now 0 the write path adds no artificial pacing.

    • The setting itself is unchanged and still round-trips through storage/UI; users who rely on auto-formatters that settle asynchronously (e.g. goimports for Go) can raise writeDelayMs back up. The constant's doc comment now documents that tradeoff.
    • All consumers already read state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS, so the one-line default change is sufficient.
  2. Removed delay(300) before scrollToFirstDiff() (src/core/tools/WriteToFileTool.ts)
    The other five write tools already call scrollToFirstDiff() without a preceding delay, and DiffViewProvider.scrollToFirstDiff() already re-reveals the first diff on a deferred 100 ms timer specifically to beat the diff editor's late layout pass — the 300 ms pause was redundant. The now-unused delay import was removed (DiffViewProvider still imports the package).

Tests

  • ClineProvider.spec.ts asserted the old default literally (toBe(1000)); it now asserts DEFAULT_WRITE_DELAY_MS.
  • pnpm --dir src exec vitest run core/webview/__tests__/ClineProvider.spec.ts core/tools/__tests__/WriteToFileTool.spec.ts → 151 + 19 passing.
  • ESLint clean on all touched files; no suppression count changes.

Tradeoff note

For languages where a post-save auto-formatter takes time to settle (Go/goimports is the documented case), the diagnostic window captured after a write is now 0 ms by default. That is the intended speed/safety tradeoff per Zoo-Code-Org#1375; the setting remains available for users who need the old behavior.

…oo-Code-Org#1375)

Two latency sources on the agent file-write path were removed or defaulted off:

- DEFAULT_WRITE_DELAY_MS is now 0 instead of 1000, so writes no longer wait a full second for post-save diagnostics by default. The setting itself is unchanged: users who rely on auto-formatters that settle asynchronously (e.g. goimports for Go) can raise writeDelayMs back up; the comment on the constant documents that tradeoff.

- WriteToFileTool no longer waits delay(300) before scrollToFirstDiff(). The other five write tools (EditFile, Edit, SearchReplace, ApplyPatch, ApplyDiff) already call scrollToFirstDiff() directly, and DiffViewProvider already re-reveals the first diff on a deferred 100ms timer to beat the diff editor's late layout pass, so the 300ms pause was redundant pacing. The delay() import is removed (DiffViewProvider still uses the package).

Tests: ClineProvider spec now asserts the default via DEFAULT_WRITE_DELAY_MS instead of a hardcoded 1000. WriteToFileTool and ClineProvider suites pass (19 + 151).
@easonLiangWorldedtech

Copy link
Copy Markdown
Owner Author

opened as cross-repo upstream PR instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants