Skip to content

perf(app): debounce file watcher invalidations#21857

Open
Dredok wants to merge 1 commit intoanomalyco:devfrom
Dredok:perf/watcher-debounce
Open

perf(app): debounce file watcher invalidations#21857
Dredok wants to merge 1 commit intoanomalyco:devfrom
Dredok:perf/watcher-debounce

Conversation

@Dredok
Copy link
Copy Markdown

@Dredok Dredok commented Apr 10, 2026

Issue for this PR

Closes #21854

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Batches file watcher invalidations over a 150ms window before flushing. When an agent writes N files in quick succession, the watcher was calling loadFile/refreshDir synchronously for each event, firing N parallel HTTP requests within milliseconds. Now it collects targets in a Set and flushes once per window.

How did you verify your code works?

  • Asked an agent to create 15 files at once — Network tab shows a single batch of requests after a short pause instead of 15 simultaneous ones.
  • Watcher tests updated with fake timers — all 4 pass.
  • bun typecheck passes from packages/opencode.

Screenshots / recordings

No UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Collect invalidation targets over a short window (150ms) and flush them
in a single batch. This avoids firing N parallel HTTP requests when an
agent writes N files in quick succession.
@Dredok Dredok requested a review from adamdotdevin as a code owner April 10, 2026 09:29
@github-actions github-actions bot added needs:title needs:compliance This means the issue will auto-close after 2 hours. labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title perf(app): debounce file watcher invalidations doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File watcher fires parallel HTTP requests for every file an agent writes

1 participant